@yiyi_zhang/reactflow-ui 0.3.0 → 0.5.0-beta.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.
- package/README.md +61 -22
- package/dist/AiWorkflowIDE.d.ts +217 -0
- package/dist/WorkflowIDE.d.ts +22 -3
- package/dist/ai-BJwQZcGK.js +15168 -0
- package/dist/ai.d.ts +30 -0
- package/dist/arc-BUGZGgtu.js +83 -0
- package/dist/architectureDiagram-3BPJPVTR-ZcgvTwSO.js +4692 -0
- package/dist/blockDiagram-GPEHLZMM-DtVtOBbH.js +2418 -0
- package/dist/c4Diagram-AAUBKEIU-tBS5Rcvm.js +1577 -0
- package/dist/channel-CURI9jmI.js +5 -0
- package/dist/chunk-2J33WTMH-D7gashNz.js +19 -0
- package/dist/chunk-4BX2VUAB-DE3VjyiZ.js +8 -0
- package/dist/chunk-55IACEB6-GYZ_m2MY.js +8 -0
- package/dist/chunk-727SXJPM-D4WVyvOg.js +1528 -0
- package/dist/chunk-AQP2D5EJ-Os2Uwqya.js +1387 -0
- package/dist/chunk-FMBD7UC4-B3CSVzS4.js +19 -0
- package/dist/chunk-ND2GUHAM-CNj_s1aK.js +68 -0
- package/dist/chunk-QZHKN3VN-DoV8iUKo.js +15 -0
- package/dist/classDiagram-4FO5ZUOK-Dr9C18x4.js +16 -0
- package/dist/classDiagram-v2-Q7XG4LA2-Dr9C18x4.js +16 -0
- package/dist/components/AiNative/AgentTimeline.d.ts +18 -0
- package/dist/components/AiNative/AiCommandCenter.d.ts +40 -0
- package/dist/components/AiNative/AiConfigPanel.d.ts +9 -0
- package/dist/components/AiNative/BusinessCanvas.d.ts +15 -0
- package/dist/components/AiNative/CanvasPreview.d.ts +16 -0
- package/dist/components/AiNative/ClarificationCard.d.ts +9 -0
- package/dist/components/AiNative/FailureSummaryCard.d.ts +20 -0
- package/dist/components/AiNative/LibraryPanel.d.ts +9 -0
- package/dist/components/AiNative/MermaidBlock.d.ts +6 -0
- package/dist/components/AiNative/PlanCard.d.ts +15 -0
- package/dist/components/AiNative/ProposalPreviewCard.d.ts +21 -0
- package/dist/components/AiNative/RecommendationCard.d.ts +10 -0
- package/dist/components/AiNative/RepairCard.d.ts +17 -0
- package/dist/components/AiNative/ReviewBar.d.ts +21 -0
- package/dist/components/AiNative/WorkflowRunCard.d.ts +14 -0
- package/dist/components/Controls/ModeSlider.d.ts +2 -0
- package/dist/components/ExecutionSummaryPanel.d.ts +4 -0
- package/dist/components/WorkflowRunPanel.d.ts +12 -0
- package/dist/components/nodes/NodeWrapper.d.ts +2 -1
- package/dist/cose-bilkent-S5V4N54A-CgQlI-io.js +2609 -0
- package/dist/cytoscape.esm-kVAWcYoG.js +18755 -0
- package/dist/dagre-BM42HDAG-CFMIuOmS.js +445 -0
- package/dist/defaultLocale-BgPVtth8.js +171 -0
- package/dist/diagram-2AECGRRQ-C5jZp2YX.js +217 -0
- package/dist/diagram-5GNKFQAL-DRUVcHpp.js +123 -0
- package/dist/diagram-KO2AKTUF-BOl4aaej.js +461 -0
- package/dist/diagram-LMA3HP47-ZeckPR2Q.js +142 -0
- package/dist/diagram-OG6HWLK6-qUWeLfa-.js +528 -0
- package/dist/erDiagram-TEJ5UH35-Bw_CWS13.js +899 -0
- package/dist/flowDiagram-I6XJVG4X-D3xEvQA-.js +1628 -0
- package/dist/ganttDiagram-6RSMTGT7-D8GvenY3.js +2707 -0
- package/dist/gitGraphDiagram-PVQCEYII-BWrN_HOm.js +815 -0
- package/dist/graph-BRoPeNF3.js +1545 -0
- package/dist/hooks/useNodeExecution.d.ts +1 -1
- package/dist/hooks/useNodeLayout.d.ts +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/infoDiagram-5YYISTIA-Da8FG5tB.js +24 -0
- package/dist/init-DjUOC4st.js +16 -0
- package/dist/ishikawaDiagram-YF4QCWOH-Bg2_mKEc.js +621 -0
- package/dist/journeyDiagram-JHISSGLW-sFIxGfua.js +834 -0
- package/dist/kanban-definition-UN3LZRKU-CGmopzHd.js +724 -0
- package/dist/katex-DoRnZ_sp.js +11682 -0
- package/dist/layout-D9EpM4Fg.js +1728 -0
- package/dist/linear-BA49eco4.js +259 -0
- package/dist/mermaid.core-XSpZEAKP.js +16137 -0
- package/dist/mindmap-definition-RKZ34NQL-Bqf76QGB.js +827 -0
- package/dist/ordinal-B6-f3MAq.js +61 -0
- package/dist/pieDiagram-4H26LBE5-hHiP8HzL.js +163 -0
- package/dist/quadrantDiagram-W4KKPZXB-DSccwH8B.js +1024 -0
- package/dist/reactflow-ui-ai.es.js +12 -0
- package/dist/reactflow-ui.css +1 -1
- package/dist/reactflow-ui.es.js +8198 -7039
- package/dist/reactflow-ui.umd.js +52 -17
- package/dist/requirementDiagram-4Y6WPE33-DIpyoYZ_.js +882 -0
- package/dist/sankeyDiagram-5OEKKPKP-DsaPqq8D.js +847 -0
- package/dist/sequenceDiagram-3UESZ5HK-BNg7orie.js +2891 -0
- package/dist/services/ai/agentRunner.d.ts +51 -0
- package/dist/services/ai/contextEngine.d.ts +83 -0
- package/dist/services/ai/draftPersistence.d.ts +22 -0
- package/dist/services/ai/errorMessages.d.ts +16 -0
- package/dist/services/ai/intentClassifier.d.ts +17 -0
- package/dist/services/ai/protocolAdapter.d.ts +114 -0
- package/dist/services/ai/ruleEngine.d.ts +57 -0
- package/dist/services/ai/schemaRegistry.d.ts +51 -0
- package/dist/services/ai/systemPrompt.d.ts +30 -0
- package/dist/services/ai/toolDefs.d.ts +9 -0
- package/dist/services/ai/toolExecutor.d.ts +83 -0
- package/dist/services/ai/toolRegistry.d.ts +38 -0
- package/dist/services/ai/transport.d.ts +58 -0
- package/dist/services/aiService.d.ts +27 -5
- package/dist/stateDiagram-AJRCARHV-Rv1mSmnJ.js +263 -0
- package/dist/stateDiagram-v2-BHNVJYJU-BME16k02.js +16 -0
- package/dist/store/aiStore.d.ts +199 -0
- package/dist/store/ideStoresContext.d.ts +39 -0
- package/dist/store/libraryStore.d.ts +25 -0
- package/dist/timeline-definition-PNZ67QCA-CmmzdVk-.js +1055 -0
- package/dist/types/aiEvents.d.ts +38 -0
- package/dist/types/conductor.d.ts +23 -2
- package/dist/types/workflow.d.ts +36 -0
- package/dist/types/workflowLibrary.d.ts +27 -0
- package/dist/utils/executionAnalyzer.d.ts +32 -0
- package/dist/utils/nodeMeta.d.ts +6 -0
- package/dist/utils/proposalPreview.d.ts +19 -0
- package/dist/utils/taskTypeMeta.d.ts +18 -0
- package/dist/utils/workflowToMermaid.d.ts +7 -0
- package/dist/vennDiagram-CIIHVFJN-BQt00w9Q.js +1557 -0
- package/dist/wardley-L42UT6IY-D7b2ujEZ.js +22512 -0
- package/dist/wardleyDiagram-YWT4CUSO-LZpiODGN.js +675 -0
- package/dist/xychartDiagram-2RQKCTM6-BpJlv_mc.js +1342 -0
- package/package.json +14 -4
package/dist/reactflow-ui.umd.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(De,O){typeof exports=="object"&&typeof module<"u"?O(exports,require("react"),require("reactflow"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","reactflow","react-dom"],O):(De=typeof globalThis<"u"?globalThis:De||self,O(De.ReactflowUI={},De.React,De.ReactFlow,De.ReactDOM))})(this,(function(De,O,A,Qr){"use strict";var Er=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function cg(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Nr={exports:{}},ur={};var Yi;function dg(){if(Yi)return ur;Yi=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function r(t,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:t,key:o,ref:s!==void 0?s:null,props:a}}return ur.Fragment=n,ur.jsx=r,ur.jsxs=r,ur}var fr={};var Xi;function ug(){return Xi||(Xi=1,process.env.NODE_ENV!=="production"&&(function(){function e(q){if(q==null)return null;if(typeof q=="function")return q.$$typeof===S?null:q.displayName||q.name||null;if(typeof q=="string")return q;switch(q){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 q=="object")switch(typeof q.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),q.$$typeof){case m:return"Portal";case k:return q.displayName||"Context";case b:return(q._context.displayName||"Context")+".Consumer";case w:var G=q.render;return q=q.displayName,q||(q=G.displayName||G.name||"",q=q!==""?"ForwardRef("+q+")":"ForwardRef"),q;case L:return G=q.displayName||null,G!==null?G:e(q.type)||"Memo";case T:G=q._payload,q=q._init;try{return e(q(G))}catch{}}return null}function n(q){return""+q}function r(q){try{n(q);var G=!1}catch{G=!0}if(G){G=console;var ie=G.error,R=typeof Symbol=="function"&&Symbol.toStringTag&&q[Symbol.toStringTag]||q.constructor.name||"Object";return ie.call(G,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",R),n(q)}}function t(q){if(q===v)return"<>";if(typeof q=="object"&&q!==null&&q.$$typeof===T)return"<...>";try{var G=e(q);return G?"<"+G+">":"<...>"}catch{return"<...>"}}function s(){var q=D.A;return q===null?null:q.getOwner()}function a(){return Error("react-stack-top-frame")}function o(q){if(I.call(q,"key")){var G=Object.getOwnPropertyDescriptor(q,"key").get;if(G&&G.isReactWarning)return!1}return q.key!==void 0}function i(q,G){function ie(){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)",G))}ie.isReactWarning=!0,Object.defineProperty(q,"key",{get:ie,configurable:!0})}function u(){var q=e(this.type);return K[q]||(K[q]=!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.")),q=this.props.ref,q!==void 0?q:null}function c(q,G,ie,R,M,_){var B=ie.ref;return q={$$typeof:g,type:q,key:G,props:ie,_owner:R},(B!==void 0?B:null)!==null?Object.defineProperty(q,"ref",{enumerable:!1,get:u}):Object.defineProperty(q,"ref",{enumerable:!1,value:null}),q._store={},Object.defineProperty(q._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(q,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(q,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:M}),Object.defineProperty(q,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:_}),Object.freeze&&(Object.freeze(q.props),Object.freeze(q)),q}function d(q,G,ie,R,M,_){var B=G.children;if(B!==void 0)if(R)if(P(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(G,"key")){B=e(q);var $=Object.keys(G).filter(function(U){return U!=="key"});R=0<$.length?"{key: someKey, "+$.join(": ..., ")+": ...}":"{key: someKey}",re[B+R]||($=0<$.length?"{"+$.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} />`,E,P,z,P),se[P+E]=!0)}if(P=null,K!==void 0&&(t(K),P=""+K),i(Y)&&(t(Y.key),P=""+Y.key),"key"in Y){K={};for(var ee in Y)ee!=="key"&&(K[ee]=Y[ee])}else K=Y;return P&&s(K,typeof _=="function"?_.displayName||_.name||"Unknown":_),u(_,P,K,o(),j,M)}function f(_){p(_)?_._store&&(_._store.validated=1):typeof _=="object"&&_!==null&&_.$$typeof===w&&(_._payload.status==="fulfilled"?p(_._payload.value)&&_._payload.value._store&&(_._payload.value._store.validated=1):_._store&&(_._store.validated=1))}function p(_){return typeof _=="object"&&_!==null&&_.$$typeof===g}var h=q,g=Symbol.for("react.transitional.element"),v=Symbol.for("react.portal"),m=Symbol.for("react.fragment"),x=Symbol.for("react.strict_mode"),y=Symbol.for("react.profiler"),b=Symbol.for("react.consumer"),k=Symbol.for("react.context"),S=Symbol.for("react.forward_ref"),C=Symbol.for("react.suspense"),N=Symbol.for("react.suspense_list"),A=Symbol.for("react.memo"),w=Symbol.for("react.lazy"),I=Symbol.for("react.activity"),R=Symbol.for("react.client.reference"),B=h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D=Object.prototype.hasOwnProperty,L=Array.isArray,F=console.createTask?console.createTask:function(){return null};h={react_stack_bottom_frame:function(_){return _()}};var W,V={},Z=h.react_stack_bottom_frame.bind(h,a)(),le=F(n(a)),se={};ur.Fragment=m,ur.jsx=function(_,Y,K){var E=1e4>B.recentlyCreatedOwnerStacks++;return c(_,Y,K,!1,E?Error("react-stack-top-frame"):Z,E?F(n(_)):le)},ur.jsxs=function(_,Y,K){var E=1e4>B.recentlyCreatedOwnerStacks++;return c(_,Y,K,!0,E?Error("react-stack-top-frame"):Z,E?F(n(_)):le)}})()),ur}var Hs;function Zh(){return Hs||(Hs=1,process.env.NODE_ENV==="production"?Sr.exports=Yh():Sr.exports=Xh()),Sr.exports}var d=Zh();const Ks=e=>{let r;const t=new Set,n=(u,c)=>{const f=typeof u=="function"?u(r):u;if(!Object.is(f,r)){const p=r;r=c??(typeof f!="object"||f===null)?f:Object.assign({},r,f),t.forEach(h=>h(r,p))}},o=()=>r,s={setState:n,getState:o,getInitialState:()=>l,subscribe:u=>(t.add(u),()=>t.delete(u))},l=r=e(n,o,s);return s},Us=(e=>e?Ks(e):Ks),Qh=e=>e;function Vr(e,r=Qh){const t=q.useSyncExternalStore(e.subscribe,q.useCallback(()=>r(e.getState()),[e,r]),q.useCallback(()=>r(e.getInitialState()),[e,r]));return q.useDebugValue(t),t}const eg=e=>{const r=Us(e),t=n=>Vr(r,n);return Object.assign(t,r),t},rg=(e=>eg);function Js(e,r){let t;try{t=e()}catch{return}return{getItem:o=>{var a;const i=l=>l===null?null:JSON.parse(l,void 0),s=(a=t.getItem(o))!=null?a:null;return s instanceof Promise?s.then(i):i(s)},setItem:(o,a)=>t.setItem(o,JSON.stringify(a,void 0)),removeItem:o=>t.removeItem(o)}}const Yr=e=>r=>{try{const t=e(r);return t instanceof Promise?t:{then(n){return Yr(n)(t)},catch(n){return this}}}catch(t){return{then(n){return this},catch(n){return Yr(n)(t)}}}},tg=(e,r)=>(t,n,o)=>{let a={storage:Js(()=>localStorage),partialize:v=>v,version:0,merge:(v,m)=>({...m,...v}),...r},i=!1;const s=new Set,l=new Set;let u=a.storage;if(!u)return e((...v)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),t(...v)},n,o);const c=()=>{const v=a.partialize({...n()});return u.setItem(a.name,{state:v,version:a.version})},f=o.setState;o.setState=(v,m)=>(f(v,m),c());const p=e((...v)=>(t(...v),c()),n,o);o.getInitialState=()=>p;let h;const g=()=>{var v,m;if(!u)return;i=!1,s.forEach(y=>{var b;return y((b=n())!=null?b:p)});const x=((m=a.onRehydrateStorage)==null?void 0:m.call(a,(v=n())!=null?v:p))||void 0;return Yr(u.getItem.bind(u))(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,S]=y;if(h=a.merge(S,(b=n())!=null?b:p),t(h,!0),k)return c()}).then(()=>{x?.(h,void 0),h=n(),i=!0,l.forEach(y=>y(h))}).catch(y=>{x?.(void 0,y)})};return o.persist={setOptions:v=>{a={...a,...v},v.storage&&(u=v.storage)},clearStorage:()=>{u?.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>g(),hasHydrated:()=>i,onHydrate:v=>(s.add(v),()=>{s.delete(v)}),onFinishHydration:v=>(l.add(v),()=>{l.delete(v)})},a.skipHydration||g(),h||p};var Gs=(e,r,t)=>(o,a)=>({pastStates:t?.pastStates||[],futureStates:t?.futureStates||[],undo:(i=1)=>{if(a().pastStates.length){const s=t?.partialize?.(r())||r(),l=a().pastStates.splice(-i,i),u=l.shift();e(u),o({pastStates:a().pastStates,futureStates:a().futureStates.concat(t?.diff?.(s,u)||s,l.reverse())})}},redo:(i=1)=>{if(a().futureStates.length){const s=t?.partialize?.(r())||r(),l=a().futureStates.splice(-i,i),u=l.shift();e(u),o({pastStates:a().pastStates.concat(t?.diff?.(s,u)||s,l.reverse()),futureStates:a().futureStates})}},clear:()=>o({pastStates:[],futureStates:[]}),isTracking:!0,pause:()=>o({isTracking:!1}),resume:()=>o({isTracking:!0}),setOnSave:i=>o({_onSave:i}),_onSave:t?.onSave,_handleSet:(i,s,l,u)=>{t?.limit&&a().pastStates.length>=t?.limit&&a().pastStates.shift(),a()._onSave?.(i,l),o({pastStates:a().pastStates.concat(u||i),futureStates:[]})}}),ng=(e,r)=>(n,o,a)=>{a.temporal=Us(r?.wrapTemporal?.(Gs(n,o,r))||Gs(n,o,r));const i=r?.handleSet?.(a.temporal.getState()._handleSet)||a.temporal.getState()._handleSet,s=u=>{if(!a.temporal.getState().isTracking)return;const c=r?.partialize?.(o())||o(),f=r?.diff?.(u,c);f===null||r?.equality?.(u,c)||i(u,void 0,c,f)},l=a.setState;return a.setState=(...u)=>{const c=r?.partialize?.(o())||o();l(...u),s(c)},e((...u)=>{const c=r?.partialize?.(o())||o();n(...u),s(c)},o,a)};function ag(e,r="TB",t){const n=t?.hideEmptyBranches??!1;if(!e||!e.tasks)return{nodes:[],edges:[],taskMap:{}};const o=[],a=[],i={};let s=0;const l=e.tasks;for(let u=0;u<l.length;u++){const c=l[u],f=Vs(c,s,i,r,l,n);if(o.push(...f.nodes),a.push(...f.edges),s=f.nextId,u>0){const p=l[u-1];Xr(p,c,a,n)}Object.assign(i,f.taskMap)}if(!n&&l.length>0){const u=l[0],c="__workflow_start__";o.push({id:c,type:"plusNode",data:{label:"+",taskReferenceName:c,taskType:"PLUS",parentRef:c,edgeData:{isWorkflowStart:!0},layoutDirection:r},position:{x:0,y:0},sourcePosition:r==="LR"?O.Position.Right:O.Position.Bottom,targetPosition:r==="LR"?O.Position.Left:O.Position.Top}),a.push({id:`e-${c}-${u.taskReferenceName}`,source:c,target:u.taskReferenceName,animated:!0});const f=l[l.length-1],p="__workflow_end__";o.push({id:p,type:"plusNode",data:{label:"+",taskReferenceName:p,taskType:"PLUS",parentRef:f.taskReferenceName,layoutDirection:r},position:{x:0,y:0},sourcePosition:r==="LR"?O.Position.Right:O.Position.Bottom,targetPosition:r==="LR"?O.Position.Left:O.Position.Top}),Xr(f,{taskReferenceName:p},a,n)}return{nodes:o,edges:a,taskMap:i}}function Vs(e,r,t,n="TB",o=[],a=!1){switch(e.type||"SIMPLE"){case"DECISION":case"SWITCH":return ig(e,r,t,n,a);case"FORK_JOIN":case"FORK_JOIN_DYNAMIC":return sg(e,r,t,n);case"JOIN":case"EXCLUSIVE_JOIN":return lg(e,r,t,n,o,a);case"DO_WHILE":return cg(e,r,t,n,a);case"SUB_WORKFLOW":return ug(e,r,t,n);default:return og(e,r,t,n)}}function og(e,r,t,n="TB"){const o={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"?O.Position.Right:O.Position.Bottom,targetPosition:n==="LR"?O.Position.Left:O.Position.Top},a={[e.taskReferenceName]:e};return{nodes:[o],edges:[],taskMap:a,nextId:r+1}}function ig(e,r,t,n="TB",o=!1){const a=[],i=[];let s=r;const l={},u={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"?O.Position.Right:O.Position.Bottom,targetPosition:n==="LR"?O.Position.Left:O.Position.Top};a.push(u),l[e.taskReferenceName]=e;const c=e.decisionCases||{},f=e.defaultCase||[],p=Object.keys(c),h=(g,v)=>{if(n==="TB"){if(g===0&&v>1)return"left";if(g===1&&v>2)return"right"}else{if(g===0&&v>1)return"top";if(g===1&&v>2)return"bottom"}return null};if(p.forEach((g,v)=>{const m=c[g],x=h(v,p.length+1);if(m&&m.length>0){const y=wr(m,s,{...t,...l},n,o);a.push(...y.nodes),i.push(...y.edges),Object.assign(l,y.taskMap),s=y.nextId;const b=m[0].taskReferenceName;i.push({id:`e-${e.taskReferenceName}-${b}`,source:e.taskReferenceName,sourceHandle:x||void 0,target:b,label:g,animated:!0,data:{branchCase:g},style:{stroke:"#3b82f6"}})}else if(!o){const y=`${e.taskReferenceName}_empty_${g}`;a.push({id:y,type:"plusNode",data:{label:`${g} (空)`,parentRef:e.taskReferenceName,edgeData:{branchCase:g},layoutDirection:n,taskReferenceName:y,taskType:"EMPTY_BRANCH"},position:{x:0,y:0},sourcePosition:n==="LR"?O.Position.Right:O.Position.Bottom,targetPosition:n==="LR"?O.Position.Left:O.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:x||void 0,target:y,label:g,animated:!0,data:{branchCase:g},style:{stroke:"#3b82f6",strokeDasharray:"5,5"}})}}),f&&f.length>0){const g=wr(f,s,{...t,...l},n,o);a.push(...g.nodes),i.push(...g.edges),Object.assign(l,g.taskMap),s=g.nextId;const v=f[0].taskReferenceName;i.push({id:`e-${e.taskReferenceName}-${v}`,source:e.taskReferenceName,target:v,label:"default",animated:!0,data:{branchCase:"default"},style:{stroke:"#f59e0b"}})}else if(!o){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"?O.Position.Right:O.Position.Bottom,targetPosition:n==="LR"?O.Position.Left:O.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}-${g}`,source:e.taskReferenceName,target:g,label:"default",animated:!0,data:{branchCase:"default"},style:{stroke:"#f59e0b",strokeDasharray:"5,5"}})}return{nodes:a,edges:i,taskMap:l,nextId:s}}function sg(e,r,t,n="TB"){const o=[],a=[];let i=r;const s={},l=e.type==="FORK_JOIN_DYNAMIC",u={id:e.taskReferenceName,type:"forkNode",data:{label:e.name,taskReferenceName:e.taskReferenceName,taskType:e.type,task:e,isDynamic:l,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?O.Position.Right:O.Position.Bottom,targetPosition:n==="LR"?O.Position.Left:O.Position.Top};if(o.push(u),s[e.taskReferenceName]=e,l){const c=`${e.taskReferenceName}_dynamic_placeholder`;o.push({id:c,type:"dynamicPlaceholderNode",data:{label:"动态分支",taskReferenceName:c,taskType:"DYNAMIC_PLACEHOLDER",layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?O.Position.Right:O.Position.Bottom,targetPosition:n==="LR"?O.Position.Left:O.Position.Top}),a.push({id:`e-${e.taskReferenceName}-${c}`,source:e.taskReferenceName,target:c,animated:!0,style:{stroke:"#10b981",strokeDasharray:"5,5",strokeWidth:2}}),s[c]={taskReferenceName:c,type:"DYNAMIC_PLACEHOLDER"}}return l||(e.forkTasks||[]).forEach((f,p)=>{if(f&&f.length>0){const h=wr(f,i,{...t,...s},n,!1);o.push(...h.nodes),a.push(...h.edges),Object.assign(s,h.taskMap),i=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:o,edges:a,taskMap:s,nextId:i}}function cg(e,r,t,n="TB",o=!1){const a={},i=e.taskReferenceName,s={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"?O.Position.Right:O.Position.Bottom,targetPosition:n==="LR"?O.Position.Left:O.Position.Top,style:{pointerEvents:"none"}};a[i]=e;const l=e.loopOver||[],u=[],c=[];let f=r+1;if(l.length>0){const p=wr(l,f,{...t,...a},n,o);if(f=p.nextId,Object.assign(a,p.taskMap),p.nodes.forEach(h=>{u.push({...h,parentId:h.parentId??i,extent:h.parentId?h.extent:"parent"})}),c.push(...p.edges),!o){const h=l[0],g=`__loop_start__${i}`;u.push({id:g,type:"plusNode",parentId:i,extent:"parent",data:{label:"+",taskReferenceName:g,taskType:"PLUS",parentRef:i,edgeData:{isLoopBodyStart:!0,loopId:i},layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?O.Position.Right:O.Position.Bottom,targetPosition:n==="LR"?O.Position.Left:O.Position.Top}),c.push({id:`e-${g}-${h.taskReferenceName}`,source:g,target:h.taskReferenceName,animated:!0})}if(!o){const h=l[l.length-1],g=`__loop_end__${i}`;u.push({id:g,type:"plusNode",parentId:i,extent:"parent",data:{label:"+",taskReferenceName:g,taskType:"PLUS",parentRef:h.taskReferenceName,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?O.Position.Right:O.Position.Bottom,targetPosition:n==="LR"?O.Position.Left:O.Position.Top}),c.push({id:`e-${h.taskReferenceName}-${g}`,source:h.taskReferenceName,target:g,animated:!0})}}else if(!o){const p=`${i}_loop_empty_plus`;u.push({id:p,type:"plusNode",parentId:i,extent:"parent",data:{label:"+ 添加",taskReferenceName:p,taskType:"PLUS",parentRef:i,edgeData:{isLoopAdd:!0},layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?O.Position.Right:O.Position.Bottom,targetPosition:n==="LR"?O.Position.Left:O.Position.Top})}return{nodes:[s,...u],edges:c,taskMap:a,nextId:f}}function ug(e,r,t,n="TB"){const o={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"?O.Position.Right:O.Position.Bottom,targetPosition:n==="LR"?O.Position.Left:O.Position.Top},a={[e.taskReferenceName]:e};return{nodes:[o],edges:[],taskMap:a,nextId:r+1}}function lg(e,r,t,n="TB",o=[],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"?O.Position.Right:O.Position.Bottom,targetPosition:n==="LR"?O.Position.Left:O.Position.Top},s={[e.taskReferenceName]:e},l=[],u=[];(e.joinOn||[]).forEach(p=>{const h=o.find(g=>g.taskReferenceName===p)||t[p];h&&Tr(h,a).forEach(v=>{u.push({id:`e-${v}-${e.taskReferenceName}`,source:v,target:e.taskReferenceName,animated:!0})})});const f=o.findIndex(p=>p.taskReferenceName===e.taskReferenceName);if(f>0){const p=o[f-1];if(p.type==="FORK_JOIN_DYNAMIC"){const h=`${p.taskReferenceName}_dynamic_placeholder`;u.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,v)=>{if((!g||g.length===0)&&!a){const m=`${p.taskReferenceName}_empty_branch_${v}`;l.push({id:m,type:"default",data:{label:`分支 ${v+1} (空)`,layoutDirection:n,taskReferenceName:m,taskType:"EMPTY_BRANCH"},position:{x:0,y:0},sourcePosition:n==="LR"?O.Position.Right:O.Position.Bottom,targetPosition:n==="LR"?O.Position.Left:O.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"}}),u.push({id:`e-${p.taskReferenceName}-${m}`,source:p.taskReferenceName,sourceHandle:`branch_${v}`,target:m,label:`分支 ${v+1}`,animated:!0,data:{forkIndex:v},style:{stroke:"#10b981",strokeDasharray:"5,5"}}),u.push({id:`e-${m}-${e.taskReferenceName}`,source:m,target:e.taskReferenceName,animated:!0,style:{strokeDasharray:"5,5"}})}})}return{nodes:[i,...l],edges:u,taskMap:s,nextId:r+1}}function wr(e,r,t,n="TB",o=!1){const a=[],i=[];let s=r;const l={};for(let u=0;u<e.length;u++){const c=e[u],f={...t,...l},p=Vs(c,s,f,n,e,o);if(a.push(...p.nodes),i.push(...p.edges),Object.assign(l,p.taskMap),s=p.nextId,u>0){const h=e[u-1];Xr(h,c,i,o)}}return{nodes:a,edges:i,taskMap:l,nextId:s}}function Xr(e,r,t,n=!1){if(e.type==="FORK_JOIN"||e.type==="FORK_JOIN_DYNAMIC")return;const o=Tr(e,n),a=r.taskReferenceName;o.forEach(i=>{const s=`e-${i}-${a}`;t.find(l=>l.id===s)||t.push({id:s,source:i,target:a,animated:!0})})}function Tr(e,r=!1){const t=e.type||"SIMPLE";if(t==="DECISION"||t==="SWITCH"){const n=[],o=e.decisionCases||{},a=e.defaultCase||[];if(Object.entries(o).forEach(([i,s])=>{if(s&&s.length>0){const l=s[s.length-1];n.push(...Tr(l,r))}else r||n.push(`${e.taskReferenceName}_empty_${i}`)}),a.length>0){const i=a[a.length-1];n.push(...Tr(i,r))}else r||n.push(`${e.taskReferenceName}_empty_default`);return n.length>0?n:[e.taskReferenceName]}return[e.taskReferenceName]}const _e=ag;function Zr(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 Qr,Ys;function dg(){if(Ys)return Qr;Ys=1;function e(){this.__data__=[],this.size=0}return Qr=e,Qr}var et,Xs;function Ze(){if(Xs)return et;Xs=1;function e(r,t){return r===t||r!==r&&t!==t}return et=e,et}var rt,Zs;function Er(){if(Zs)return rt;Zs=1;var e=Ze();function r(t,n){for(var o=t.length;o--;)if(e(t[o][0],n))return o;return-1}return rt=r,rt}var tt,Qs;function fg(){if(Qs)return tt;Qs=1;var e=Er(),r=Array.prototype,t=r.splice;function n(o){var a=this.__data__,i=e(a,o);if(i<0)return!1;var s=a.length-1;return i==s?a.pop():t.call(a,i,1),--this.size,!0}return tt=n,tt}var nt,ec;function pg(){if(ec)return nt;ec=1;var e=Er();function r(t){var n=this.__data__,o=e(n,t);return o<0?void 0:n[o][1]}return nt=r,nt}var at,rc;function hg(){if(rc)return at;rc=1;var e=Er();function r(t){return e(this.__data__,t)>-1}return at=r,at}var ot,tc;function gg(){if(tc)return ot;tc=1;var e=Er();function r(t,n){var o=this.__data__,a=e(o,t);return a<0?(++this.size,o.push([t,n])):o[a][1]=n,this}return ot=r,ot}var it,nc;function Nr(){if(nc)return it;nc=1;var e=dg(),r=fg(),t=pg(),n=hg(),o=gg();function a(i){var s=-1,l=i==null?0:i.length;for(this.clear();++s<l;){var u=i[s];this.set(u[0],u[1])}}return a.prototype.clear=e,a.prototype.delete=r,a.prototype.get=t,a.prototype.has=n,a.prototype.set=o,it=a,it}var st,ac;function vg(){if(ac)return st;ac=1;var e=Nr();function r(){this.__data__=new e,this.size=0}return st=r,st}var ct,oc;function mg(){if(oc)return ct;oc=1;function e(r){var t=this.__data__,n=t.delete(r);return this.size=t.size,n}return ct=e,ct}var ut,ic;function yg(){if(ic)return ut;ic=1;function e(r){return this.__data__.get(r)}return ut=e,ut}var lt,sc;function xg(){if(sc)return lt;sc=1;function e(r){return this.__data__.has(r)}return lt=e,lt}var dt,cc;function uc(){if(cc)return dt;cc=1;var e=typeof _r=="object"&&_r&&_r.Object===Object&&_r;return dt=e,dt}var ft,lc;function Re(){if(lc)return ft;lc=1;var e=uc(),r=typeof self=="object"&&self&&self.Object===Object&&self,t=e||r||Function("return this")();return ft=t,ft}var pt,dc;function Qe(){if(dc)return pt;dc=1;var e=Re(),r=e.Symbol;return pt=r,pt}var ht,fc;function bg(){if(fc)return ht;fc=1;var e=Qe(),r=Object.prototype,t=r.hasOwnProperty,n=r.toString,o=e?e.toStringTag:void 0;function a(i){var s=t.call(i,o),l=i[o];try{i[o]=void 0;var u=!0}catch{}var c=n.call(i);return u&&(s?i[o]=l:delete i[o]),c}return ht=a,ht}var gt,pc;function kg(){if(pc)return gt;pc=1;var e=Object.prototype,r=e.toString;function t(n){return r.call(n)}return gt=t,gt}var vt,hc;function He(){if(hc)return vt;hc=1;var e=Qe(),r=bg(),t=kg(),n="[object Null]",o="[object Undefined]",a=e?e.toStringTag:void 0;function i(s){return s==null?s===void 0?o:n:a&&a in Object(s)?r(s):t(s)}return vt=i,vt}var mt,gc;function Te(){if(gc)return mt;gc=1;function e(r){var t=typeof r;return r!=null&&(t=="object"||t=="function")}return mt=e,mt}var yt,vc;function lr(){if(vc)return yt;vc=1;var e=He(),r=Te(),t="[object AsyncFunction]",n="[object Function]",o="[object GeneratorFunction]",a="[object Proxy]";function i(s){if(!r(s))return!1;var l=e(s);return l==n||l==o||l==t||l==a}return yt=i,yt}var xt,mc;function _g(){if(mc)return xt;mc=1;var e=Re(),r=e["__core-js_shared__"];return xt=r,xt}var bt,yc;function Sg(){if(yc)return bt;yc=1;var e=_g(),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 bt=t,bt}var kt,xc;function bc(){if(xc)return kt;xc=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 kt=t,kt}var _t,kc;function wg(){if(kc)return _t;kc=1;var e=lr(),r=Sg(),t=Te(),n=bc(),o=/[\\^$.*+?()[\]{}|]/g,a=/^\[object .+?Constructor\]$/,i=Function.prototype,s=Object.prototype,l=i.toString,u=s.hasOwnProperty,c=RegExp("^"+l.call(u).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function f(p){if(!t(p)||r(p))return!1;var h=e(p)?c:a;return h.test(n(p))}return _t=f,_t}var St,_c;function Tg(){if(_c)return St;_c=1;function e(r,t){return r?.[t]}return St=e,St}var wt,Sc;function Ke(){if(Sc)return wt;Sc=1;var e=wg(),r=Tg();function t(n,o){var a=r(n,o);return e(a)?a:void 0}return wt=t,wt}var Tt,wc;function Et(){if(wc)return Tt;wc=1;var e=Ke(),r=Re(),t=e(r,"Map");return Tt=t,Tt}var Nt,Tc;function Cr(){if(Tc)return Nt;Tc=1;var e=Ke(),r=e(Object,"create");return Nt=r,Nt}var Ct,Ec;function Eg(){if(Ec)return Ct;Ec=1;var e=Cr();function r(){this.__data__=e?e(null):{},this.size=0}return Ct=r,Ct}var It,Nc;function Ng(){if(Nc)return It;Nc=1;function e(r){var t=this.has(r)&&delete this.__data__[r];return this.size-=t?1:0,t}return It=e,It}var Rt,Cc;function Cg(){if(Cc)return Rt;Cc=1;var e=Cr(),r="__lodash_hash_undefined__",t=Object.prototype,n=t.hasOwnProperty;function o(a){var i=this.__data__;if(e){var s=i[a];return s===r?void 0:s}return n.call(i,a)?i[a]:void 0}return Rt=o,Rt}var jt,Ic;function Ig(){if(Ic)return jt;Ic=1;var e=Cr(),r=Object.prototype,t=r.hasOwnProperty;function n(o){var a=this.__data__;return e?a[o]!==void 0:t.call(a,o)}return jt=n,jt}var Ot,Rc;function Rg(){if(Rc)return Ot;Rc=1;var e=Cr(),r="__lodash_hash_undefined__";function t(n,o){var a=this.__data__;return this.size+=this.has(n)?0:1,a[n]=e&&o===void 0?r:o,this}return Ot=t,Ot}var Pt,jc;function jg(){if(jc)return Pt;jc=1;var e=Eg(),r=Ng(),t=Cg(),n=Ig(),o=Rg();function a(i){var s=-1,l=i==null?0:i.length;for(this.clear();++s<l;){var u=i[s];this.set(u[0],u[1])}}return a.prototype.clear=e,a.prototype.delete=r,a.prototype.get=t,a.prototype.has=n,a.prototype.set=o,Pt=a,Pt}var At,Oc;function Og(){if(Oc)return At;Oc=1;var e=jg(),r=Nr(),t=Et();function n(){this.size=0,this.__data__={hash:new e,map:new(t||r),string:new e}}return At=n,At}var qt,Pc;function Pg(){if(Pc)return qt;Pc=1;function e(r){var t=typeof r;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?r!=="__proto__":r===null}return qt=e,qt}var Lt,Ac;function Ir(){if(Ac)return Lt;Ac=1;var e=Pg();function r(t,n){var o=t.__data__;return e(n)?o[typeof n=="string"?"string":"hash"]:o.map}return Lt=r,Lt}var Dt,qc;function Ag(){if(qc)return Dt;qc=1;var e=Ir();function r(t){var n=e(this,t).delete(t);return this.size-=n?1:0,n}return Dt=r,Dt}var Mt,Lc;function qg(){if(Lc)return Mt;Lc=1;var e=Ir();function r(t){return e(this,t).get(t)}return Mt=r,Mt}var Wt,Dc;function Lg(){if(Dc)return Wt;Dc=1;var e=Ir();function r(t){return e(this,t).has(t)}return Wt=r,Wt}var Bt,Mc;function Dg(){if(Mc)return Bt;Mc=1;var e=Ir();function r(t,n){var o=e(this,t),a=o.size;return o.set(t,n),this.size+=o.size==a?0:1,this}return Bt=r,Bt}var Ft,Wc;function zt(){if(Wc)return Ft;Wc=1;var e=Og(),r=Ag(),t=qg(),n=Lg(),o=Dg();function a(i){var s=-1,l=i==null?0:i.length;for(this.clear();++s<l;){var u=i[s];this.set(u[0],u[1])}}return a.prototype.clear=e,a.prototype.delete=r,a.prototype.get=t,a.prototype.has=n,a.prototype.set=o,Ft=a,Ft}var $t,Bc;function Mg(){if(Bc)return $t;Bc=1;var e=Nr(),r=Et(),t=zt(),n=200;function o(a,i){var s=this.__data__;if(s instanceof e){var l=s.__data__;if(!r||l.length<n-1)return l.push([a,i]),this.size=++s.size,this;s=this.__data__=new t(l)}return s.set(a,i),this.size=s.size,this}return $t=o,$t}var Ht,Fc;function Rr(){if(Fc)return Ht;Fc=1;var e=Nr(),r=vg(),t=mg(),n=yg(),o=xg(),a=Mg();function i(s){var l=this.__data__=new e(s);this.size=l.size}return i.prototype.clear=r,i.prototype.delete=t,i.prototype.get=n,i.prototype.has=o,i.prototype.set=a,Ht=i,Ht}var Kt,zc;function Ut(){if(zc)return Kt;zc=1;function e(r,t){for(var n=-1,o=r==null?0:r.length;++n<o&&t(r[n],n,r)!==!1;);return r}return Kt=e,Kt}var Jt,$c;function Hc(){if($c)return Jt;$c=1;var e=Ke(),r=(function(){try{var t=e(Object,"defineProperty");return t({},"",{}),t}catch{}})();return Jt=r,Jt}var Gt,Kc;function jr(){if(Kc)return Gt;Kc=1;var e=Hc();function r(t,n,o){n=="__proto__"&&e?e(t,n,{configurable:!0,enumerable:!0,value:o,writable:!0}):t[n]=o}return Gt=r,Gt}var Vt,Uc;function Or(){if(Uc)return Vt;Uc=1;var e=jr(),r=Ze(),t=Object.prototype,n=t.hasOwnProperty;function o(a,i,s){var l=a[i];(!(n.call(a,i)&&r(l,s))||s===void 0&&!(i in a))&&e(a,i,s)}return Vt=o,Vt}var Yt,Jc;function dr(){if(Jc)return Yt;Jc=1;var e=Or(),r=jr();function t(n,o,a,i){var s=!a;a||(a={});for(var l=-1,u=o.length;++l<u;){var c=o[l],f=i?i(a[c],n[c],c,a,n):void 0;f===void 0&&(f=n[c]),s?r(a,c,f):e(a,c,f)}return a}return Yt=t,Yt}var Xt,Gc;function Wg(){if(Gc)return Xt;Gc=1;function e(r,t){for(var n=-1,o=Array(r);++n<r;)o[n]=t(n);return o}return Xt=e,Xt}var Zt,Vc;function Ae(){if(Vc)return Zt;Vc=1;function e(r){return r!=null&&typeof r=="object"}return Zt=e,Zt}var Qt,Yc;function Bg(){if(Yc)return Qt;Yc=1;var e=He(),r=Ae(),t="[object Arguments]";function n(o){return r(o)&&e(o)==t}return Qt=n,Qt}var en,Xc;function fr(){if(Xc)return en;Xc=1;var e=Bg(),r=Ae(),t=Object.prototype,n=t.hasOwnProperty,o=t.propertyIsEnumerable,a=e((function(){return arguments})())?e:function(i){return r(i)&&n.call(i,"callee")&&!o.call(i,"callee")};return en=a,en}var rn,Zc;function me(){if(Zc)return rn;Zc=1;var e=Array.isArray;return rn=e,rn}var pr={exports:{}},tn,Qc;function Fg(){if(Qc)return tn;Qc=1;function e(){return!1}return tn=e,tn}pr.exports;var eu;function er(){return eu||(eu=1,(function(e,r){var t=Re(),n=Fg(),o=r&&!r.nodeType&&r,a=o&&!0&&e&&!e.nodeType&&e,i=a&&a.exports===o,s=i?t.Buffer:void 0,l=s?s.isBuffer:void 0,u=l||n;e.exports=u})(pr,pr.exports)),pr.exports}var nn,ru;function Pr(){if(ru)return nn;ru=1;var e=9007199254740991,r=/^(?:0|[1-9]\d*)$/;function t(n,o){var a=typeof n;return o=o??e,!!o&&(a=="number"||a!="symbol"&&r.test(n))&&n>-1&&n%1==0&&n<o}return nn=t,nn}var an,tu;function on(){if(tu)return an;tu=1;var e=9007199254740991;function r(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=e}return an=r,an}var sn,nu;function zg(){if(nu)return sn;nu=1;var e=He(),r=on(),t=Ae(),n="[object Arguments]",o="[object Array]",a="[object Boolean]",i="[object Date]",s="[object Error]",l="[object Function]",u="[object Map]",c="[object Number]",f="[object Object]",p="[object RegExp]",h="[object Set]",g="[object String]",v="[object WeakMap]",m="[object ArrayBuffer]",x="[object DataView]",y="[object Float32Array]",b="[object Float64Array]",k="[object Int8Array]",S="[object Int16Array]",C="[object Int32Array]",N="[object Uint8Array]",A="[object Uint8ClampedArray]",w="[object Uint16Array]",I="[object Uint32Array]",R={};R[y]=R[b]=R[k]=R[S]=R[C]=R[N]=R[A]=R[w]=R[I]=!0,R[n]=R[o]=R[m]=R[a]=R[x]=R[i]=R[s]=R[l]=R[u]=R[c]=R[f]=R[p]=R[h]=R[g]=R[v]=!1;function B(D){return t(D)&&r(D.length)&&!!R[e(D)]}return sn=B,sn}var cn,au;function Ar(){if(au)return cn;au=1;function e(r){return function(t){return r(t)}}return cn=e,cn}var hr={exports:{}};hr.exports;var ou;function un(){return ou||(ou=1,(function(e,r){var t=uc(),n=r&&!r.nodeType&&r,o=n&&!0&&e&&!e.nodeType&&e,a=o&&o.exports===n,i=a&&t.process,s=(function(){try{var l=o&&o.require&&o.require("util").types;return l||i&&i.binding&&i.binding("util")}catch{}})();e.exports=s})(hr,hr.exports)),hr.exports}var ln,iu;function gr(){if(iu)return ln;iu=1;var e=zg(),r=Ar(),t=un(),n=t&&t.isTypedArray,o=n?r(n):e;return ln=o,ln}var dn,su;function cu(){if(su)return dn;su=1;var e=Wg(),r=fr(),t=me(),n=er(),o=Pr(),a=gr(),i=Object.prototype,s=i.hasOwnProperty;function l(u,c){var f=t(u),p=!f&&r(u),h=!f&&!p&&n(u),g=!f&&!p&&!h&&a(u),v=f||p||h||g,m=v?e(u.length,String):[],x=m.length;for(var y in u)(c||s.call(u,y))&&!(v&&(y=="length"||h&&(y=="offset"||y=="parent")||g&&(y=="buffer"||y=="byteLength"||y=="byteOffset")||o(y,x)))&&m.push(y);return m}return dn=l,dn}var fn,uu;function qr(){if(uu)return fn;uu=1;var e=Object.prototype;function r(t){var n=t&&t.constructor,o=typeof n=="function"&&n.prototype||e;return t===o}return fn=r,fn}var pn,lu;function du(){if(lu)return pn;lu=1;function e(r,t){return function(n){return r(t(n))}}return pn=e,pn}var hn,fu;function $g(){if(fu)return hn;fu=1;var e=du(),r=e(Object.keys,Object);return hn=r,hn}var gn,pu;function vn(){if(pu)return gn;pu=1;var e=qr(),r=$g(),t=Object.prototype,n=t.hasOwnProperty;function o(a){if(!e(a))return r(a);var i=[];for(var s in Object(a))n.call(a,s)&&s!="constructor"&&i.push(s);return i}return gn=o,gn}var mn,hu;function De(){if(hu)return mn;hu=1;var e=lr(),r=on();function t(n){return n!=null&&r(n.length)&&!e(n)}return mn=t,mn}var yn,gu;function Be(){if(gu)return yn;gu=1;var e=cu(),r=vn(),t=De();function n(o){return t(o)?e(o):r(o)}return yn=n,yn}var xn,vu;function Hg(){if(vu)return xn;vu=1;var e=dr(),r=Be();function t(n,o){return n&&e(o,r(o),n)}return xn=t,xn}var bn,mu;function Kg(){if(mu)return bn;mu=1;function e(r){var t=[];if(r!=null)for(var n in Object(r))t.push(n);return t}return bn=e,bn}var kn,yu;function Ug(){if(yu)return kn;yu=1;var e=Te(),r=qr(),t=Kg(),n=Object.prototype,o=n.hasOwnProperty;function a(i){if(!e(i))return t(i);var s=r(i),l=[];for(var u in i)u=="constructor"&&(s||!o.call(i,u))||l.push(u);return l}return kn=a,kn}var _n,xu;function Ue(){if(xu)return _n;xu=1;var e=cu(),r=Ug(),t=De();function n(o){return t(o)?e(o,!0):r(o)}return _n=n,_n}var Sn,bu;function Jg(){if(bu)return Sn;bu=1;var e=dr(),r=Ue();function t(n,o){return n&&e(o,r(o),n)}return Sn=t,Sn}var vr={exports:{}};vr.exports;var ku;function _u(){return ku||(ku=1,(function(e,r){var t=Re(),n=r&&!r.nodeType&&r,o=n&&!0&&e&&!e.nodeType&&e,a=o&&o.exports===n,i=a?t.Buffer:void 0,s=i?i.allocUnsafe:void 0;function l(u,c){if(c)return u.slice();var f=u.length,p=s?s(f):new u.constructor(f);return u.copy(p),p}e.exports=l})(vr,vr.exports)),vr.exports}var wn,Su;function wu(){if(Su)return wn;Su=1;function e(r,t){var n=-1,o=r.length;for(t||(t=Array(o));++n<o;)t[n]=r[n];return t}return wn=e,wn}var Tn,Tu;function Eu(){if(Tu)return Tn;Tu=1;function e(r,t){for(var n=-1,o=r==null?0:r.length,a=0,i=[];++n<o;){var s=r[n];t(s,n,r)&&(i[a++]=s)}return i}return Tn=e,Tn}var En,Nu;function Cu(){if(Nu)return En;Nu=1;function e(){return[]}return En=e,En}var Nn,Iu;function Cn(){if(Iu)return Nn;Iu=1;var e=Eu(),r=Cu(),t=Object.prototype,n=t.propertyIsEnumerable,o=Object.getOwnPropertySymbols,a=o?function(i){return i==null?[]:(i=Object(i),e(o(i),function(s){return n.call(i,s)}))}:r;return Nn=a,Nn}var In,Ru;function Gg(){if(Ru)return In;Ru=1;var e=dr(),r=Cn();function t(n,o){return e(n,r(n),o)}return In=t,In}var Rn,ju;function jn(){if(ju)return Rn;ju=1;function e(r,t){for(var n=-1,o=t.length,a=r.length;++n<o;)r[a+n]=t[n];return r}return Rn=e,Rn}var On,Ou;function Lr(){if(Ou)return On;Ou=1;var e=du(),r=e(Object.getPrototypeOf,Object);return On=r,On}var Pn,Pu;function Au(){if(Pu)return Pn;Pu=1;var e=jn(),r=Lr(),t=Cn(),n=Cu(),o=Object.getOwnPropertySymbols,a=o?function(i){for(var s=[];i;)e(s,t(i)),i=r(i);return s}:n;return Pn=a,Pn}var An,qu;function Vg(){if(qu)return An;qu=1;var e=dr(),r=Au();function t(n,o){return e(n,r(n),o)}return An=t,An}var qn,Lu;function Du(){if(Lu)return qn;Lu=1;var e=jn(),r=me();function t(n,o,a){var i=o(n);return r(n)?i:e(i,a(n))}return qn=t,qn}var Ln,Mu;function Wu(){if(Mu)return Ln;Mu=1;var e=Du(),r=Cn(),t=Be();function n(o){return e(o,t,r)}return Ln=n,Ln}var Dn,Bu;function Yg(){if(Bu)return Dn;Bu=1;var e=Du(),r=Au(),t=Ue();function n(o){return e(o,t,r)}return Dn=n,Dn}var Mn,Fu;function Xg(){if(Fu)return Mn;Fu=1;var e=Ke(),r=Re(),t=e(r,"DataView");return Mn=t,Mn}var Wn,zu;function Zg(){if(zu)return Wn;zu=1;var e=Ke(),r=Re(),t=e(r,"Promise");return Wn=t,Wn}var Bn,$u;function Hu(){if($u)return Bn;$u=1;var e=Ke(),r=Re(),t=e(r,"Set");return Bn=t,Bn}var Fn,Ku;function Qg(){if(Ku)return Fn;Ku=1;var e=Ke(),r=Re(),t=e(r,"WeakMap");return Fn=t,Fn}var zn,Uu;function rr(){if(Uu)return zn;Uu=1;var e=Xg(),r=Et(),t=Zg(),n=Hu(),o=Qg(),a=He(),i=bc(),s="[object Map]",l="[object Object]",u="[object Promise]",c="[object Set]",f="[object WeakMap]",p="[object DataView]",h=i(e),g=i(r),v=i(t),m=i(n),x=i(o),y=a;return(e&&y(new e(new ArrayBuffer(1)))!=p||r&&y(new r)!=s||t&&y(t.resolve())!=u||n&&y(new n)!=c||o&&y(new o)!=f)&&(y=function(b){var k=a(b),S=k==l?b.constructor:void 0,C=S?i(S):"";if(C)switch(C){case h:return p;case g:return s;case v:return u;case m:return c;case x:return f}return k}),zn=y,zn}var $n,Ju;function ev(){if(Ju)return $n;Ju=1;var e=Object.prototype,r=e.hasOwnProperty;function t(n){var o=n.length,a=new n.constructor(o);return o&&typeof n[0]=="string"&&r.call(n,"index")&&(a.index=n.index,a.input=n.input),a}return $n=t,$n}var Hn,Gu;function Vu(){if(Gu)return Hn;Gu=1;var e=Re(),r=e.Uint8Array;return Hn=r,Hn}var Kn,Yu;function Un(){if(Yu)return Kn;Yu=1;var e=Vu();function r(t){var n=new t.constructor(t.byteLength);return new e(n).set(new e(t)),n}return Kn=r,Kn}var Jn,Xu;function rv(){if(Xu)return Jn;Xu=1;var e=Un();function r(t,n){var o=n?e(t.buffer):t.buffer;return new t.constructor(o,t.byteOffset,t.byteLength)}return Jn=r,Jn}var Gn,Zu;function tv(){if(Zu)return Gn;Zu=1;var e=/\w*$/;function r(t){var n=new t.constructor(t.source,e.exec(t));return n.lastIndex=t.lastIndex,n}return Gn=r,Gn}var Vn,Qu;function nv(){if(Qu)return Vn;Qu=1;var e=Qe(),r=e?e.prototype:void 0,t=r?r.valueOf:void 0;function n(o){return t?Object(t.call(o)):{}}return Vn=n,Vn}var Yn,el;function rl(){if(el)return Yn;el=1;var e=Un();function r(t,n){var o=n?e(t.buffer):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}return Yn=r,Yn}var Xn,tl;function av(){if(tl)return Xn;tl=1;var e=Un(),r=rv(),t=tv(),n=nv(),o=rl(),a="[object Boolean]",i="[object Date]",s="[object Map]",l="[object Number]",u="[object RegExp]",c="[object Set]",f="[object String]",p="[object Symbol]",h="[object ArrayBuffer]",g="[object DataView]",v="[object Float32Array]",m="[object Float64Array]",x="[object Int8Array]",y="[object Int16Array]",b="[object Int32Array]",k="[object Uint8Array]",S="[object Uint8ClampedArray]",C="[object Uint16Array]",N="[object Uint32Array]";function A(w,I,R){var B=w.constructor;switch(I){case h:return e(w);case a:case i:return new B(+w);case g:return r(w,R);case v:case m:case x:case y:case b:case k:case S:case C:case N:return o(w,R);case s:return new B;case l:case f:return new B(w);case u:return t(w);case c:return new B;case p:return n(w)}}return Xn=A,Xn}var Zn,nl;function al(){if(nl)return Zn;nl=1;var e=Te(),r=Object.create,t=(function(){function n(){}return function(o){if(!e(o))return{};if(r)return r(o);n.prototype=o;var a=new n;return n.prototype=void 0,a}})();return Zn=t,Zn}var Qn,ol;function il(){if(ol)return Qn;ol=1;var e=al(),r=Lr(),t=qr();function n(o){return typeof o.constructor=="function"&&!t(o)?e(r(o)):{}}return Qn=n,Qn}var ea,sl;function ov(){if(sl)return ea;sl=1;var e=rr(),r=Ae(),t="[object Map]";function n(o){return r(o)&&e(o)==t}return ea=n,ea}var ra,cl;function iv(){if(cl)return ra;cl=1;var e=ov(),r=Ar(),t=un(),n=t&&t.isMap,o=n?r(n):e;return ra=o,ra}var ta,ul;function sv(){if(ul)return ta;ul=1;var e=rr(),r=Ae(),t="[object Set]";function n(o){return r(o)&&e(o)==t}return ta=n,ta}var na,ll;function cv(){if(ll)return na;ll=1;var e=sv(),r=Ar(),t=un(),n=t&&t.isSet,o=n?r(n):e;return na=o,na}var aa,dl;function fl(){if(dl)return aa;dl=1;var e=Rr(),r=Ut(),t=Or(),n=Hg(),o=Jg(),a=_u(),i=wu(),s=Gg(),l=Vg(),u=Wu(),c=Yg(),f=rr(),p=ev(),h=av(),g=il(),v=me(),m=er(),x=iv(),y=Te(),b=cv(),k=Be(),S=Ue(),C=1,N=2,A=4,w="[object Arguments]",I="[object Array]",R="[object Boolean]",B="[object Date]",D="[object Error]",L="[object Function]",F="[object GeneratorFunction]",W="[object Map]",V="[object Number]",Z="[object Object]",le="[object RegExp]",se="[object Set]",_="[object String]",Y="[object Symbol]",K="[object WeakMap]",E="[object ArrayBuffer]",j="[object DataView]",M="[object Float32Array]",P="[object Float64Array]",z="[object Int8Array]",ee="[object Int16Array]",ae="[object Int32Array]",ie="[object Uint8Array]",ne="[object Uint8ClampedArray]",G="[object Uint16Array]",J="[object Uint32Array]",H={};H[w]=H[I]=H[E]=H[j]=H[R]=H[B]=H[M]=H[P]=H[z]=H[ee]=H[ae]=H[W]=H[V]=H[Z]=H[le]=H[se]=H[_]=H[Y]=H[ie]=H[ne]=H[G]=H[J]=!0,H[D]=H[L]=H[K]=!1;function $(X,de,ue,he,T,U){var Q,te=de&C,re=de&N,ge=de&A;if(ue&&(Q=T?ue(X,he,T,U):ue(X)),Q!==void 0)return Q;if(!y(X))return X;var ve=v(X);if(ve){if(Q=p(X),!te)return i(X,Q)}else{var ce=f(X),ye=ce==L||ce==F;if(m(X))return a(X,te);if(ce==Z||ce==w||ye&&!T){if(Q=re||ye?{}:g(X),!te)return re?l(X,o(Q,X)):s(X,n(Q,X))}else{if(!H[ce])return T?X:{};Q=h(X,ce,te)}}U||(U=new e);var $e=U.get(X);if($e)return $e;U.set(X,Q),b(X)?X.forEach(function(fe){Q.add($(fe,de,ue,fe,X,U))}):x(X)&&X.forEach(function(fe,Ie){Q.set(Ie,$(fe,de,ue,Ie,X,U))});var Ce=ge?re?c:u:re?S:k,Xe=ve?void 0:Ce(X);return r(Xe||X,function(fe,Ie){Xe&&(Ie=fe,fe=X[Ie]),t(Q,Ie,$(fe,de,ue,Ie,X,U))}),Q}return aa=$,aa}var oa,pl;function uv(){if(pl)return oa;pl=1;var e=fl(),r=4;function t(n){return e(n,r)}return oa=t,oa}var ia,hl;function sa(){if(hl)return ia;hl=1;function e(r){return function(){return r}}return ia=e,ia}var ca,gl;function lv(){if(gl)return ca;gl=1;function e(r){return function(t,n,o){for(var a=-1,i=Object(t),s=o(t),l=s.length;l--;){var u=s[r?l:++a];if(n(i[u],u,i)===!1)break}return t}}return ca=e,ca}var ua,vl;function la(){if(vl)return ua;vl=1;var e=lv(),r=e();return ua=r,ua}var da,ml;function fa(){if(ml)return da;ml=1;var e=la(),r=Be();function t(n,o){return n&&e(n,o,r)}return da=t,da}var pa,yl;function dv(){if(yl)return pa;yl=1;var e=De();function r(t,n){return function(o,a){if(o==null)return o;if(!e(o))return t(o,a);for(var i=o.length,s=n?i:-1,l=Object(o);(n?s--:++s<i)&&a(l[s],s,l)!==!1;);return o}}return pa=r,pa}var ha,xl;function Dr(){if(xl)return ha;xl=1;var e=fa(),r=dv(),t=r(e);return ha=t,ha}var ga,bl;function Je(){if(bl)return ga;bl=1;function e(r){return r}return ga=e,ga}var va,kl;function _l(){if(kl)return va;kl=1;var e=Je();function r(t){return typeof t=="function"?t:e}return va=r,va}var ma,Sl;function wl(){if(Sl)return ma;Sl=1;var e=Ut(),r=Dr(),t=_l(),n=me();function o(a,i){var s=n(a)?e:r;return s(a,t(i))}return ma=o,ma}var ya,Tl;function El(){return Tl||(Tl=1,ya=wl()),ya}var xa,Nl;function fv(){if(Nl)return xa;Nl=1;var e=Dr();function r(t,n){var o=[];return e(t,function(a,i,s){n(a,i,s)&&o.push(a)}),o}return xa=r,xa}var ba,Cl;function pv(){if(Cl)return ba;Cl=1;var e="__lodash_hash_undefined__";function r(t){return this.__data__.set(t,e),this}return ba=r,ba}var ka,Il;function hv(){if(Il)return ka;Il=1;function e(r){return this.__data__.has(r)}return ka=e,ka}var _a,Rl;function jl(){if(Rl)return _a;Rl=1;var e=zt(),r=pv(),t=hv();function n(o){var a=-1,i=o==null?0:o.length;for(this.__data__=new e;++a<i;)this.add(o[a])}return n.prototype.add=n.prototype.push=r,n.prototype.has=t,_a=n,_a}var Sa,Ol;function gv(){if(Ol)return Sa;Ol=1;function e(r,t){for(var n=-1,o=r==null?0:r.length;++n<o;)if(t(r[n],n,r))return!0;return!1}return Sa=e,Sa}var wa,Pl;function Al(){if(Pl)return wa;Pl=1;function e(r,t){return r.has(t)}return wa=e,wa}var Ta,ql;function Ll(){if(ql)return Ta;ql=1;var e=jl(),r=gv(),t=Al(),n=1,o=2;function a(i,s,l,u,c,f){var p=l&n,h=i.length,g=s.length;if(h!=g&&!(p&&g>h))return!1;var v=f.get(i),m=f.get(s);if(v&&m)return v==s&&m==i;var x=-1,y=!0,b=l&o?new e:void 0;for(f.set(i,s),f.set(s,i);++x<h;){var k=i[x],S=s[x];if(u)var C=p?u(S,k,x,s,i,f):u(k,S,x,i,s,f);if(C!==void 0){if(C)continue;y=!1;break}if(b){if(!r(s,function(N,A){if(!t(b,A)&&(k===N||c(k,N,l,u,f)))return b.push(A)})){y=!1;break}}else if(!(k===S||c(k,S,l,u,f))){y=!1;break}}return f.delete(i),f.delete(s),y}return Ta=a,Ta}var Ea,Dl;function vv(){if(Dl)return Ea;Dl=1;function e(r){var t=-1,n=Array(r.size);return r.forEach(function(o,a){n[++t]=[a,o]}),n}return Ea=e,Ea}var Na,Ml;function Ca(){if(Ml)return Na;Ml=1;function e(r){var t=-1,n=Array(r.size);return r.forEach(function(o){n[++t]=o}),n}return Na=e,Na}var Ia,Wl;function mv(){if(Wl)return Ia;Wl=1;var e=Qe(),r=Vu(),t=Ze(),n=Ll(),o=vv(),a=Ca(),i=1,s=2,l="[object Boolean]",u="[object Date]",c="[object Error]",f="[object Map]",p="[object Number]",h="[object RegExp]",g="[object Set]",v="[object String]",m="[object Symbol]",x="[object ArrayBuffer]",y="[object DataView]",b=e?e.prototype:void 0,k=b?b.valueOf:void 0;function S(C,N,A,w,I,R,B){switch(A){case y:if(C.byteLength!=N.byteLength||C.byteOffset!=N.byteOffset)return!1;C=C.buffer,N=N.buffer;case x:return!(C.byteLength!=N.byteLength||!R(new r(C),new r(N)));case l:case u:case p:return t(+C,+N);case c:return C.name==N.name&&C.message==N.message;case h:case v:return C==N+"";case f:var D=o;case g:var L=w&i;if(D||(D=a),C.size!=N.size&&!L)return!1;var F=B.get(C);if(F)return F==N;w|=s,B.set(C,N);var W=n(D(C),D(N),w,I,R,B);return B.delete(C),W;case m:if(k)return k.call(C)==k.call(N)}return!1}return Ia=S,Ia}var Ra,Bl;function yv(){if(Bl)return Ra;Bl=1;var e=Wu(),r=1,t=Object.prototype,n=t.hasOwnProperty;function o(a,i,s,l,u,c){var f=s&r,p=e(a),h=p.length,g=e(i),v=g.length;if(h!=v&&!f)return!1;for(var m=h;m--;){var x=p[m];if(!(f?x in i:n.call(i,x)))return!1}var y=c.get(a),b=c.get(i);if(y&&b)return y==i&&b==a;var k=!0;c.set(a,i),c.set(i,a);for(var S=f;++m<h;){x=p[m];var C=a[x],N=i[x];if(l)var A=f?l(N,C,x,i,a,c):l(C,N,x,a,i,c);if(!(A===void 0?C===N||u(C,N,s,l,c):A)){k=!1;break}S||(S=x=="constructor")}if(k&&!S){var w=a.constructor,I=i.constructor;w!=I&&"constructor"in a&&"constructor"in i&&!(typeof w=="function"&&w instanceof w&&typeof I=="function"&&I instanceof I)&&(k=!1)}return c.delete(a),c.delete(i),k}return Ra=o,Ra}var ja,Fl;function xv(){if(Fl)return ja;Fl=1;var e=Rr(),r=Ll(),t=mv(),n=yv(),o=rr(),a=me(),i=er(),s=gr(),l=1,u="[object Arguments]",c="[object Array]",f="[object Object]",p=Object.prototype,h=p.hasOwnProperty;function g(v,m,x,y,b,k){var S=a(v),C=a(m),N=S?c:o(v),A=C?c:o(m);N=N==u?f:N,A=A==u?f:A;var w=N==f,I=A==f,R=N==A;if(R&&i(v)){if(!i(m))return!1;S=!0,w=!1}if(R&&!w)return k||(k=new e),S||s(v)?r(v,m,x,y,b,k):t(v,m,N,x,y,b,k);if(!(x&l)){var B=w&&h.call(v,"__wrapped__"),D=I&&h.call(m,"__wrapped__");if(B||D){var L=B?v.value():v,F=D?m.value():m;return k||(k=new e),b(L,F,x,y,k)}}return R?(k||(k=new e),n(v,m,x,y,b,k)):!1}return ja=g,ja}var Oa,zl;function $l(){if(zl)return Oa;zl=1;var e=xv(),r=Ae();function t(n,o,a,i,s){return n===o?!0:n==null||o==null||!r(n)&&!r(o)?n!==n&&o!==o:e(n,o,a,i,t,s)}return Oa=t,Oa}var Pa,Hl;function bv(){if(Hl)return Pa;Hl=1;var e=Rr(),r=$l(),t=1,n=2;function o(a,i,s,l){var u=s.length,c=u,f=!l;if(a==null)return!c;for(a=Object(a);u--;){var p=s[u];if(f&&p[2]?p[1]!==a[p[0]]:!(p[0]in a))return!1}for(;++u<c;){p=s[u];var h=p[0],g=a[h],v=p[1];if(f&&p[2]){if(g===void 0&&!(h in a))return!1}else{var m=new e;if(l)var x=l(g,v,h,a,i,m);if(!(x===void 0?r(v,g,t|n,l,m):x))return!1}}return!0}return Pa=o,Pa}var Aa,Kl;function Ul(){if(Kl)return Aa;Kl=1;var e=Te();function r(t){return t===t&&!e(t)}return Aa=r,Aa}var qa,Jl;function kv(){if(Jl)return qa;Jl=1;var e=Ul(),r=Be();function t(n){for(var o=r(n),a=o.length;a--;){var i=o[a],s=n[i];o[a]=[i,s,e(s)]}return o}return qa=t,qa}var La,Gl;function Vl(){if(Gl)return La;Gl=1;function e(r,t){return function(n){return n==null?!1:n[r]===t&&(t!==void 0||r in Object(n))}}return La=e,La}var Da,Yl;function _v(){if(Yl)return Da;Yl=1;var e=bv(),r=kv(),t=Vl();function n(o){var a=r(o);return a.length==1&&a[0][2]?t(a[0][0],a[0][1]):function(i){return i===o||e(i,o,a)}}return Da=n,Da}var Ma,Xl;function tr(){if(Xl)return Ma;Xl=1;var e=He(),r=Ae(),t="[object Symbol]";function n(o){return typeof o=="symbol"||r(o)&&e(o)==t}return Ma=n,Ma}var Wa,Zl;function Ba(){if(Zl)return Wa;Zl=1;var e=me(),r=tr(),t=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;function o(a,i){if(e(a))return!1;var s=typeof a;return s=="number"||s=="symbol"||s=="boolean"||a==null||r(a)?!0:n.test(a)||!t.test(a)||i!=null&&a in Object(i)}return Wa=o,Wa}var Fa,Ql;function Sv(){if(Ql)return Fa;Ql=1;var e=zt(),r="Expected a function";function t(n,o){if(typeof n!="function"||o!=null&&typeof o!="function")throw new TypeError(r);var a=function(){var i=arguments,s=o?o.apply(this,i):i[0],l=a.cache;if(l.has(s))return l.get(s);var u=n.apply(this,i);return a.cache=l.set(s,u)||l,u};return a.cache=new(t.Cache||e),a}return t.Cache=e,Fa=t,Fa}var za,ed;function wv(){if(ed)return za;ed=1;var e=Sv(),r=500;function t(n){var o=e(n,function(i){return a.size===r&&a.clear(),i}),a=o.cache;return o}return za=t,za}var $a,rd;function Tv(){if(rd)return $a;rd=1;var e=wv(),r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,t=/\\(\\)?/g,n=e(function(o){var a=[];return o.charCodeAt(0)===46&&a.push(""),o.replace(r,function(i,s,l,u){a.push(l?u.replace(t,"$1"):s||i)}),a});return $a=n,$a}var Ha,td;function Mr(){if(td)return Ha;td=1;function e(r,t){for(var n=-1,o=r==null?0:r.length,a=Array(o);++n<o;)a[n]=t(r[n],n,r);return a}return Ha=e,Ha}var Ka,nd;function Ev(){if(nd)return Ka;nd=1;var e=Qe(),r=Mr(),t=me(),n=tr(),o=e?e.prototype:void 0,a=o?o.toString:void 0;function i(s){if(typeof s=="string")return s;if(t(s))return r(s,i)+"";if(n(s))return a?a.call(s):"";var l=s+"";return l=="0"&&1/s==-1/0?"-0":l}return Ka=i,Ka}var Ua,ad;function od(){if(ad)return Ua;ad=1;var e=Ev();function r(t){return t==null?"":e(t)}return Ua=r,Ua}var Ja,id;function Wr(){if(id)return Ja;id=1;var e=me(),r=Ba(),t=Tv(),n=od();function o(a,i){return e(a)?a:r(a,i)?[a]:t(n(a))}return Ja=o,Ja}var Ga,sd;function mr(){if(sd)return Ga;sd=1;var e=tr();function r(t){if(typeof t=="string"||e(t))return t;var n=t+"";return n=="0"&&1/t==-1/0?"-0":n}return Ga=r,Ga}var Va,cd;function Br(){if(cd)return Va;cd=1;var e=Wr(),r=mr();function t(n,o){o=e(o,n);for(var a=0,i=o.length;n!=null&&a<i;)n=n[r(o[a++])];return a&&a==i?n:void 0}return Va=t,Va}var Ya,ud;function Nv(){if(ud)return Ya;ud=1;var e=Br();function r(t,n,o){var a=t==null?void 0:e(t,n);return a===void 0?o:a}return Ya=r,Ya}var Xa,ld;function Cv(){if(ld)return Xa;ld=1;function e(r,t){return r!=null&&t in Object(r)}return Xa=e,Xa}var Za,dd;function fd(){if(dd)return Za;dd=1;var e=Wr(),r=fr(),t=me(),n=Pr(),o=on(),a=mr();function i(s,l,u){l=e(l,s);for(var c=-1,f=l.length,p=!1;++c<f;){var h=a(l[c]);if(!(p=s!=null&&u(s,h)))break;s=s[h]}return p||++c!=f?p:(f=s==null?0:s.length,!!f&&o(f)&&n(h,f)&&(t(s)||r(s)))}return Za=i,Za}var Qa,pd;function hd(){if(pd)return Qa;pd=1;var e=Cv(),r=fd();function t(n,o){return n!=null&&r(n,o,e)}return Qa=t,Qa}var eo,gd;function Iv(){if(gd)return eo;gd=1;var e=$l(),r=Nv(),t=hd(),n=Ba(),o=Ul(),a=Vl(),i=mr(),s=1,l=2;function u(c,f){return n(c)&&o(f)?a(i(c),f):function(p){var h=r(p,c);return h===void 0&&h===f?t(p,c):e(f,h,s|l)}}return eo=u,eo}var ro,vd;function md(){if(vd)return ro;vd=1;function e(r){return function(t){return t?.[r]}}return ro=e,ro}var to,yd;function Rv(){if(yd)return to;yd=1;var e=Br();function r(t){return function(n){return e(n,t)}}return to=r,to}var no,xd;function jv(){if(xd)return no;xd=1;var e=md(),r=Rv(),t=Ba(),n=mr();function o(a){return t(a)?e(n(a)):r(a)}return no=o,no}var ao,bd;function Me(){if(bd)return ao;bd=1;var e=_v(),r=Iv(),t=Je(),n=me(),o=jv();function a(i){return typeof i=="function"?i:i==null?t:typeof i=="object"?n(i)?r(i[0],i[1]):e(i):o(i)}return ao=a,ao}var oo,kd;function _d(){if(kd)return oo;kd=1;var e=Eu(),r=fv(),t=Me(),n=me();function o(a,i){var s=n(a)?e:r;return s(a,t(i,3))}return oo=o,oo}var io,Sd;function Ov(){if(Sd)return io;Sd=1;var e=Object.prototype,r=e.hasOwnProperty;function t(n,o){return n!=null&&r.call(n,o)}return io=t,io}var so,wd;function Td(){if(wd)return so;wd=1;var e=Ov(),r=fd();function t(n,o){return n!=null&&r(n,o,e)}return so=t,so}var co,Ed;function Pv(){if(Ed)return co;Ed=1;var e=vn(),r=rr(),t=fr(),n=me(),o=De(),a=er(),i=qr(),s=gr(),l="[object Map]",u="[object Set]",c=Object.prototype,f=c.hasOwnProperty;function p(h){if(h==null)return!0;if(o(h)&&(n(h)||typeof h=="string"||typeof h.splice=="function"||a(h)||s(h)||t(h)))return!h.length;var g=r(h);if(g==l||g==u)return!h.size;if(i(h))return!e(h).length;for(var v in h)if(f.call(h,v))return!1;return!0}return co=p,co}var uo,Nd;function Cd(){if(Nd)return uo;Nd=1;function e(r){return r===void 0}return uo=e,uo}var lo,Id;function Rd(){if(Id)return lo;Id=1;var e=Dr(),r=De();function t(n,o){var a=-1,i=r(n)?Array(n.length):[];return e(n,function(s,l,u){i[++a]=o(s,l,u)}),i}return lo=t,lo}var fo,jd;function Od(){if(jd)return fo;jd=1;var e=Mr(),r=Me(),t=Rd(),n=me();function o(a,i){var s=n(a)?e:t;return s(a,r(i,3))}return fo=o,fo}var po,Pd;function Av(){if(Pd)return po;Pd=1;function e(r,t,n,o){var a=-1,i=r==null?0:r.length;for(o&&i&&(n=r[++a]);++a<i;)n=t(n,r[a],a,r);return n}return po=e,po}var ho,Ad;function qv(){if(Ad)return ho;Ad=1;function e(r,t,n,o,a){return a(r,function(i,s,l){n=o?(o=!1,i):t(n,i,s,l)}),n}return ho=e,ho}var go,qd;function Ld(){if(qd)return go;qd=1;var e=Av(),r=Dr(),t=Me(),n=qv(),o=me();function a(i,s,l){var u=o(i)?e:n,c=arguments.length<3;return u(i,t(s,4),l,c,r)}return go=a,go}var vo,Dd;function Lv(){if(Dd)return vo;Dd=1;var e=He(),r=me(),t=Ae(),n="[object String]";function o(a){return typeof a=="string"||!r(a)&&t(a)&&e(a)==n}return vo=o,vo}var mo,Md;function Dv(){if(Md)return mo;Md=1;var e=md(),r=e("length");return mo=r,mo}var yo,Wd;function Mv(){if(Wd)return yo;Wd=1;var e="\\ud800-\\udfff",r="\\u0300-\\u036f",t="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",o=r+t+n,a="\\ufe0e\\ufe0f",i="\\u200d",s=RegExp("["+i+e+o+a+"]");function l(u){return s.test(u)}return yo=l,yo}var xo,Bd;function Wv(){if(Bd)return xo;Bd=1;var e="\\ud800-\\udfff",r="\\u0300-\\u036f",t="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",o=r+t+n,a="\\ufe0e\\ufe0f",i="["+e+"]",s="["+o+"]",l="\\ud83c[\\udffb-\\udfff]",u="(?:"+s+"|"+l+")",c="[^"+e+"]",f="(?:\\ud83c[\\udde6-\\uddff]){2}",p="[\\ud800-\\udbff][\\udc00-\\udfff]",h="\\u200d",g=u+"?",v="["+a+"]?",m="(?:"+h+"(?:"+[c,f,p].join("|")+")"+v+g+")*",x=v+g+m,y="(?:"+[c+s+"?",s,f,p,i].join("|")+")",b=RegExp(l+"(?="+l+")|"+y+x,"g");function k(S){for(var C=b.lastIndex=0;b.test(S);)++C;return C}return xo=k,xo}var bo,Fd;function Bv(){if(Fd)return bo;Fd=1;var e=Dv(),r=Mv(),t=Wv();function n(o){return r(o)?t(o):e(o)}return bo=n,bo}var ko,zd;function Fv(){if(zd)return ko;zd=1;var e=vn(),r=rr(),t=De(),n=Lv(),o=Bv(),a="[object Map]",i="[object Set]";function s(l){if(l==null)return 0;if(t(l))return n(l)?o(l):l.length;var u=r(l);return u==a||u==i?l.size:e(l).length}return ko=s,ko}var _o,$d;function zv(){if($d)return _o;$d=1;var e=Ut(),r=al(),t=fa(),n=Me(),o=Lr(),a=me(),i=er(),s=lr(),l=Te(),u=gr();function c(f,p,h){var g=a(f),v=g||i(f)||u(f);if(p=n(p,4),h==null){var m=f&&f.constructor;v?h=g?new m:[]:l(f)?h=s(m)?r(o(f)):{}:h={}}return(v?e:t)(f,function(x,y,b){return p(h,x,y,b)}),h}return _o=c,_o}var So,Hd;function $v(){if(Hd)return So;Hd=1;var e=Qe(),r=fr(),t=me(),n=e?e.isConcatSpreadable:void 0;function o(a){return t(a)||r(a)||!!(n&&a&&a[n])}return So=o,So}var wo,Kd;function To(){if(Kd)return wo;Kd=1;var e=jn(),r=$v();function t(n,o,a,i,s){var l=-1,u=n.length;for(a||(a=r),s||(s=[]);++l<u;){var c=n[l];o>0&&a(c)?o>1?t(c,o-1,a,i,s):e(s,c):i||(s[s.length]=c)}return s}return wo=t,wo}var Eo,Ud;function Hv(){if(Ud)return Eo;Ud=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 Eo=e,Eo}var No,Jd;function Gd(){if(Jd)return No;Jd=1;var e=Hv(),r=Math.max;function t(n,o,a){return o=r(o===void 0?n.length-1:o,0),function(){for(var i=arguments,s=-1,l=r(i.length-o,0),u=Array(l);++s<l;)u[s]=i[o+s];s=-1;for(var c=Array(o+1);++s<o;)c[s]=i[s];return c[o]=a(u),e(n,this,c)}}return No=t,No}var Co,Vd;function Kv(){if(Vd)return Co;Vd=1;var e=sa(),r=Hc(),t=Je(),n=r?function(o,a){return r(o,"toString",{configurable:!0,enumerable:!1,value:e(a),writable:!0})}:t;return Co=n,Co}var Io,Yd;function Uv(){if(Yd)return Io;Yd=1;var e=800,r=16,t=Date.now;function n(o){var a=0,i=0;return function(){var s=t(),l=r-(s-i);if(i=s,l>0){if(++a>=e)return arguments[0]}else a=0;return o.apply(void 0,arguments)}}return Io=n,Io}var Ro,Xd;function Zd(){if(Xd)return Ro;Xd=1;var e=Kv(),r=Uv(),t=r(e);return Ro=t,Ro}var jo,Qd;function Fr(){if(Qd)return jo;Qd=1;var e=Je(),r=Gd(),t=Zd();function n(o,a){return t(r(o,a,e),o+"")}return jo=n,jo}var Oo,ef;function rf(){if(ef)return Oo;ef=1;function e(r,t,n,o){for(var a=r.length,i=n+(o?1:-1);o?i--:++i<a;)if(t(r[i],i,r))return i;return-1}return Oo=e,Oo}var Po,tf;function Jv(){if(tf)return Po;tf=1;function e(r){return r!==r}return Po=e,Po}var Ao,nf;function Gv(){if(nf)return Ao;nf=1;function e(r,t,n){for(var o=n-1,a=r.length;++o<a;)if(r[o]===t)return o;return-1}return Ao=e,Ao}var qo,af;function Vv(){if(af)return qo;af=1;var e=rf(),r=Jv(),t=Gv();function n(o,a,i){return a===a?t(o,a,i):e(o,r,i)}return qo=n,qo}var Lo,of;function Yv(){if(of)return Lo;of=1;var e=Vv();function r(t,n){var o=t==null?0:t.length;return!!o&&e(t,n,0)>-1}return Lo=r,Lo}var Do,sf;function Xv(){if(sf)return Do;sf=1;function e(r,t,n){for(var o=-1,a=r==null?0:r.length;++o<a;)if(n(t,r[o]))return!0;return!1}return Do=e,Do}var Mo,cf;function Zv(){if(cf)return Mo;cf=1;function e(){}return Mo=e,Mo}var Wo,uf;function Qv(){if(uf)return Wo;uf=1;var e=Hu(),r=Zv(),t=Ca(),n=1/0,o=e&&1/t(new e([,-0]))[1]==n?function(a){return new e(a)}:r;return Wo=o,Wo}var Bo,lf;function em(){if(lf)return Bo;lf=1;var e=jl(),r=Yv(),t=Xv(),n=Al(),o=Qv(),a=Ca(),i=200;function s(l,u,c){var f=-1,p=r,h=l.length,g=!0,v=[],m=v;if(c)g=!1,p=t;else if(h>=i){var x=u?null:o(l);if(x)return a(x);g=!1,p=n,m=new e}else m=u?[]:v;e:for(;++f<h;){var y=l[f],b=u?u(y):y;if(y=c||y!==0?y:0,g&&b===b){for(var k=m.length;k--;)if(m[k]===b)continue e;u&&m.push(b),v.push(y)}else p(m,b,c)||(m!==v&&m.push(b),v.push(y))}return v}return Bo=s,Bo}var Fo,df;function ff(){if(df)return Fo;df=1;var e=De(),r=Ae();function t(n){return r(n)&&e(n)}return Fo=t,Fo}var zo,pf;function rm(){if(pf)return zo;pf=1;var e=To(),r=Fr(),t=em(),n=ff(),o=r(function(a){return t(e(a,1,n,!0))});return zo=o,zo}var $o,hf;function tm(){if(hf)return $o;hf=1;var e=Mr();function r(t,n){return e(n,function(o){return t[o]})}return $o=r,$o}var Ho,gf;function vf(){if(gf)return Ho;gf=1;var e=tm(),r=Be();function t(n){return n==null?[]:e(n,r(n))}return Ho=t,Ho}var Ko,mf;function Ee(){if(mf)return Ko;mf=1;var e;if(typeof Zr=="function")try{e={clone:uv(),constant:sa(),each:El(),filter:_d(),has:Td(),isArray:me(),isEmpty:Pv(),isFunction:lr(),isUndefined:Cd(),keys:Be(),map:Od(),reduce:Ld(),size:Fv(),transform:zv(),union:rm(),values:vf()}}catch{}return e||(e=window._),Ko=e,Ko}var Uo,yf;function Jo(){if(yf)return Uo;yf=1;var e=Ee();Uo=o;var r="\0",t="\0",n="";function o(c){this._isDirected=e.has(c,"directed")?c.directed:!0,this._isMultigraph=e.has(c,"multigraph")?c.multigraph:!1,this._isCompound=e.has(c,"compound")?c.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={}}o.prototype._nodeCount=0,o.prototype._edgeCount=0,o.prototype.isDirected=function(){return this._isDirected},o.prototype.isMultigraph=function(){return this._isMultigraph},o.prototype.isCompound=function(){return this._isCompound},o.prototype.setGraph=function(c){return this._label=c,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(c){return e.isFunction(c)||(c=e.constant(c)),this._defaultNodeLabelFn=c,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return e.keys(this._nodes)},o.prototype.sources=function(){var c=this;return e.filter(this.nodes(),function(f){return e.isEmpty(c._in[f])})},o.prototype.sinks=function(){var c=this;return e.filter(this.nodes(),function(f){return e.isEmpty(c._out[f])})},o.prototype.setNodes=function(c,f){var p=arguments,h=this;return e.each(c,function(g){p.length>1?h.setNode(g,f):h.setNode(g)}),this},o.prototype.setNode=function(c,f){return e.has(this._nodes,c)?(arguments.length>1&&(this._nodes[c]=f),this):(this._nodes[c]=arguments.length>1?f:this._defaultNodeLabelFn(c),this._isCompound&&(this._parent[c]=t,this._children[c]={},this._children[t][c]=!0),this._in[c]={},this._preds[c]={},this._out[c]={},this._sucs[c]={},++this._nodeCount,this)},o.prototype.node=function(c){return this._nodes[c]},o.prototype.hasNode=function(c){return e.has(this._nodes,c)},o.prototype.removeNode=function(c){var f=this;if(e.has(this._nodes,c)){var p=function(h){f.removeEdge(f._edgeObjs[h])};delete this._nodes[c],this._isCompound&&(this._removeFromParentsChildList(c),delete this._parent[c],e.each(this.children(c),function(h){f.setParent(h)}),delete this._children[c]),e.each(e.keys(this._in[c]),p),delete this._in[c],delete this._preds[c],e.each(e.keys(this._out[c]),p),delete this._out[c],delete this._sucs[c],--this._nodeCount}return this},o.prototype.setParent=function(c,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===c)throw new Error("Setting "+f+" as parent of "+c+" would create a cycle");this.setNode(f)}return this.setNode(c),this._removeFromParentsChildList(c),this._parent[c]=f,this._children[f][c]=!0,this},o.prototype._removeFromParentsChildList=function(c){delete this._children[this._parent[c]][c]},o.prototype.parent=function(c){if(this._isCompound){var f=this._parent[c];if(f!==t)return f}},o.prototype.children=function(c){if(e.isUndefined(c)&&(c=t),this._isCompound){var f=this._children[c];if(f)return e.keys(f)}else{if(c===t)return this.nodes();if(this.hasNode(c))return[]}},o.prototype.predecessors=function(c){var f=this._preds[c];if(f)return e.keys(f)},o.prototype.successors=function(c){var f=this._sucs[c];if(f)return e.keys(f)},o.prototype.neighbors=function(c){var f=this.predecessors(c);if(f)return e.union(f,this.successors(c))},o.prototype.isLeaf=function(c){var f;return this.isDirected()?f=this.successors(c):f=this.neighbors(c),f.length===0},o.prototype.filterNodes=function(c){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(v,m){c(m)&&f.setNode(m,v)}),e.each(this._edgeObjs,function(v){f.hasNode(v.v)&&f.hasNode(v.w)&&f.setEdge(v,p.edge(v))});var h={};function g(v){var m=p.parent(v);return m===void 0||f.hasNode(m)?(h[v]=m,m):m in h?h[m]:g(m)}return this._isCompound&&e.each(f.nodes(),function(v){f.setParent(v,g(v))}),f},o.prototype.setDefaultEdgeLabel=function(c){return e.isFunction(c)||(c=e.constant(c)),this._defaultEdgeLabelFn=c,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(c,f){var p=this,h=arguments;return e.reduce(c,function(g,v){return h.length>1?p.setEdge(g,v,f):p.setEdge(g,v),v}),this},o.prototype.setEdge=function(){var c,f,p,h,g=!1,v=arguments[0];typeof v=="object"&&v!==null&&"v"in v?(c=v.v,f=v.w,p=v.name,arguments.length===2&&(h=arguments[1],g=!0)):(c=v,f=arguments[1],p=arguments[3],arguments.length>2&&(h=arguments[2],g=!0)),c=""+c,f=""+f,e.isUndefined(p)||(p=""+p);var m=s(this._isDirected,c,f,p);if(e.has(this._edgeLabels,m))return g&&(this._edgeLabels[m]=h),this;if(!e.isUndefined(p)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(c),this.setNode(f),this._edgeLabels[m]=g?h:this._defaultEdgeLabelFn(c,f,p);var x=l(this._isDirected,c,f,p);return c=x.v,f=x.w,Object.freeze(x),this._edgeObjs[m]=x,a(this._preds[f],c),a(this._sucs[c],f),this._in[f][m]=x,this._out[c][m]=x,this._edgeCount++,this},o.prototype.edge=function(c,f,p){var h=arguments.length===1?u(this._isDirected,arguments[0]):s(this._isDirected,c,f,p);return this._edgeLabels[h]},o.prototype.hasEdge=function(c,f,p){var h=arguments.length===1?u(this._isDirected,arguments[0]):s(this._isDirected,c,f,p);return e.has(this._edgeLabels,h)},o.prototype.removeEdge=function(c,f,p){var h=arguments.length===1?u(this._isDirected,arguments[0]):s(this._isDirected,c,f,p),g=this._edgeObjs[h];return g&&(c=g.v,f=g.w,delete this._edgeLabels[h],delete this._edgeObjs[h],i(this._preds[f],c),i(this._sucs[c],f),delete this._in[f][h],delete this._out[c][h],this._edgeCount--),this},o.prototype.inEdges=function(c,f){var p=this._in[c];if(p){var h=e.values(p);return f?e.filter(h,function(g){return g.v===f}):h}},o.prototype.outEdges=function(c,f){var p=this._out[c];if(p){var h=e.values(p);return f?e.filter(h,function(g){return g.w===f}):h}},o.prototype.nodeEdges=function(c,f){var p=this.inEdges(c,f);if(p)return p.concat(this.outEdges(c,f))};function a(c,f){c[f]?c[f]++:c[f]=1}function i(c,f){--c[f]||delete c[f]}function s(c,f,p,h){var g=""+f,v=""+p;if(!c&&g>v){var m=g;g=v,v=m}return g+n+v+n+(e.isUndefined(h)?r:h)}function l(c,f,p,h){var g=""+f,v=""+p;if(!c&&g>v){var m=g;g=v,v=m}var x={v:g,w:v};return h&&(x.name=h),x}function u(c,f){return s(c,f.v,f.w,f.name)}return Uo}var Go,xf;function nm(){return xf||(xf=1,Go="2.1.8"),Go}var Vo,bf;function am(){return bf||(bf=1,Vo={Graph:Jo(),version:nm()}),Vo}var Yo,kf;function om(){if(kf)return Yo;kf=1;var e=Ee(),r=Jo();Yo={write:t,read:a};function t(i){var s={options:{directed:i.isDirected(),multigraph:i.isMultigraph(),compound:i.isCompound()},nodes:n(i),edges:o(i)};return e.isUndefined(i.graph())||(s.value=e.clone(i.graph())),s}function n(i){return e.map(i.nodes(),function(s){var l=i.node(s),u=i.parent(s),c={v:s};return e.isUndefined(l)||(c.value=l),e.isUndefined(u)||(c.parent=u),c})}function o(i){return e.map(i.edges(),function(s){var l=i.edge(s),u={v:s.v,w:s.w};return e.isUndefined(s.name)||(u.name=s.name),e.isUndefined(l)||(u.value=l),u})}function a(i){var s=new r(i.options).setGraph(i.value);return e.each(i.nodes,function(l){s.setNode(l.v,l.value),l.parent&&s.setParent(l.v,l.parent)}),e.each(i.edges,function(l){s.setEdge({v:l.v,w:l.w,name:l.name},l.value)}),s}return Yo}var Xo,_f;function im(){if(_f)return Xo;_f=1;var e=Ee();Xo=r;function r(t){var n={},o=[],a;function i(s){e.has(n,s)||(n[s]=!0,a.push(s),e.each(t.successors(s),i),e.each(t.predecessors(s),i))}return e.each(t.nodes(),function(s){a=[],i(s),a.length&&o.push(a)}),o}return Xo}var Zo,Sf;function wf(){if(Sf)return Zo;Sf=1;var e=Ee();Zo=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 o=this._keyIndices;if(t=String(t),!e.has(o,t)){var a=this._arr,i=a.length;return o[t]=i,a.push({key:t,priority:n}),this._decrease(i),!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 o=this._keyIndices[t];if(n>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[o].priority+" New: "+n);this._arr[o].priority=n,this._decrease(o)},r.prototype._heapify=function(t){var n=this._arr,o=2*t,a=o+1,i=t;o<n.length&&(i=n[o].priority<n[i].priority?o:i,a<n.length&&(i=n[a].priority<n[i].priority?a:i),i!==t&&(this._swap(t,i),this._heapify(i)))},r.prototype._decrease=function(t){for(var n=this._arr,o=n[t].priority,a;t!==0&&(a=t>>1,!(n[a].priority<o));)this._swap(t,a),t=a},r.prototype._swap=function(t,n){var o=this._arr,a=this._keyIndices,i=o[t],s=o[n];o[t]=s,o[n]=i,a[s.key]=t,a[i.key]=n},Zo}var Qo,Tf;function Ef(){if(Tf)return Qo;Tf=1;var e=Ee(),r=wf();Qo=n;var t=e.constant(1);function n(a,i,s,l){return o(a,String(i),s||t,l||function(u){return a.outEdges(u)})}function o(a,i,s,l){var u={},c=new r,f,p,h=function(g){var v=g.v!==f?g.v:g.w,m=u[v],x=s(g),y=p.distance+x;if(x<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+g+" Weight: "+x);y<m.distance&&(m.distance=y,m.predecessor=f,c.decrease(v,y))};for(a.nodes().forEach(function(g){var v=g===i?0:Number.POSITIVE_INFINITY;u[g]={distance:v},c.add(g,v)});c.size()>0&&(f=c.removeMin(),p=u[f],p.distance!==Number.POSITIVE_INFINITY);)l(f).forEach(h);return u}return Qo}var ei,Nf;function sm(){if(Nf)return ei;Nf=1;var e=Ef(),r=Ee();ei=t;function t(n,o,a){return r.transform(n.nodes(),function(i,s){i[s]=e(n,s,o,a)},{})}return ei}var ri,Cf;function If(){if(Cf)return ri;Cf=1;var e=Ee();ri=r;function r(t){var n=0,o=[],a={},i=[];function s(l){var u=a[l]={onStack:!0,lowlink:n,index:n++};if(o.push(l),t.successors(l).forEach(function(p){e.has(a,p)?a[p].onStack&&(u.lowlink=Math.min(u.lowlink,a[p].index)):(s(p),u.lowlink=Math.min(u.lowlink,a[p].lowlink))}),u.lowlink===u.index){var c=[],f;do f=o.pop(),a[f].onStack=!1,c.push(f);while(l!==f);i.push(c)}}return t.nodes().forEach(function(l){e.has(a,l)||s(l)}),i}return ri}var ti,Rf;function cm(){if(Rf)return ti;Rf=1;var e=Ee(),r=If();ti=t;function t(n){return e.filter(r(n),function(o){return o.length>1||o.length===1&&n.hasEdge(o[0],o[0])})}return ti}var ni,jf;function um(){if(jf)return ni;jf=1;var e=Ee();ni=t;var r=e.constant(1);function t(o,a,i){return n(o,a||r,i||function(s){return o.outEdges(s)})}function n(o,a,i){var s={},l=o.nodes();return l.forEach(function(u){s[u]={},s[u][u]={distance:0},l.forEach(function(c){u!==c&&(s[u][c]={distance:Number.POSITIVE_INFINITY})}),i(u).forEach(function(c){var f=c.v===u?c.w:c.v,p=a(c);s[u][f]={distance:p,predecessor:u}})}),l.forEach(function(u){var c=s[u];l.forEach(function(f){var p=s[f];l.forEach(function(h){var g=p[u],v=c[h],m=p[h],x=g.distance+v.distance;x<m.distance&&(m.distance=x,m.predecessor=v.predecessor)})})}),s}return ni}var ai,Of;function Pf(){if(Of)return ai;Of=1;var e=Ee();ai=r,r.CycleException=t;function r(n){var o={},a={},i=[];function s(l){if(e.has(a,l))throw new t;e.has(o,l)||(a[l]=!0,o[l]=!0,e.each(n.predecessors(l),s),delete a[l],i.push(l))}if(e.each(n.sinks(),s),e.size(o)!==n.nodeCount())throw new t;return i}function t(){}return t.prototype=new Error,ai}var oi,Af;function lm(){if(Af)return oi;Af=1;var e=Pf();oi=r;function r(t){try{e(t)}catch(n){if(n instanceof e.CycleException)return!1;throw n}return!0}return oi}var ii,qf;function Lf(){if(qf)return ii;qf=1;var e=Ee();ii=r;function r(n,o,a){e.isArray(o)||(o=[o]);var i=(n.isDirected()?n.successors:n.neighbors).bind(n),s=[],l={};return e.each(o,function(u){if(!n.hasNode(u))throw new Error("Graph does not have node: "+u);t(n,u,a==="post",l,i,s)}),s}function t(n,o,a,i,s,l){e.has(i,o)||(i[o]=!0,a||l.push(o),e.each(s(o),function(u){t(n,u,a,i,s,l)}),a&&l.push(o))}return ii}var si,Df;function dm(){if(Df)return si;Df=1;var e=Lf();si=r;function r(t,n){return e(t,n,"post")}return si}var ci,Mf;function fm(){if(Mf)return ci;Mf=1;var e=Lf();ci=r;function r(t,n){return e(t,n,"pre")}return ci}var ui,Wf;function pm(){if(Wf)return ui;Wf=1;var e=Ee(),r=Jo(),t=wf();ui=n;function n(o,a){var i=new r,s={},l=new t,u;function c(p){var h=p.v===u?p.w:p.v,g=l.priority(h);if(g!==void 0){var v=a(p);v<g&&(s[h]=u,l.decrease(h,v))}}if(o.nodeCount()===0)return i;e.each(o.nodes(),function(p){l.add(p,Number.POSITIVE_INFINITY),i.setNode(p)}),l.decrease(o.nodes()[0],0);for(var f=!1;l.size()>0;){if(u=l.removeMin(),e.has(s,u))i.setEdge(u,s[u]);else{if(f)throw new Error("Input graph is not connected: "+o);f=!0}o.nodeEdges(u).forEach(c)}return i}return ui}var li,Bf;function hm(){return Bf||(Bf=1,li={components:im(),dijkstra:Ef(),dijkstraAll:sm(),findCycles:cm(),floydWarshall:um(),isAcyclic:lm(),postorder:dm(),preorder:fm(),prim:pm(),tarjan:If(),topsort:Pf()}),li}var di,Ff;function gm(){if(Ff)return di;Ff=1;var e=am();return di={Graph:e.Graph,json:om(),alg:hm(),version:e.version},di}var fi,zf;function je(){if(zf)return fi;zf=1;var e;if(typeof Zr=="function")try{e=gm()}catch{}return e||(e=window.graphlib),fi=e,fi}var pi,$f;function vm(){if($f)return pi;$f=1;var e=fl(),r=1,t=4;function n(o){return e(o,r|t)}return pi=n,pi}var hi,Hf;function zr(){if(Hf)return hi;Hf=1;var e=Ze(),r=De(),t=Pr(),n=Te();function o(a,i,s){if(!n(s))return!1;var l=typeof i;return(l=="number"?r(s)&&t(i,s.length):l=="string"&&i in s)?e(s[i],a):!1}return hi=o,hi}var gi,Kf;function mm(){if(Kf)return gi;Kf=1;var e=Fr(),r=Ze(),t=zr(),n=Ue(),o=Object.prototype,a=o.hasOwnProperty,i=e(function(s,l){s=Object(s);var u=-1,c=l.length,f=c>2?l[2]:void 0;for(f&&t(l[0],l[1],f)&&(c=1);++u<c;)for(var p=l[u],h=n(p),g=-1,v=h.length;++g<v;){var m=h[g],x=s[m];(x===void 0||r(x,o[m])&&!a.call(s,m))&&(s[m]=p[m])}return s});return gi=i,gi}var vi,Uf;function ym(){if(Uf)return vi;Uf=1;var e=Me(),r=De(),t=Be();function n(o){return function(a,i,s){var l=Object(a);if(!r(a)){var u=e(i,3);a=t(a),i=function(f){return u(l[f],f,l)}}var c=o(a,i,s);return c>-1?l[u?a[c]:c]:void 0}}return vi=n,vi}var mi,Jf;function xm(){if(Jf)return mi;Jf=1;var e=/\s/;function r(t){for(var n=t.length;n--&&e.test(t.charAt(n)););return n}return mi=r,mi}var yi,Gf;function bm(){if(Gf)return yi;Gf=1;var e=xm(),r=/^\s+/;function t(n){return n&&n.slice(0,e(n)+1).replace(r,"")}return yi=t,yi}var xi,Vf;function km(){if(Vf)return xi;Vf=1;var e=bm(),r=Te(),t=tr(),n=NaN,o=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,i=/^0o[0-7]+$/i,s=parseInt;function l(u){if(typeof u=="number")return u;if(t(u))return n;if(r(u)){var c=typeof u.valueOf=="function"?u.valueOf():u;u=r(c)?c+"":c}if(typeof u!="string")return u===0?u:+u;u=e(u);var f=a.test(u);return f||i.test(u)?s(u.slice(2),f?2:8):o.test(u)?n:+u}return xi=l,xi}var bi,Yf;function Xf(){if(Yf)return bi;Yf=1;var e=km(),r=1/0,t=17976931348623157e292;function n(o){if(!o)return o===0?o:0;if(o=e(o),o===r||o===-r){var a=o<0?-1:1;return a*t}return o===o?o:0}return bi=n,bi}var ki,Zf;function _m(){if(Zf)return ki;Zf=1;var e=Xf();function r(t){var n=e(t),o=n%1;return n===n?o?n-o:n:0}return ki=r,ki}var _i,Qf;function Sm(){if(Qf)return _i;Qf=1;var e=rf(),r=Me(),t=_m(),n=Math.max;function o(a,i,s){var l=a==null?0:a.length;if(!l)return-1;var u=s==null?0:t(s);return u<0&&(u=n(l+u,0)),e(a,r(i,3),u)}return _i=o,_i}var Si,ep;function wm(){if(ep)return Si;ep=1;var e=ym(),r=Sm(),t=e(r);return Si=t,Si}var wi,rp;function tp(){if(rp)return wi;rp=1;var e=To();function r(t){var n=t==null?0:t.length;return n?e(t,1):[]}return wi=r,wi}var Ti,np;function Tm(){if(np)return Ti;np=1;var e=la(),r=_l(),t=Ue();function n(o,a){return o==null?o:e(o,r(a),t)}return Ti=n,Ti}var Ei,ap;function Em(){if(ap)return Ei;ap=1;function e(r){var t=r==null?0:r.length;return t?r[t-1]:void 0}return Ei=e,Ei}var Ni,op;function Nm(){if(op)return Ni;op=1;var e=jr(),r=fa(),t=Me();function n(o,a){var i={};return a=t(a,3),r(o,function(s,l,u){e(i,l,a(s,l,u))}),i}return Ni=n,Ni}var Ci,ip;function Ii(){if(ip)return Ci;ip=1;var e=tr();function r(t,n,o){for(var a=-1,i=t.length;++a<i;){var s=t[a],l=n(s);if(l!=null&&(u===void 0?l===l&&!e(l):o(l,u)))var u=l,c=s}return c}return Ci=r,Ci}var Ri,sp;function Cm(){if(sp)return Ri;sp=1;function e(r,t){return r>t}return Ri=e,Ri}var ji,cp;function Im(){if(cp)return ji;cp=1;var e=Ii(),r=Cm(),t=Je();function n(o){return o&&o.length?e(o,t,r):void 0}return ji=n,ji}var Oi,up;function lp(){if(up)return Oi;up=1;var e=jr(),r=Ze();function t(n,o,a){(a!==void 0&&!r(n[o],a)||a===void 0&&!(o in n))&&e(n,o,a)}return Oi=t,Oi}var Pi,dp;function Rm(){if(dp)return Pi;dp=1;var e=He(),r=Lr(),t=Ae(),n="[object Object]",o=Function.prototype,a=Object.prototype,i=o.toString,s=a.hasOwnProperty,l=i.call(Object);function u(c){if(!t(c)||e(c)!=n)return!1;var f=r(c);if(f===null)return!0;var p=s.call(f,"constructor")&&f.constructor;return typeof p=="function"&&p instanceof p&&i.call(p)==l}return Pi=u,Pi}var Ai,fp;function pp(){if(fp)return Ai;fp=1;function e(r,t){if(!(t==="constructor"&&typeof r[t]=="function")&&t!="__proto__")return r[t]}return Ai=e,Ai}var qi,hp;function jm(){if(hp)return qi;hp=1;var e=dr(),r=Ue();function t(n){return e(n,r(n))}return qi=t,qi}var Li,gp;function Om(){if(gp)return Li;gp=1;var e=lp(),r=_u(),t=rl(),n=wu(),o=il(),a=fr(),i=me(),s=ff(),l=er(),u=lr(),c=Te(),f=Rm(),p=gr(),h=pp(),g=jm();function v(m,x,y,b,k,S,C){var N=h(m,y),A=h(x,y),w=C.get(A);if(w){e(m,y,w);return}var I=S?S(N,A,y+"",m,x,C):void 0,R=I===void 0;if(R){var B=i(A),D=!B&&l(A),L=!B&&!D&&p(A);I=A,B||D||L?i(N)?I=N:s(N)?I=n(N):D?(R=!1,I=r(A,!0)):L?(R=!1,I=t(A,!0)):I=[]:f(A)||a(A)?(I=N,a(N)?I=g(N):(!c(N)||u(N))&&(I=o(A))):R=!1}R&&(C.set(A,I),k(I,A,b,S,C),C.delete(A)),e(m,y,I)}return Li=v,Li}var Di,vp;function Pm(){if(vp)return Di;vp=1;var e=Rr(),r=lp(),t=la(),n=Om(),o=Te(),a=Ue(),i=pp();function s(l,u,c,f,p){l!==u&&t(u,function(h,g){if(p||(p=new e),o(h))n(l,u,g,c,s,f,p);else{var v=f?f(i(l,g),h,g+"",l,u,p):void 0;v===void 0&&(v=h),r(l,g,v)}},a)}return Di=s,Di}var Mi,mp;function Am(){if(mp)return Mi;mp=1;var e=Fr(),r=zr();function t(n){return e(function(o,a){var i=-1,s=a.length,l=s>1?a[s-1]:void 0,u=s>2?a[2]:void 0;for(l=n.length>3&&typeof l=="function"?(s--,l):void 0,u&&r(a[0],a[1],u)&&(l=s<3?void 0:l,s=1),o=Object(o);++i<s;){var c=a[i];c&&n(o,c,i,l)}return o})}return Mi=t,Mi}var Wi,yp;function qm(){if(yp)return Wi;yp=1;var e=Pm(),r=Am(),t=r(function(n,o,a){e(n,o,a)});return Wi=t,Wi}var Bi,xp;function bp(){if(xp)return Bi;xp=1;function e(r,t){return r<t}return Bi=e,Bi}var Fi,kp;function Lm(){if(kp)return Fi;kp=1;var e=Ii(),r=bp(),t=Je();function n(o){return o&&o.length?e(o,t,r):void 0}return Fi=n,Fi}var zi,_p;function Dm(){if(_p)return zi;_p=1;var e=Ii(),r=Me(),t=bp();function n(o,a){return o&&o.length?e(o,r(a,2),t):void 0}return zi=n,zi}var $i,Sp;function Mm(){if(Sp)return $i;Sp=1;var e=Re(),r=function(){return e.Date.now()};return $i=r,$i}var Hi,wp;function Wm(){if(wp)return Hi;wp=1;var e=Or(),r=Wr(),t=Pr(),n=Te(),o=mr();function a(i,s,l,u){if(!n(i))return i;s=r(s,i);for(var c=-1,f=s.length,p=f-1,h=i;h!=null&&++c<f;){var g=o(s[c]),v=l;if(g==="__proto__"||g==="constructor"||g==="prototype")return i;if(c!=p){var m=h[g];v=u?u(m,g,h):void 0,v===void 0&&(v=n(m)?m:t(s[c+1])?[]:{})}e(h,g,v),h=h[g]}return i}return Hi=a,Hi}var Ki,Tp;function Bm(){if(Tp)return Ki;Tp=1;var e=Br(),r=Wm(),t=Wr();function n(o,a,i){for(var s=-1,l=a.length,u={};++s<l;){var c=a[s],f=e(o,c);i(f,c)&&r(u,t(c,o),f)}return u}return Ki=n,Ki}var Ui,Ep;function Fm(){if(Ep)return Ui;Ep=1;var e=Bm(),r=hd();function t(n,o){return e(n,o,function(a,i){return r(n,i)})}return Ui=t,Ui}var Ji,Np;function zm(){if(Np)return Ji;Np=1;var e=tp(),r=Gd(),t=Zd();function n(o){return t(r(o,void 0,e),o+"")}return Ji=n,Ji}var Gi,Cp;function $m(){if(Cp)return Gi;Cp=1;var e=Fm(),r=zm(),t=r(function(n,o){return n==null?{}:e(n,o)});return Gi=t,Gi}var Vi,Ip;function Hm(){if(Ip)return Vi;Ip=1;var e=Math.ceil,r=Math.max;function t(n,o,a,i){for(var s=-1,l=r(e((o-n)/(a||1)),0),u=Array(l);l--;)u[i?l:++s]=n,n+=a;return u}return Vi=t,Vi}var Yi,Rp;function Km(){if(Rp)return Yi;Rp=1;var e=Hm(),r=zr(),t=Xf();function n(o){return function(a,i,s){return s&&typeof s!="number"&&r(a,i,s)&&(i=s=void 0),a=t(a),i===void 0?(i=a,a=0):i=t(i),s=s===void 0?a<i?1:-1:t(s),e(a,i,s,o)}}return Yi=n,Yi}var Xi,jp;function Um(){if(jp)return Xi;jp=1;var e=Km(),r=e();return Xi=r,Xi}var Zi,Op;function Jm(){if(Op)return Zi;Op=1;function e(r,t){var n=r.length;for(r.sort(t);n--;)r[n]=r[n].value;return r}return Zi=e,Zi}var Qi,Pp;function Gm(){if(Pp)return Qi;Pp=1;var e=tr();function r(t,n){if(t!==n){var o=t!==void 0,a=t===null,i=t===t,s=e(t),l=n!==void 0,u=n===null,c=n===n,f=e(n);if(!u&&!f&&!s&&t>n||s&&l&&c&&!u&&!f||a&&l&&c||!o&&c||!i)return 1;if(!a&&!s&&!f&&t<n||f&&o&&i&&!a&&!s||u&&o&&i||!l&&i||!c)return-1}return 0}return Qi=r,Qi}var es,Ap;function Vm(){if(Ap)return es;Ap=1;var e=Gm();function r(t,n,o){for(var a=-1,i=t.criteria,s=n.criteria,l=i.length,u=o.length;++a<l;){var c=e(i[a],s[a]);if(c){if(a>=u)return c;var f=o[a];return c*(f=="desc"?-1:1)}}return t.index-n.index}return es=r,es}var rs,qp;function Ym(){if(qp)return rs;qp=1;var e=Mr(),r=Br(),t=Me(),n=Rd(),o=Jm(),a=Ar(),i=Vm(),s=Je(),l=me();function u(c,f,p){f.length?f=e(f,function(v){return l(v)?function(m){return r(m,v.length===1?v[0]:v)}:v}):f=[s];var h=-1;f=e(f,a(t));var g=n(c,function(v,m,x){var y=e(f,function(b){return b(v)});return{criteria:y,index:++h,value:v}});return o(g,function(v,m){return i(v,m,p)})}return rs=u,rs}var ts,Lp;function Xm(){if(Lp)return ts;Lp=1;var e=To(),r=Ym(),t=Fr(),n=zr(),o=t(function(a,i){if(a==null)return[];var s=i.length;return s>1&&n(a,i[0],i[1])?i=[]:s>2&&n(i[0],i[1],i[2])&&(i=[i[0]]),r(a,e(i,1),[])});return ts=o,ts}var ns,Dp;function Zm(){if(Dp)return ns;Dp=1;var e=od(),r=0;function t(n){var o=++r;return e(n)+o}return ns=t,ns}var as,Mp;function Qm(){if(Mp)return as;Mp=1;function e(r,t,n){for(var o=-1,a=r.length,i=t.length,s={};++o<a;){var l=o<i?t[o]:void 0;n(s,r[o],l)}return s}return as=e,as}var os,Wp;function ey(){if(Wp)return os;Wp=1;var e=Or(),r=Qm();function t(n,o){return r(n||[],o||[],e)}return os=t,os}var is,Bp;function pe(){if(Bp)return is;Bp=1;var e;if(typeof Zr=="function")try{e={cloneDeep:vm(),constant:sa(),defaults:mm(),each:El(),filter:_d(),find:wm(),flatten:tp(),forEach:wl(),forIn:Tm(),has:Td(),isUndefined:Cd(),last:Em(),map:Od(),mapValues:Nm(),max:Im(),merge:qm(),min:Lm(),minBy:Dm(),now:Mm(),pick:$m(),range:Um(),reduce:Ld(),sortBy:Xm(),uniqueId:Zm(),values:vf(),zipObject:ey()}}catch{}return e||(e=window._),is=e,is}var ss,Fp;function ry(){if(Fp)return ss;Fp=1,ss=e;function e(){var n={};n._next=n._prev=n,this._sentinel=n}e.prototype.dequeue=function(){var n=this._sentinel,o=n._prev;if(o!==n)return r(o),o},e.prototype.enqueue=function(n){var o=this._sentinel;n._prev&&n._next&&r(n),n._next=o._next,o._next._prev=n,o._next=n,n._prev=o},e.prototype.toString=function(){for(var n=[],o=this._sentinel,a=o._prev;a!==o;)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,o){if(n!=="_next"&&n!=="_prev")return o}return ss}var cs,zp;function ty(){if(zp)return cs;zp=1;var e=pe(),r=je().Graph,t=ry();cs=o;var n=e.constant(1);function o(u,c){if(u.nodeCount()<=1)return[];var f=s(u,c||n),p=a(f.graph,f.buckets,f.zeroIdx);return e.flatten(e.map(p,function(h){return u.outEdges(h.v,h.w)}),!0)}function a(u,c,f){for(var p=[],h=c[c.length-1],g=c[0],v;u.nodeCount();){for(;v=g.dequeue();)i(u,c,f,v);for(;v=h.dequeue();)i(u,c,f,v);if(u.nodeCount()){for(var m=c.length-2;m>0;--m)if(v=c[m].dequeue(),v){p=p.concat(i(u,c,f,v,!0));break}}}return p}function i(u,c,f,p,h){var g=h?[]:void 0;return e.forEach(u.inEdges(p.v),function(v){var m=u.edge(v),x=u.node(v.v);h&&g.push({v:v.v,w:v.w}),x.out-=m,l(c,f,x)}),e.forEach(u.outEdges(p.v),function(v){var m=u.edge(v),x=v.w,y=u.node(x);y.in-=m,l(c,f,y)}),u.removeNode(p.v),g}function s(u,c){var f=new r,p=0,h=0;e.forEach(u.nodes(),function(m){f.setNode(m,{v:m,in:0,out:0})}),e.forEach(u.edges(),function(m){var x=f.edge(m.v,m.w)||0,y=c(m),b=x+y;f.setEdge(m.v,m.w,b),h=Math.max(h,f.node(m.v).out+=y),p=Math.max(p,f.node(m.w).in+=y)});var g=e.range(h+p+3).map(function(){return new t}),v=p+1;return e.forEach(f.nodes(),function(m){l(g,v,f.node(m))}),{graph:f,buckets:g,zeroIdx:v}}function l(u,c,f){f.out?f.in?u[f.out-f.in+c].enqueue(f):u[u.length-1].enqueue(f):u[0].enqueue(f)}return cs}var us,$p;function ny(){if($p)return us;$p=1;var e=pe(),r=ty();us={run:t,undo:o};function t(a){var i=a.graph().acyclicer==="greedy"?r(a,s(a)):n(a);e.forEach(i,function(l){var u=a.edge(l);a.removeEdge(l),u.forwardName=l.name,u.reversed=!0,a.setEdge(l.w,l.v,u,e.uniqueId("rev"))});function s(l){return function(u){return l.edge(u).weight}}}function n(a){var i=[],s={},l={};function u(c){e.has(l,c)||(l[c]=!0,s[c]=!0,e.forEach(a.outEdges(c),function(f){e.has(s,f.w)?i.push(f):u(f.w)}),delete s[c])}return e.forEach(a.nodes(),u),i}function o(a){e.forEach(a.edges(),function(i){var s=a.edge(i);if(s.reversed){a.removeEdge(i);var l=s.forwardName;delete s.reversed,delete s.forwardName,a.setEdge(i.w,i.v,s,l)}})}return us}var ls,Hp;function Se(){if(Hp)return ls;Hp=1;var e=pe(),r=je().Graph;ls={addDummyNode:t,simplify:n,asNonCompoundGraph:o,successorWeights:a,predecessorWeights:i,intersectRect:s,buildLayerMatrix:l,normalizeRanks:u,removeEmptyRanks:c,addBorderNode:f,maxRank:p,partition:h,time:g,notime:v};function t(m,x,y,b){var k;do k=e.uniqueId(b);while(m.hasNode(k));return y.dummy=x,m.setNode(k,y),k}function n(m){var x=new r().setGraph(m.graph());return e.forEach(m.nodes(),function(y){x.setNode(y,m.node(y))}),e.forEach(m.edges(),function(y){var b=x.edge(y.v,y.w)||{weight:0,minlen:1},k=m.edge(y);x.setEdge(y.v,y.w,{weight:b.weight+k.weight,minlen:Math.max(b.minlen,k.minlen)})}),x}function o(m){var x=new r({multigraph:m.isMultigraph()}).setGraph(m.graph());return e.forEach(m.nodes(),function(y){m.children(y).length||x.setNode(y,m.node(y))}),e.forEach(m.edges(),function(y){x.setEdge(y,m.edge(y))}),x}function a(m){var x=e.map(m.nodes(),function(y){var b={};return e.forEach(m.outEdges(y),function(k){b[k.w]=(b[k.w]||0)+m.edge(k).weight}),b});return e.zipObject(m.nodes(),x)}function i(m){var x=e.map(m.nodes(),function(y){var b={};return e.forEach(m.inEdges(y),function(k){b[k.v]=(b[k.v]||0)+m.edge(k).weight}),b});return e.zipObject(m.nodes(),x)}function s(m,x){var y=m.x,b=m.y,k=x.x-y,S=x.y-b,C=m.width/2,N=m.height/2;if(!k&&!S)throw new Error("Not possible to find intersection inside of the rectangle");var A,w;return Math.abs(S)*C>Math.abs(k)*N?(S<0&&(N=-N),A=N*k/S,w=N):(k<0&&(C=-C),A=C,w=C*S/k),{x:y+A,y:b+w}}function l(m){var x=e.map(e.range(p(m)+1),function(){return[]});return e.forEach(m.nodes(),function(y){var b=m.node(y),k=b.rank;e.isUndefined(k)||(x[k][b.order]=y)}),x}function u(m){var x=e.min(e.map(m.nodes(),function(y){return m.node(y).rank}));e.forEach(m.nodes(),function(y){var b=m.node(y);e.has(b,"rank")&&(b.rank-=x)})}function c(m){var x=e.min(e.map(m.nodes(),function(S){return m.node(S).rank})),y=[];e.forEach(m.nodes(),function(S){var C=m.node(S).rank-x;y[C]||(y[C]=[]),y[C].push(S)});var b=0,k=m.graph().nodeRankFactor;e.forEach(y,function(S,C){e.isUndefined(S)&&C%k!==0?--b:b&&e.forEach(S,function(N){m.node(N).rank+=b})})}function f(m,x,y,b){var k={width:0,height:0};return arguments.length>=4&&(k.rank=y,k.order=b),t(m,"border",k,x)}function p(m){return e.max(e.map(m.nodes(),function(x){var y=m.node(x).rank;if(!e.isUndefined(y))return y}))}function h(m,x){var y={lhs:[],rhs:[]};return e.forEach(m,function(b){x(b)?y.lhs.push(b):y.rhs.push(b)}),y}function g(m,x){var y=e.now();try{return x()}finally{console.log(m+" time: "+(e.now()-y)+"ms")}}function v(m,x){return x()}return ls}var ds,Kp;function ay(){if(Kp)return ds;Kp=1;var e=pe(),r=Se();ds={run:t,undo:o};function t(a){a.graph().dummyChains=[],e.forEach(a.edges(),function(i){n(a,i)})}function n(a,i){var s=i.v,l=a.node(s).rank,u=i.w,c=a.node(u).rank,f=i.name,p=a.edge(i),h=p.labelRank;if(c!==l+1){a.removeEdge(i);var g,v,m;for(m=0,++l;l<c;++m,++l)p.points=[],v={width:0,height:0,edgeLabel:p,edgeObj:i,rank:l},g=r.addDummyNode(a,"edge",v,"_d"),l===h&&(v.width=p.width,v.height=p.height,v.dummy="edge-label",v.labelpos=p.labelpos),a.setEdge(s,g,{weight:p.weight},f),m===0&&a.graph().dummyChains.push(g),s=g;a.setEdge(s,u,{weight:p.weight},f)}}function o(a){e.forEach(a.graph().dummyChains,function(i){var s=a.node(i),l=s.edgeLabel,u;for(a.setEdge(s.edgeObj,l);s.dummy;)u=a.successors(i)[0],a.removeNode(i),l.points.push({x:s.x,y:s.y}),s.dummy==="edge-label"&&(l.x=s.x,l.y=s.y,l.width=s.width,l.height=s.height),i=u,s=a.node(i)})}return ds}var fs,Up;function $r(){if(Up)return fs;Up=1;var e=pe();fs={longestPath:r,slack:t};function r(n){var o={};function a(i){var s=n.node(i);if(e.has(o,i))return s.rank;o[i]=!0;var l=e.min(e.map(n.outEdges(i),function(u){return a(u.w)-n.edge(u).minlen}));return(l===Number.POSITIVE_INFINITY||l===void 0||l===null)&&(l=0),s.rank=l}e.forEach(n.sources(),a)}function t(n,o){return n.node(o.w).rank-n.node(o.v).rank-n.edge(o).minlen}return fs}var ps,Jp;function Gp(){if(Jp)return ps;Jp=1;var e=pe(),r=je().Graph,t=$r().slack;ps=n;function n(s){var l=new r({directed:!1}),u=s.nodes()[0],c=s.nodeCount();l.setNode(u,{});for(var f,p;o(l,s)<c;)f=a(l,s),p=l.hasNode(f.v)?t(s,f):-t(s,f),i(l,s,p);return l}function o(s,l){function u(c){e.forEach(l.nodeEdges(c),function(f){var p=f.v,h=c===p?f.w:p;!s.hasNode(h)&&!t(l,f)&&(s.setNode(h,{}),s.setEdge(c,h,{}),u(h))})}return e.forEach(s.nodes(),u),s.nodeCount()}function a(s,l){return e.minBy(l.edges(),function(u){if(s.hasNode(u.v)!==s.hasNode(u.w))return t(l,u)})}function i(s,l,u){e.forEach(s.nodes(),function(c){l.node(c).rank+=u})}return ps}var hs,Vp;function oy(){if(Vp)return hs;Vp=1;var e=pe(),r=Gp(),t=$r().slack,n=$r().longestPath,o=je().alg.preorder,a=je().alg.postorder,i=Se().simplify;hs=s,s.initLowLimValues=f,s.initCutValues=l,s.calcCutValue=c,s.leaveEdge=h,s.enterEdge=g,s.exchangeEdges=v;function s(b){b=i(b),n(b);var k=r(b);f(k),l(k,b);for(var S,C;S=h(k);)C=g(k,b,S),v(k,b,S,C)}function l(b,k){var S=a(b,b.nodes());S=S.slice(0,S.length-1),e.forEach(S,function(C){u(b,k,C)})}function u(b,k,S){var C=b.node(S),N=C.parent;b.edge(S,N).cutvalue=c(b,k,S)}function c(b,k,S){var C=b.node(S),N=C.parent,A=!0,w=k.edge(S,N),I=0;return w||(A=!1,w=k.edge(N,S)),I=w.weight,e.forEach(k.nodeEdges(S),function(R){var B=R.v===S,D=B?R.w:R.v;if(D!==N){var L=B===A,F=k.edge(R).weight;if(I+=L?F:-F,x(b,S,D)){var W=b.edge(S,D).cutvalue;I+=L?-W:W}}}),I}function f(b,k){arguments.length<2&&(k=b.nodes()[0]),p(b,{},1,k)}function p(b,k,S,C,N){var A=S,w=b.node(C);return k[C]=!0,e.forEach(b.neighbors(C),function(I){e.has(k,I)||(S=p(b,k,S,I,C))}),w.low=A,w.lim=S++,N?w.parent=N:delete w.parent,S}function h(b){return e.find(b.edges(),function(k){return b.edge(k).cutvalue<0})}function g(b,k,S){var C=S.v,N=S.w;k.hasEdge(C,N)||(C=S.w,N=S.v);var A=b.node(C),w=b.node(N),I=A,R=!1;A.lim>w.lim&&(I=w,R=!0);var B=e.filter(k.edges(),function(D){return R===y(b,b.node(D.v),I)&&R!==y(b,b.node(D.w),I)});return e.minBy(B,function(D){return t(k,D)})}function v(b,k,S,C){var N=S.v,A=S.w;b.removeEdge(N,A),b.setEdge(C.v,C.w,{}),f(b),l(b,k),m(b,k)}function m(b,k){var S=e.find(b.nodes(),function(N){return!k.node(N).parent}),C=o(b,S);C=C.slice(1),e.forEach(C,function(N){var A=b.node(N).parent,w=k.edge(N,A),I=!1;w||(w=k.edge(A,N),I=!0),k.node(N).rank=k.node(A).rank+(I?w.minlen:-w.minlen)})}function x(b,k,S){return b.hasEdge(k,S)}function y(b,k,S){return S.low<=k.lim&&k.lim<=S.lim}return hs}var gs,Yp;function iy(){if(Yp)return gs;Yp=1;var e=$r(),r=e.longestPath,t=Gp(),n=oy();gs=o;function o(l){switch(l.graph().ranker){case"network-simplex":s(l);break;case"tight-tree":i(l);break;case"longest-path":a(l);break;default:s(l)}}var a=r;function i(l){r(l),t(l)}function s(l){n(l)}return gs}var vs,Xp;function sy(){if(Xp)return vs;Xp=1;var e=pe();vs=r;function r(o){var a=n(o);e.forEach(o.graph().dummyChains,function(i){for(var s=o.node(i),l=s.edgeObj,u=t(o,a,l.v,l.w),c=u.path,f=u.lca,p=0,h=c[p],g=!0;i!==l.w;){if(s=o.node(i),g){for(;(h=c[p])!==f&&o.node(h).maxRank<s.rank;)p++;h===f&&(g=!1)}if(!g){for(;p<c.length-1&&o.node(h=c[p+1]).minRank<=s.rank;)p++;h=c[p]}o.setParent(i,h),i=o.successors(i)[0]}})}function t(o,a,i,s){var l=[],u=[],c=Math.min(a[i].low,a[s].low),f=Math.max(a[i].lim,a[s].lim),p,h;p=i;do p=o.parent(p),l.push(p);while(p&&(a[p].low>c||f>a[p].lim));for(h=p,p=s;(p=o.parent(p))!==h;)u.push(p);return{path:l.concat(u.reverse()),lca:h}}function n(o){var a={},i=0;function s(l){var u=i;e.forEach(o.children(l),s),a[l]={low:u,lim:i++}}return e.forEach(o.children(),s),a}return vs}var ms,Zp;function cy(){if(Zp)return ms;Zp=1;var e=pe(),r=Se();ms={run:t,cleanup:i};function t(s){var l=r.addDummyNode(s,"root",{},"_root"),u=o(s),c=e.max(e.values(u))-1,f=2*c+1;s.graph().nestingRoot=l,e.forEach(s.edges(),function(h){s.edge(h).minlen*=f});var p=a(s)+1;e.forEach(s.children(),function(h){n(s,l,f,p,c,u,h)}),s.graph().nodeRankFactor=f}function n(s,l,u,c,f,p,h){var g=s.children(h);if(!g.length){h!==l&&s.setEdge(l,h,{weight:0,minlen:u});return}var v=r.addBorderNode(s,"_bt"),m=r.addBorderNode(s,"_bb"),x=s.node(h);s.setParent(v,h),x.borderTop=v,s.setParent(m,h),x.borderBottom=m,e.forEach(g,function(y){n(s,l,u,c,f,p,y);var b=s.node(y),k=b.borderTop?b.borderTop:y,S=b.borderBottom?b.borderBottom:y,C=b.borderTop?c:2*c,N=k!==S?1:f-p[h]+1;s.setEdge(v,k,{weight:C,minlen:N,nestingEdge:!0}),s.setEdge(S,m,{weight:C,minlen:N,nestingEdge:!0})}),s.parent(h)||s.setEdge(l,v,{weight:0,minlen:f+p[h]})}function o(s){var l={};function u(c,f){var p=s.children(c);p&&p.length&&e.forEach(p,function(h){u(h,f+1)}),l[c]=f}return e.forEach(s.children(),function(c){u(c,1)}),l}function a(s){return e.reduce(s.edges(),function(l,u){return l+s.edge(u).weight},0)}function i(s){var l=s.graph();s.removeNode(l.nestingRoot),delete l.nestingRoot,e.forEach(s.edges(),function(u){var c=s.edge(u);c.nestingEdge&&s.removeEdge(u)})}return ms}var ys,Qp;function uy(){if(Qp)return ys;Qp=1;var e=pe(),r=Se();ys=t;function t(o){function a(i){var s=o.children(i),l=o.node(i);if(s.length&&e.forEach(s,a),e.has(l,"minRank")){l.borderLeft=[],l.borderRight=[];for(var u=l.minRank,c=l.maxRank+1;u<c;++u)n(o,"borderLeft","_bl",i,l,u),n(o,"borderRight","_br",i,l,u)}}e.forEach(o.children(),a)}function n(o,a,i,s,l,u){var c={width:0,height:0,rank:u,borderType:a},f=l[a][u-1],p=r.addDummyNode(o,"border",c,i);l[a][u]=p,o.setParent(p,s),f&&o.setEdge(f,p,{weight:1})}return ys}var xs,eh;function ly(){if(eh)return xs;eh=1;var e=pe();xs={adjust:r,undo:t};function r(u){var c=u.graph().rankdir.toLowerCase();(c==="lr"||c==="rl")&&n(u)}function t(u){var c=u.graph().rankdir.toLowerCase();(c==="bt"||c==="rl")&&a(u),(c==="lr"||c==="rl")&&(s(u),n(u))}function n(u){e.forEach(u.nodes(),function(c){o(u.node(c))}),e.forEach(u.edges(),function(c){o(u.edge(c))})}function o(u){var c=u.width;u.width=u.height,u.height=c}function a(u){e.forEach(u.nodes(),function(c){i(u.node(c))}),e.forEach(u.edges(),function(c){var f=u.edge(c);e.forEach(f.points,i),e.has(f,"y")&&i(f)})}function i(u){u.y=-u.y}function s(u){e.forEach(u.nodes(),function(c){l(u.node(c))}),e.forEach(u.edges(),function(c){var f=u.edge(c);e.forEach(f.points,l),e.has(f,"x")&&l(f)})}function l(u){var c=u.x;u.x=u.y,u.y=c}return xs}var bs,rh;function dy(){if(rh)return bs;rh=1;var e=pe();bs=r;function r(t){var n={},o=e.filter(t.nodes(),function(u){return!t.children(u).length}),a=e.max(e.map(o,function(u){return t.node(u).rank})),i=e.map(e.range(a+1),function(){return[]});function s(u){if(!e.has(n,u)){n[u]=!0;var c=t.node(u);i[c.rank].push(u),e.forEach(t.successors(u),s)}}var l=e.sortBy(o,function(u){return t.node(u).rank});return e.forEach(l,s),i}return bs}var ks,th;function fy(){if(th)return ks;th=1;var e=pe();ks=r;function r(n,o){for(var a=0,i=1;i<o.length;++i)a+=t(n,o[i-1],o[i]);return a}function t(n,o,a){for(var i=e.zipObject(a,e.map(a,function(p,h){return h})),s=e.flatten(e.map(o,function(p){return e.sortBy(e.map(n.outEdges(p),function(h){return{pos:i[h.w],weight:n.edge(h).weight}}),"pos")}),!0),l=1;l<a.length;)l<<=1;var u=2*l-1;l-=1;var c=e.map(new Array(u),function(){return 0}),f=0;return e.forEach(s.forEach(function(p){var h=p.pos+l;c[h]+=p.weight;for(var g=0;h>0;)h%2&&(g+=c[h+1]),h=h-1>>1,c[h]+=p.weight;f+=p.weight*g})),f}return ks}var _s,nh;function py(){if(nh)return _s;nh=1;var e=pe();_s=r;function r(t,n){return e.map(n,function(o){var a=t.inEdges(o);if(a.length){var i=e.reduce(a,function(s,l){var u=t.edge(l),c=t.node(l.v);return{sum:s.sum+u.weight*c.order,weight:s.weight+u.weight}},{sum:0,weight:0});return{v:o,barycenter:i.sum/i.weight,weight:i.weight}}else return{v:o}})}return _s}var Ss,ah;function hy(){if(ah)return Ss;ah=1;var e=pe();Ss=r;function r(o,a){var i={};e.forEach(o,function(l,u){var c=i[l.v]={indegree:0,in:[],out:[],vs:[l.v],i:u};e.isUndefined(l.barycenter)||(c.barycenter=l.barycenter,c.weight=l.weight)}),e.forEach(a.edges(),function(l){var u=i[l.v],c=i[l.w];!e.isUndefined(u)&&!e.isUndefined(c)&&(c.indegree++,u.out.push(i[l.w]))});var s=e.filter(i,function(l){return!l.indegree});return t(s)}function t(o){var a=[];function i(u){return function(c){c.merged||(e.isUndefined(c.barycenter)||e.isUndefined(u.barycenter)||c.barycenter>=u.barycenter)&&n(u,c)}}function s(u){return function(c){c.in.push(u),--c.indegree===0&&o.push(c)}}for(;o.length;){var l=o.pop();a.push(l),e.forEach(l.in.reverse(),i(l)),e.forEach(l.out,s(l))}return e.map(e.filter(a,function(u){return!u.merged}),function(u){return e.pick(u,["vs","i","barycenter","weight"])})}function n(o,a){var i=0,s=0;o.weight&&(i+=o.barycenter*o.weight,s+=o.weight),a.weight&&(i+=a.barycenter*a.weight,s+=a.weight),o.vs=a.vs.concat(o.vs),o.barycenter=i/s,o.weight=s,o.i=Math.min(a.i,o.i),a.merged=!0}return Ss}var ws,oh;function gy(){if(oh)return ws;oh=1;var e=pe(),r=Se();ws=t;function t(a,i){var s=r.partition(a,function(v){return e.has(v,"barycenter")}),l=s.lhs,u=e.sortBy(s.rhs,function(v){return-v.i}),c=[],f=0,p=0,h=0;l.sort(o(!!i)),h=n(c,u,h),e.forEach(l,function(v){h+=v.vs.length,c.push(v.vs),f+=v.barycenter*v.weight,p+=v.weight,h=n(c,u,h)});var g={vs:e.flatten(c,!0)};return p&&(g.barycenter=f/p,g.weight=p),g}function n(a,i,s){for(var l;i.length&&(l=e.last(i)).i<=s;)i.pop(),a.push(l.vs),s++;return s}function o(a){return function(i,s){return i.barycenter<s.barycenter?-1:i.barycenter>s.barycenter?1:a?s.i-i.i:i.i-s.i}}return ws}var Ts,ih;function vy(){if(ih)return Ts;ih=1;var e=pe(),r=py(),t=hy(),n=gy();Ts=o;function o(s,l,u,c){var f=s.children(l),p=s.node(l),h=p?p.borderLeft:void 0,g=p?p.borderRight:void 0,v={};h&&(f=e.filter(f,function(S){return S!==h&&S!==g}));var m=r(s,f);e.forEach(m,function(S){if(s.children(S.v).length){var C=o(s,S.v,u,c);v[S.v]=C,e.has(C,"barycenter")&&i(S,C)}});var x=t(m,u);a(x,v);var y=n(x,c);if(h&&(y.vs=e.flatten([h,y.vs,g],!0),s.predecessors(h).length)){var b=s.node(s.predecessors(h)[0]),k=s.node(s.predecessors(g)[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(s,l){e.forEach(s,function(u){u.vs=e.flatten(u.vs.map(function(c){return l[c]?l[c].vs:c}),!0)})}function i(s,l){e.isUndefined(s.barycenter)?(s.barycenter=l.barycenter,s.weight=l.weight):(s.barycenter=(s.barycenter*s.weight+l.barycenter*l.weight)/(s.weight+l.weight),s.weight+=l.weight)}return Ts}var Es,sh;function my(){if(sh)return Es;sh=1;var e=pe(),r=je().Graph;Es=t;function t(o,a,i){var s=n(o),l=new r({compound:!0}).setGraph({root:s}).setDefaultNodeLabel(function(u){return o.node(u)});return e.forEach(o.nodes(),function(u){var c=o.node(u),f=o.parent(u);(c.rank===a||c.minRank<=a&&a<=c.maxRank)&&(l.setNode(u),l.setParent(u,f||s),e.forEach(o[i](u),function(p){var h=p.v===u?p.w:p.v,g=l.edge(h,u),v=e.isUndefined(g)?0:g.weight;l.setEdge(h,u,{weight:o.edge(p).weight+v})}),e.has(c,"minRank")&&l.setNode(u,{borderLeft:c.borderLeft[a],borderRight:c.borderRight[a]}))}),l}function n(o){for(var a;o.hasNode(a=e.uniqueId("_root")););return a}return Es}var Ns,ch;function yy(){if(ch)return Ns;ch=1;var e=pe();Ns=r;function r(t,n,o){var a={},i;e.forEach(o,function(s){for(var l=t.parent(s),u,c;l;){if(u=t.parent(l),u?(c=a[u],a[u]=l):(c=i,i=l),c&&c!==l){n.setEdge(c,l);return}l=u}})}return Ns}var Cs,uh;function xy(){if(uh)return Cs;uh=1;var e=pe(),r=dy(),t=fy(),n=vy(),o=my(),a=yy(),i=je().Graph,s=Se();Cs=l;function l(p){var h=s.maxRank(p),g=u(p,e.range(1,h+1),"inEdges"),v=u(p,e.range(h-1,-1,-1),"outEdges"),m=r(p);f(p,m);for(var x=Number.POSITIVE_INFINITY,y,b=0,k=0;k<4;++b,++k){c(b%2?g:v,b%4>=2),m=s.buildLayerMatrix(p);var S=t(p,m);S<x&&(k=0,y=e.cloneDeep(m),x=S)}f(p,y)}function u(p,h,g){return e.map(h,function(v){return o(p,v,g)})}function c(p,h){var g=new i;e.forEach(p,function(v){var m=v.graph().root,x=n(v,m,g,h);e.forEach(x.vs,function(y,b){v.node(y).order=b}),a(v,g,x.vs)})}function f(p,h){e.forEach(h,function(g){e.forEach(g,function(v,m){p.node(v).order=m})})}return Cs}var Is,lh;function by(){if(lh)return Is;lh=1;var e=pe(),r=je().Graph,t=Se();Is={positionX:g,findType1Conflicts:n,findType2Conflicts:o,addConflict:i,hasConflict:s,verticalAlignment:l,horizontalCompaction:u,alignCoordinates:p,findSmallestWidthAlignment:f,balance:h};function n(x,y){var b={};function k(S,C){var N=0,A=0,w=S.length,I=e.last(C);return e.forEach(C,function(R,B){var D=a(x,R),L=D?x.node(D).order:w;(D||R===I)&&(e.forEach(C.slice(A,B+1),function(F){e.forEach(x.predecessors(F),function(W){var V=x.node(W),Z=V.order;(Z<N||L<Z)&&!(V.dummy&&x.node(F).dummy)&&i(b,W,F)})}),A=B+1,N=L)}),C}return e.reduce(y,k),b}function o(x,y){var b={};function k(C,N,A,w,I){var R;e.forEach(e.range(N,A),function(B){R=C[B],x.node(R).dummy&&e.forEach(x.predecessors(R),function(D){var L=x.node(D);L.dummy&&(L.order<w||L.order>I)&&i(b,D,R)})})}function S(C,N){var A=-1,w,I=0;return e.forEach(N,function(R,B){if(x.node(R).dummy==="border"){var D=x.predecessors(R);D.length&&(w=x.node(D[0]).order,k(N,I,B,A,w),I=B,A=w)}k(N,I,N.length,w,C.length)}),N}return e.reduce(y,S),b}function a(x,y){if(x.node(y).dummy)return e.find(x.predecessors(y),function(b){return x.node(b).dummy})}function i(x,y,b){if(y>b){var k=y;y=b,b=k}var S=x[y];S||(x[y]=S={}),S[b]=!0}function s(x,y,b){if(y>b){var k=y;y=b,b=k}return e.has(x[y],b)}function l(x,y,b,k){var S={},C={},N={};return e.forEach(y,function(A){e.forEach(A,function(w,I){S[w]=w,C[w]=w,N[w]=I})}),e.forEach(y,function(A){var w=-1;e.forEach(A,function(I){var R=k(I);if(R.length){R=e.sortBy(R,function(W){return N[W]});for(var B=(R.length-1)/2,D=Math.floor(B),L=Math.ceil(B);D<=L;++D){var F=R[D];C[I]===I&&w<N[F]&&!s(b,I,F)&&(C[F]=I,C[I]=S[I]=S[F],w=N[F])}}})}),{root:S,align:C}}function u(x,y,b,k,S){var C={},N=c(x,y,b,S),A=S?"borderLeft":"borderRight";function w(B,D){for(var L=N.nodes(),F=L.pop(),W={};F;)W[F]?B(F):(W[F]=!0,L.push(F),L=L.concat(D(F))),F=L.pop()}function I(B){C[B]=N.inEdges(B).reduce(function(D,L){return Math.max(D,C[L.v]+N.edge(L))},0)}function R(B){var D=N.outEdges(B).reduce(function(F,W){return Math.min(F,C[W.w]-N.edge(W))},Number.POSITIVE_INFINITY),L=x.node(B);D!==Number.POSITIVE_INFINITY&&L.borderType!==A&&(C[B]=Math.max(C[B],D))}return w(I,N.predecessors.bind(N)),w(R,N.successors.bind(N)),e.forEach(k,function(B){C[B]=C[b[B]]}),C}function c(x,y,b,k){var S=new r,C=x.graph(),N=v(C.nodesep,C.edgesep,k);return e.forEach(y,function(A){var w;e.forEach(A,function(I){var R=b[I];if(S.setNode(R),w){var B=b[w],D=S.edge(B,R);S.setEdge(B,R,Math.max(N(x,I,w),D||0))}w=I})}),S}function f(x,y){return e.minBy(e.values(y),function(b){var k=Number.NEGATIVE_INFINITY,S=Number.POSITIVE_INFINITY;return e.forIn(b,function(C,N){var A=m(x,N)/2;k=Math.max(C+A,k),S=Math.min(C-A,S)}),k-S})}function p(x,y){var b=e.values(y),k=e.min(b),S=e.max(b);e.forEach(["u","d"],function(C){e.forEach(["l","r"],function(N){var A=C+N,w=x[A],I;if(w!==y){var R=e.values(w);I=N==="l"?k-e.min(R):S-e.max(R),I&&(x[A]=e.mapValues(w,function(B){return B+I}))}})})}function h(x,y){return e.mapValues(x.ul,function(b,k){if(y)return x[y.toLowerCase()][k];var S=e.sortBy(e.map(x,k));return(S[1]+S[2])/2})}function g(x){var y=t.buildLayerMatrix(x),b=e.merge(n(x,y),o(x,y)),k={},S;e.forEach(["u","d"],function(N){S=N==="u"?y:e.values(y).reverse(),e.forEach(["l","r"],function(A){A==="r"&&(S=e.map(S,function(B){return e.values(B).reverse()}));var w=(N==="u"?x.predecessors:x.successors).bind(x),I=l(x,S,b,w),R=u(x,S,I.root,I.align,A==="r");A==="r"&&(R=e.mapValues(R,function(B){return-B})),k[N+A]=R})});var C=f(x,k);return p(k,C),h(k,x.graph().align)}function v(x,y,b){return function(k,S,C){var N=k.node(S),A=k.node(C),w=0,I;if(w+=N.width/2,e.has(N,"labelpos"))switch(N.labelpos.toLowerCase()){case"l":I=-N.width/2;break;case"r":I=N.width/2;break}if(I&&(w+=b?I:-I),I=0,w+=(N.dummy?y:x)/2,w+=(A.dummy?y:x)/2,w+=A.width/2,e.has(A,"labelpos"))switch(A.labelpos.toLowerCase()){case"l":I=A.width/2;break;case"r":I=-A.width/2;break}return I&&(w+=b?I:-I),I=0,w}}function m(x,y){return x.node(y).width}return Is}var Rs,dh;function ky(){if(dh)return Rs;dh=1;var e=pe(),r=Se(),t=by().positionX;Rs=n;function n(a){a=r.asNonCompoundGraph(a),o(a),e.forEach(t(a),function(i,s){a.node(s).x=i})}function o(a){var i=r.buildLayerMatrix(a),s=a.graph().ranksep,l=0;e.forEach(i,function(u){var c=e.max(e.map(u,function(f){return a.node(f).height}));e.forEach(u,function(f){a.node(f).y=l+c/2}),l+=c+s})}return Rs}var js,fh;function _y(){if(fh)return js;fh=1;var e=pe(),r=ny(),t=ay(),n=iy(),o=Se().normalizeRanks,a=sy(),i=Se().removeEmptyRanks,s=cy(),l=uy(),u=ly(),c=xy(),f=ky(),p=Se(),h=je().Graph;js=g;function g(E,j){var M=j&&j.debugTiming?p.time:p.notime;M("layout",function(){var P=M(" buildLayoutGraph",function(){return w(E)});M(" runLayout",function(){v(P,M)}),M(" updateInputGraph",function(){m(E,P)})})}function v(E,j){j(" makeSpaceForEdgeLabels",function(){I(E)}),j(" removeSelfEdges",function(){le(E)}),j(" acyclic",function(){r.run(E)}),j(" nestingGraph.run",function(){s.run(E)}),j(" rank",function(){n(p.asNonCompoundGraph(E))}),j(" injectEdgeLabelProxies",function(){R(E)}),j(" removeEmptyRanks",function(){i(E)}),j(" nestingGraph.cleanup",function(){s.cleanup(E)}),j(" normalizeRanks",function(){o(E)}),j(" assignRankMinMax",function(){B(E)}),j(" removeEdgeLabelProxies",function(){D(E)}),j(" normalize.run",function(){t.run(E)}),j(" parentDummyChains",function(){a(E)}),j(" addBorderSegments",function(){l(E)}),j(" order",function(){c(E)}),j(" insertSelfEdges",function(){se(E)}),j(" adjustCoordinateSystem",function(){u.adjust(E)}),j(" position",function(){f(E)}),j(" positionSelfEdges",function(){_(E)}),j(" removeBorderNodes",function(){Z(E)}),j(" normalize.undo",function(){t.undo(E)}),j(" fixupEdgeLabelCoords",function(){W(E)}),j(" undoCoordinateSystem",function(){u.undo(E)}),j(" translateGraph",function(){L(E)}),j(" assignNodeIntersects",function(){F(E)}),j(" reversePoints",function(){V(E)}),j(" acyclic.undo",function(){r.undo(E)})}function m(E,j){e.forEach(E.nodes(),function(M){var P=E.node(M),z=j.node(M);P&&(P.x=z.x,P.y=z.y,j.children(M).length&&(P.width=z.width,P.height=z.height))}),e.forEach(E.edges(),function(M){var P=E.edge(M),z=j.edge(M);P.points=z.points,e.has(z,"x")&&(P.x=z.x,P.y=z.y)}),E.graph().width=j.graph().width,E.graph().height=j.graph().height}var x=["nodesep","edgesep","ranksep","marginx","marginy"],y={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},b=["acyclicer","ranker","rankdir","align"],k=["width","height"],S={width:0,height:0},C=["minlen","weight","width","height","labeloffset"],N={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},A=["labelpos"];function w(E){var j=new h({multigraph:!0,compound:!0}),M=K(E.graph());return j.setGraph(e.merge({},y,Y(M,x),e.pick(M,b))),e.forEach(E.nodes(),function(P){var z=K(E.node(P));j.setNode(P,e.defaults(Y(z,k),S)),j.setParent(P,E.parent(P))}),e.forEach(E.edges(),function(P){var z=K(E.edge(P));j.setEdge(P,e.merge({},N,Y(z,C),e.pick(z,A)))}),j}function I(E){var j=E.graph();j.ranksep/=2,e.forEach(E.edges(),function(M){var P=E.edge(M);P.minlen*=2,P.labelpos.toLowerCase()!=="c"&&(j.rankdir==="TB"||j.rankdir==="BT"?P.width+=P.labeloffset:P.height+=P.labeloffset)})}function R(E){e.forEach(E.edges(),function(j){var M=E.edge(j);if(M.width&&M.height){var P=E.node(j.v),z=E.node(j.w),ee={rank:(z.rank-P.rank)/2+P.rank,e:j};p.addDummyNode(E,"edge-proxy",ee,"_ep")}})}function B(E){var j=0;e.forEach(E.nodes(),function(M){var P=E.node(M);P.borderTop&&(P.minRank=E.node(P.borderTop).rank,P.maxRank=E.node(P.borderBottom).rank,j=e.max(j,P.maxRank))}),E.graph().maxRank=j}function D(E){e.forEach(E.nodes(),function(j){var M=E.node(j);M.dummy==="edge-proxy"&&(E.edge(M.e).labelRank=M.rank,E.removeNode(j))})}function L(E){var j=Number.POSITIVE_INFINITY,M=0,P=Number.POSITIVE_INFINITY,z=0,ee=E.graph(),ae=ee.marginx||0,ie=ee.marginy||0;function ne(G){var J=G.x,H=G.y,$=G.width,X=G.height;j=Math.min(j,J-$/2),M=Math.max(M,J+$/2),P=Math.min(P,H-X/2),z=Math.max(z,H+X/2)}e.forEach(E.nodes(),function(G){ne(E.node(G))}),e.forEach(E.edges(),function(G){var J=E.edge(G);e.has(J,"x")&&ne(J)}),j-=ae,P-=ie,e.forEach(E.nodes(),function(G){var J=E.node(G);J.x-=j,J.y-=P}),e.forEach(E.edges(),function(G){var J=E.edge(G);e.forEach(J.points,function(H){H.x-=j,H.y-=P}),e.has(J,"x")&&(J.x-=j),e.has(J,"y")&&(J.y-=P)}),ee.width=M-j+ae,ee.height=z-P+ie}function F(E){e.forEach(E.edges(),function(j){var M=E.edge(j),P=E.node(j.v),z=E.node(j.w),ee,ae;M.points?(ee=M.points[0],ae=M.points[M.points.length-1]):(M.points=[],ee=z,ae=P),M.points.unshift(p.intersectRect(P,ee)),M.points.push(p.intersectRect(z,ae))})}function W(E){e.forEach(E.edges(),function(j){var M=E.edge(j);if(e.has(M,"x"))switch((M.labelpos==="l"||M.labelpos==="r")&&(M.width-=M.labeloffset),M.labelpos){case"l":M.x-=M.width/2+M.labeloffset;break;case"r":M.x+=M.width/2+M.labeloffset;break}})}function V(E){e.forEach(E.edges(),function(j){var M=E.edge(j);M.reversed&&M.points.reverse()})}function Z(E){e.forEach(E.nodes(),function(j){if(E.children(j).length){var M=E.node(j),P=E.node(M.borderTop),z=E.node(M.borderBottom),ee=E.node(e.last(M.borderLeft)),ae=E.node(e.last(M.borderRight));M.width=Math.abs(ae.x-ee.x),M.height=Math.abs(z.y-P.y),M.x=ee.x+M.width/2,M.y=P.y+M.height/2}}),e.forEach(E.nodes(),function(j){E.node(j).dummy==="border"&&E.removeNode(j)})}function le(E){e.forEach(E.edges(),function(j){if(j.v===j.w){var M=E.node(j.v);M.selfEdges||(M.selfEdges=[]),M.selfEdges.push({e:j,label:E.edge(j)}),E.removeEdge(j)}})}function se(E){var j=p.buildLayerMatrix(E);e.forEach(j,function(M){var P=0;e.forEach(M,function(z,ee){var ae=E.node(z);ae.order=ee+P,e.forEach(ae.selfEdges,function(ie){p.addDummyNode(E,"selfedge",{width:ie.label.width,height:ie.label.height,rank:ae.rank,order:ee+ ++P,e:ie.e,label:ie.label},"_se")}),delete ae.selfEdges})})}function _(E){e.forEach(E.nodes(),function(j){var M=E.node(j);if(M.dummy==="selfedge"){var P=E.node(M.e.v),z=P.x+P.width/2,ee=P.y,ae=M.x-z,ie=P.height/2;E.setEdge(M.e,M.label),E.removeNode(j),M.label.points=[{x:z+2*ae/3,y:ee-ie},{x:z+5*ae/6,y:ee-ie},{x:z+ae,y:ee},{x:z+5*ae/6,y:ee+ie},{x:z+2*ae/3,y:ee+ie}],M.label.x=M.x,M.label.y=M.y}})}function Y(E,j){return e.mapValues(e.pick(E,j),Number)}function K(E){var j={};return e.forEach(E,function(M,P){j[P.toLowerCase()]=M}),j}return js}var Os,ph;function Sy(){if(ph)return Os;ph=1;var e=pe(),r=Se(),t=je().Graph;Os={debugOrdering:n};function n(o){var a=r.buildLayerMatrix(o),i=new t({compound:!0,multigraph:!0}).setGraph({});return e.forEach(o.nodes(),function(s){i.setNode(s,{label:s}),i.setParent(s,"layer"+o.node(s).rank)}),e.forEach(o.edges(),function(s){i.setEdge(s.v,s.w,{},s.name)}),e.forEach(a,function(s,l){var u="layer"+l;i.setNode(u,{rank:"same"}),e.reduce(s,function(c,f){return i.setEdge(c,f,{style:"invis"}),f})}),i}return Os}var Ps,hh;function wy(){return hh||(hh=1,Ps="0.8.5"),Ps}var As,gh;function Ty(){return gh||(gh=1,As={graphlib:je(),layout:_y(),debug:Sy(),util:{time:Se().time,notime:Se().notime},version:wy()}),As}var Ey=Ty();const vh=Vh(Ey);function nr(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 Ny(e,r,t=8){const n=[];if(e.length<t)return n;const o=new Map,a={},i={};e.forEach(f=>{o.set(f.id,f),a[f.id]=[],i[f.id]=[]}),r.forEach(f=>{a[f.source]&&a[f.source].push(f.target),i[f.target]&&i[f.target].push(f.source)});const s=new Set,l=new Set(["input","output","decisionNode","forkNode","joinNode","loopNode","default","plusNode"]),u=f=>!l.has(f.type||""),c=[...e].sort((f,p)=>f.position.y-p.position.y);for(const f of c){if(s.has(f.id)||!u(f)||a[f.id].length>1)continue;const p=[f.id];let h=f,g=a[h.id];for(;g&&g.length===1;){const v=g[0],m=o.get(v);if(!m||s.has(v)||!u(m)||i[v].length!==1)break;p.push(v),h=m,g=a[h.id]}p.length>=t&&(n.push(p),p.forEach(v=>s.add(v)))}return n}function Cy(e,r,t,n,o,a=5,i="view"){const s=r.find(y=>y.id===e[0]),{width:l,height:u}=nr(s||r[0],t),c=Math.max(.7,1-(e.length-10)/80),f=i==="edit"||i==="run"?1.15:1,p=Math.min(n,Math.round(60*c*f)),h=Math.min(o,Math.round(80*c*f)),g=l+p,v=u+h;let m=0,x=0;if(t==="TB"){const y=Math.ceil(e.length/a);m=a*g-p,x=y*v-h}else m=Math.ceil(e.length/a)*g-p,x=a*v-h;return m+=40,x+=40,{width:m,height:x,gridKW:g,gridKH:v,cols:a}}const qs=58,mh=20,Iy=16;function Ry(e,r,t,n){if(e.length===0)return{positionedChildren:[],containerWidth:280,containerHeight:qs+50};const o=e.map(f=>({...f,parentId:void 0,extent:void 0})),{nodes:a}=Ls(o,r,{direction:t,mode:n,enableSnakeLayout:!1});let i=0,s=0;a.forEach(f=>{const{width:p,height:h}=nr(f,t);i=Math.max(i,f.position.x+p),s=Math.max(s,f.position.y+h)});const l=Math.max(300,i+mh*2),u=qs+s+Iy;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+mh,y:f.position.y+qs}}}),containerWidth:l,containerHeight:u}}function Ls(e,r,t={}){const{direction:n="TB",mode:o="view",enableSnakeLayout:a=!0,snakeColumns:i=5,snakeMinChainLength:s=8,snakeMinNodeCount:l=10}=t,u=e.length,c=e.filter(w=>w.type!=="plusNode").length;let f=n==="LR"?150:120,p=n==="LR"?120:100,h=f,g=p;if(u>15){let w=Math.max(.5,1-(u-15)/50),I=Math.max(.4,1-(u-15)/40);(o==="edit"||o==="run")&&(w=1-(1-w)*.5,I=1-(1-I)*.5),h=Math.round(f*w),g=Math.round(p*I)}const v=a&&c>l?Ny(e,r,s):[],m={};v.forEach((w,I)=>{w.forEach(R=>{m[R]=I})});const x=new vh.graphlib.Graph;x.setDefaultEdgeLabel(()=>({})),x.setGraph({rankdir:n,ranker:"network-simplex",ranksep:h,nodesep:g,edgesep:50,marginx:50,marginy:50});const y=new Set,b={};e.forEach(w=>{const I=m[w.id];if(I!==void 0){if(!y.has(I)){y.add(I);const R=Cy(v[I],e,n,g,h,i,o);b[I]=R,x.setNode(`__CHAIN_${I}`,{width:R.width,height:R.height})}}else{const{width:R,height:B}=nr(w,n);x.setNode(w.id,{width:R,height:B})}}),r.forEach(w=>{const I=m[w.source],R=m[w.target];let B=w.source,D=w.target;I!==void 0&&(B=`__CHAIN_${I}`),R!==void 0&&(D=`__CHAIN_${R}`),B!==D&&x.setEdge(B,D)}),vh.layout(x);const k={};for(const w of e)k[w.id]={...w};const S=[],C=new Set;e.forEach(w=>{if(m[w.id]===void 0){const I=x.node(w.id),R=k[w.id],{width:B,height:D}=nr(R,n);R.position={x:I.x-B/2,y:I.y-D/2},R.data={...R.data,sourcePosition:void 0,targetPosition:void 0},R.sourcePosition=n==="LR"?O.Position.Right:O.Position.Bottom,R.targetPosition=n==="LR"?O.Position.Left:O.Position.Top,S.push(R)}else C.add(w.id)}),v.forEach((w,I)=>{const R=`__CHAIN_${I}`,B=x.node(R),D=b[I],L=B.x-D.width/2+20,F=B.y-D.height/2+20,W=D.cols,V=D.gridKW,Z=D.gridKH;w.forEach((le,se)=>{const _=k[le];let Y=0,K=0,E,j;if(n==="TB"){const M=Math.floor(se/W),P=se%W,z=M%2===0,ee=Math.ceil(w.length/W),ae=M===ee-1,ie=w.length%W||W,ne=ae?(W-ie)*V/2:0;let G;z?G=P*V+ne:G=(W-1-P)*V-ne;const J=M*Z;Y=L+G,K=F+J;const H=ae?ie:W;z?(j=O.Position.Left,E=O.Position.Right,P===H-1&&se!==w.length-1&&(E=O.Position.Bottom),P===0&&se!==0&&(j=O.Position.Top)):(j=O.Position.Right,E=O.Position.Left,P===H-1&&se!==w.length-1&&(E=O.Position.Bottom),P===0&&se!==0&&(j=O.Position.Top)),se===0&&(j=O.Position.Top),se===w.length-1&&(E=O.Position.Bottom)}else{const M=Math.floor(se/W),P=se%W,z=M%2===0,ee=Math.ceil(w.length/W),ae=M===ee-1,ie=w.length%W||W,ne=ae?Math.max(0,(W-ie)*Z)/2:0,G=M*V;let J;z?J=P*Z+ne:J=(W-1-P)*Z-ne,Y=L+G,K=F+J;const H=ae?ie:W;z?(j=O.Position.Top,E=O.Position.Bottom,P===H-1&&se!==w.length-1&&(E=O.Position.Right),P===0&&se!==0&&(j=O.Position.Left)):(j=O.Position.Bottom,E=O.Position.Top,P===H-1&&se!==w.length-1&&(E=O.Position.Right),P===0&&se!==0&&(j=O.Position.Left)),se===0&&(j=O.Position.Left),se===w.length-1&&(E=O.Position.Right)}_.position={x:Y,y:K},_.data={..._.data,sourcePosition:E,targetPosition:j},_.sourcePosition=E,_.targetPosition=j,S.push(_)})});const N=S.reduce((w,I)=>({...w,[I.id]:I}),{}),A=r.map(w=>{const I=N[w.source],R=N[w.target];if(!I||!R||C.has(I.id)||I.type!=="decisionNode")return w;const{width:B,height:D}=nr(I,n),{width:L,height:F}=nr(R,n),W={x:I.position.x+B/2,y:I.position.y+D/2},V={x:R.position.x+L/2,y:R.position.y+F/2};let Z=null;if(n==="TB"){const le=B*.25;V.x<W.x-le?Z="left":V.x>W.x+le&&(Z="right")}else{const le=D*.25;V.y<W.y-le?Z="top":V.y>W.y+le&&(Z="bottom")}return{...w,sourceHandle:Z}});return{nodes:S,edges:A}}function be(e,r,t={}){const n=t.direction||"TB",o=t.mode||"view",a=e.filter(x=>x.parentId),i=e.filter(x=>!x.parentId);if(a.length===0)return Ls(e,r,t);const s=new Map(a.map(x=>[x.id,x])),l={},u=[];r.forEach(x=>{const y=s.get(x.source),b=s.get(x.target);if(y?.parentId&&y.parentId===b?.parentId){const k=y.parentId;l[k]||(l[k]=[]),l[k].push(x)}else u.push(x)});const c={};a.forEach(x=>{const y=x.parentId;c[y]||(c[y]=[]),c[y].push(x)});const f={},p=[];for(const[x,y]of Object.entries(c)){const b=l[x]||[],{positionedChildren:k,containerWidth:S,containerHeight:C}=Ry(y,b,n,o);f[x]={width:S,height:C},p.push(...k)}const h=i.map(x=>{if(x.type==="loopNode"&&f[x.id]){const{width:y,height:b}=f[x.id];return{...x,data:{...x.data,_layoutWidth:y,_layoutHeight:b},style:{...x.style,width:y,height:b}}}return x}),{nodes:g,edges:v}=Ls(h,u,t);return{nodes:[...g.map(x=>{if(x.type==="loopNode"&&f[x.id]){const{width:y,height:b}=f[x.id];return{...x,width:y,height:b,style:{...x.style,width:y,height:b}}}return x}),...p],edges:[...v,...Object.values(l).flat()]}}function we(e,r){if(!e)return null;for(const t of e){if(t.taskReferenceName===r)return t;if(t.decisionCases){for(const o of Object.keys(t.decisionCases)){const a=we(t.decisionCases[o],r);if(a)return a}const n=we(t.defaultCase,r);if(n)return n}if(t.forkTasks)for(const n of t.forkTasks){const o=we(n,r);if(o)return o}if(t.loopOver){const n=we(t.loopOver,r);if(n)return n}}return null}function qe(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 o of Object.keys(n.decisionCases))if(qe(n.decisionCases[o],r))return!0;if(qe(n.defaultCase,r))return!0}if(n.forkTasks){for(const o of n.forkTasks)if(qe(o,r))return!0}if(n.loopOver&&qe(n.loopOver,r))return!0}return!1}function ar(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 o of Object.values(t.decisionCases)){const a=ar(o,r);if(a)return a}const n=ar(t.defaultCase,r);if(n)return n}if(t.forkTasks)for(const n of t.forkTasks){const o=ar(n,r);if(o)return o}if(t.loopOver){const n=ar(t.loopOver,r);if(n)return n}}return null}function yh(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 xh(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 Oe(e,r,t){if(!e)return!1;const n=e.findIndex(o=>o.taskReferenceName===r);if(n!==-1)return e.splice(n+1,0,t),!0;for(const o of e){if(o.decisionCases){for(const a of Object.keys(o.decisionCases))if(Oe(o.decisionCases[a],r,t))return!0;if(Oe(o.defaultCase,r,t))return!0}if(o.forkTasks){for(const a of o.forkTasks)if(Oe(a,r,t))return!0}if(o.loopOver&&Oe(o.loopOver,r,t))return!0}return!1}function or(e,r,t,n){for(const o of e||[]){if(o.taskReferenceName===r){if(t.branchCase==="default")return o.defaultCase||(o.defaultCase=[]),o.defaultCase.unshift(n),!0;if(t.branchCase!==void 0)return o.decisionCases||(o.decisionCases={}),o.decisionCases[t.branchCase]||(o.decisionCases[t.branchCase]=[]),o.decisionCases[t.branchCase].unshift(n),!0;if(t.forkIndex!==void 0)return o.forkTasks||(o.forkTasks=[]),o.forkTasks[t.forkIndex].unshift(n),!0;if(t.isLoopAdd)return o.loopOver||(o.loopOver=[]),o.loopOver.unshift(n),!0}if(o.decisionCases){for(const a of Object.keys(o.decisionCases))if(or(o.decisionCases[a],r,t,n))return!0;if(or(o.defaultCase,r,t,n))return!0}if(o.forkTasks){for(const a of o.forkTasks)if(or(a,r,t,n))return!0}if(o.loopOver&&or(o.loopOver,r,t,n))return!0}return!1}function ke(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 o=[];(t.forkTasks||[]).forEach(a=>{a&&a.length>0&&o.push(a[a.length-1].taskReferenceName)}),n.joinOn=o}}t.decisionCases&&(Object.values(t.decisionCases).forEach(n=>ke(n)),t.defaultCase&&ke(t.defaultCase)),t.forkTasks&&t.forkTasks.forEach(n=>ke(n)),t.loopOver&&ke(t.loopOver)}}const jy=[{field:"name",type:"required",message:"工作流名称 (name) 必填"},{field:"version",type:"required",message:"工作流版本 (version) 必填"},{field:"tasks",type:"min_length",value:1,message:"工作流必须包含至少一个任务"}],bh={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"}]}},Oy=(e,r)=>r.split(".").reduce((t,n)=>t&&t[n]!==void 0?t[n]:void 0,e),Ds=(e,r,t,n)=>{const{errors:o,warnings:a}=n,i=e.taskReferenceName||"GLOBAL";r.forEach(s=>{const l=Oy(e,s.field);let u=!0;switch(s.type){case"required":u=l!=null&&l!=="";break;case"min_length":u=Array.isArray(l)&&l.length>=s.value;break;case"pattern":u=s.value.test(l);break;case"enum":u=s.value.includes(l);break;case"unique":s.field==="taskReferenceName"&&l&&(t.taskRefs.has(l)?u=!1:t.taskRefs.add(l));break;case"custom":typeof s.validate=="function"&&(u=s.validate(l,e,t));break}if(!u){const c={type:e.taskReferenceName?"TASK":"GLOBAL",ref:i,message:s.message};s.level==="warning"?a.push(c):o.push(c)}})},Ne=e=>{const r=[],t=[],n={taskRefs:new Set,taskMap:{}};if(!e)return{isValid:!1,errors:[{type:"GLOBAL",ref:"",message:"工作流定义为空"}],warnings:[]};if(Ds(e,jy,n,{errors:r,warnings:t}),!e.tasks||e.tasks.length===0)return{isValid:!1,errors:r,warnings:t};const o=i=>{i.forEach(s=>{Ds(s,bh.common,n,{errors:r,warnings:t});const l=bh.types[s.type];l&&Ds(s,l,n,{errors:r,warnings:t}),s.decisionCases&&Object.keys(s.decisionCases).forEach(u=>{o(s.decisionCases[u])}),s.defaultCase&&o(s.defaultCase),s.forkTasks&&s.forkTasks.forEach(u=>o(u)),s.loopOver&&o(s.loopOver)})};o(e.tasks);const a=Py(e.tasks);return r.push(...a),{isValid:r.length===0,errors:r,warnings:t}},Py=e=>{const r=[],t=new Map,n=new Set,o=c=>{for(let f=0;f<c.length;f++){const p=c[f],h=p.taskReferenceName;if(n.add(h),t.has(h)||t.set(h,[]),f<c.length-1){const g=c[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),o(g));if(p.defaultCase&&p.defaultCase.length>0&&(t.get(h).push(p.defaultCase[0].taskReferenceName),o(p.defaultCase)),p.forkTasks)for(const g of p.forkTasks)g.length>0&&(t.get(h).push(g[0].taskReferenceName),o(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)}};o(e);const a=0,i=1,s=2,l=new Map;for(const c of n)l.set(c,a);const u=c=>{l.set(c,i);const f=t.get(c)||[];for(const p of f)if(l.has(p)){if(l.get(p)===i)return r.push({type:"GLOBAL",ref:p,message:`检测到环路:任务 "${c}" → "${p}" 形成了循环依赖`}),!0;if(l.get(p)===a&&u(p))return!0}return l.set(c,s),!1};for(const c of n)l.get(c)===a&&u(c);return r};function Ay(e,r){const t=new Set(e),n={};e.forEach(s=>n[s]=0),r.forEach(s=>{t.has(s.source)&&t.has(s.target)&&(n[s.target]=(n[s.target]??0)+1)});const o=[];let a=e.filter(s=>n[s]===0);const i={...n};for(;a.length>0;){o.push([...a]);const s=[];a.forEach(l=>{r.forEach(u=>{u.source===l&&t.has(u.target)&&(i[u.target]--,i[u.target]===0&&s.push(u.target))})}),a=s}return o}const oe=rg()(tg(ng((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,setWorkflow:(t,n)=>{const o=n||r().layoutDirection,a=JSON.parse(JSON.stringify(t));ke(a.tasks);const{nodes:i,edges:s,taskMap:l}=_e(a,o,{hideEmptyBranches:r().mode!=="edit"}),{nodes:u,edges:c}=be(i,s,{direction:o,mode:r().mode}),f=Ne(a);e({workflowDef:a,nodes:u,edges:c,taskMap:l,validationResults:f,layoutDirection:o,workflowLoadKey:r().workflowLoadKey+1})},setMode:t=>{r().mode==="run"&&t!=="run"&&e({executionData:null,workflowInstance:null,dynamicRuntimeTasksByFork:{}}),e({mode:t});const{workflowDef:o,layoutDirection:a}=r();if(o){const{nodes:i,edges:s,taskMap:l}=_e(o,a,{hideEmptyBranches:t!=="edit"}),{nodes:u,edges:c}=be(i,s,{direction:a,mode:t});e({nodes:u,edges:c,taskMap:l})}},setExecutionData:t=>e({executionData:t,dynamicRuntimeTasksByFork:t===null?{}:r().dynamicRuntimeTasksByFork}),updateTaskStatus:(t,n)=>{const{executionData:o}=r();if(!o)return;const a={...o};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=[],o=null,a=r().workflowDef;if(Array.isArray(t.tasks)?(n=t.tasks,t.workflowId&&t.status&&(o=t,t.workflowDefinition&&(a=t.workflowDefinition))):Array.isArray(t)&&(n=t),n.length===0)return;const i={};n.forEach(p=>{const h=p.referenceTaskName;h&&(i[h]||(i[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}),i[h].attempts.push(p))}),Object.values(i).forEach(p=>{p.attempts.some(v=>v.iteration!==void 0&&v.iteration>0)?(p.attempts.sort((v,m)=>(v.iteration??0)-(m.iteration??0)),p.totalIterations=p.attempts.reduce((v,m)=>Math.max(v,m.iteration??0),0),p.startTime=p.attempts[0]?.startTime):p.attempts.sort((v,m)=>(v.retryCount??0)-(m.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 s=r().taskMap,u=r().workflowDef?.tasks||[],c=[];u.forEach((p,h)=>{if(p.type==="FORK_JOIN_DYNAMIC"){for(let g=h+1;g<u.length;g++)if(u[g].type==="JOIN"||u[g].type==="EXCLUSIVE_JOIN"){c.push({forkRef:p.taskReferenceName,joinRef:u[g].taskReferenceName});break}}});const f={};c.forEach(({forkRef:p,joinRef:h})=>{const g=n.findIndex(x=>x.referenceTaskName===p),v=n.findIndex(x=>x.referenceTaskName===h);if(g<0||v<0)return;const m=new Set;f[p]=n.slice(g+1,v).filter(x=>!x.referenceTaskName||!x.taskId||s[x.referenceTaskName]||m.has(x.referenceTaskName)?!1:(m.add(x.referenceTaskName),!0)).map(x=>x)}),e({executionData:i,dynamicRuntimeTasksByFork:f,workflowInstance:o,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:o,edges:a,taskMap:i}=_e(n,t,{hideEmptyBranches:r().mode!=="edit"}),{nodes:s,edges:l}=be(o,a,{direction:t,mode:r().mode});e({nodes:s,edges:l,taskMap:i,layoutDirection:t})}else e({layoutDirection:t})},onNodesChange:t=>{const n=r().nodes,o=new Set(n.map(i=>i.id)),a=t.filter(i=>"id"in i&&o.has(i.id));a.length!==0&&e({nodes:O.applyNodeChanges(a,n)})},onEdgesChange:t=>{const n=r().edges,o=O.applyEdgeChanges(t,n);o!==n&&e({edges:o})},onConnect:t=>{const{edges:n,layoutDirection:o}=r(),a=O.addEdge(t,n),{nodes:i,edges:s}=be(r().nodes,a,{direction:o,mode:r().mode});e({edges:s,nodes:i})},checkTaskRefUniqueness:(t,n)=>{if(t===n)return!0;const{taskMap:o}=r();return!o[t]},updateTask:(t,n,o)=>{const{workflowDef:a,layoutDirection:i}=r();if(!a)return;const s=JSON.parse(JSON.stringify(a)),l=we(s.tasks,t);if(l){typeof n=="object"?Object.assign(l,n):l[n]=o,ke(s.tasks);const{nodes:u,edges:c,taskMap:f}=_e(s,i,{hideEmptyBranches:r().mode!=="edit"}),{nodes:p,edges:h}=be(u,c,{direction:i,mode:r().mode}),g=Ne(s);e({workflowDef:s,nodes:p,edges:h,taskMap:f,validationResults:g})}},updateWorkflowProperties:t=>{const{workflowDef:n,layoutDirection:o}=r();if(!n)return;const a=JSON.parse(JSON.stringify(n));Object.assign(a,t),ke(a.tasks);const{nodes:i,edges:s,taskMap:l}=_e(a,o,{hideEmptyBranches:r().mode!=="edit"}),{nodes:u,edges:c}=be(i,s,{direction:o,mode:r().mode}),f=Ne(a);e({workflowDef:a,nodes:u,edges:c,taskMap:l,validationResults:f})},addNode:(t,n,o,a,i={})=>{const{workflowDef:s,layoutDirection:l}=r();if(!s)return;const u=JSON.parse(JSON.stringify(s)),c={name:t.data.label,taskReferenceName:t.data.taskReferenceName,type:t.data.taskType||"SIMPLE",inputParameters:{}};switch(c.type){case"HTTP":c.httpRequest={method:"GET",uri:"https://example.com/api",headers:{"Content-Type":"application/json"},body:{}};break;case"KAFKA_PUBLISH":c.inputParameters={topic:"my_topic",value:"${workflow.input.value}",bootStrapServers:"localhost:9092",headers:{},key:"msg_key"};break;case"JSON_JQ_TRANSFORM":c.inputParameters={queryExpression:".name",input:{}};break;case"SET_VARIABLE":c.inputParameters={variableName:"variableValue"};break;case"SUB_WORKFLOW":c.subWorkflowParam={name:"execution_workflow",version:1};break;case"EVENT":c.sink="conductor";break;case"WAIT":c.inputParameters={duration:"30s"};break;case"TERMINATE":c.inputParameters={terminationStatus:"COMPLETED",workflowOutput:{}};break}if(c.type==="FORK_JOIN"||c.type==="FORK_JOIN_DYNAMIC"){c.type==="FORK_JOIN"?c.forkTasks=[[],[]]:(c.dynamicForkTasksParam="dynamic_tasks",c.dynamicForkTasksInputParamName="input");const x={name:`${c.name}_join`,taskReferenceName:`${c.taskReferenceName}_join`,type:"JOIN",joinOn:[]};if(i.isWorkflowStart)u.tasks.unshift(x),u.tasks.unshift(c);else if(i.isLoopBodyStart){const y=we(u.tasks,n);y&&(y.loopOver||(y.loopOver=[]),y.loopOver.unshift(x),y.loopOver.unshift(c))}else i.branchCase!==void 0||i.forkIndex!==void 0||i.isLoopAdd?(or(u.tasks,n,i,c),Oe(u.tasks,c.taskReferenceName,x)):u.tasks.length===0?u.tasks.push(c,x):(Oe(u.tasks,n,c),Oe(u.tasks,c.taskReferenceName,x))}else if(c.type==="DECISION"||c.type==="SWITCH"?(c.evaluatorType="value-param",c.caseValueParam="case_param",c.decisionCases={case1:[]},c.defaultCase=[]):c.type==="DO_WHILE"?(c.loopCondition="$.taskReferenceName.output.value < 10",c.loopOver=[]):c.type==="INLINE"?(c.evaluatorType="graaljs",c.inputParameters={expression:`function execute(input) {
|
|
6
|
+
<%s key={someKey} {...props} />`,R,B,$,B),re[B+R]=!0)}if(B=null,ie!==void 0&&(r(ie),B=""+ie),o(G)&&(r(G.key),B=""+G.key),"key"in G){ie={};for(var X in G)X!=="key"&&(ie[X]=G[X])}else ie=G;return B&&i(ie,typeof q=="function"?q.displayName||q.name||"Unknown":q),c(q,B,ie,s(),M,_)}function f(q){p(q)?q._store&&(q._store.validated=1):typeof q=="object"&&q!==null&&q.$$typeof===T&&(q._payload.status==="fulfilled"?p(q._payload.value)&&q._payload.value._store&&(q._payload.value._store.validated=1):q._store&&(q._store.validated=1))}function p(q){return typeof q=="object"&&q!==null&&q.$$typeof===g}var h=O,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"),D=h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I=Object.prototype.hasOwnProperty,P=Array.isArray,F=console.createTask?console.createTask:function(){return null};h={react_stack_bottom_frame:function(q){return q()}};var W,K={},V=h.react_stack_bottom_frame.bind(h,a)(),te=F(t(a)),re={};fr.Fragment=v,fr.jsx=function(q,G,ie){var R=1e4>D.recentlyCreatedOwnerStacks++;return d(q,G,ie,!1,R?Error("react-stack-top-frame"):V,R?F(t(q)):te)},fr.jsxs=function(q,G,ie){var R=1e4>D.recentlyCreatedOwnerStacks++;return d(q,G,ie,!0,R?Error("react-stack-top-frame"):V,R?F(t(q)):te)}})()),fr}var Zi;function fg(){return Zi||(Zi=1,process.env.NODE_ENV==="production"?Nr.exports=dg():Nr.exports=ug()),Nr.exports}var l=fg();const Qi=e=>{let n;const r=new Set,t=(c,d)=>{const f=typeof c=="function"?c(n):c;if(!Object.is(f,n)){const p=n;n=d??(typeof f!="object"||f===null)?f:Object.assign({},n,f),r.forEach(h=>h(n,p))}},s=()=>n,i={setState:t,getState:s,getInitialState:()=>u,subscribe:c=>(r.add(c),()=>r.delete(c))},u=n=e(t,s,i);return i},el=(e=>e?Qi(e):Qi),pg=e=>e;function et(e,n=pg){const r=O.useSyncExternalStore(e.subscribe,O.useCallback(()=>n(e.getState()),[e,n]),O.useCallback(()=>n(e.getInitialState()),[e,n]));return O.useDebugValue(r),r}const hg=e=>{const n=el(e),r=t=>et(n,t);return Object.assign(r,n),r},rt=(e=>hg);function tt(e,n){let r;try{r=e()}catch{return}return{getItem:s=>{var a;const o=u=>u===null?null:JSON.parse(u,void 0),i=(a=r.getItem(s))!=null?a:null;return i instanceof Promise?i.then(o):o(i)},setItem:(s,a)=>r.setItem(s,JSON.stringify(a,void 0)),removeItem:s=>r.removeItem(s)}}const nt=e=>n=>{try{const r=e(n);return r instanceof Promise?r:{then(t){return nt(t)(r)},catch(t){return this}}}catch(r){return{then(t){return this},catch(t){return nt(t)(r)}}}},rl=(e,n)=>(r,t,s)=>{let a={storage:tt(()=>localStorage),partialize:m=>m,version:0,merge:(m,v)=>({...v,...m}),...n},o=!1;const i=new Set,u=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.`),r(...m)},t,s);const d=()=>{const m=a.partialize({...t()});return c.setItem(a.name,{state:m,version:a.version})},f=s.setState;s.setState=(m,v)=>(f(m,v),d());const p=e((...m)=>(r(...m),d()),t,s);s.getInitialState=()=>p;let h;const g=()=>{var m,v;if(!c)return;o=!1,i.forEach(x=>{var b;return x((b=t())!=null?b:p)});const y=((v=a.onRehydrateStorage)==null?void 0:v.call(a,(m=t())!=null?m:p))||void 0;return nt(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=t())!=null?b:p),r(h,!0),k)return d()}).then(()=>{y?.(h,void 0),h=t(),o=!0,u.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=>(u.add(m),()=>{u.delete(m)})},a.skipHydration||g(),h||p};var tl=(e,n,r)=>(s,a)=>({pastStates:r?.pastStates||[],futureStates:r?.futureStates||[],undo:(o=1)=>{if(a().pastStates.length){const i=r?.partialize?.(n())||n(),u=a().pastStates.splice(-o,o),c=u.shift();e(c),s({pastStates:a().pastStates,futureStates:a().futureStates.concat(r?.diff?.(i,c)||i,u.reverse())})}},redo:(o=1)=>{if(a().futureStates.length){const i=r?.partialize?.(n())||n(),u=a().futureStates.splice(-o,o),c=u.shift();e(c),s({pastStates:a().pastStates.concat(r?.diff?.(i,c)||i,u.reverse()),futureStates:a().futureStates})}},clear:()=>s({pastStates:[],futureStates:[]}),isTracking:!0,pause:()=>s({isTracking:!1}),resume:()=>s({isTracking:!0}),setOnSave:o=>s({_onSave:o}),_onSave:r?.onSave,_handleSet:(o,i,u,c)=>{r?.limit&&a().pastStates.length>=r?.limit&&a().pastStates.shift(),a()._onSave?.(o,u),s({pastStates:a().pastStates.concat(c||o),futureStates:[]})}}),gg=(e,n)=>(t,s,a)=>{a.temporal=el(n?.wrapTemporal?.(tl(t,s,n))||tl(t,s,n));const o=n?.handleSet?.(a.temporal.getState()._handleSet)||a.temporal.getState()._handleSet,i=c=>{if(!a.temporal.getState().isTracking)return;const d=n?.partialize?.(s())||s(),f=n?.diff?.(c,d);f===null||n?.equality?.(c,d)||o(c,void 0,d,f)},u=a.setState;return a.setState=(...c)=>{const d=n?.partialize?.(s())||s();u(...c),i(d)},e((...c)=>{const d=n?.partialize?.(s())||s();t(...c),i(d)},s,a)};function mg(e,n="TB",r){const t=r?.hideEmptyBranches??!1;if(!e||!e.tasks)return{nodes:[],edges:[],taskMap:{}};const s=[],a=[],o={};let i=0;const u=e.tasks;for(let c=0;c<u.length;c++){const d=u[c],f=nl(d,i,o,n,u,t);if(s.push(...f.nodes),a.push(...f.edges),i=f.nextId,c>0){const p=u[c-1];at(p,d,a,t)}Object.assign(o,f.taskMap)}if(!t&&u.length>0){const c=u[0],d="__workflow_start__";s.push({id:d,type:"plusNode",data:{label:"+",taskReferenceName:d,taskType:"PLUS",parentRef:d,edgeData:{isWorkflowStart:!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}),a.push({id:`e-${d}-${c.taskReferenceName}`,source:d,target:c.taskReferenceName,animated:!0});const f=u[u.length-1],p="__workflow_end__";s.push({id:p,type:"plusNode",data:{label:"+",taskReferenceName:p,taskType:"PLUS",parentRef:f.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}),at(f,{taskReferenceName:p},a,t)}return{nodes:s,edges:a,taskMap:o}}function nl(e,n,r,t="TB",s=[],a=!1){switch(e.type||"SIMPLE"){case"DECISION":case"SWITCH":return yg(e,n,r,t,a);case"FORK_JOIN":case"FORK_JOIN_DYNAMIC":return xg(e,n,r,t);case"JOIN":case"EXCLUSIVE_JOIN":return _g(e,n,r,t,s,a);case"DO_WHILE":return bg(e,n,r,t,a);case"SUB_WORKFLOW":return kg(e,n,r,t);default:return vg(e,n,r,t)}}function vg(e,n,r,t="TB"){const s={id:e.taskReferenceName,type:"taskNode",data:{label:e.name,taskReferenceName:e.taskReferenceName,taskType:e.type||"SIMPLE",task:e,layoutDirection:t},position:{x:0,y:0},sourcePosition:t==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:t==="LR"?A.Position.Left:A.Position.Top},a={[e.taskReferenceName]:e};return{nodes:[s],edges:[],taskMap:a,nextId:n+1}}function yg(e,n,r,t="TB",s=!1){const a=[],o=[];let i=n;const u={},c={id:e.taskReferenceName,type:"decisionNode",data:{label:e.name,taskReferenceName:e.taskReferenceName,taskType:e.type,task:e,layoutDirection:t},position:{x:0,y:0},sourcePosition:t==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:t==="LR"?A.Position.Left:A.Position.Top};a.push(c),u[e.taskReferenceName]=e;const d=e.decisionCases||{},f=e.defaultCase||[],p=Object.keys(d),h=(g,m)=>{if(t==="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=d[g],y=h(m,p.length+1);if(v&&v.length>0){const x=Cr(v,i,{...r,...u},t,s);a.push(...x.nodes),o.push(...x.edges),Object.assign(u,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:t,taskReferenceName:x,taskType:"EMPTY_BRANCH"},position:{x:0,y:0},sourcePosition:t==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:t==="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=Cr(f,i,{...r,...u},t,s);a.push(...g.nodes),o.push(...g.edges),Object.assign(u,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:t,taskReferenceName:g,taskType:"EMPTY_BRANCH"},position:{x:0,y:0},sourcePosition:t==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:t==="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:u,nextId:i}}function xg(e,n,r,t="TB"){const s=[],a=[];let o=n;const i={},u=e.type==="FORK_JOIN_DYNAMIC",c={id:e.taskReferenceName,type:"forkNode",data:{label:e.name,taskReferenceName:e.taskReferenceName,taskType:e.type,task:e,isDynamic:u,layoutDirection:t},position:{x:0,y:0},sourcePosition:t==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:t==="LR"?A.Position.Left:A.Position.Top};if(s.push(c),i[e.taskReferenceName]=e,u){const d=`${e.taskReferenceName}_dynamic_placeholder`;s.push({id:d,type:"dynamicPlaceholderNode",data:{label:"动态分支",taskReferenceName:d,taskType:"DYNAMIC_PLACEHOLDER",layoutDirection:t},position:{x:0,y:0},sourcePosition:t==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:t==="LR"?A.Position.Left:A.Position.Top}),a.push({id:`e-${e.taskReferenceName}-${d}`,source:e.taskReferenceName,target:d,animated:!0,style:{stroke:"#10b981",strokeDasharray:"5,5",strokeWidth:2}}),i[d]={taskReferenceName:d,type:"DYNAMIC_PLACEHOLDER"}}return u||(e.forkTasks||[]).forEach((f,p)=>{if(f&&f.length>0){const h=Cr(f,o,{...r,...i},t,!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 bg(e,n,r,t="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:t},position:{x:0,y:0},sourcePosition:t==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:t==="LR"?A.Position.Left:A.Position.Top,style:{pointerEvents:"none"}};a[o]=e;const u=e.loopOver||[],c=[],d=[];let f=n+1;if(u.length>0){const p=Cr(u,f,{...r,...a},t,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"})}),d.push(...p.edges),!s){const h=u[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:t},position:{x:0,y:0},sourcePosition:t==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:t==="LR"?A.Position.Left:A.Position.Top}),d.push({id:`e-${g}-${h.taskReferenceName}`,source:g,target:h.taskReferenceName,animated:!0})}if(!s){const h=u[u.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:t},position:{x:0,y:0},sourcePosition:t==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:t==="LR"?A.Position.Left:A.Position.Top}),d.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:t},position:{x:0,y:0},sourcePosition:t==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:t==="LR"?A.Position.Left:A.Position.Top})}return{nodes:[i,...c],edges:d,taskMap:a,nextId:f}}function kg(e,n,r,t="TB"){const s={id:e.taskReferenceName,type:"subWorkflowNode",data:{label:e.name,taskReferenceName:e.taskReferenceName,taskType:e.type,task:e,layoutDirection:t},position:{x:0,y:0},sourcePosition:t==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:t==="LR"?A.Position.Left:A.Position.Top},a={[e.taskReferenceName]:e};return{nodes:[s],edges:[],taskMap:a,nextId:n+1}}function _g(e,n,r,t="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:t},position:{x:0,y:0},sourcePosition:t==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:t==="LR"?A.Position.Left:A.Position.Top},i={[e.taskReferenceName]:e},u=[],c=[];(e.joinOn||[]).forEach(p=>{const h=s.find(g=>g.taskReferenceName===p)||r[p];h&&jr(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}`;u.push({id:v,type:"default",data:{label:`分支 ${m+1} (空)`,layoutDirection:t,taskReferenceName:v,taskType:"EMPTY_BRANCH"},position:{x:0,y:0},sourcePosition:t==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:t==="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,...u],edges:c,taskMap:i,nextId:n+1}}function Cr(e,n,r,t="TB",s=!1){const a=[],o=[];let i=n;const u={};for(let c=0;c<e.length;c++){const d=e[c],f={...r,...u},p=nl(d,i,f,t,e,s);if(a.push(...p.nodes),o.push(...p.edges),Object.assign(u,p.taskMap),i=p.nextId,c>0){const h=e[c-1];at(h,d,o,s)}}return{nodes:a,edges:o,taskMap:u,nextId:i}}function at(e,n,r,t=!1){if(e.type==="FORK_JOIN"||e.type==="FORK_JOIN_DYNAMIC")return;const s=jr(e,t),a=n.taskReferenceName;s.forEach(o=>{const i=`e-${o}-${a}`;r.find(u=>u.id===i)||r.push({id:i,source:o,target:a,animated:!0})})}function jr(e,n=!1){const r=e.type||"SIMPLE";if(r==="DECISION"||r==="SWITCH"){const t=[],s=e.decisionCases||{},a=e.defaultCase||[];if(Object.entries(s).forEach(([o,i])=>{if(i&&i.length>0){const u=i[i.length-1];t.push(...jr(u,n))}else n||t.push(`${e.taskReferenceName}_empty_${o}`)}),a.length>0){const o=a[a.length-1];t.push(...jr(o,n))}else n||t.push(`${e.taskReferenceName}_empty_default`);return t.length>0?t:[e.taskReferenceName]}return[e.taskReferenceName]}const Te=mg;function st(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 ot,al;function Sg(){if(al)return ot;al=1;function e(){this.__data__=[],this.size=0}return ot=e,ot}var it,sl;function Qe(){if(sl)return it;sl=1;function e(n,r){return n===r||n!==n&&r!==r}return it=e,it}var lt,ol;function Ir(){if(ol)return lt;ol=1;var e=Qe();function n(r,t){for(var s=r.length;s--;)if(e(r[s][0],t))return s;return-1}return lt=n,lt}var ct,il;function wg(){if(il)return ct;il=1;var e=Ir(),n=Array.prototype,r=n.splice;function t(s){var a=this.__data__,o=e(a,s);if(o<0)return!1;var i=a.length-1;return o==i?a.pop():r.call(a,o,1),--this.size,!0}return ct=t,ct}var dt,ll;function Tg(){if(ll)return dt;ll=1;var e=Ir();function n(r){var t=this.__data__,s=e(t,r);return s<0?void 0:t[s][1]}return dt=n,dt}var ut,cl;function Eg(){if(cl)return ut;cl=1;var e=Ir();function n(r){return e(this.__data__,r)>-1}return ut=n,ut}var ft,dl;function Ng(){if(dl)return ft;dl=1;var e=Ir();function n(r,t){var s=this.__data__,a=e(s,r);return a<0?(++this.size,s.push([r,t])):s[a][1]=t,this}return ft=n,ft}var pt,ul;function Rr(){if(ul)return pt;ul=1;var e=Sg(),n=wg(),r=Tg(),t=Eg(),s=Ng();function a(o){var i=-1,u=o==null?0:o.length;for(this.clear();++i<u;){var c=o[i];this.set(c[0],c[1])}}return a.prototype.clear=e,a.prototype.delete=n,a.prototype.get=r,a.prototype.has=t,a.prototype.set=s,pt=a,pt}var ht,fl;function Cg(){if(fl)return ht;fl=1;var e=Rr();function n(){this.__data__=new e,this.size=0}return ht=n,ht}var gt,pl;function jg(){if(pl)return gt;pl=1;function e(n){var r=this.__data__,t=r.delete(n);return this.size=r.size,t}return gt=e,gt}var mt,hl;function Ig(){if(hl)return mt;hl=1;function e(n){return this.__data__.get(n)}return mt=e,mt}var vt,gl;function Rg(){if(gl)return vt;gl=1;function e(n){return this.__data__.has(n)}return vt=e,vt}var yt,ml;function vl(){if(ml)return yt;ml=1;var e=typeof Er=="object"&&Er&&Er.Object===Object&&Er;return yt=e,yt}var xt,yl;function Pe(){if(yl)return xt;yl=1;var e=vl(),n=typeof self=="object"&&self&&self.Object===Object&&self,r=e||n||Function("return this")();return xt=r,xt}var bt,xl;function er(){if(xl)return bt;xl=1;var e=Pe(),n=e.Symbol;return bt=n,bt}var kt,bl;function Og(){if(bl)return kt;bl=1;var e=er(),n=Object.prototype,r=n.hasOwnProperty,t=n.toString,s=e?e.toStringTag:void 0;function a(o){var i=r.call(o,s),u=o[s];try{o[s]=void 0;var c=!0}catch{}var d=t.call(o);return c&&(i?o[s]=u:delete o[s]),d}return kt=a,kt}var _t,kl;function Pg(){if(kl)return _t;kl=1;var e=Object.prototype,n=e.toString;function r(t){return n.call(t)}return _t=r,_t}var St,_l;function Je(){if(_l)return St;_l=1;var e=er(),n=Og(),r=Pg(),t="[object Null]",s="[object Undefined]",a=e?e.toStringTag:void 0;function o(i){return i==null?i===void 0?s:t:a&&a in Object(i)?n(i):r(i)}return St=o,St}var wt,Sl;function Ie(){if(Sl)return wt;Sl=1;function e(n){var r=typeof n;return n!=null&&(r=="object"||r=="function")}return wt=e,wt}var Tt,wl;function pr(){if(wl)return Tt;wl=1;var e=Je(),n=Ie(),r="[object AsyncFunction]",t="[object Function]",s="[object GeneratorFunction]",a="[object Proxy]";function o(i){if(!n(i))return!1;var u=e(i);return u==t||u==s||u==r||u==a}return Tt=o,Tt}var Et,Tl;function Ag(){if(Tl)return Et;Tl=1;var e=Pe(),n=e["__core-js_shared__"];return Et=n,Et}var Nt,El;function Lg(){if(El)return Nt;El=1;var e=Ag(),n=(function(){var t=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""})();function r(t){return!!n&&n in t}return Nt=r,Nt}var Ct,Nl;function Cl(){if(Nl)return Ct;Nl=1;var e=Function.prototype,n=e.toString;function r(t){if(t!=null){try{return n.call(t)}catch{}try{return t+""}catch{}}return""}return Ct=r,Ct}var jt,jl;function qg(){if(jl)return jt;jl=1;var e=pr(),n=Lg(),r=Ie(),t=Cl(),s=/[\\^$.*+?()[\]{}|]/g,a=/^\[object .+?Constructor\]$/,o=Function.prototype,i=Object.prototype,u=o.toString,c=i.hasOwnProperty,d=RegExp("^"+u.call(c).replace(s,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function f(p){if(!r(p)||n(p))return!1;var h=e(p)?d:a;return h.test(t(p))}return jt=f,jt}var It,Il;function Dg(){if(Il)return It;Il=1;function e(n,r){return n?.[r]}return It=e,It}var Rt,Rl;function Ge(){if(Rl)return Rt;Rl=1;var e=qg(),n=Dg();function r(t,s){var a=n(t,s);return e(a)?a:void 0}return Rt=r,Rt}var Ot,Ol;function Pt(){if(Ol)return Ot;Ol=1;var e=Ge(),n=Pe(),r=e(n,"Map");return Ot=r,Ot}var At,Pl;function Or(){if(Pl)return At;Pl=1;var e=Ge(),n=e(Object,"create");return At=n,At}var Lt,Al;function Mg(){if(Al)return Lt;Al=1;var e=Or();function n(){this.__data__=e?e(null):{},this.size=0}return Lt=n,Lt}var qt,Ll;function Wg(){if(Ll)return qt;Ll=1;function e(n){var r=this.has(n)&&delete this.__data__[n];return this.size-=r?1:0,r}return qt=e,qt}var Dt,ql;function Bg(){if(ql)return Dt;ql=1;var e=Or(),n="__lodash_hash_undefined__",r=Object.prototype,t=r.hasOwnProperty;function s(a){var o=this.__data__;if(e){var i=o[a];return i===n?void 0:i}return t.call(o,a)?o[a]:void 0}return Dt=s,Dt}var Mt,Dl;function Fg(){if(Dl)return Mt;Dl=1;var e=Or(),n=Object.prototype,r=n.hasOwnProperty;function t(s){var a=this.__data__;return e?a[s]!==void 0:r.call(a,s)}return Mt=t,Mt}var Wt,Ml;function $g(){if(Ml)return Wt;Ml=1;var e=Or(),n="__lodash_hash_undefined__";function r(t,s){var a=this.__data__;return this.size+=this.has(t)?0:1,a[t]=e&&s===void 0?n:s,this}return Wt=r,Wt}var Bt,Wl;function zg(){if(Wl)return Bt;Wl=1;var e=Mg(),n=Wg(),r=Bg(),t=Fg(),s=$g();function a(o){var i=-1,u=o==null?0:o.length;for(this.clear();++i<u;){var c=o[i];this.set(c[0],c[1])}}return a.prototype.clear=e,a.prototype.delete=n,a.prototype.get=r,a.prototype.has=t,a.prototype.set=s,Bt=a,Bt}var Ft,Bl;function Hg(){if(Bl)return Ft;Bl=1;var e=zg(),n=Rr(),r=Pt();function t(){this.size=0,this.__data__={hash:new e,map:new(r||n),string:new e}}return Ft=t,Ft}var $t,Fl;function Kg(){if(Fl)return $t;Fl=1;function e(n){var r=typeof n;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?n!=="__proto__":n===null}return $t=e,$t}var zt,$l;function Pr(){if($l)return zt;$l=1;var e=Kg();function n(r,t){var s=r.__data__;return e(t)?s[typeof t=="string"?"string":"hash"]:s.map}return zt=n,zt}var Ht,zl;function Ug(){if(zl)return Ht;zl=1;var e=Pr();function n(r){var t=e(this,r).delete(r);return this.size-=t?1:0,t}return Ht=n,Ht}var Kt,Hl;function Jg(){if(Hl)return Kt;Hl=1;var e=Pr();function n(r){return e(this,r).get(r)}return Kt=n,Kt}var Ut,Kl;function Gg(){if(Kl)return Ut;Kl=1;var e=Pr();function n(r){return e(this,r).has(r)}return Ut=n,Ut}var Jt,Ul;function Vg(){if(Ul)return Jt;Ul=1;var e=Pr();function n(r,t){var s=e(this,r),a=s.size;return s.set(r,t),this.size+=s.size==a?0:1,this}return Jt=n,Jt}var Gt,Jl;function Vt(){if(Jl)return Gt;Jl=1;var e=Hg(),n=Ug(),r=Jg(),t=Gg(),s=Vg();function a(o){var i=-1,u=o==null?0:o.length;for(this.clear();++i<u;){var c=o[i];this.set(c[0],c[1])}}return a.prototype.clear=e,a.prototype.delete=n,a.prototype.get=r,a.prototype.has=t,a.prototype.set=s,Gt=a,Gt}var Yt,Gl;function Yg(){if(Gl)return Yt;Gl=1;var e=Rr(),n=Pt(),r=Vt(),t=200;function s(a,o){var i=this.__data__;if(i instanceof e){var u=i.__data__;if(!n||u.length<t-1)return u.push([a,o]),this.size=++i.size,this;i=this.__data__=new r(u)}return i.set(a,o),this.size=i.size,this}return Yt=s,Yt}var Xt,Vl;function Ar(){if(Vl)return Xt;Vl=1;var e=Rr(),n=Cg(),r=jg(),t=Ig(),s=Rg(),a=Yg();function o(i){var u=this.__data__=new e(i);this.size=u.size}return o.prototype.clear=n,o.prototype.delete=r,o.prototype.get=t,o.prototype.has=s,o.prototype.set=a,Xt=o,Xt}var Zt,Yl;function Qt(){if(Yl)return Zt;Yl=1;function e(n,r){for(var t=-1,s=n==null?0:n.length;++t<s&&r(n[t],t,n)!==!1;);return n}return Zt=e,Zt}var en,Xl;function Zl(){if(Xl)return en;Xl=1;var e=Ge(),n=(function(){try{var r=e(Object,"defineProperty");return r({},"",{}),r}catch{}})();return en=n,en}var rn,Ql;function Lr(){if(Ql)return rn;Ql=1;var e=Zl();function n(r,t,s){t=="__proto__"&&e?e(r,t,{configurable:!0,enumerable:!0,value:s,writable:!0}):r[t]=s}return rn=n,rn}var tn,ec;function qr(){if(ec)return tn;ec=1;var e=Lr(),n=Qe(),r=Object.prototype,t=r.hasOwnProperty;function s(a,o,i){var u=a[o];(!(t.call(a,o)&&n(u,i))||i===void 0&&!(o in a))&&e(a,o,i)}return tn=s,tn}var nn,rc;function hr(){if(rc)return nn;rc=1;var e=qr(),n=Lr();function r(t,s,a,o){var i=!a;a||(a={});for(var u=-1,c=s.length;++u<c;){var d=s[u],f=o?o(a[d],t[d],d,a,t):void 0;f===void 0&&(f=t[d]),i?n(a,d,f):e(a,d,f)}return a}return nn=r,nn}var an,tc;function Xg(){if(tc)return an;tc=1;function e(n,r){for(var t=-1,s=Array(n);++t<n;)s[t]=r(t);return s}return an=e,an}var sn,nc;function Me(){if(nc)return sn;nc=1;function e(n){return n!=null&&typeof n=="object"}return sn=e,sn}var on,ac;function Zg(){if(ac)return on;ac=1;var e=Je(),n=Me(),r="[object Arguments]";function t(s){return n(s)&&e(s)==r}return on=t,on}var ln,sc;function gr(){if(sc)return ln;sc=1;var e=Zg(),n=Me(),r=Object.prototype,t=r.hasOwnProperty,s=r.propertyIsEnumerable,a=e((function(){return arguments})())?e:function(o){return n(o)&&t.call(o,"callee")&&!s.call(o,"callee")};return ln=a,ln}var cn,oc;function ke(){if(oc)return cn;oc=1;var e=Array.isArray;return cn=e,cn}var mr={exports:{}},dn,ic;function Qg(){if(ic)return dn;ic=1;function e(){return!1}return dn=e,dn}mr.exports;var lc;function rr(){return lc||(lc=1,(function(e,n){var r=Pe(),t=Qg(),s=n&&!n.nodeType&&n,a=s&&!0&&e&&!e.nodeType&&e,o=a&&a.exports===s,i=o?r.Buffer:void 0,u=i?i.isBuffer:void 0,c=u||t;e.exports=c})(mr,mr.exports)),mr.exports}var un,cc;function Dr(){if(cc)return un;cc=1;var e=9007199254740991,n=/^(?:0|[1-9]\d*)$/;function r(t,s){var a=typeof t;return s=s??e,!!s&&(a=="number"||a!="symbol"&&n.test(t))&&t>-1&&t%1==0&&t<s}return un=r,un}var fn,dc;function pn(){if(dc)return fn;dc=1;var e=9007199254740991;function n(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=e}return fn=n,fn}var hn,uc;function em(){if(uc)return hn;uc=1;var e=Je(),n=pn(),r=Me(),t="[object Arguments]",s="[object Array]",a="[object Boolean]",o="[object Date]",i="[object Error]",u="[object Function]",c="[object Map]",d="[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[t]=S[s]=S[v]=S[a]=S[y]=S[o]=S[i]=S[u]=S[c]=S[d]=S[f]=S[p]=S[h]=S[g]=S[m]=!1;function D(I){return r(I)&&n(I.length)&&!!S[e(I)]}return hn=D,hn}var gn,fc;function Mr(){if(fc)return gn;fc=1;function e(n){return function(r){return n(r)}}return gn=e,gn}var vr={exports:{}};vr.exports;var pc;function mn(){return pc||(pc=1,(function(e,n){var r=vl(),t=n&&!n.nodeType&&n,s=t&&!0&&e&&!e.nodeType&&e,a=s&&s.exports===t,o=a&&r.process,i=(function(){try{var u=s&&s.require&&s.require("util").types;return u||o&&o.binding&&o.binding("util")}catch{}})();e.exports=i})(vr,vr.exports)),vr.exports}var vn,hc;function yr(){if(hc)return vn;hc=1;var e=em(),n=Mr(),r=mn(),t=r&&r.isTypedArray,s=t?n(t):e;return vn=s,vn}var yn,gc;function mc(){if(gc)return yn;gc=1;var e=Xg(),n=gr(),r=ke(),t=rr(),s=Dr(),a=yr(),o=Object.prototype,i=o.hasOwnProperty;function u(c,d){var f=r(c),p=!f&&n(c),h=!f&&!p&&t(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)(d||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 yn=u,yn}var xn,vc;function Wr(){if(vc)return xn;vc=1;var e=Object.prototype;function n(r){var t=r&&r.constructor,s=typeof t=="function"&&t.prototype||e;return r===s}return xn=n,xn}var bn,yc;function xc(){if(yc)return bn;yc=1;function e(n,r){return function(t){return n(r(t))}}return bn=e,bn}var kn,bc;function rm(){if(bc)return kn;bc=1;var e=xc(),n=e(Object.keys,Object);return kn=n,kn}var _n,kc;function Sn(){if(kc)return _n;kc=1;var e=Wr(),n=rm(),r=Object.prototype,t=r.hasOwnProperty;function s(a){if(!e(a))return n(a);var o=[];for(var i in Object(a))t.call(a,i)&&i!="constructor"&&o.push(i);return o}return _n=s,_n}var wn,_c;function Be(){if(_c)return wn;_c=1;var e=pr(),n=pn();function r(t){return t!=null&&n(t.length)&&!e(t)}return wn=r,wn}var Tn,Sc;function ze(){if(Sc)return Tn;Sc=1;var e=mc(),n=Sn(),r=Be();function t(s){return r(s)?e(s):n(s)}return Tn=t,Tn}var En,wc;function tm(){if(wc)return En;wc=1;var e=hr(),n=ze();function r(t,s){return t&&e(s,n(s),t)}return En=r,En}var Nn,Tc;function nm(){if(Tc)return Nn;Tc=1;function e(n){var r=[];if(n!=null)for(var t in Object(n))r.push(t);return r}return Nn=e,Nn}var Cn,Ec;function am(){if(Ec)return Cn;Ec=1;var e=Ie(),n=Wr(),r=nm(),t=Object.prototype,s=t.hasOwnProperty;function a(o){if(!e(o))return r(o);var i=n(o),u=[];for(var c in o)c=="constructor"&&(i||!s.call(o,c))||u.push(c);return u}return Cn=a,Cn}var jn,Nc;function Ve(){if(Nc)return jn;Nc=1;var e=mc(),n=am(),r=Be();function t(s){return r(s)?e(s,!0):n(s)}return jn=t,jn}var In,Cc;function sm(){if(Cc)return In;Cc=1;var e=hr(),n=Ve();function r(t,s){return t&&e(s,n(s),t)}return In=r,In}var xr={exports:{}};xr.exports;var jc;function Ic(){return jc||(jc=1,(function(e,n){var r=Pe(),t=n&&!n.nodeType&&n,s=t&&!0&&e&&!e.nodeType&&e,a=s&&s.exports===t,o=a?r.Buffer:void 0,i=o?o.allocUnsafe:void 0;function u(c,d){if(d)return c.slice();var f=c.length,p=i?i(f):new c.constructor(f);return c.copy(p),p}e.exports=u})(xr,xr.exports)),xr.exports}var Rn,Rc;function Oc(){if(Rc)return Rn;Rc=1;function e(n,r){var t=-1,s=n.length;for(r||(r=Array(s));++t<s;)r[t]=n[t];return r}return Rn=e,Rn}var On,Pc;function Ac(){if(Pc)return On;Pc=1;function e(n,r){for(var t=-1,s=n==null?0:n.length,a=0,o=[];++t<s;){var i=n[t];r(i,t,n)&&(o[a++]=i)}return o}return On=e,On}var Pn,Lc;function qc(){if(Lc)return Pn;Lc=1;function e(){return[]}return Pn=e,Pn}var An,Dc;function Ln(){if(Dc)return An;Dc=1;var e=Ac(),n=qc(),r=Object.prototype,t=r.propertyIsEnumerable,s=Object.getOwnPropertySymbols,a=s?function(o){return o==null?[]:(o=Object(o),e(s(o),function(i){return t.call(o,i)}))}:n;return An=a,An}var qn,Mc;function om(){if(Mc)return qn;Mc=1;var e=hr(),n=Ln();function r(t,s){return e(t,n(t),s)}return qn=r,qn}var Dn,Wc;function Mn(){if(Wc)return Dn;Wc=1;function e(n,r){for(var t=-1,s=r.length,a=n.length;++t<s;)n[a+t]=r[t];return n}return Dn=e,Dn}var Wn,Bc;function Br(){if(Bc)return Wn;Bc=1;var e=xc(),n=e(Object.getPrototypeOf,Object);return Wn=n,Wn}var Bn,Fc;function $c(){if(Fc)return Bn;Fc=1;var e=Mn(),n=Br(),r=Ln(),t=qc(),s=Object.getOwnPropertySymbols,a=s?function(o){for(var i=[];o;)e(i,r(o)),o=n(o);return i}:t;return Bn=a,Bn}var Fn,zc;function im(){if(zc)return Fn;zc=1;var e=hr(),n=$c();function r(t,s){return e(t,n(t),s)}return Fn=r,Fn}var $n,Hc;function Kc(){if(Hc)return $n;Hc=1;var e=Mn(),n=ke();function r(t,s,a){var o=s(t);return n(t)?o:e(o,a(t))}return $n=r,$n}var zn,Uc;function Jc(){if(Uc)return zn;Uc=1;var e=Kc(),n=Ln(),r=ze();function t(s){return e(s,r,n)}return zn=t,zn}var Hn,Gc;function lm(){if(Gc)return Hn;Gc=1;var e=Kc(),n=$c(),r=Ve();function t(s){return e(s,r,n)}return Hn=t,Hn}var Kn,Vc;function cm(){if(Vc)return Kn;Vc=1;var e=Ge(),n=Pe(),r=e(n,"DataView");return Kn=r,Kn}var Un,Yc;function dm(){if(Yc)return Un;Yc=1;var e=Ge(),n=Pe(),r=e(n,"Promise");return Un=r,Un}var Jn,Xc;function Zc(){if(Xc)return Jn;Xc=1;var e=Ge(),n=Pe(),r=e(n,"Set");return Jn=r,Jn}var Gn,Qc;function um(){if(Qc)return Gn;Qc=1;var e=Ge(),n=Pe(),r=e(n,"WeakMap");return Gn=r,Gn}var Vn,ed;function tr(){if(ed)return Vn;ed=1;var e=cm(),n=Pt(),r=dm(),t=Zc(),s=um(),a=Je(),o=Cl(),i="[object Map]",u="[object Object]",c="[object Promise]",d="[object Set]",f="[object WeakMap]",p="[object DataView]",h=o(e),g=o(n),m=o(r),v=o(t),y=o(s),x=a;return(e&&x(new e(new ArrayBuffer(1)))!=p||n&&x(new n)!=i||r&&x(r.resolve())!=c||t&&x(new t)!=d||s&&x(new s)!=f)&&(x=function(b){var k=a(b),w=k==u?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 d;case y:return f}return k}),Vn=x,Vn}var Yn,rd;function fm(){if(rd)return Yn;rd=1;var e=Object.prototype,n=e.hasOwnProperty;function r(t){var s=t.length,a=new t.constructor(s);return s&&typeof t[0]=="string"&&n.call(t,"index")&&(a.index=t.index,a.input=t.input),a}return Yn=r,Yn}var Xn,td;function nd(){if(td)return Xn;td=1;var e=Pe(),n=e.Uint8Array;return Xn=n,Xn}var Zn,ad;function Qn(){if(ad)return Zn;ad=1;var e=nd();function n(r){var t=new r.constructor(r.byteLength);return new e(t).set(new e(r)),t}return Zn=n,Zn}var ea,sd;function pm(){if(sd)return ea;sd=1;var e=Qn();function n(r,t){var s=t?e(r.buffer):r.buffer;return new r.constructor(s,r.byteOffset,r.byteLength)}return ea=n,ea}var ra,od;function hm(){if(od)return ra;od=1;var e=/\w*$/;function n(r){var t=new r.constructor(r.source,e.exec(r));return t.lastIndex=r.lastIndex,t}return ra=n,ra}var ta,id;function gm(){if(id)return ta;id=1;var e=er(),n=e?e.prototype:void 0,r=n?n.valueOf:void 0;function t(s){return r?Object(r.call(s)):{}}return ta=t,ta}var na,ld;function cd(){if(ld)return na;ld=1;var e=Qn();function n(r,t){var s=t?e(r.buffer):r.buffer;return new r.constructor(s,r.byteOffset,r.length)}return na=n,na}var aa,dd;function mm(){if(dd)return aa;dd=1;var e=Qn(),n=pm(),r=hm(),t=gm(),s=cd(),a="[object Boolean]",o="[object Date]",i="[object Map]",u="[object Number]",c="[object RegExp]",d="[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 D=T.constructor;switch(C){case h:return e(T);case a:case o:return new D(+T);case g:return n(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 D;case u:case f:return new D(T);case c:return r(T);case d:return new D;case p:return t(T)}}return aa=L,aa}var sa,ud;function fd(){if(ud)return sa;ud=1;var e=Ie(),n=Object.create,r=(function(){function t(){}return function(s){if(!e(s))return{};if(n)return n(s);t.prototype=s;var a=new t;return t.prototype=void 0,a}})();return sa=r,sa}var oa,pd;function hd(){if(pd)return oa;pd=1;var e=fd(),n=Br(),r=Wr();function t(s){return typeof s.constructor=="function"&&!r(s)?e(n(s)):{}}return oa=t,oa}var ia,gd;function vm(){if(gd)return ia;gd=1;var e=tr(),n=Me(),r="[object Map]";function t(s){return n(s)&&e(s)==r}return ia=t,ia}var la,md;function ym(){if(md)return la;md=1;var e=vm(),n=Mr(),r=mn(),t=r&&r.isMap,s=t?n(t):e;return la=s,la}var ca,vd;function xm(){if(vd)return ca;vd=1;var e=tr(),n=Me(),r="[object Set]";function t(s){return n(s)&&e(s)==r}return ca=t,ca}var da,yd;function bm(){if(yd)return da;yd=1;var e=xm(),n=Mr(),r=mn(),t=r&&r.isSet,s=t?n(t):e;return da=s,da}var ua,xd;function bd(){if(xd)return ua;xd=1;var e=Ar(),n=Qt(),r=qr(),t=tm(),s=sm(),a=Ic(),o=Oc(),i=om(),u=im(),c=Jc(),d=lm(),f=tr(),p=fm(),h=mm(),g=hd(),m=ke(),v=rr(),y=ym(),x=Ie(),b=bm(),k=ze(),w=Ve(),j=1,N=2,L=4,T="[object Arguments]",C="[object Array]",S="[object Boolean]",D="[object Date]",I="[object Error]",P="[object Function]",F="[object GeneratorFunction]",W="[object Map]",K="[object Number]",V="[object Object]",te="[object RegExp]",re="[object Set]",q="[object String]",G="[object Symbol]",ie="[object WeakMap]",R="[object ArrayBuffer]",M="[object DataView]",_="[object Float32Array]",B="[object Float64Array]",$="[object Int8Array]",X="[object Int16Array]",U="[object Int32Array]",le="[object Uint8Array]",Q="[object Uint8ClampedArray]",ee="[object Uint16Array]",he="[object Uint32Array]",z={};z[T]=z[C]=z[R]=z[M]=z[S]=z[D]=z[_]=z[B]=z[$]=z[X]=z[U]=z[W]=z[K]=z[V]=z[te]=z[re]=z[q]=z[G]=z[le]=z[Q]=z[ee]=z[he]=!0,z[I]=z[P]=z[ie]=!1;function Z(H,ne,Y,ge,ae,pe){var me,Ne=ne&j,ce=ne&N,E=ne&L;if(Y&&(me=ae?Y(H,ge,ae,pe):Y(H)),me!==void 0)return me;if(!x(H))return H;var J=m(H);if(J){if(me=p(H),!Ne)return o(H,me)}else{var se=f(H),ue=se==P||se==F;if(v(H))return a(H,Ne);if(se==V||se==T||ue&&!ae){if(me=ce||ue?{}:g(H),!Ne)return ce?u(H,s(me,H)):i(H,t(me,H))}else{if(!z[se])return ae?H:{};me=h(H,se,Ne)}}pe||(pe=new e);var de=pe.get(H);if(de)return de;pe.set(H,me),b(H)?H.forEach(function(fe){me.add(Z(fe,ne,Y,fe,H,pe))}):y(H)&&H.forEach(function(fe,_e){me.set(_e,Z(fe,ne,Y,_e,H,pe))});var ve=E?ce?d:c:ce?w:k,xe=J?void 0:ve(H);return n(xe||H,function(fe,_e){xe&&(_e=fe,fe=H[_e]),r(me,_e,Z(fe,ne,Y,_e,H,pe))}),me}return ua=Z,ua}var fa,kd;function km(){if(kd)return fa;kd=1;var e=bd(),n=4;function r(t){return e(t,n)}return fa=r,fa}var pa,_d;function ha(){if(_d)return pa;_d=1;function e(n){return function(){return n}}return pa=e,pa}var ga,Sd;function _m(){if(Sd)return ga;Sd=1;function e(n){return function(r,t,s){for(var a=-1,o=Object(r),i=s(r),u=i.length;u--;){var c=i[n?u:++a];if(t(o[c],c,o)===!1)break}return r}}return ga=e,ga}var ma,wd;function va(){if(wd)return ma;wd=1;var e=_m(),n=e();return ma=n,ma}var ya,Td;function xa(){if(Td)return ya;Td=1;var e=va(),n=ze();function r(t,s){return t&&e(t,s,n)}return ya=r,ya}var ba,Ed;function Sm(){if(Ed)return ba;Ed=1;var e=Be();function n(r,t){return function(s,a){if(s==null)return s;if(!e(s))return r(s,a);for(var o=s.length,i=t?o:-1,u=Object(s);(t?i--:++i<o)&&a(u[i],i,u)!==!1;);return s}}return ba=n,ba}var ka,Nd;function Fr(){if(Nd)return ka;Nd=1;var e=xa(),n=Sm(),r=n(e);return ka=r,ka}var _a,Cd;function Ye(){if(Cd)return _a;Cd=1;function e(n){return n}return _a=e,_a}var Sa,jd;function Id(){if(jd)return Sa;jd=1;var e=Ye();function n(r){return typeof r=="function"?r:e}return Sa=n,Sa}var wa,Rd;function Od(){if(Rd)return wa;Rd=1;var e=Qt(),n=Fr(),r=Id(),t=ke();function s(a,o){var i=t(a)?e:n;return i(a,r(o))}return wa=s,wa}var Ta,Pd;function Ad(){return Pd||(Pd=1,Ta=Od()),Ta}var Ea,Ld;function wm(){if(Ld)return Ea;Ld=1;var e=Fr();function n(r,t){var s=[];return e(r,function(a,o,i){t(a,o,i)&&s.push(a)}),s}return Ea=n,Ea}var Na,qd;function Tm(){if(qd)return Na;qd=1;var e="__lodash_hash_undefined__";function n(r){return this.__data__.set(r,e),this}return Na=n,Na}var Ca,Dd;function Em(){if(Dd)return Ca;Dd=1;function e(n){return this.__data__.has(n)}return Ca=e,Ca}var ja,Md;function Wd(){if(Md)return ja;Md=1;var e=Vt(),n=Tm(),r=Em();function t(s){var a=-1,o=s==null?0:s.length;for(this.__data__=new e;++a<o;)this.add(s[a])}return t.prototype.add=t.prototype.push=n,t.prototype.has=r,ja=t,ja}var Ia,Bd;function Nm(){if(Bd)return Ia;Bd=1;function e(n,r){for(var t=-1,s=n==null?0:n.length;++t<s;)if(r(n[t],t,n))return!0;return!1}return Ia=e,Ia}var Ra,Fd;function $d(){if(Fd)return Ra;Fd=1;function e(n,r){return n.has(r)}return Ra=e,Ra}var Oa,zd;function Hd(){if(zd)return Oa;zd=1;var e=Wd(),n=Nm(),r=$d(),t=1,s=2;function a(o,i,u,c,d,f){var p=u&t,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=u&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(!n(i,function(N,L){if(!r(b,L)&&(k===N||d(k,N,u,c,f)))return b.push(L)})){x=!1;break}}else if(!(k===w||d(k,w,u,c,f))){x=!1;break}}return f.delete(o),f.delete(i),x}return Oa=a,Oa}var Pa,Kd;function Cm(){if(Kd)return Pa;Kd=1;function e(n){var r=-1,t=Array(n.size);return n.forEach(function(s,a){t[++r]=[a,s]}),t}return Pa=e,Pa}var Aa,Ud;function La(){if(Ud)return Aa;Ud=1;function e(n){var r=-1,t=Array(n.size);return n.forEach(function(s){t[++r]=s}),t}return Aa=e,Aa}var qa,Jd;function jm(){if(Jd)return qa;Jd=1;var e=er(),n=nd(),r=Qe(),t=Hd(),s=Cm(),a=La(),o=1,i=2,u="[object Boolean]",c="[object Date]",d="[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,D){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 n(j),new n(N)));case u:case c:case p:return r(+j,+N);case d:return j.name==N.name&&j.message==N.message;case h:case m:return j==N+"";case f:var I=s;case g:var P=T&o;if(I||(I=a),j.size!=N.size&&!P)return!1;var F=D.get(j);if(F)return F==N;T|=i,D.set(j,N);var W=t(I(j),I(N),T,C,S,D);return D.delete(j),W;case v:if(k)return k.call(j)==k.call(N)}return!1}return qa=w,qa}var Da,Gd;function Im(){if(Gd)return Da;Gd=1;var e=Jc(),n=1,r=Object.prototype,t=r.hasOwnProperty;function s(a,o,i,u,c,d){var f=i&n,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:t.call(o,y)))return!1}var x=d.get(a),b=d.get(o);if(x&&b)return x==o&&b==a;var k=!0;d.set(a,o),d.set(o,a);for(var w=f;++v<h;){y=p[v];var j=a[y],N=o[y];if(u)var L=f?u(N,j,y,o,a,d):u(j,N,y,a,o,d);if(!(L===void 0?j===N||c(j,N,i,u,d):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 d.delete(a),d.delete(o),k}return Da=s,Da}var Ma,Vd;function Rm(){if(Vd)return Ma;Vd=1;var e=Ar(),n=Hd(),r=jm(),t=Im(),s=tr(),a=ke(),o=rr(),i=yr(),u=1,c="[object Arguments]",d="[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?d:s(m),L=j?d: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)?n(m,v,y,x,b,k):r(m,v,N,y,x,b,k);if(!(y&u)){var D=T&&h.call(m,"__wrapped__"),I=C&&h.call(v,"__wrapped__");if(D||I){var P=D?m.value():m,F=I?v.value():v;return k||(k=new e),b(P,F,y,x,k)}}return S?(k||(k=new e),t(m,v,y,x,b,k)):!1}return Ma=g,Ma}var Wa,Yd;function Xd(){if(Yd)return Wa;Yd=1;var e=Rm(),n=Me();function r(t,s,a,o,i){return t===s?!0:t==null||s==null||!n(t)&&!n(s)?t!==t&&s!==s:e(t,s,a,o,r,i)}return Wa=r,Wa}var Ba,Zd;function Om(){if(Zd)return Ba;Zd=1;var e=Ar(),n=Xd(),r=1,t=2;function s(a,o,i,u){var c=i.length,d=c,f=!u;if(a==null)return!d;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<d;){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(u)var y=u(g,m,h,a,o,v);if(!(y===void 0?n(m,g,r|t,u,v):y))return!1}}return!0}return Ba=s,Ba}var Fa,Qd;function eu(){if(Qd)return Fa;Qd=1;var e=Ie();function n(r){return r===r&&!e(r)}return Fa=n,Fa}var $a,ru;function Pm(){if(ru)return $a;ru=1;var e=eu(),n=ze();function r(t){for(var s=n(t),a=s.length;a--;){var o=s[a],i=t[o];s[a]=[o,i,e(i)]}return s}return $a=r,$a}var za,tu;function nu(){if(tu)return za;tu=1;function e(n,r){return function(t){return t==null?!1:t[n]===r&&(r!==void 0||n in Object(t))}}return za=e,za}var Ha,au;function Am(){if(au)return Ha;au=1;var e=Om(),n=Pm(),r=nu();function t(s){var a=n(s);return a.length==1&&a[0][2]?r(a[0][0],a[0][1]):function(o){return o===s||e(o,s,a)}}return Ha=t,Ha}var Ka,su;function nr(){if(su)return Ka;su=1;var e=Je(),n=Me(),r="[object Symbol]";function t(s){return typeof s=="symbol"||n(s)&&e(s)==r}return Ka=t,Ka}var Ua,ou;function Ja(){if(ou)return Ua;ou=1;var e=ke(),n=nr(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,t=/^\w*$/;function s(a,o){if(e(a))return!1;var i=typeof a;return i=="number"||i=="symbol"||i=="boolean"||a==null||n(a)?!0:t.test(a)||!r.test(a)||o!=null&&a in Object(o)}return Ua=s,Ua}var Ga,iu;function Lm(){if(iu)return Ga;iu=1;var e=Vt(),n="Expected a function";function r(t,s){if(typeof t!="function"||s!=null&&typeof s!="function")throw new TypeError(n);var a=function(){var o=arguments,i=s?s.apply(this,o):o[0],u=a.cache;if(u.has(i))return u.get(i);var c=t.apply(this,o);return a.cache=u.set(i,c)||u,c};return a.cache=new(r.Cache||e),a}return r.Cache=e,Ga=r,Ga}var Va,lu;function qm(){if(lu)return Va;lu=1;var e=Lm(),n=500;function r(t){var s=e(t,function(o){return a.size===n&&a.clear(),o}),a=s.cache;return s}return Va=r,Va}var Ya,cu;function Dm(){if(cu)return Ya;cu=1;var e=qm(),n=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,t=e(function(s){var a=[];return s.charCodeAt(0)===46&&a.push(""),s.replace(n,function(o,i,u,c){a.push(u?c.replace(r,"$1"):i||o)}),a});return Ya=t,Ya}var Xa,du;function $r(){if(du)return Xa;du=1;function e(n,r){for(var t=-1,s=n==null?0:n.length,a=Array(s);++t<s;)a[t]=r(n[t],t,n);return a}return Xa=e,Xa}var Za,uu;function Mm(){if(uu)return Za;uu=1;var e=er(),n=$r(),r=ke(),t=nr(),s=e?e.prototype:void 0,a=s?s.toString:void 0;function o(i){if(typeof i=="string")return i;if(r(i))return n(i,o)+"";if(t(i))return a?a.call(i):"";var u=i+"";return u=="0"&&1/i==-1/0?"-0":u}return Za=o,Za}var Qa,fu;function pu(){if(fu)return Qa;fu=1;var e=Mm();function n(r){return r==null?"":e(r)}return Qa=n,Qa}var es,hu;function zr(){if(hu)return es;hu=1;var e=ke(),n=Ja(),r=Dm(),t=pu();function s(a,o){return e(a)?a:n(a,o)?[a]:r(t(a))}return es=s,es}var rs,gu;function br(){if(gu)return rs;gu=1;var e=nr();function n(r){if(typeof r=="string"||e(r))return r;var t=r+"";return t=="0"&&1/r==-1/0?"-0":t}return rs=n,rs}var ts,mu;function Hr(){if(mu)return ts;mu=1;var e=zr(),n=br();function r(t,s){s=e(s,t);for(var a=0,o=s.length;t!=null&&a<o;)t=t[n(s[a++])];return a&&a==o?t:void 0}return ts=r,ts}var ns,vu;function Wm(){if(vu)return ns;vu=1;var e=Hr();function n(r,t,s){var a=r==null?void 0:e(r,t);return a===void 0?s:a}return ns=n,ns}var as,yu;function Bm(){if(yu)return as;yu=1;function e(n,r){return n!=null&&r in Object(n)}return as=e,as}var ss,xu;function bu(){if(xu)return ss;xu=1;var e=zr(),n=gr(),r=ke(),t=Dr(),s=pn(),a=br();function o(i,u,c){u=e(u,i);for(var d=-1,f=u.length,p=!1;++d<f;){var h=a(u[d]);if(!(p=i!=null&&c(i,h)))break;i=i[h]}return p||++d!=f?p:(f=i==null?0:i.length,!!f&&s(f)&&t(h,f)&&(r(i)||n(i)))}return ss=o,ss}var os,ku;function _u(){if(ku)return os;ku=1;var e=Bm(),n=bu();function r(t,s){return t!=null&&n(t,s,e)}return os=r,os}var is,Su;function Fm(){if(Su)return is;Su=1;var e=Xd(),n=Wm(),r=_u(),t=Ja(),s=eu(),a=nu(),o=br(),i=1,u=2;function c(d,f){return t(d)&&s(f)?a(o(d),f):function(p){var h=n(p,d);return h===void 0&&h===f?r(p,d):e(f,h,i|u)}}return is=c,is}var ls,wu;function Tu(){if(wu)return ls;wu=1;function e(n){return function(r){return r?.[n]}}return ls=e,ls}var cs,Eu;function $m(){if(Eu)return cs;Eu=1;var e=Hr();function n(r){return function(t){return e(t,r)}}return cs=n,cs}var ds,Nu;function zm(){if(Nu)return ds;Nu=1;var e=Tu(),n=$m(),r=Ja(),t=br();function s(a){return r(a)?e(t(a)):n(a)}return ds=s,ds}var us,Cu;function Fe(){if(Cu)return us;Cu=1;var e=Am(),n=Fm(),r=Ye(),t=ke(),s=zm();function a(o){return typeof o=="function"?o:o==null?r:typeof o=="object"?t(o)?n(o[0],o[1]):e(o):s(o)}return us=a,us}var fs,ju;function Iu(){if(ju)return fs;ju=1;var e=Ac(),n=wm(),r=Fe(),t=ke();function s(a,o){var i=t(a)?e:n;return i(a,r(o,3))}return fs=s,fs}var ps,Ru;function Hm(){if(Ru)return ps;Ru=1;var e=Object.prototype,n=e.hasOwnProperty;function r(t,s){return t!=null&&n.call(t,s)}return ps=r,ps}var hs,Ou;function Pu(){if(Ou)return hs;Ou=1;var e=Hm(),n=bu();function r(t,s){return t!=null&&n(t,s,e)}return hs=r,hs}var gs,Au;function Km(){if(Au)return gs;Au=1;var e=Sn(),n=tr(),r=gr(),t=ke(),s=Be(),a=rr(),o=Wr(),i=yr(),u="[object Map]",c="[object Set]",d=Object.prototype,f=d.hasOwnProperty;function p(h){if(h==null)return!0;if(s(h)&&(t(h)||typeof h=="string"||typeof h.splice=="function"||a(h)||i(h)||r(h)))return!h.length;var g=n(h);if(g==u||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 gs=p,gs}var ms,Lu;function qu(){if(Lu)return ms;Lu=1;function e(n){return n===void 0}return ms=e,ms}var vs,Du;function Mu(){if(Du)return vs;Du=1;var e=Fr(),n=Be();function r(t,s){var a=-1,o=n(t)?Array(t.length):[];return e(t,function(i,u,c){o[++a]=s(i,u,c)}),o}return vs=r,vs}var ys,Wu;function Bu(){if(Wu)return ys;Wu=1;var e=$r(),n=Fe(),r=Mu(),t=ke();function s(a,o){var i=t(a)?e:r;return i(a,n(o,3))}return ys=s,ys}var xs,Fu;function Um(){if(Fu)return xs;Fu=1;function e(n,r,t,s){var a=-1,o=n==null?0:n.length;for(s&&o&&(t=n[++a]);++a<o;)t=r(t,n[a],a,n);return t}return xs=e,xs}var bs,$u;function Jm(){if($u)return bs;$u=1;function e(n,r,t,s,a){return a(n,function(o,i,u){t=s?(s=!1,o):r(t,o,i,u)}),t}return bs=e,bs}var ks,zu;function Hu(){if(zu)return ks;zu=1;var e=Um(),n=Fr(),r=Fe(),t=Jm(),s=ke();function a(o,i,u){var c=s(o)?e:t,d=arguments.length<3;return c(o,r(i,4),u,d,n)}return ks=a,ks}var _s,Ku;function Gm(){if(Ku)return _s;Ku=1;var e=Je(),n=ke(),r=Me(),t="[object String]";function s(a){return typeof a=="string"||!n(a)&&r(a)&&e(a)==t}return _s=s,_s}var Ss,Uu;function Vm(){if(Uu)return Ss;Uu=1;var e=Tu(),n=e("length");return Ss=n,Ss}var ws,Ju;function Ym(){if(Ju)return ws;Ju=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",t="\\u20d0-\\u20ff",s=n+r+t,a="\\ufe0e\\ufe0f",o="\\u200d",i=RegExp("["+o+e+s+a+"]");function u(c){return i.test(c)}return ws=u,ws}var Ts,Gu;function Xm(){if(Gu)return Ts;Gu=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",t="\\u20d0-\\u20ff",s=n+r+t,a="\\ufe0e\\ufe0f",o="["+e+"]",i="["+s+"]",u="\\ud83c[\\udffb-\\udfff]",c="(?:"+i+"|"+u+")",d="[^"+e+"]",f="(?:\\ud83c[\\udde6-\\uddff]){2}",p="[\\ud800-\\udbff][\\udc00-\\udfff]",h="\\u200d",g=c+"?",m="["+a+"]?",v="(?:"+h+"(?:"+[d,f,p].join("|")+")"+m+g+")*",y=m+g+v,x="(?:"+[d+i+"?",i,f,p,o].join("|")+")",b=RegExp(u+"(?="+u+")|"+x+y,"g");function k(w){for(var j=b.lastIndex=0;b.test(w);)++j;return j}return Ts=k,Ts}var Es,Vu;function Zm(){if(Vu)return Es;Vu=1;var e=Vm(),n=Ym(),r=Xm();function t(s){return n(s)?r(s):e(s)}return Es=t,Es}var Ns,Yu;function Qm(){if(Yu)return Ns;Yu=1;var e=Sn(),n=tr(),r=Be(),t=Gm(),s=Zm(),a="[object Map]",o="[object Set]";function i(u){if(u==null)return 0;if(r(u))return t(u)?s(u):u.length;var c=n(u);return c==a||c==o?u.size:e(u).length}return Ns=i,Ns}var Cs,Xu;function ev(){if(Xu)return Cs;Xu=1;var e=Qt(),n=fd(),r=xa(),t=Fe(),s=Br(),a=ke(),o=rr(),i=pr(),u=Ie(),c=yr();function d(f,p,h){var g=a(f),m=g||o(f)||c(f);if(p=t(p,4),h==null){var v=f&&f.constructor;m?h=g?new v:[]:u(f)?h=i(v)?n(s(f)):{}:h={}}return(m?e:r)(f,function(y,x,b){return p(h,y,x,b)}),h}return Cs=d,Cs}var js,Zu;function rv(){if(Zu)return js;Zu=1;var e=er(),n=gr(),r=ke(),t=e?e.isConcatSpreadable:void 0;function s(a){return r(a)||n(a)||!!(t&&a&&a[t])}return js=s,js}var Is,Qu;function Rs(){if(Qu)return Is;Qu=1;var e=Mn(),n=rv();function r(t,s,a,o,i){var u=-1,c=t.length;for(a||(a=n),i||(i=[]);++u<c;){var d=t[u];s>0&&a(d)?s>1?r(d,s-1,a,o,i):e(i,d):o||(i[i.length]=d)}return i}return Is=r,Is}var Os,ef;function tv(){if(ef)return Os;ef=1;function e(n,r,t){switch(t.length){case 0:return n.call(r);case 1:return n.call(r,t[0]);case 2:return n.call(r,t[0],t[1]);case 3:return n.call(r,t[0],t[1],t[2])}return n.apply(r,t)}return Os=e,Os}var Ps,rf;function tf(){if(rf)return Ps;rf=1;var e=tv(),n=Math.max;function r(t,s,a){return s=n(s===void 0?t.length-1:s,0),function(){for(var o=arguments,i=-1,u=n(o.length-s,0),c=Array(u);++i<u;)c[i]=o[s+i];i=-1;for(var d=Array(s+1);++i<s;)d[i]=o[i];return d[s]=a(c),e(t,this,d)}}return Ps=r,Ps}var As,nf;function nv(){if(nf)return As;nf=1;var e=ha(),n=Zl(),r=Ye(),t=n?function(s,a){return n(s,"toString",{configurable:!0,enumerable:!1,value:e(a),writable:!0})}:r;return As=t,As}var Ls,af;function av(){if(af)return Ls;af=1;var e=800,n=16,r=Date.now;function t(s){var a=0,o=0;return function(){var i=r(),u=n-(i-o);if(o=i,u>0){if(++a>=e)return arguments[0]}else a=0;return s.apply(void 0,arguments)}}return Ls=t,Ls}var qs,sf;function of(){if(sf)return qs;sf=1;var e=nv(),n=av(),r=n(e);return qs=r,qs}var Ds,lf;function Kr(){if(lf)return Ds;lf=1;var e=Ye(),n=tf(),r=of();function t(s,a){return r(n(s,a,e),s+"")}return Ds=t,Ds}var Ms,cf;function df(){if(cf)return Ms;cf=1;function e(n,r,t,s){for(var a=n.length,o=t+(s?1:-1);s?o--:++o<a;)if(r(n[o],o,n))return o;return-1}return Ms=e,Ms}var Ws,uf;function sv(){if(uf)return Ws;uf=1;function e(n){return n!==n}return Ws=e,Ws}var Bs,ff;function ov(){if(ff)return Bs;ff=1;function e(n,r,t){for(var s=t-1,a=n.length;++s<a;)if(n[s]===r)return s;return-1}return Bs=e,Bs}var Fs,pf;function iv(){if(pf)return Fs;pf=1;var e=df(),n=sv(),r=ov();function t(s,a,o){return a===a?r(s,a,o):e(s,n,o)}return Fs=t,Fs}var $s,hf;function lv(){if(hf)return $s;hf=1;var e=iv();function n(r,t){var s=r==null?0:r.length;return!!s&&e(r,t,0)>-1}return $s=n,$s}var zs,gf;function cv(){if(gf)return zs;gf=1;function e(n,r,t){for(var s=-1,a=n==null?0:n.length;++s<a;)if(t(r,n[s]))return!0;return!1}return zs=e,zs}var Hs,mf;function dv(){if(mf)return Hs;mf=1;function e(){}return Hs=e,Hs}var Ks,vf;function uv(){if(vf)return Ks;vf=1;var e=Zc(),n=dv(),r=La(),t=1/0,s=e&&1/r(new e([,-0]))[1]==t?function(a){return new e(a)}:n;return Ks=s,Ks}var Us,yf;function fv(){if(yf)return Us;yf=1;var e=Wd(),n=lv(),r=cv(),t=$d(),s=uv(),a=La(),o=200;function i(u,c,d){var f=-1,p=n,h=u.length,g=!0,m=[],v=m;if(d)g=!1,p=r;else if(h>=o){var y=c?null:s(u);if(y)return a(y);g=!1,p=t,v=new e}else v=c?[]:m;e:for(;++f<h;){var x=u[f],b=c?c(x):x;if(x=d||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,d)||(v!==m&&v.push(b),m.push(x))}return m}return Us=i,Us}var Js,xf;function bf(){if(xf)return Js;xf=1;var e=Be(),n=Me();function r(t){return n(t)&&e(t)}return Js=r,Js}var Gs,kf;function pv(){if(kf)return Gs;kf=1;var e=Rs(),n=Kr(),r=fv(),t=bf(),s=n(function(a){return r(e(a,1,t,!0))});return Gs=s,Gs}var Vs,_f;function hv(){if(_f)return Vs;_f=1;var e=$r();function n(r,t){return e(t,function(s){return r[s]})}return Vs=n,Vs}var Ys,Sf;function wf(){if(Sf)return Ys;Sf=1;var e=hv(),n=ze();function r(t){return t==null?[]:e(t,n(t))}return Ys=r,Ys}var Xs,Tf;function Re(){if(Tf)return Xs;Tf=1;var e;if(typeof st=="function")try{e={clone:km(),constant:ha(),each:Ad(),filter:Iu(),has:Pu(),isArray:ke(),isEmpty:Km(),isFunction:pr(),isUndefined:qu(),keys:ze(),map:Bu(),reduce:Hu(),size:Qm(),transform:ev(),union:pv(),values:wf()}}catch{}return e||(e=window._),Xs=e,Xs}var Zs,Ef;function Qs(){if(Ef)return Zs;Ef=1;var e=Re();Zs=s;var n="\0",r="\0",t="";function s(d){this._isDirected=e.has(d,"directed")?d.directed:!0,this._isMultigraph=e.has(d,"multigraph")?d.multigraph:!1,this._isCompound=e.has(d,"compound")?d.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(d){return this._label=d,this},s.prototype.graph=function(){return this._label},s.prototype.setDefaultNodeLabel=function(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultNodeLabelFn=d,this},s.prototype.nodeCount=function(){return this._nodeCount},s.prototype.nodes=function(){return e.keys(this._nodes)},s.prototype.sources=function(){var d=this;return e.filter(this.nodes(),function(f){return e.isEmpty(d._in[f])})},s.prototype.sinks=function(){var d=this;return e.filter(this.nodes(),function(f){return e.isEmpty(d._out[f])})},s.prototype.setNodes=function(d,f){var p=arguments,h=this;return e.each(d,function(g){p.length>1?h.setNode(g,f):h.setNode(g)}),this},s.prototype.setNode=function(d,f){return e.has(this._nodes,d)?(arguments.length>1&&(this._nodes[d]=f),this):(this._nodes[d]=arguments.length>1?f:this._defaultNodeLabelFn(d),this._isCompound&&(this._parent[d]=r,this._children[d]={},this._children[r][d]=!0),this._in[d]={},this._preds[d]={},this._out[d]={},this._sucs[d]={},++this._nodeCount,this)},s.prototype.node=function(d){return this._nodes[d]},s.prototype.hasNode=function(d){return e.has(this._nodes,d)},s.prototype.removeNode=function(d){var f=this;if(e.has(this._nodes,d)){var p=function(h){f.removeEdge(f._edgeObjs[h])};delete this._nodes[d],this._isCompound&&(this._removeFromParentsChildList(d),delete this._parent[d],e.each(this.children(d),function(h){f.setParent(h)}),delete this._children[d]),e.each(e.keys(this._in[d]),p),delete this._in[d],delete this._preds[d],e.each(e.keys(this._out[d]),p),delete this._out[d],delete this._sucs[d],--this._nodeCount}return this},s.prototype.setParent=function(d,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 p=f;!e.isUndefined(p);p=this.parent(p))if(p===d)throw new Error("Setting "+f+" as parent of "+d+" would create a cycle");this.setNode(f)}return this.setNode(d),this._removeFromParentsChildList(d),this._parent[d]=f,this._children[f][d]=!0,this},s.prototype._removeFromParentsChildList=function(d){delete this._children[this._parent[d]][d]},s.prototype.parent=function(d){if(this._isCompound){var f=this._parent[d];if(f!==r)return f}},s.prototype.children=function(d){if(e.isUndefined(d)&&(d=r),this._isCompound){var f=this._children[d];if(f)return e.keys(f)}else{if(d===r)return this.nodes();if(this.hasNode(d))return[]}},s.prototype.predecessors=function(d){var f=this._preds[d];if(f)return e.keys(f)},s.prototype.successors=function(d){var f=this._sucs[d];if(f)return e.keys(f)},s.prototype.neighbors=function(d){var f=this.predecessors(d);if(f)return e.union(f,this.successors(d))},s.prototype.isLeaf=function(d){var f;return this.isDirected()?f=this.successors(d):f=this.neighbors(d),f.length===0},s.prototype.filterNodes=function(d){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){d(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(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultEdgeLabelFn=d,this},s.prototype.edgeCount=function(){return this._edgeCount},s.prototype.edges=function(){return e.values(this._edgeObjs)},s.prototype.setPath=function(d,f){var p=this,h=arguments;return e.reduce(d,function(g,m){return h.length>1?p.setEdge(g,m,f):p.setEdge(g,m),m}),this},s.prototype.setEdge=function(){var d,f,p,h,g=!1,m=arguments[0];typeof m=="object"&&m!==null&&"v"in m?(d=m.v,f=m.w,p=m.name,arguments.length===2&&(h=arguments[1],g=!0)):(d=m,f=arguments[1],p=arguments[3],arguments.length>2&&(h=arguments[2],g=!0)),d=""+d,f=""+f,e.isUndefined(p)||(p=""+p);var v=i(this._isDirected,d,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(d),this.setNode(f),this._edgeLabels[v]=g?h:this._defaultEdgeLabelFn(d,f,p);var y=u(this._isDirected,d,f,p);return d=y.v,f=y.w,Object.freeze(y),this._edgeObjs[v]=y,a(this._preds[f],d),a(this._sucs[d],f),this._in[f][v]=y,this._out[d][v]=y,this._edgeCount++,this},s.prototype.edge=function(d,f,p){var h=arguments.length===1?c(this._isDirected,arguments[0]):i(this._isDirected,d,f,p);return this._edgeLabels[h]},s.prototype.hasEdge=function(d,f,p){var h=arguments.length===1?c(this._isDirected,arguments[0]):i(this._isDirected,d,f,p);return e.has(this._edgeLabels,h)},s.prototype.removeEdge=function(d,f,p){var h=arguments.length===1?c(this._isDirected,arguments[0]):i(this._isDirected,d,f,p),g=this._edgeObjs[h];return g&&(d=g.v,f=g.w,delete this._edgeLabels[h],delete this._edgeObjs[h],o(this._preds[f],d),o(this._sucs[d],f),delete this._in[f][h],delete this._out[d][h],this._edgeCount--),this},s.prototype.inEdges=function(d,f){var p=this._in[d];if(p){var h=e.values(p);return f?e.filter(h,function(g){return g.v===f}):h}},s.prototype.outEdges=function(d,f){var p=this._out[d];if(p){var h=e.values(p);return f?e.filter(h,function(g){return g.w===f}):h}},s.prototype.nodeEdges=function(d,f){var p=this.inEdges(d,f);if(p)return p.concat(this.outEdges(d,f))};function a(d,f){d[f]?d[f]++:d[f]=1}function o(d,f){--d[f]||delete d[f]}function i(d,f,p,h){var g=""+f,m=""+p;if(!d&&g>m){var v=g;g=m,m=v}return g+t+m+t+(e.isUndefined(h)?n:h)}function u(d,f,p,h){var g=""+f,m=""+p;if(!d&&g>m){var v=g;g=m,m=v}var y={v:g,w:m};return h&&(y.name=h),y}function c(d,f){return i(d,f.v,f.w,f.name)}return Zs}var eo,Nf;function gv(){return Nf||(Nf=1,eo="2.1.8"),eo}var ro,Cf;function mv(){return Cf||(Cf=1,ro={Graph:Qs(),version:gv()}),ro}var to,jf;function vv(){if(jf)return to;jf=1;var e=Re(),n=Qs();to={write:r,read:a};function r(o){var i={options:{directed:o.isDirected(),multigraph:o.isMultigraph(),compound:o.isCompound()},nodes:t(o),edges:s(o)};return e.isUndefined(o.graph())||(i.value=e.clone(o.graph())),i}function t(o){return e.map(o.nodes(),function(i){var u=o.node(i),c=o.parent(i),d={v:i};return e.isUndefined(u)||(d.value=u),e.isUndefined(c)||(d.parent=c),d})}function s(o){return e.map(o.edges(),function(i){var u=o.edge(i),c={v:i.v,w:i.w};return e.isUndefined(i.name)||(c.name=i.name),e.isUndefined(u)||(c.value=u),c})}function a(o){var i=new n(o.options).setGraph(o.value);return e.each(o.nodes,function(u){i.setNode(u.v,u.value),u.parent&&i.setParent(u.v,u.parent)}),e.each(o.edges,function(u){i.setEdge({v:u.v,w:u.w,name:u.name},u.value)}),i}return to}var no,If;function yv(){if(If)return no;If=1;var e=Re();no=n;function n(r){var t={},s=[],a;function o(i){e.has(t,i)||(t[i]=!0,a.push(i),e.each(r.successors(i),o),e.each(r.predecessors(i),o))}return e.each(r.nodes(),function(i){a=[],o(i),a.length&&s.push(a)}),s}return no}var ao,Rf;function Of(){if(Rf)return ao;Rf=1;var e=Re();ao=n;function n(){this._arr=[],this._keyIndices={}}return n.prototype.size=function(){return this._arr.length},n.prototype.keys=function(){return this._arr.map(function(r){return r.key})},n.prototype.has=function(r){return e.has(this._keyIndices,r)},n.prototype.priority=function(r){var t=this._keyIndices[r];if(t!==void 0)return this._arr[t].priority},n.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},n.prototype.add=function(r,t){var s=this._keyIndices;if(r=String(r),!e.has(s,r)){var a=this._arr,o=a.length;return s[r]=o,a.push({key:r,priority:t}),this._decrease(o),!0}return!1},n.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},n.prototype.decrease=function(r,t){var s=this._keyIndices[r];if(t>this._arr[s].priority)throw new Error("New priority is greater than current priority. Key: "+r+" Old: "+this._arr[s].priority+" New: "+t);this._arr[s].priority=t,this._decrease(s)},n.prototype._heapify=function(r){var t=this._arr,s=2*r,a=s+1,o=r;s<t.length&&(o=t[s].priority<t[o].priority?s:o,a<t.length&&(o=t[a].priority<t[o].priority?a:o),o!==r&&(this._swap(r,o),this._heapify(o)))},n.prototype._decrease=function(r){for(var t=this._arr,s=t[r].priority,a;r!==0&&(a=r>>1,!(t[a].priority<s));)this._swap(r,a),r=a},n.prototype._swap=function(r,t){var s=this._arr,a=this._keyIndices,o=s[r],i=s[t];s[r]=i,s[t]=o,a[i.key]=r,a[o.key]=t},ao}var so,Pf;function Af(){if(Pf)return so;Pf=1;var e=Re(),n=Of();so=t;var r=e.constant(1);function t(a,o,i,u){return s(a,String(o),i||r,u||function(c){return a.outEdges(c)})}function s(a,o,i,u){var c={},d=new n,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,d.decrease(m,x))};for(a.nodes().forEach(function(g){var m=g===o?0:Number.POSITIVE_INFINITY;c[g]={distance:m},d.add(g,m)});d.size()>0&&(f=d.removeMin(),p=c[f],p.distance!==Number.POSITIVE_INFINITY);)u(f).forEach(h);return c}return so}var oo,Lf;function xv(){if(Lf)return oo;Lf=1;var e=Af(),n=Re();oo=r;function r(t,s,a){return n.transform(t.nodes(),function(o,i){o[i]=e(t,i,s,a)},{})}return oo}var io,qf;function Df(){if(qf)return io;qf=1;var e=Re();io=n;function n(r){var t=0,s=[],a={},o=[];function i(u){var c=a[u]={onStack:!0,lowlink:t,index:t++};if(s.push(u),r.successors(u).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 d=[],f;do f=s.pop(),a[f].onStack=!1,d.push(f);while(u!==f);o.push(d)}}return r.nodes().forEach(function(u){e.has(a,u)||i(u)}),o}return io}var lo,Mf;function bv(){if(Mf)return lo;Mf=1;var e=Re(),n=Df();lo=r;function r(t){return e.filter(n(t),function(s){return s.length>1||s.length===1&&t.hasEdge(s[0],s[0])})}return lo}var co,Wf;function kv(){if(Wf)return co;Wf=1;var e=Re();co=r;var n=e.constant(1);function r(s,a,o){return t(s,a||n,o||function(i){return s.outEdges(i)})}function t(s,a,o){var i={},u=s.nodes();return u.forEach(function(c){i[c]={},i[c][c]={distance:0},u.forEach(function(d){c!==d&&(i[c][d]={distance:Number.POSITIVE_INFINITY})}),o(c).forEach(function(d){var f=d.v===c?d.w:d.v,p=a(d);i[c][f]={distance:p,predecessor:c}})}),u.forEach(function(c){var d=i[c];u.forEach(function(f){var p=i[f];u.forEach(function(h){var g=p[c],m=d[h],v=p[h],y=g.distance+m.distance;y<v.distance&&(v.distance=y,v.predecessor=m.predecessor)})})}),i}return co}var uo,Bf;function Ff(){if(Bf)return uo;Bf=1;var e=Re();uo=n,n.CycleException=r;function n(t){var s={},a={},o=[];function i(u){if(e.has(a,u))throw new r;e.has(s,u)||(a[u]=!0,s[u]=!0,e.each(t.predecessors(u),i),delete a[u],o.push(u))}if(e.each(t.sinks(),i),e.size(s)!==t.nodeCount())throw new r;return o}function r(){}return r.prototype=new Error,uo}var fo,$f;function _v(){if($f)return fo;$f=1;var e=Ff();fo=n;function n(r){try{e(r)}catch(t){if(t instanceof e.CycleException)return!1;throw t}return!0}return fo}var po,zf;function Hf(){if(zf)return po;zf=1;var e=Re();po=n;function n(t,s,a){e.isArray(s)||(s=[s]);var o=(t.isDirected()?t.successors:t.neighbors).bind(t),i=[],u={};return e.each(s,function(c){if(!t.hasNode(c))throw new Error("Graph does not have node: "+c);r(t,c,a==="post",u,o,i)}),i}function r(t,s,a,o,i,u){e.has(o,s)||(o[s]=!0,a||u.push(s),e.each(i(s),function(c){r(t,c,a,o,i,u)}),a&&u.push(s))}return po}var ho,Kf;function Sv(){if(Kf)return ho;Kf=1;var e=Hf();ho=n;function n(r,t){return e(r,t,"post")}return ho}var go,Uf;function wv(){if(Uf)return go;Uf=1;var e=Hf();go=n;function n(r,t){return e(r,t,"pre")}return go}var mo,Jf;function Tv(){if(Jf)return mo;Jf=1;var e=Re(),n=Qs(),r=Of();mo=t;function t(s,a){var o=new n,i={},u=new r,c;function d(p){var h=p.v===c?p.w:p.v,g=u.priority(h);if(g!==void 0){var m=a(p);m<g&&(i[h]=c,u.decrease(h,m))}}if(s.nodeCount()===0)return o;e.each(s.nodes(),function(p){u.add(p,Number.POSITIVE_INFINITY),o.setNode(p)}),u.decrease(s.nodes()[0],0);for(var f=!1;u.size()>0;){if(c=u.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(d)}return o}return mo}var vo,Gf;function Ev(){return Gf||(Gf=1,vo={components:yv(),dijkstra:Af(),dijkstraAll:xv(),findCycles:bv(),floydWarshall:kv(),isAcyclic:_v(),postorder:Sv(),preorder:wv(),prim:Tv(),tarjan:Df(),topsort:Ff()}),vo}var yo,Vf;function Nv(){if(Vf)return yo;Vf=1;var e=mv();return yo={Graph:e.Graph,json:vv(),alg:Ev(),version:e.version},yo}var xo,Yf;function Ae(){if(Yf)return xo;Yf=1;var e;if(typeof st=="function")try{e=Nv()}catch{}return e||(e=window.graphlib),xo=e,xo}var bo,Xf;function Cv(){if(Xf)return bo;Xf=1;var e=bd(),n=1,r=4;function t(s){return e(s,n|r)}return bo=t,bo}var ko,Zf;function Ur(){if(Zf)return ko;Zf=1;var e=Qe(),n=Be(),r=Dr(),t=Ie();function s(a,o,i){if(!t(i))return!1;var u=typeof o;return(u=="number"?n(i)&&r(o,i.length):u=="string"&&o in i)?e(i[o],a):!1}return ko=s,ko}var _o,Qf;function jv(){if(Qf)return _o;Qf=1;var e=Kr(),n=Qe(),r=Ur(),t=Ve(),s=Object.prototype,a=s.hasOwnProperty,o=e(function(i,u){i=Object(i);var c=-1,d=u.length,f=d>2?u[2]:void 0;for(f&&r(u[0],u[1],f)&&(d=1);++c<d;)for(var p=u[c],h=t(p),g=-1,m=h.length;++g<m;){var v=h[g],y=i[v];(y===void 0||n(y,s[v])&&!a.call(i,v))&&(i[v]=p[v])}return i});return _o=o,_o}var So,ep;function Iv(){if(ep)return So;ep=1;var e=Fe(),n=Be(),r=ze();function t(s){return function(a,o,i){var u=Object(a);if(!n(a)){var c=e(o,3);a=r(a),o=function(f){return c(u[f],f,u)}}var d=s(a,o,i);return d>-1?u[c?a[d]:d]:void 0}}return So=t,So}var wo,rp;function Rv(){if(rp)return wo;rp=1;var e=/\s/;function n(r){for(var t=r.length;t--&&e.test(r.charAt(t)););return t}return wo=n,wo}var To,tp;function Ov(){if(tp)return To;tp=1;var e=Rv(),n=/^\s+/;function r(t){return t&&t.slice(0,e(t)+1).replace(n,"")}return To=r,To}var Eo,np;function Pv(){if(np)return Eo;np=1;var e=Ov(),n=Ie(),r=nr(),t=NaN,s=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,o=/^0o[0-7]+$/i,i=parseInt;function u(c){if(typeof c=="number")return c;if(r(c))return t;if(n(c)){var d=typeof c.valueOf=="function"?c.valueOf():c;c=n(d)?d+"":d}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)?t:+c}return Eo=u,Eo}var No,ap;function sp(){if(ap)return No;ap=1;var e=Pv(),n=1/0,r=17976931348623157e292;function t(s){if(!s)return s===0?s:0;if(s=e(s),s===n||s===-n){var a=s<0?-1:1;return a*r}return s===s?s:0}return No=t,No}var Co,op;function Av(){if(op)return Co;op=1;var e=sp();function n(r){var t=e(r),s=t%1;return t===t?s?t-s:t:0}return Co=n,Co}var jo,ip;function Lv(){if(ip)return jo;ip=1;var e=df(),n=Fe(),r=Av(),t=Math.max;function s(a,o,i){var u=a==null?0:a.length;if(!u)return-1;var c=i==null?0:r(i);return c<0&&(c=t(u+c,0)),e(a,n(o,3),c)}return jo=s,jo}var Io,lp;function qv(){if(lp)return Io;lp=1;var e=Iv(),n=Lv(),r=e(n);return Io=r,Io}var Ro,cp;function dp(){if(cp)return Ro;cp=1;var e=Rs();function n(r){var t=r==null?0:r.length;return t?e(r,1):[]}return Ro=n,Ro}var Oo,up;function Dv(){if(up)return Oo;up=1;var e=va(),n=Id(),r=Ve();function t(s,a){return s==null?s:e(s,n(a),r)}return Oo=t,Oo}var Po,fp;function Mv(){if(fp)return Po;fp=1;function e(n){var r=n==null?0:n.length;return r?n[r-1]:void 0}return Po=e,Po}var Ao,pp;function Wv(){if(pp)return Ao;pp=1;var e=Lr(),n=xa(),r=Fe();function t(s,a){var o={};return a=r(a,3),n(s,function(i,u,c){e(o,u,a(i,u,c))}),o}return Ao=t,Ao}var Lo,hp;function qo(){if(hp)return Lo;hp=1;var e=nr();function n(r,t,s){for(var a=-1,o=r.length;++a<o;){var i=r[a],u=t(i);if(u!=null&&(c===void 0?u===u&&!e(u):s(u,c)))var c=u,d=i}return d}return Lo=n,Lo}var Do,gp;function Bv(){if(gp)return Do;gp=1;function e(n,r){return n>r}return Do=e,Do}var Mo,mp;function Fv(){if(mp)return Mo;mp=1;var e=qo(),n=Bv(),r=Ye();function t(s){return s&&s.length?e(s,r,n):void 0}return Mo=t,Mo}var Wo,vp;function yp(){if(vp)return Wo;vp=1;var e=Lr(),n=Qe();function r(t,s,a){(a!==void 0&&!n(t[s],a)||a===void 0&&!(s in t))&&e(t,s,a)}return Wo=r,Wo}var Bo,xp;function $v(){if(xp)return Bo;xp=1;var e=Je(),n=Br(),r=Me(),t="[object Object]",s=Function.prototype,a=Object.prototype,o=s.toString,i=a.hasOwnProperty,u=o.call(Object);function c(d){if(!r(d)||e(d)!=t)return!1;var f=n(d);if(f===null)return!0;var p=i.call(f,"constructor")&&f.constructor;return typeof p=="function"&&p instanceof p&&o.call(p)==u}return Bo=c,Bo}var Fo,bp;function kp(){if(bp)return Fo;bp=1;function e(n,r){if(!(r==="constructor"&&typeof n[r]=="function")&&r!="__proto__")return n[r]}return Fo=e,Fo}var $o,_p;function zv(){if(_p)return $o;_p=1;var e=hr(),n=Ve();function r(t){return e(t,n(t))}return $o=r,$o}var zo,Sp;function Hv(){if(Sp)return zo;Sp=1;var e=yp(),n=Ic(),r=cd(),t=Oc(),s=hd(),a=gr(),o=ke(),i=bf(),u=rr(),c=pr(),d=Ie(),f=$v(),p=yr(),h=kp(),g=zv();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 D=o(L),I=!D&&u(L),P=!D&&!I&&p(L);C=L,D||I||P?o(N)?C=N:i(N)?C=t(N):I?(S=!1,C=n(L,!0)):P?(S=!1,C=r(L,!0)):C=[]:f(L)||a(L)?(C=N,a(N)?C=g(N):(!d(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 zo=m,zo}var Ho,wp;function Kv(){if(wp)return Ho;wp=1;var e=Ar(),n=yp(),r=va(),t=Hv(),s=Ie(),a=Ve(),o=kp();function i(u,c,d,f,p){u!==c&&r(c,function(h,g){if(p||(p=new e),s(h))t(u,c,g,d,i,f,p);else{var m=f?f(o(u,g),h,g+"",u,c,p):void 0;m===void 0&&(m=h),n(u,g,m)}},a)}return Ho=i,Ho}var Ko,Tp;function Uv(){if(Tp)return Ko;Tp=1;var e=Kr(),n=Ur();function r(t){return e(function(s,a){var o=-1,i=a.length,u=i>1?a[i-1]:void 0,c=i>2?a[2]:void 0;for(u=t.length>3&&typeof u=="function"?(i--,u):void 0,c&&n(a[0],a[1],c)&&(u=i<3?void 0:u,i=1),s=Object(s);++o<i;){var d=a[o];d&&t(s,d,o,u)}return s})}return Ko=r,Ko}var Uo,Ep;function Jv(){if(Ep)return Uo;Ep=1;var e=Kv(),n=Uv(),r=n(function(t,s,a){e(t,s,a)});return Uo=r,Uo}var Jo,Np;function Cp(){if(Np)return Jo;Np=1;function e(n,r){return n<r}return Jo=e,Jo}var Go,jp;function Gv(){if(jp)return Go;jp=1;var e=qo(),n=Cp(),r=Ye();function t(s){return s&&s.length?e(s,r,n):void 0}return Go=t,Go}var Vo,Ip;function Vv(){if(Ip)return Vo;Ip=1;var e=qo(),n=Fe(),r=Cp();function t(s,a){return s&&s.length?e(s,n(a,2),r):void 0}return Vo=t,Vo}var Yo,Rp;function Yv(){if(Rp)return Yo;Rp=1;var e=Pe(),n=function(){return e.Date.now()};return Yo=n,Yo}var Xo,Op;function Xv(){if(Op)return Xo;Op=1;var e=qr(),n=zr(),r=Dr(),t=Ie(),s=br();function a(o,i,u,c){if(!t(o))return o;i=n(i,o);for(var d=-1,f=i.length,p=f-1,h=o;h!=null&&++d<f;){var g=s(i[d]),m=u;if(g==="__proto__"||g==="constructor"||g==="prototype")return o;if(d!=p){var v=h[g];m=c?c(v,g,h):void 0,m===void 0&&(m=t(v)?v:r(i[d+1])?[]:{})}e(h,g,m),h=h[g]}return o}return Xo=a,Xo}var Zo,Pp;function Zv(){if(Pp)return Zo;Pp=1;var e=Hr(),n=Xv(),r=zr();function t(s,a,o){for(var i=-1,u=a.length,c={};++i<u;){var d=a[i],f=e(s,d);o(f,d)&&n(c,r(d,s),f)}return c}return Zo=t,Zo}var Qo,Ap;function Qv(){if(Ap)return Qo;Ap=1;var e=Zv(),n=_u();function r(t,s){return e(t,s,function(a,o){return n(t,o)})}return Qo=r,Qo}var ei,Lp;function ey(){if(Lp)return ei;Lp=1;var e=dp(),n=tf(),r=of();function t(s){return r(n(s,void 0,e),s+"")}return ei=t,ei}var ri,qp;function ry(){if(qp)return ri;qp=1;var e=Qv(),n=ey(),r=n(function(t,s){return t==null?{}:e(t,s)});return ri=r,ri}var ti,Dp;function ty(){if(Dp)return ti;Dp=1;var e=Math.ceil,n=Math.max;function r(t,s,a,o){for(var i=-1,u=n(e((s-t)/(a||1)),0),c=Array(u);u--;)c[o?u:++i]=t,t+=a;return c}return ti=r,ti}var ni,Mp;function ny(){if(Mp)return ni;Mp=1;var e=ty(),n=Ur(),r=sp();function t(s){return function(a,o,i){return i&&typeof i!="number"&&n(a,o,i)&&(o=i=void 0),a=r(a),o===void 0?(o=a,a=0):o=r(o),i=i===void 0?a<o?1:-1:r(i),e(a,o,i,s)}}return ni=t,ni}var ai,Wp;function ay(){if(Wp)return ai;Wp=1;var e=ny(),n=e();return ai=n,ai}var si,Bp;function sy(){if(Bp)return si;Bp=1;function e(n,r){var t=n.length;for(n.sort(r);t--;)n[t]=n[t].value;return n}return si=e,si}var oi,Fp;function oy(){if(Fp)return oi;Fp=1;var e=nr();function n(r,t){if(r!==t){var s=r!==void 0,a=r===null,o=r===r,i=e(r),u=t!==void 0,c=t===null,d=t===t,f=e(t);if(!c&&!f&&!i&&r>t||i&&u&&d&&!c&&!f||a&&u&&d||!s&&d||!o)return 1;if(!a&&!i&&!f&&r<t||f&&s&&o&&!a&&!i||c&&s&&o||!u&&o||!d)return-1}return 0}return oi=n,oi}var ii,$p;function iy(){if($p)return ii;$p=1;var e=oy();function n(r,t,s){for(var a=-1,o=r.criteria,i=t.criteria,u=o.length,c=s.length;++a<u;){var d=e(o[a],i[a]);if(d){if(a>=c)return d;var f=s[a];return d*(f=="desc"?-1:1)}}return r.index-t.index}return ii=n,ii}var li,zp;function ly(){if(zp)return li;zp=1;var e=$r(),n=Hr(),r=Fe(),t=Mu(),s=sy(),a=Mr(),o=iy(),i=Ye(),u=ke();function c(d,f,p){f.length?f=e(f,function(m){return u(m)?function(v){return n(v,m.length===1?m[0]:m)}:m}):f=[i];var h=-1;f=e(f,a(r));var g=t(d,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 li=c,li}var ci,Hp;function cy(){if(Hp)return ci;Hp=1;var e=Rs(),n=ly(),r=Kr(),t=Ur(),s=r(function(a,o){if(a==null)return[];var i=o.length;return i>1&&t(a,o[0],o[1])?o=[]:i>2&&t(o[0],o[1],o[2])&&(o=[o[0]]),n(a,e(o,1),[])});return ci=s,ci}var di,Kp;function dy(){if(Kp)return di;Kp=1;var e=pu(),n=0;function r(t){var s=++n;return e(t)+s}return di=r,di}var ui,Up;function uy(){if(Up)return ui;Up=1;function e(n,r,t){for(var s=-1,a=n.length,o=r.length,i={};++s<a;){var u=s<o?r[s]:void 0;t(i,n[s],u)}return i}return ui=e,ui}var fi,Jp;function fy(){if(Jp)return fi;Jp=1;var e=qr(),n=uy();function r(t,s){return n(t||[],s||[],e)}return fi=r,fi}var pi,Gp;function be(){if(Gp)return pi;Gp=1;var e;if(typeof st=="function")try{e={cloneDeep:Cv(),constant:ha(),defaults:jv(),each:Ad(),filter:Iu(),find:qv(),flatten:dp(),forEach:Od(),forIn:Dv(),has:Pu(),isUndefined:qu(),last:Mv(),map:Bu(),mapValues:Wv(),max:Fv(),merge:Jv(),min:Gv(),minBy:Vv(),now:Yv(),pick:ry(),range:ay(),reduce:Hu(),sortBy:cy(),uniqueId:dy(),values:wf(),zipObject:fy()}}catch{}return e||(e=window._),pi=e,pi}var hi,Vp;function py(){if(Vp)return hi;Vp=1,hi=e;function e(){var t={};t._next=t._prev=t,this._sentinel=t}e.prototype.dequeue=function(){var t=this._sentinel,s=t._prev;if(s!==t)return n(s),s},e.prototype.enqueue=function(t){var s=this._sentinel;t._prev&&t._next&&n(t),t._next=s._next,s._next._prev=t,s._next=t,t._prev=s},e.prototype.toString=function(){for(var t=[],s=this._sentinel,a=s._prev;a!==s;)t.push(JSON.stringify(a,r)),a=a._prev;return"["+t.join(", ")+"]"};function n(t){t._prev._next=t._next,t._next._prev=t._prev,delete t._next,delete t._prev}function r(t,s){if(t!=="_next"&&t!=="_prev")return s}return hi}var gi,Yp;function hy(){if(Yp)return gi;Yp=1;var e=be(),n=Ae().Graph,r=py();gi=s;var t=e.constant(1);function s(c,d){if(c.nodeCount()<=1)return[];var f=i(c,d||t),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,d,f){for(var p=[],h=d[d.length-1],g=d[0],m;c.nodeCount();){for(;m=g.dequeue();)o(c,d,f,m);for(;m=h.dequeue();)o(c,d,f,m);if(c.nodeCount()){for(var v=d.length-2;v>0;--v)if(m=d[v].dequeue(),m){p=p.concat(o(c,d,f,m,!0));break}}}return p}function o(c,d,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,u(d,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,u(d,f,x)}),c.removeNode(p.v),g}function i(c,d){var f=new n,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=d(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 r}),m=p+1;return e.forEach(f.nodes(),function(v){u(g,m,f.node(v))}),{graph:f,buckets:g,zeroIdx:m}}function u(c,d,f){f.out?f.in?c[f.out-f.in+d].enqueue(f):c[c.length-1].enqueue(f):c[0].enqueue(f)}return gi}var mi,Xp;function gy(){if(Xp)return mi;Xp=1;var e=be(),n=hy();mi={run:r,undo:s};function r(a){var o=a.graph().acyclicer==="greedy"?n(a,i(a)):t(a);e.forEach(o,function(u){var c=a.edge(u);a.removeEdge(u),c.forwardName=u.name,c.reversed=!0,a.setEdge(u.w,u.v,c,e.uniqueId("rev"))});function i(u){return function(c){return u.edge(c).weight}}}function t(a){var o=[],i={},u={};function c(d){e.has(u,d)||(u[d]=!0,i[d]=!0,e.forEach(a.outEdges(d),function(f){e.has(i,f.w)?o.push(f):c(f.w)}),delete i[d])}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 u=i.forwardName;delete i.reversed,delete i.forwardName,a.setEdge(o.w,o.v,i,u)}})}return mi}var vi,Zp;function Ce(){if(Zp)return vi;Zp=1;var e=be(),n=Ae().Graph;vi={addDummyNode:r,simplify:t,asNonCompoundGraph:s,successorWeights:a,predecessorWeights:o,intersectRect:i,buildLayerMatrix:u,normalizeRanks:c,removeEmptyRanks:d,addBorderNode:f,maxRank:p,partition:h,time:g,notime:m};function r(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 t(v){var y=new n().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 n({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 u(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 d(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),r(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 vi}var yi,Qp;function my(){if(Qp)return yi;Qp=1;var e=be(),n=Ce();yi={run:r,undo:s};function r(a){a.graph().dummyChains=[],e.forEach(a.edges(),function(o){t(a,o)})}function t(a,o){var i=o.v,u=a.node(i).rank,c=o.w,d=a.node(c).rank,f=o.name,p=a.edge(o),h=p.labelRank;if(d!==u+1){a.removeEdge(o);var g,m,v;for(v=0,++u;u<d;++v,++u)p.points=[],m={width:0,height:0,edgeLabel:p,edgeObj:o,rank:u},g=n.addDummyNode(a,"edge",m,"_d"),u===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),u=i.edgeLabel,c;for(a.setEdge(i.edgeObj,u);i.dummy;)c=a.successors(o)[0],a.removeNode(o),u.points.push({x:i.x,y:i.y}),i.dummy==="edge-label"&&(u.x=i.x,u.y=i.y,u.width=i.width,u.height=i.height),o=c,i=a.node(o)})}return yi}var xi,eh;function Jr(){if(eh)return xi;eh=1;var e=be();xi={longestPath:n,slack:r};function n(t){var s={};function a(o){var i=t.node(o);if(e.has(s,o))return i.rank;s[o]=!0;var u=e.min(e.map(t.outEdges(o),function(c){return a(c.w)-t.edge(c).minlen}));return(u===Number.POSITIVE_INFINITY||u===void 0||u===null)&&(u=0),i.rank=u}e.forEach(t.sources(),a)}function r(t,s){return t.node(s.w).rank-t.node(s.v).rank-t.edge(s).minlen}return xi}var bi,rh;function th(){if(rh)return bi;rh=1;var e=be(),n=Ae().Graph,r=Jr().slack;bi=t;function t(i){var u=new n({directed:!1}),c=i.nodes()[0],d=i.nodeCount();u.setNode(c,{});for(var f,p;s(u,i)<d;)f=a(u,i),p=u.hasNode(f.v)?r(i,f):-r(i,f),o(u,i,p);return u}function s(i,u){function c(d){e.forEach(u.nodeEdges(d),function(f){var p=f.v,h=d===p?f.w:p;!i.hasNode(h)&&!r(u,f)&&(i.setNode(h,{}),i.setEdge(d,h,{}),c(h))})}return e.forEach(i.nodes(),c),i.nodeCount()}function a(i,u){return e.minBy(u.edges(),function(c){if(i.hasNode(c.v)!==i.hasNode(c.w))return r(u,c)})}function o(i,u,c){e.forEach(i.nodes(),function(d){u.node(d).rank+=c})}return bi}var ki,nh;function vy(){if(nh)return ki;nh=1;var e=be(),n=th(),r=Jr().slack,t=Jr().longestPath,s=Ae().alg.preorder,a=Ae().alg.postorder,o=Ce().simplify;ki=i,i.initLowLimValues=f,i.initCutValues=u,i.calcCutValue=d,i.leaveEdge=h,i.enterEdge=g,i.exchangeEdges=m;function i(b){b=o(b),t(b);var k=n(b);f(k),u(k,b);for(var w,j;w=h(k);)j=g(k,b,w),m(k,b,w,j)}function u(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=d(b,k,w)}function d(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 D=S.v===w,I=D?S.w:S.v;if(I!==N){var P=D===L,F=k.edge(S).weight;if(C+=P?F:-F,y(b,w,I)){var W=b.edge(w,I).cutvalue;C+=P?-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 D=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(D,function(I){return r(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),u(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 ki}var _i,ah;function yy(){if(ah)return _i;ah=1;var e=Jr(),n=e.longestPath,r=th(),t=vy();_i=s;function s(u){switch(u.graph().ranker){case"network-simplex":i(u);break;case"tight-tree":o(u);break;case"longest-path":a(u);break;default:i(u)}}var a=n;function o(u){n(u),r(u)}function i(u){t(u)}return _i}var Si,sh;function xy(){if(sh)return Si;sh=1;var e=be();Si=n;function n(s){var a=t(s);e.forEach(s.graph().dummyChains,function(o){for(var i=s.node(o),u=i.edgeObj,c=r(s,a,u.v,u.w),d=c.path,f=c.lca,p=0,h=d[p],g=!0;o!==u.w;){if(i=s.node(o),g){for(;(h=d[p])!==f&&s.node(h).maxRank<i.rank;)p++;h===f&&(g=!1)}if(!g){for(;p<d.length-1&&s.node(h=d[p+1]).minRank<=i.rank;)p++;h=d[p]}s.setParent(o,h),o=s.successors(o)[0]}})}function r(s,a,o,i){var u=[],c=[],d=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),u.push(p);while(p&&(a[p].low>d||f>a[p].lim));for(h=p,p=i;(p=s.parent(p))!==h;)c.push(p);return{path:u.concat(c.reverse()),lca:h}}function t(s){var a={},o=0;function i(u){var c=o;e.forEach(s.children(u),i),a[u]={low:c,lim:o++}}return e.forEach(s.children(),i),a}return Si}var wi,oh;function by(){if(oh)return wi;oh=1;var e=be(),n=Ce();wi={run:r,cleanup:o};function r(i){var u=n.addDummyNode(i,"root",{},"_root"),c=s(i),d=e.max(e.values(c))-1,f=2*d+1;i.graph().nestingRoot=u,e.forEach(i.edges(),function(h){i.edge(h).minlen*=f});var p=a(i)+1;e.forEach(i.children(),function(h){t(i,u,f,p,d,c,h)}),i.graph().nodeRankFactor=f}function t(i,u,c,d,f,p,h){var g=i.children(h);if(!g.length){h!==u&&i.setEdge(u,h,{weight:0,minlen:c});return}var m=n.addBorderNode(i,"_bt"),v=n.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){t(i,u,c,d,f,p,x);var b=i.node(x),k=b.borderTop?b.borderTop:x,w=b.borderBottom?b.borderBottom:x,j=b.borderTop?d:2*d,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(u,m,{weight:0,minlen:f+p[h]})}function s(i){var u={};function c(d,f){var p=i.children(d);p&&p.length&&e.forEach(p,function(h){c(h,f+1)}),u[d]=f}return e.forEach(i.children(),function(d){c(d,1)}),u}function a(i){return e.reduce(i.edges(),function(u,c){return u+i.edge(c).weight},0)}function o(i){var u=i.graph();i.removeNode(u.nestingRoot),delete u.nestingRoot,e.forEach(i.edges(),function(c){var d=i.edge(c);d.nestingEdge&&i.removeEdge(c)})}return wi}var Ti,ih;function ky(){if(ih)return Ti;ih=1;var e=be(),n=Ce();Ti=r;function r(s){function a(o){var i=s.children(o),u=s.node(o);if(i.length&&e.forEach(i,a),e.has(u,"minRank")){u.borderLeft=[],u.borderRight=[];for(var c=u.minRank,d=u.maxRank+1;c<d;++c)t(s,"borderLeft","_bl",o,u,c),t(s,"borderRight","_br",o,u,c)}}e.forEach(s.children(),a)}function t(s,a,o,i,u,c){var d={width:0,height:0,rank:c,borderType:a},f=u[a][c-1],p=n.addDummyNode(s,"border",d,o);u[a][c]=p,s.setParent(p,i),f&&s.setEdge(f,p,{weight:1})}return Ti}var Ei,lh;function _y(){if(lh)return Ei;lh=1;var e=be();Ei={adjust:n,undo:r};function n(c){var d=c.graph().rankdir.toLowerCase();(d==="lr"||d==="rl")&&t(c)}function r(c){var d=c.graph().rankdir.toLowerCase();(d==="bt"||d==="rl")&&a(c),(d==="lr"||d==="rl")&&(i(c),t(c))}function t(c){e.forEach(c.nodes(),function(d){s(c.node(d))}),e.forEach(c.edges(),function(d){s(c.edge(d))})}function s(c){var d=c.width;c.width=c.height,c.height=d}function a(c){e.forEach(c.nodes(),function(d){o(c.node(d))}),e.forEach(c.edges(),function(d){var f=c.edge(d);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(d){u(c.node(d))}),e.forEach(c.edges(),function(d){var f=c.edge(d);e.forEach(f.points,u),e.has(f,"x")&&u(f)})}function u(c){var d=c.x;c.x=c.y,c.y=d}return Ei}var Ni,ch;function Sy(){if(ch)return Ni;ch=1;var e=be();Ni=n;function n(r){var t={},s=e.filter(r.nodes(),function(c){return!r.children(c).length}),a=e.max(e.map(s,function(c){return r.node(c).rank})),o=e.map(e.range(a+1),function(){return[]});function i(c){if(!e.has(t,c)){t[c]=!0;var d=r.node(c);o[d.rank].push(c),e.forEach(r.successors(c),i)}}var u=e.sortBy(s,function(c){return r.node(c).rank});return e.forEach(u,i),o}return Ni}var Ci,dh;function wy(){if(dh)return Ci;dh=1;var e=be();Ci=n;function n(t,s){for(var a=0,o=1;o<s.length;++o)a+=r(t,s[o-1],s[o]);return a}function r(t,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(t.outEdges(p),function(h){return{pos:o[h.w],weight:t.edge(h).weight}}),"pos")}),!0),u=1;u<a.length;)u<<=1;var c=2*u-1;u-=1;var d=e.map(new Array(c),function(){return 0}),f=0;return e.forEach(i.forEach(function(p){var h=p.pos+u;d[h]+=p.weight;for(var g=0;h>0;)h%2&&(g+=d[h+1]),h=h-1>>1,d[h]+=p.weight;f+=p.weight*g})),f}return Ci}var ji,uh;function Ty(){if(uh)return ji;uh=1;var e=be();ji=n;function n(r,t){return e.map(t,function(s){var a=r.inEdges(s);if(a.length){var o=e.reduce(a,function(i,u){var c=r.edge(u),d=r.node(u.v);return{sum:i.sum+c.weight*d.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 ji}var Ii,fh;function Ey(){if(fh)return Ii;fh=1;var e=be();Ii=n;function n(s,a){var o={};e.forEach(s,function(u,c){var d=o[u.v]={indegree:0,in:[],out:[],vs:[u.v],i:c};e.isUndefined(u.barycenter)||(d.barycenter=u.barycenter,d.weight=u.weight)}),e.forEach(a.edges(),function(u){var c=o[u.v],d=o[u.w];!e.isUndefined(c)&&!e.isUndefined(d)&&(d.indegree++,c.out.push(o[u.w]))});var i=e.filter(o,function(u){return!u.indegree});return r(i)}function r(s){var a=[];function o(c){return function(d){d.merged||(e.isUndefined(d.barycenter)||e.isUndefined(c.barycenter)||d.barycenter>=c.barycenter)&&t(c,d)}}function i(c){return function(d){d.in.push(c),--d.indegree===0&&s.push(d)}}for(;s.length;){var u=s.pop();a.push(u),e.forEach(u.in.reverse(),o(u)),e.forEach(u.out,i(u))}return e.map(e.filter(a,function(c){return!c.merged}),function(c){return e.pick(c,["vs","i","barycenter","weight"])})}function t(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 Ii}var Ri,ph;function Ny(){if(ph)return Ri;ph=1;var e=be(),n=Ce();Ri=r;function r(a,o){var i=n.partition(a,function(m){return e.has(m,"barycenter")}),u=i.lhs,c=e.sortBy(i.rhs,function(m){return-m.i}),d=[],f=0,p=0,h=0;u.sort(s(!!o)),h=t(d,c,h),e.forEach(u,function(m){h+=m.vs.length,d.push(m.vs),f+=m.barycenter*m.weight,p+=m.weight,h=t(d,c,h)});var g={vs:e.flatten(d,!0)};return p&&(g.barycenter=f/p,g.weight=p),g}function t(a,o,i){for(var u;o.length&&(u=e.last(o)).i<=i;)o.pop(),a.push(u.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 Ri}var Oi,hh;function Cy(){if(hh)return Oi;hh=1;var e=be(),n=Ty(),r=Ey(),t=Ny();Oi=s;function s(i,u,c,d){var f=i.children(u),p=i.node(u),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=n(i,f);e.forEach(v,function(w){if(i.children(w.v).length){var j=s(i,w.v,c,d);m[w.v]=j,e.has(j,"barycenter")&&o(w,j)}});var y=r(v,c);a(y,m);var x=t(y,d);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,u){e.forEach(i,function(c){c.vs=e.flatten(c.vs.map(function(d){return u[d]?u[d].vs:d}),!0)})}function o(i,u){e.isUndefined(i.barycenter)?(i.barycenter=u.barycenter,i.weight=u.weight):(i.barycenter=(i.barycenter*i.weight+u.barycenter*u.weight)/(i.weight+u.weight),i.weight+=u.weight)}return Oi}var Pi,gh;function jy(){if(gh)return Pi;gh=1;var e=be(),n=Ae().Graph;Pi=r;function r(s,a,o){var i=t(s),u=new n({compound:!0}).setGraph({root:i}).setDefaultNodeLabel(function(c){return s.node(c)});return e.forEach(s.nodes(),function(c){var d=s.node(c),f=s.parent(c);(d.rank===a||d.minRank<=a&&a<=d.maxRank)&&(u.setNode(c),u.setParent(c,f||i),e.forEach(s[o](c),function(p){var h=p.v===c?p.w:p.v,g=u.edge(h,c),m=e.isUndefined(g)?0:g.weight;u.setEdge(h,c,{weight:s.edge(p).weight+m})}),e.has(d,"minRank")&&u.setNode(c,{borderLeft:d.borderLeft[a],borderRight:d.borderRight[a]}))}),u}function t(s){for(var a;s.hasNode(a=e.uniqueId("_root")););return a}return Pi}var Ai,mh;function Iy(){if(mh)return Ai;mh=1;var e=be();Ai=n;function n(r,t,s){var a={},o;e.forEach(s,function(i){for(var u=r.parent(i),c,d;u;){if(c=r.parent(u),c?(d=a[c],a[c]=u):(d=o,o=u),d&&d!==u){t.setEdge(d,u);return}u=c}})}return Ai}var Li,vh;function Ry(){if(vh)return Li;vh=1;var e=be(),n=Sy(),r=wy(),t=Cy(),s=jy(),a=Iy(),o=Ae().Graph,i=Ce();Li=u;function u(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=n(p);f(p,v);for(var y=Number.POSITIVE_INFINITY,x,b=0,k=0;k<4;++b,++k){d(b%2?g:m,b%4>=2),v=i.buildLayerMatrix(p);var w=r(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 d(p,h){var g=new o;e.forEach(p,function(m){var v=m.graph().root,y=t(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 Li}var qi,yh;function Oy(){if(yh)return qi;yh=1;var e=be(),n=Ae().Graph,r=Ce();qi={positionX:g,findType1Conflicts:t,findType2Conflicts:s,addConflict:o,hasConflict:i,verticalAlignment:u,horizontalCompaction:c,alignCoordinates:p,findSmallestWidthAlignment:f,balance:h};function t(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,D){var I=a(y,S),P=I?y.node(I).order:T;(I||S===C)&&(e.forEach(j.slice(L,D+1),function(F){e.forEach(y.predecessors(F),function(W){var K=y.node(W),V=K.order;(V<N||P<V)&&!(K.dummy&&y.node(F).dummy)&&o(b,W,F)})}),L=D+1,N=P)}),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(D){S=j[D],y.node(S).dummy&&e.forEach(y.predecessors(S),function(I){var P=y.node(I);P.dummy&&(P.order<T||P.order>C)&&o(b,I,S)})})}function w(j,N){var L=-1,T,C=0;return e.forEach(N,function(S,D){if(y.node(S).dummy==="border"){var I=y.predecessors(S);I.length&&(T=y.node(I[0]).order,k(N,C,D,L,T),C=D,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 u(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 D=(S.length-1)/2,I=Math.floor(D),P=Math.ceil(D);I<=P;++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=d(y,x,b,w),L=w?"borderLeft":"borderRight";function T(D,I){for(var P=N.nodes(),F=P.pop(),W={};F;)W[F]?D(F):(W[F]=!0,P.push(F),P=P.concat(I(F))),F=P.pop()}function C(D){j[D]=N.inEdges(D).reduce(function(I,P){return Math.max(I,j[P.v]+N.edge(P))},0)}function S(D){var I=N.outEdges(D).reduce(function(F,W){return Math.min(F,j[W.w]-N.edge(W))},Number.POSITIVE_INFINITY),P=y.node(D);I!==Number.POSITIVE_INFINITY&&P.borderType!==L&&(j[D]=Math.max(j[D],I))}return T(C,N.predecessors.bind(N)),T(S,N.successors.bind(N)),e.forEach(k,function(D){j[D]=j[b[D]]}),j}function d(y,x,b,k){var w=new n,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 D=b[T],I=w.edge(D,S);w.setEdge(D,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(D){return D+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=r.buildLayerMatrix(y),b=e.merge(t(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(D){return e.values(D).reverse()}));var T=(N==="u"?y.predecessors:y.successors).bind(y),C=u(y,w,b,T),S=c(y,w,C.root,C.align,L==="r");L==="r"&&(S=e.mapValues(S,function(D){return-D})),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 qi}var Di,xh;function Py(){if(xh)return Di;xh=1;var e=be(),n=Ce(),r=Oy().positionX;Di=t;function t(a){a=n.asNonCompoundGraph(a),s(a),e.forEach(r(a),function(o,i){a.node(i).x=o})}function s(a){var o=n.buildLayerMatrix(a),i=a.graph().ranksep,u=0;e.forEach(o,function(c){var d=e.max(e.map(c,function(f){return a.node(f).height}));e.forEach(c,function(f){a.node(f).y=u+d/2}),u+=d+i})}return Di}var Mi,bh;function Ay(){if(bh)return Mi;bh=1;var e=be(),n=gy(),r=my(),t=yy(),s=Ce().normalizeRanks,a=xy(),o=Ce().removeEmptyRanks,i=by(),u=ky(),c=_y(),d=Ry(),f=Py(),p=Ce(),h=Ae().Graph;Mi=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(){te(R)}),M(" acyclic",function(){n.run(R)}),M(" nestingGraph.run",function(){i.run(R)}),M(" rank",function(){t(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(){D(R)}),M(" removeEdgeLabelProxies",function(){I(R)}),M(" normalize.run",function(){r.run(R)}),M(" parentDummyChains",function(){a(R)}),M(" addBorderSegments",function(){u(R)}),M(" order",function(){d(R)}),M(" insertSelfEdges",function(){re(R)}),M(" adjustCoordinateSystem",function(){c.adjust(R)}),M(" position",function(){f(R)}),M(" positionSelfEdges",function(){q(R)}),M(" removeBorderNodes",function(){V(R)}),M(" normalize.undo",function(){r.undo(R)}),M(" fixupEdgeLabelCoords",function(){W(R)}),M(" undoCoordinateSystem",function(){c.undo(R)}),M(" translateGraph",function(){P(R)}),M(" assignNodeIntersects",function(){F(R)}),M(" reversePoints",function(){K(R)}),M(" acyclic.undo",function(){n.undo(R)})}function v(R,M){e.forEach(R.nodes(),function(_){var B=R.node(_),$=M.node(_);B&&(B.x=$.x,B.y=$.y,M.children(_).length&&(B.width=$.width,B.height=$.height))}),e.forEach(R.edges(),function(_){var B=R.edge(_),$=M.edge(_);B.points=$.points,e.has($,"x")&&(B.x=$.x,B.y=$.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}),_=ie(R.graph());return M.setGraph(e.merge({},x,G(_,y),e.pick(_,b))),e.forEach(R.nodes(),function(B){var $=ie(R.node(B));M.setNode(B,e.defaults(G($,k),w)),M.setParent(B,R.parent(B))}),e.forEach(R.edges(),function(B){var $=ie(R.edge(B));M.setEdge(B,e.merge({},N,G($,j),e.pick($,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),$=R.node(M.w),X={rank:($.rank-B.rank)/2+B.rank,e:M};p.addDummyNode(R,"edge-proxy",X,"_ep")}})}function D(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 P(R){var M=Number.POSITIVE_INFINITY,_=0,B=Number.POSITIVE_INFINITY,$=0,X=R.graph(),U=X.marginx||0,le=X.marginy||0;function Q(ee){var he=ee.x,z=ee.y,Z=ee.width,H=ee.height;M=Math.min(M,he-Z/2),_=Math.max(_,he+Z/2),B=Math.min(B,z-H/2),$=Math.max($,z+H/2)}e.forEach(R.nodes(),function(ee){Q(R.node(ee))}),e.forEach(R.edges(),function(ee){var he=R.edge(ee);e.has(he,"x")&&Q(he)}),M-=U,B-=le,e.forEach(R.nodes(),function(ee){var he=R.node(ee);he.x-=M,he.y-=B}),e.forEach(R.edges(),function(ee){var he=R.edge(ee);e.forEach(he.points,function(z){z.x-=M,z.y-=B}),e.has(he,"x")&&(he.x-=M),e.has(he,"y")&&(he.y-=B)}),X.width=_-M+U,X.height=$-B+le}function F(R){e.forEach(R.edges(),function(M){var _=R.edge(M),B=R.node(M.v),$=R.node(M.w),X,U;_.points?(X=_.points[0],U=_.points[_.points.length-1]):(_.points=[],X=$,U=B),_.points.unshift(p.intersectRect(B,X)),_.points.push(p.intersectRect($,U))})}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 K(R){e.forEach(R.edges(),function(M){var _=R.edge(M);_.reversed&&_.points.reverse()})}function V(R){e.forEach(R.nodes(),function(M){if(R.children(M).length){var _=R.node(M),B=R.node(_.borderTop),$=R.node(_.borderBottom),X=R.node(e.last(_.borderLeft)),U=R.node(e.last(_.borderRight));_.width=Math.abs(U.x-X.x),_.height=Math.abs($.y-B.y),_.x=X.x+_.width/2,_.y=B.y+_.height/2}}),e.forEach(R.nodes(),function(M){R.node(M).dummy==="border"&&R.removeNode(M)})}function te(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 re(R){var M=p.buildLayerMatrix(R);e.forEach(M,function(_){var B=0;e.forEach(_,function($,X){var U=R.node($);U.order=X+B,e.forEach(U.selfEdges,function(le){p.addDummyNode(R,"selfedge",{width:le.label.width,height:le.label.height,rank:U.rank,order:X+ ++B,e:le.e,label:le.label},"_se")}),delete U.selfEdges})})}function q(R){e.forEach(R.nodes(),function(M){var _=R.node(M);if(_.dummy==="selfedge"){var B=R.node(_.e.v),$=B.x+B.width/2,X=B.y,U=_.x-$,le=B.height/2;R.setEdge(_.e,_.label),R.removeNode(M),_.label.points=[{x:$+2*U/3,y:X-le},{x:$+5*U/6,y:X-le},{x:$+U,y:X},{x:$+5*U/6,y:X+le},{x:$+2*U/3,y:X+le}],_.label.x=_.x,_.label.y=_.y}})}function G(R,M){return e.mapValues(e.pick(R,M),Number)}function ie(R){var M={};return e.forEach(R,function(_,B){M[B.toLowerCase()]=_}),M}return Mi}var Wi,kh;function Ly(){if(kh)return Wi;kh=1;var e=be(),n=Ce(),r=Ae().Graph;Wi={debugOrdering:t};function t(s){var a=n.buildLayerMatrix(s),o=new r({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,u){var c="layer"+u;o.setNode(c,{rank:"same"}),e.reduce(i,function(d,f){return o.setEdge(d,f,{style:"invis"}),f})}),o}return Wi}var Bi,_h;function qy(){return _h||(_h=1,Bi="0.8.5"),Bi}var Fi,Sh;function Dy(){return Sh||(Sh=1,Fi={graphlib:Ae(),layout:Ay(),debug:Ly(),util:{time:Ce().time,notime:Ce().notime},version:qy()}),Fi}var My=Dy();const wh=cg(My);function ar(e,n="TB"){if(e.data?._layoutWidth&&e.data?._layoutHeight)return{width:e.data._layoutWidth,height:e.data._layoutHeight};let r=240,t=80;switch(e.type){case"decisionNode":r=212,t=160;break;case"forkNode":r=240,t=95;break;case"joinNode":r=240,t=95;break;case"dynamicPlaceholderNode":r=220,t=70;break;case"loopNode":r=320,t=200;break;case"subWorkflowNode":r=240,t=95;break;case"eventNode":r=240,t=85;break;case"default":r=240,t=40;break;case"plusNode":r=e.data.label&&e.data.label!=="+"?120:32,t=32;break;default:r=240,t=95;break}return{width:r,height:t}}function Wy(e,n,r=8){const t=[];if(e.length<r)return t;const s=new Map,a={},o={};e.forEach(f=>{s.set(f.id,f),a[f.id]=[],o[f.id]=[]}),n.forEach(f=>{a[f.source]&&a[f.source].push(f.target),o[f.target]&&o[f.target].push(f.source)});const i=new Set,u=new Set(["input","output","decisionNode","forkNode","joinNode","loopNode","default","plusNode"]),c=f=>!u.has(f.type||""),d=[...e].sort((f,p)=>f.position.y-p.position.y);for(const f of d){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>=r&&(t.push(p),p.forEach(m=>i.add(m)))}return t}function By(e,n,r,t,s,a=5,o="view"){const i=n.find(x=>x.id===e[0]),{width:u,height:c}=ar(i||n[0],r),d=Math.max(.7,1-(e.length-10)/80),f=o==="edit"||o==="run"?1.15:1,p=Math.min(t,Math.round(60*d*f)),h=Math.min(s,Math.round(80*d*f)),g=u+p,m=c+h;let v=0,y=0;if(r==="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 $i=58,Th=20,Fy=16;function $y(e,n,r,t){if(e.length===0)return{positionedChildren:[],containerWidth:280,containerHeight:$i+50};const s=e.map(f=>({...f,parentId:void 0,extent:void 0})),{nodes:a}=zi(s,n,{direction:r,mode:t,enableSnakeLayout:!1});let o=0,i=0;a.forEach(f=>{const{width:p,height:h}=ar(f,r);o=Math.max(o,f.position.x+p),i=Math.max(i,f.position.y+h)});const u=Math.max(300,o+Th*2),c=$i+i+Fy;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+Th,y:f.position.y+$i}}}),containerWidth:u,containerHeight:c}}function zi(e,n,r={}){const{direction:t="TB",mode:s="view",enableSnakeLayout:a=!0,snakeColumns:o=5,snakeMinChainLength:i=8,snakeMinNodeCount:u=10}=r,c=e.length,d=e.filter(T=>T.type!=="plusNode").length;let f=t==="LR"?150:120,p=t==="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&&d>u?Wy(e,n,i):[],v={};m.forEach((T,C)=>{T.forEach(S=>{v[S]=C})});const y=new wh.graphlib.Graph;y.setDefaultEdgeLabel(()=>({})),y.setGraph({rankdir:t,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=By(m[C],e,t,g,h,o,s);b[C]=S,y.setNode(`__CHAIN_${C}`,{width:S.width,height:S.height})}}else{const{width:S,height:D}=ar(T,t);y.setNode(T.id,{width:S,height:D})}}),n.forEach(T=>{const C=v[T.source],S=v[T.target];let D=T.source,I=T.target;C!==void 0&&(D=`__CHAIN_${C}`),S!==void 0&&(I=`__CHAIN_${S}`),D!==I&&y.setEdge(D,I)}),wh.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:D,height:I}=ar(S,t);S.position={x:C.x-D/2,y:C.y-I/2},S.data={...S.data,sourcePosition:void 0,targetPosition:void 0},S.sourcePosition=t==="LR"?A.Position.Right:A.Position.Bottom,S.targetPosition=t==="LR"?A.Position.Left:A.Position.Top,w.push(S)}else j.add(T.id)}),m.forEach((T,C)=>{const S=`__CHAIN_${C}`,D=y.node(S),I=b[C],P=D.x-I.width/2+20,F=D.y-I.height/2+20,W=I.cols,K=I.gridKW,V=I.gridKH;T.forEach((te,re)=>{const q=k[te];let G=0,ie=0,R,M;if(t==="TB"){const _=Math.floor(re/W),B=re%W,$=_%2===0,X=Math.ceil(T.length/W),U=_===X-1,le=T.length%W||W,Q=U?(W-le)*K/2:0;let ee;$?ee=B*K+Q:ee=(W-1-B)*K-Q;const he=_*V;G=P+ee,ie=F+he;const z=U?le:W;$?(M=A.Position.Left,R=A.Position.Right,B===z-1&&re!==T.length-1&&(R=A.Position.Bottom),B===0&&re!==0&&(M=A.Position.Top)):(M=A.Position.Right,R=A.Position.Left,B===z-1&&re!==T.length-1&&(R=A.Position.Bottom),B===0&&re!==0&&(M=A.Position.Top)),re===0&&(M=A.Position.Top),re===T.length-1&&(R=A.Position.Bottom)}else{const _=Math.floor(re/W),B=re%W,$=_%2===0,X=Math.ceil(T.length/W),U=_===X-1,le=T.length%W||W,Q=U?Math.max(0,(W-le)*V)/2:0,ee=_*K;let he;$?he=B*V+Q:he=(W-1-B)*V-Q,G=P+ee,ie=F+he;const z=U?le:W;$?(M=A.Position.Top,R=A.Position.Bottom,B===z-1&&re!==T.length-1&&(R=A.Position.Right),B===0&&re!==0&&(M=A.Position.Left)):(M=A.Position.Bottom,R=A.Position.Top,B===z-1&&re!==T.length-1&&(R=A.Position.Right),B===0&&re!==0&&(M=A.Position.Left)),re===0&&(M=A.Position.Left),re===T.length-1&&(R=A.Position.Right)}q.position={x:G,y:ie},q.data={...q.data,sourcePosition:R,targetPosition:M},q.sourcePosition=R,q.targetPosition=M,w.push(q)})});const N=w.reduce((T,C)=>({...T,[C.id]:C}),{}),L=n.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:D,height:I}=ar(C,t),{width:P,height:F}=ar(S,t),W={x:C.position.x+D/2,y:C.position.y+I/2},K={x:S.position.x+P/2,y:S.position.y+F/2};let V=null;if(t==="TB"){const te=D*.25;K.x<W.x-te?V="left":K.x>W.x+te&&(V="right")}else{const te=I*.25;K.y<W.y-te?V="top":K.y>W.y+te&&(V="bottom")}return{...T,sourceHandle:V}});return{nodes:w,edges:L}}function Se(e,n,r={}){const t=r.direction||"TB",s=r.mode||"view",a=e.filter(y=>y.parentId),o=e.filter(y=>!y.parentId);if(a.length===0)return zi(e,n,r);const i=new Map(a.map(y=>[y.id,y])),u={},c=[];n.forEach(y=>{const x=i.get(y.source),b=i.get(y.target);if(x?.parentId&&x.parentId===b?.parentId){const k=x.parentId;u[k]||(u[k]=[]),u[k].push(y)}else c.push(y)});const d={};a.forEach(y=>{const x=y.parentId;d[x]||(d[x]=[]),d[x].push(y)});const f={},p=[];for(const[y,x]of Object.entries(d)){const b=u[y]||[],{positionedChildren:k,containerWidth:w,containerHeight:j}=$y(x,b,t,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}=zi(h,c,r);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(u).flat()]}}function je(e,n){if(!e)return null;for(const r of e){if(r.taskReferenceName===n)return r;if(r.decisionCases){for(const s of Object.keys(r.decisionCases)){const a=je(r.decisionCases[s],n);if(a)return a}const t=je(r.defaultCase,n);if(t)return t}if(r.forkTasks)for(const t of r.forkTasks){const s=je(t,n);if(s)return s}if(r.loopOver){const t=je(r.loopOver,n);if(t)return t}}return null}function We(e,n){if(!e)return!1;const r=e.findIndex(t=>t.taskReferenceName===n);if(r!==-1)return e.splice(r,1),!0;for(const t of e){if(t.decisionCases){for(const s of Object.keys(t.decisionCases))if(We(t.decisionCases[s],n))return!0;if(We(t.defaultCase,n))return!0}if(t.forkTasks){for(const s of t.forkTasks)if(We(s,n))return!0}if(t.loopOver&&We(t.loopOver,n))return!0}return!1}function sr(e,n){if(!e)return null;if(e.some(r=>r.taskReferenceName===n))return e;for(const r of e){if(r.decisionCases){for(const s of Object.values(r.decisionCases)){const a=sr(s,n);if(a)return a}const t=sr(r.defaultCase,n);if(t)return t}if(r.forkTasks)for(const t of r.forkTasks){const s=sr(t,n);if(s)return s}if(r.loopOver){const t=sr(r.loopOver,n);if(t)return t}}return null}function Eh(e,n){const r=e.findIndex(t=>t.taskReferenceName===n);if(r<0)return null;for(let t=r+1;t<e.length;t++)if(e[t].type==="JOIN"||e[t].type==="EXCLUSIVE_JOIN")return e[t].taskReferenceName;return null}function Nh(e,n){const r=e.findIndex(t=>t.taskReferenceName===n);if(r<0)return null;for(let t=r-1;t>=0;t--)if(e[t].type==="FORK_JOIN"||e[t].type==="FORK_JOIN_DYNAMIC")return e[t].taskReferenceName;return null}function Le(e,n,r){if(!e)return!1;if(n==="start")return e.unshift(r),!0;const t=e.findIndex(s=>s.taskReferenceName===n);if(t!==-1)return e.splice(t+1,0,r),!0;for(const s of e){if(s.decisionCases){for(const a of Object.keys(s.decisionCases))if(Le(s.decisionCases[a],n,r))return!0;if(Le(s.defaultCase,n,r))return!0}if(s.forkTasks){for(const a of s.forkTasks)if(Le(a,n,r))return!0}if(s.loopOver&&Le(s.loopOver,n,r))return!0}return!1}function or(e,n,r,t){for(const s of e||[]){if(s.taskReferenceName===n){if(r.branchCase==="default")return s.defaultCase||(s.defaultCase=[]),s.defaultCase.unshift(t),!0;if(r.branchCase!==void 0)return s.decisionCases||(s.decisionCases={}),s.decisionCases[r.branchCase]||(s.decisionCases[r.branchCase]=[]),s.decisionCases[r.branchCase].unshift(t),!0;if(r.forkIndex!==void 0)return s.forkTasks||(s.forkTasks=[]),s.forkTasks[r.forkIndex].unshift(t),!0;if(r.isLoopAdd)return s.loopOver||(s.loopOver=[]),s.loopOver.unshift(t),!0}if(s.decisionCases){for(const a of Object.keys(s.decisionCases))if(or(s.decisionCases[a],n,r,t))return!0;if(or(s.defaultCase,n,r,t))return!0}if(s.forkTasks){for(const a of s.forkTasks)if(or(a,n,r,t))return!0}if(s.loopOver&&or(s.loopOver,n,r,t))return!0}return!1}function Ee(e){if(e)for(let n=0;n<e.length;n++){const r=e[n];if(r.type==="FORK_JOIN"&&n+1<e.length){const t=e[n+1];if(t.type==="JOIN"){const s=[];(r.forkTasks||[]).forEach(a=>{a&&a.length>0&&s.push(a[a.length-1].taskReferenceName)}),t.joinOn=s}}r.decisionCases&&(Object.values(r.decisionCases).forEach(t=>Ee(t)),r.defaultCase&&Ee(r.defaultCase)),r.forkTasks&&r.forkTasks.forEach(t=>Ee(t)),r.loopOver&&Ee(r.loopOver)}}const zy=[{field:"name",type:"required",message:"工作流名称 (name) 必填"},{field:"version",type:"required",message:"工作流版本 (version) 必填"},{field:"tasks",type:"min_length",value:1,message:"工作流必须包含至少一个任务"}],Ch={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,n)=>!!(n?.inputParameters?.expression||n?.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,n)=>!!n?.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,n)=>!!(n?.loopCondition||n?.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 n=Object.keys(e||{});return new Set(n).size===n.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,n)=>!!(n?.dynamicForkTasksParam||n?.forkTaskType||n?.forkTaskWorkflow),message:"FORK_JOIN_DYNAMIC 任务需要配置 dynamicForkTasksParam 或 forkTaskType 或 forkTaskWorkflow",level:"warning"}]}};class Hy{rules=[];setRules(n){this.rules=[...n]}getRules(){return this.rules}hasRules(){return this.rules.length>0}runAll(n){const r=[],t=[];for(const s of this.rules)try{const a=s.validate(n);for(const o of a)s.level==="warning"?t.push(o):r.push(o)}catch{r.push({type:"GLOBAL",ref:"",message:`自定义规则 "${s.id}" 执行异常`})}return{errors:r,warnings:t}}buildPromptSection(){return this.rules.length===0?null:`## 业务校验规则(必须遵守)
|
|
7
|
+
以下规则由集成方定义,生成工作流时必须满足:
|
|
8
|
+
${this.rules.map(r=>`- ${r.description}`).join(`
|
|
9
|
+
`)}`}}const jh=new Hy,Ky=(e,n)=>n.split(".").reduce((r,t)=>r&&r[t]!==void 0?r[t]:void 0,e),Hi=(e,n,r,t)=>{const{errors:s,warnings:a}=t,o=e.taskReferenceName||"GLOBAL";n.forEach(i=>{const u=Ky(e,i.field);let c=!0;switch(i.type){case"required":c=u!=null&&u!=="";break;case"min_length":c=Array.isArray(u)&&u.length>=i.value;break;case"pattern":c=i.value.test(u);break;case"enum":c=i.value.includes(u);break;case"unique":i.field==="taskReferenceName"&&u&&(r.taskRefs.has(u)?c=!1:r.taskRefs.add(u));break;case"custom":typeof i.validate=="function"&&(c=i.validate(u,e,r));break}if(!c){const d={type:e.taskReferenceName?"TASK":"GLOBAL",ref:o,message:i.message};i.level==="warning"?a.push(d):s.push(d)}})},Oe=e=>{const n=[],r=[],t={taskRefs:new Set,taskMap:{}};if(!e)return{isValid:!1,errors:[{type:"GLOBAL",ref:"",message:"工作流定义为空"}],warnings:[]};if(Hi(e,zy,t,{errors:n,warnings:r}),!e.tasks||e.tasks.length===0)return{isValid:!1,errors:n,warnings:r};const s=o=>{o.forEach(i=>{Hi(i,Ch.common,t,{errors:n,warnings:r});const u=Ch.types[i.type];u&&Hi(i,u,t,{errors:n,warnings:r}),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=Uy(e.tasks);if(n.push(...a),jh.hasRules()){const o=jh.runAll(e);n.push(...o.errors),r.push(...o.warnings)}return{isValid:n.length===0,errors:n,warnings:r}},Uy=e=>{const n=[],r=new Map,t=new Set,s=d=>{for(let f=0;f<d.length;f++){const p=d[f],h=p.taskReferenceName;if(t.add(h),r.has(h)||r.set(h,[]),f<d.length-1){const g=d[f+1].taskReferenceName;p.type!=="FORK_JOIN"&&p.type!=="FORK_JOIN_DYNAMIC"&&r.get(h).push(g)}if(p.decisionCases)for(const g of Object.values(p.decisionCases))g.length>0&&(r.get(h).push(g[0].taskReferenceName),s(g));if(p.defaultCase&&p.defaultCase.length>0&&(r.get(h).push(p.defaultCase[0].taskReferenceName),s(p.defaultCase)),p.forkTasks)for(const g of p.forkTasks)g.length>0&&(r.get(h).push(g[0].taskReferenceName),s(g));if(p.loopOver)for(const g of p.loopOver)t.add(g.taskReferenceName);if(p.joinOn)for(const g of p.joinOn)r.has(g)||r.set(g,[]),r.get(g).push(h)}};s(e);const a=0,o=1,i=2,u=new Map;for(const d of t)u.set(d,a);const c=d=>{u.set(d,o);const f=r.get(d)||[];for(const p of f)if(u.has(p)){if(u.get(p)===o)return n.push({type:"GLOBAL",ref:p,message:`检测到环路:任务 "${d}" → "${p}" 形成了循环依赖`}),!0;if(u.get(p)===a&&c(p))return!0}return u.set(d,i),!1};for(const d of t)u.get(d)===a&&c(d);return n};function Jy(e,n){const r=new Set(e),t={};e.forEach(i=>t[i]=0),n.forEach(i=>{r.has(i.source)&&r.has(i.target)&&(t[i.target]=(t[i.target]??0)+1)});const s=[];let a=e.filter(i=>t[i]===0);const o={...t};for(;a.length>0;){s.push([...a]);const i=[];a.forEach(u=>{n.forEach(c=>{c.source===u&&r.has(c.target)&&(o[c.target]--,o[c.target]===0&&i.push(c.target))})}),a=i}return s}const oe=rt()(rl(gg((e,n)=>({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,setWorkflow:(r,t)=>{const s=t||n().layoutDirection,a=JSON.parse(JSON.stringify(r));Ee(a.tasks);const{nodes:o,edges:i,taskMap:u}=Te(a,s,{hideEmptyBranches:n().mode!=="edit"}),{nodes:c,edges:d}=Se(o,i,{direction:s,mode:n().mode}),f=Oe(a);e({workflowDef:a,nodes:c,edges:d,taskMap:u,validationResults:f,layoutDirection:s,workflowLoadKey:n().workflowLoadKey+1})},setMode:r=>{n().mode==="run"&&r!=="run"&&e({executionData:null,workflowInstance:null,dynamicRuntimeTasksByFork:{}}),e({mode:r});const{workflowDef:s,layoutDirection:a}=n();if(s){const{nodes:o,edges:i,taskMap:u}=Te(s,a,{hideEmptyBranches:r!=="edit"}),{nodes:c,edges:d}=Se(o,i,{direction:a,mode:r});e({nodes:c,edges:d,taskMap:u})}},setExecutionData:r=>e({executionData:r,dynamicRuntimeTasksByFork:r===null?{}:n().dynamicRuntimeTasksByFork}),updateTaskStatus:(r,t)=>{const{executionData:s}=n();if(!s)return;const a={...s};a[r]&&(a[r]={...a[r],status:t},e({executionData:a}))},loadSampleExecution:async()=>{try{const t=await(await fetch("/sample-workflows/sample-execution.json")).json();n().importExecutionJSON(t)}catch(r){console.error("Failed to load sample execution:",r),alert("加载示例运行数据失败")}},importExecutionJSON:r=>{if(!r)return;let t=[],s=null,a=n().workflowDef;if(Array.isArray(r.tasks)?(t=r.tasks,r.workflowId&&r.status&&(s=r,r.workflowDefinition&&(a=r.workflowDefinition))):Array.isArray(r)&&(t=r),t.length===0)return;const o={};t.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(n().workflowDef)&&n().setWorkflow(a);const i=n().taskMap,c=n().workflowDef?.tasks||[],d=[];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"){d.push({forkRef:p.taskReferenceName,joinRef:c[g].taskReferenceName});break}}});const f={};d.forEach(({forkRef:p,joinRef:h})=>{const g=t.findIndex(y=>y.referenceTaskName===p),m=t.findIndex(y=>y.referenceTaskName===h);if(g<0||m<0)return;const v=new Set;f[p]=t.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:r=>e({selectedTask:r?{...r}:null}),setIsDetailPanelOpen:r=>e({isDetailPanelOpen:r}),selectTaskAction:(r,t=!0)=>{e({selectedTask:r?{...r}:null,isDetailPanelOpen:r?t:!1,selectedTaskInstance:null})},setSelectedTaskInstance:r=>e({selectedTaskInstance:r}),setLayoutDirection:r=>{const{workflowDef:t}=n();if(t){const{nodes:s,edges:a,taskMap:o}=Te(t,r,{hideEmptyBranches:n().mode!=="edit"}),{nodes:i,edges:u}=Se(s,a,{direction:r,mode:n().mode});e({nodes:i,edges:u,taskMap:o,layoutDirection:r})}else e({layoutDirection:r})},onNodesChange:r=>{const t=n().nodes,s=new Set(t.map(o=>o.id)),a=r.filter(o=>"id"in o&&s.has(o.id));a.length!==0&&e({nodes:A.applyNodeChanges(a,t)})},onEdgesChange:r=>{const t=n().edges,s=A.applyEdgeChanges(r,t);s!==t&&e({edges:s})},onConnect:r=>{const{edges:t,layoutDirection:s}=n(),a=A.addEdge(r,t),{nodes:o,edges:i}=Se(n().nodes,a,{direction:s,mode:n().mode});e({edges:i,nodes:o})},checkTaskRefUniqueness:(r,t)=>{if(r===t)return!0;const{taskMap:s}=n();return!s[r]},updateTask:(r,t,s)=>{const{workflowDef:a,layoutDirection:o}=n();if(!a)return;const i=JSON.parse(JSON.stringify(a)),u=je(i.tasks,r);if(u){typeof t=="object"?Object.assign(u,t):u[t]=s,Ee(i.tasks);const{nodes:c,edges:d,taskMap:f}=Te(i,o,{hideEmptyBranches:n().mode!=="edit"}),{nodes:p,edges:h}=Se(c,d,{direction:o,mode:n().mode}),g=Oe(i);e({workflowDef:i,nodes:p,edges:h,taskMap:f,validationResults:g})}},updateWorkflowProperties:r=>{const{workflowDef:t,layoutDirection:s}=n();if(!t)return;const a=JSON.parse(JSON.stringify(t));Object.assign(a,r),Ee(a.tasks);const{nodes:o,edges:i,taskMap:u}=Te(a,s,{hideEmptyBranches:n().mode!=="edit"}),{nodes:c,edges:d}=Se(o,i,{direction:s,mode:n().mode}),f=Oe(a);e({workflowDef:a,nodes:c,edges:d,taskMap:u,validationResults:f})},addNode:(r,t,s,a,o={})=>{const{workflowDef:i,layoutDirection:u}=n();if(!i)return;const c=JSON.parse(JSON.stringify(i)),d={name:r.data.label,taskReferenceName:r.data.taskReferenceName,type:r.data.taskType||"SIMPLE",inputParameters:{}};switch(d.type){case"HTTP":d.httpRequest={method:"GET",uri:"https://example.com/api",headers:{"Content-Type":"application/json"},body:{}};break;case"KAFKA_PUBLISH":d.inputParameters={topic:"my_topic",value:"${workflow.input.value}",bootStrapServers:"localhost:9092",headers:{},key:"msg_key"};break;case"JSON_JQ_TRANSFORM":d.inputParameters={queryExpression:".name",input:{}};break;case"SET_VARIABLE":d.inputParameters={variableName:"variableValue"};break;case"SUB_WORKFLOW":d.subWorkflowParam={name:"execution_workflow",version:1};break;case"EVENT":d.sink="conductor";break;case"WAIT":d.inputParameters={duration:"30s"};break;case"TERMINATE":d.inputParameters={terminationStatus:"COMPLETED",workflowOutput:{}};break}if(d.type==="FORK_JOIN"||d.type==="FORK_JOIN_DYNAMIC"){d.type==="FORK_JOIN"?d.forkTasks=[[],[]]:(d.dynamicForkTasksParam="dynamic_tasks",d.dynamicForkTasksInputParamName="input");const y={name:`${d.name}_join`,taskReferenceName:`${d.taskReferenceName}_join`,type:"JOIN",joinOn:[]};if(o.isWorkflowStart)c.tasks.unshift(y),c.tasks.unshift(d);else if(o.isLoopBodyStart){const x=je(c.tasks,t);x&&(x.loopOver||(x.loopOver=[]),x.loopOver.unshift(y),x.loopOver.unshift(d))}else o.branchCase!==void 0||o.forkIndex!==void 0||o.isLoopAdd?(or(c.tasks,t,o,d),Le(c.tasks,d.taskReferenceName,y)):c.tasks.length===0?c.tasks.push(d,y):(Le(c.tasks,t,d),Le(c.tasks,d.taskReferenceName,y))}else if(d.type==="DECISION"||d.type==="SWITCH"?(d.evaluatorType="value-param",d.caseValueParam="case_param",d.decisionCases={case1:[]},d.defaultCase=[]):d.type==="DO_WHILE"?(d.loopCondition="$.taskReferenceName.output.value < 10",d.loopOver=[]):d.type==="INLINE"?(d.evaluatorType="graaljs",d.inputParameters={expression:`function execute(input) {
|
|
7
10
|
return { result: input };
|
|
8
11
|
}
|
|
9
|
-
execute($.input);`}):c.type==="DYNAMIC"?(c.dynamicTaskNameParam="taskToExecute",c.inputParameters={taskToExecute:"${workflow.input.taskName}"}):c.type==="HUMAN"?c.humanTaskDef={userFormTemplate:"",assignmentCompletionStrategy:"LEAVE_OPEN"}:c.type==="START_WORKFLOW"?c.inputParameters={startWorkflow:{name:"",version:1,input:{},correlationId:""}}:c.type==="NOOP"&&(c.inputParameters={}),i.isWorkflowStart)u.tasks.unshift(c);else if(i.isLoopBodyStart){const x=we(u.tasks,n);x&&(x.loopOver||(x.loopOver=[]),x.loopOver.unshift(c))}else i.branchCase!==void 0||i.forkIndex!==void 0||i.isLoopAdd?or(u.tasks,n,i,c):u.tasks.length===0?u.tasks.push(c):Oe(u.tasks,n,c);ke(u.tasks);const{nodes:f,edges:p,taskMap:h}=_e(u,l,{hideEmptyBranches:r().mode!=="edit"}),{nodes:g,edges:v}=be(f,p,{direction:l,mode:r().mode}),m=Ne(u);e({workflowDef:u,nodes:g,edges:v,taskMap:h,validationResults:m})},removeNode:t=>{const{workflowDef:n,layoutDirection:o,nodes:a}=r();if(!n)return;const i=JSON.parse(JSON.stringify(n)),s=ar(i.tasks,t);if(s){const g=a.find(v=>v.id===t)?.data?.taskType;if(g==="FORK_JOIN"||g==="FORK_JOIN_DYNAMIC"){const v=yh(s,t);v&&qe(i.tasks,v)}else if(g==="JOIN"||g==="EXCLUSIVE_JOIN"){const v=xh(s,t);v&&qe(i.tasks,v)}}qe(i.tasks,t),ke(i.tasks);const{nodes:l,edges:u,taskMap:c}=_e(i,o,{hideEmptyBranches:r().mode!=="edit"}),{nodes:f,edges:p}=be(l,u,{direction:o,mode:r().mode}),h=Ne(i);e({workflowDef:i,nodes:f,edges:p,taskMap:c,validationResults:h})},addLoopTask:(t,n)=>{const{workflowDef:o,layoutDirection:a}=r();if(!o)return;const i=JSON.parse(JSON.stringify(o)),s=we(i.tasks,t);if(s&&s.type==="DO_WHILE"){s.loopOver||(s.loopOver=[]);const l={name:`new_${n.toLowerCase()}`,taskReferenceName:`${t}_sub_${Date.now()}`,type:n,inputParameters:{}};s.loopOver.push(l),ke(i.tasks);const{nodes:u,edges:c,taskMap:f}=_e(i,a,{hideEmptyBranches:r().mode!=="edit"}),{nodes:p,edges:h}=be(u,c,{direction:a,mode:r().mode}),g=Ne(i);e({workflowDef:i,nodes:p,edges:h,taskMap:f,validationResults:g})}},removeLoopTask:(t,n)=>{const{workflowDef:o,layoutDirection:a}=r();if(!o)return;const i=JSON.parse(JSON.stringify(o)),s=we(i.tasks,t);if(s&&s.type==="DO_WHILE"&&s.loopOver){const l=ar(s.loopOver,n);if(l){const v=l.find(m=>m.taskReferenceName===n);if(v?.type==="FORK_JOIN"||v?.type==="FORK_JOIN_DYNAMIC"){const m=yh(l,n);m&&qe(s.loopOver,m)}else if(v?.type==="JOIN"||v?.type==="EXCLUSIVE_JOIN"){const m=xh(l,n);m&&qe(s.loopOver,m)}}qe(s.loopOver,n),ke(i.tasks);const{nodes:u,edges:c,taskMap:f}=_e(i,a,{hideEmptyBranches:r().mode!=="edit"}),{nodes:p,edges:h}=be(u,c,{direction:a,mode:r().mode}),g=Ne(i);e({workflowDef:i,nodes:p,edges:h,taskMap:f,validationResults:g})}},addDecisionBranch:(t,n)=>{const{workflowDef:o,layoutDirection:a}=r();if(!o)return;const i=JSON.parse(JSON.stringify(o)),s=we(i.tasks,t);if(s&&(s.type==="DECISION"||s.type==="SWITCH")){n==="default"?s.defaultCase||(s.defaultCase=[]):(s.decisionCases||(s.decisionCases={}),s.decisionCases[n]||(s.decisionCases[n]=[])),ke(i.tasks);const{nodes:l,edges:u,taskMap:c}=_e(i,a,{hideEmptyBranches:r().mode!=="edit"}),{nodes:f,edges:p}=be(l,u,{direction:a,mode:r().mode}),h=Ne(i);e({workflowDef:i,nodes:f,edges:p,taskMap:c,validationResults:h})}},removeDecisionBranch:(t,n)=>{const{workflowDef:o,layoutDirection:a}=r();if(!o)return;const i=JSON.parse(JSON.stringify(o)),s=we(i.tasks,t);if(s&&(s.type==="DECISION"||s.type==="SWITCH")){n==="default"?s.defaultCase=[]:s.decisionCases&&delete s.decisionCases[n],ke(i.tasks);const{nodes:l,edges:u,taskMap:c}=_e(i,a,{hideEmptyBranches:r().mode!=="edit"}),{nodes:f,edges:p}=be(l,u,{direction:a,mode:r().mode}),h=Ne(i);e({workflowDef:i,nodes:f,edges:p,taskMap:c,validationResults:h})}},renameDecisionBranch:(t,n,o)=>{const{workflowDef:a,layoutDirection:i}=r();if(!a||!o.trim()||n===o)return;const s=JSON.parse(JSON.stringify(a)),l=we(s.tasks,t);if(l&&(l.type==="DECISION"||l.type==="SWITCH")){if(!l.decisionCases||!l.decisionCases[n])return;l.decisionCases[o.trim()]=l.decisionCases[n],delete l.decisionCases[n],ke(s.tasks);const{nodes:u,edges:c,taskMap:f}=_e(s,i,{hideEmptyBranches:r().mode!=="edit"}),{nodes:p,edges:h}=be(u,c,{direction:i,mode:r().mode}),g=Ne(s);e({workflowDef:s,nodes:p,edges:h,taskMap:f,validationResults:g})}},addForkBranch:t=>{const{workflowDef:n,layoutDirection:o}=r();if(!n)return;const a=JSON.parse(JSON.stringify(n)),i=we(a.tasks,t);if(i&&i.type==="FORK_JOIN"){i.forkTasks||(i.forkTasks=[]),i.forkTasks.push([]),ke(a.tasks);const{nodes:s,edges:l,taskMap:u}=_e(a,o,{hideEmptyBranches:r().mode!=="edit"}),{nodes:c,edges:f}=be(s,l,{direction:o,mode:r().mode}),p=Ne(a);e({workflowDef:a,nodes:c,edges:f,taskMap:u,validationResults:p})}},copyTask:t=>e({copiedTask:t}),pasteTask:t=>{const{workflowDef:n,layoutDirection:o,selectedTask:a}=r();if(!n)return;const i=JSON.parse(JSON.stringify(n)),l=`_copy_${Date.now()}`,u=JSON.parse(JSON.stringify(t)),c=y=>{y.taskReferenceName=`${y.taskReferenceName}${l}`,y.decisionCases&&Object.values(y.decisionCases).forEach(b=>b.forEach(c)),y.defaultCase&&y.defaultCase.forEach(c),y.forkTasks&&y.forkTasks.forEach(b=>b.forEach(c)),y.loopOver&&y.loopOver.forEach(c)};c(u);const f=a?a.taskReferenceName:i.tasks.length>0?i.tasks[i.tasks.length-1].taskReferenceName:"start";if(u.type==="FORK_JOIN"){u.forkTasks||(u.forkTasks=[[],[]]);const y={name:`${u.name}_join`,taskReferenceName:`${u.taskReferenceName}_join`,type:"JOIN",joinOn:[]};i.tasks.length===0?i.tasks.push(u,y):(Oe(i.tasks,f,u),Oe(i.tasks,u.taskReferenceName,y))}else i.tasks.length===0?i.tasks.push(u):Oe(i.tasks,f,u);ke(i.tasks);const{nodes:p,edges:h,taskMap:g}=_e(i,o,{hideEmptyBranches:r().mode!=="edit"}),{nodes:v,edges:m}=be(p,h,{direction:o,mode:r().mode}),x=Ne(i);e({workflowDef:i,nodes:v,edges:m,taskMap:g,validationResults:x})},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:o}=r();if(o)return;const a=n.filter(f=>!["plusNode","dynamicPlaceholderNode"].includes(f.type??"")).map(f=>f.id),i=t.map(f=>({source:f.source,target:f.target})),s=Ay(a,i);e({isSimRunning:!0,simState:{}});const l={timer:null};r().__simHandle=l;let u=0;const c=()=>{if(u>=s.length||!r().isSimRunning){e({isSimRunning:!1});return}const f=s[u];e(p=>{const h={...p.simState};return f.forEach(g=>h[g]="running"),{simState:h}}),l.timer=setTimeout(()=>{r().isSimRunning&&(e(p=>{const h={...p.simState};return f.forEach(g=>h[g]="done"),{simState:h}}),u++,l.timer=setTimeout(c,280))},700)};c()},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,...o}=t,a={...o,name:t.name||"AI_Generated_Workflow",tasks:n||[],version:t.version||1,schemaVersion:2};r().setWorkflow(a)}}),{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:Js(()=>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 qy=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Ly=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(r,t,n)=>n?n.toUpperCase():t.toLowerCase()),kh=e=>{const r=Ly(e);return r.charAt(0).toUpperCase()+r.slice(1)},_h=(...e)=>e.filter((r,t,n)=>!!r&&r.trim()!==""&&n.indexOf(r)===t).join(" ").trim(),Dy=e=>{for(const r in e)if(r.startsWith("aria-")||r==="role"||r==="title")return!0};var My={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 Wy=q.forwardRef(({color:e="currentColor",size:r=24,strokeWidth:t=2,absoluteStrokeWidth:n,className:o="",children:a,iconNode:i,...s},l)=>q.createElement("svg",{ref:l,...My,width:r,height:r,stroke:e,strokeWidth:n?Number(t)*24/Number(r):t,className:_h("lucide",o),...!a&&!Dy(s)&&{"aria-hidden":"true"},...s},[...i.map(([u,c])=>q.createElement(u,c)),...Array.isArray(a)?a:[a]]));const xe=(e,r)=>{const t=q.forwardRef(({className:n,...o},a)=>q.createElement(Wy,{ref:a,iconNode:r,className:_h(`lucide-${qy(kh(e))}`,`lucide-${e}`,n),...o}));return t.displayName=kh(e),t};const Sh=xe("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 By=xe("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 Fy=xe("clock",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const wh=xe("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 zy=xe("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 Hr=xe("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 Kr=xe("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 $y=xe("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 Hy=xe("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 Ky=xe("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);const Uy=xe("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 Jy=xe("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const Th=xe("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 Ms=xe("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 Gy=xe("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);const Vy=xe("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 Yy=xe("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"}]]),Xy={business:["business"],standard:["business","control"],developer:["business","control","data"]},Ge=[{type:"SIMPLE",label:"任务节点 (Worker)",description:"在远程 Worker 上执行的任务",category:"CORE",icon:Sh,viewCategory:"business"},{type:"SUB_WORKFLOW",label:"子工作流 (Sub Workflow)",description:"调用并执行另一个工作流",category:"CORE",icon:Kr,viewCategory:"business"},{type:"START_WORKFLOW",label:"启动工作流 (Start Workflow)",description:"启动另一个工作流(不等待结果)",category:"SYSTEM",icon:Uy,viewCategory:"business"},{type:"HTTP",label:"HTTP 请求",description:"发起 REST/HTTP 调用",category:"SYSTEM",icon:$y,viewCategory:"business"},{type:"INLINE",label:"内联脚本 (Inline)",description:"执行内联脚本(JS/Python/GraalJS)",category:"SYSTEM",icon:wh,viewCategory:"data"},{type:"JSON_JQ_TRANSFORM",label:"JSON 转换 (JQ)",description:"使用 JQ 表达式转换 JSON 数据",category:"SYSTEM",icon:Gy,viewCategory:"data"},{type:"KAFKA_PUBLISH",label:"Kafka 推送",description:"向 Kafka 主题推送消息",category:"SYSTEM",icon:Hy,viewCategory:"data"},{type:"EVENT",label:"事件 (Event)",description:"向外部队列系统发布事件",category:"SYSTEM",icon:Yy,viewCategory:"data"},{type:"WAIT",label:"等待 (Wait)",description:"暂停流程,直到特定时间或时长",category:"SYSTEM",icon:Fy,viewCategory:"control"},{type:"SET_VARIABLE",label:"设置变量 (Set Variable)",description:"设置工作流上下文变量",category:"SYSTEM",icon:zy,viewCategory:"data"},{type:"TERMINATE",label:"终止 (Terminate)",description:"提前结束工作流执行",category:"SYSTEM",icon:By,viewCategory:"control"},{type:"HUMAN",label:"人工审批 (Human)",description:"等待人工审核或表单提交",category:"SYSTEM",icon:Vy,viewCategory:"business"},{type:"DYNAMIC",label:"动态任务 (Dynamic)",description:"运行时动态决定任务类型",category:"SYSTEM",icon:Ms,viewCategory:"data"},{type:"NOOP",label:"空操作 (Noop)",description:"占位符任务,无实际操作",category:"SYSTEM",icon:Ky,viewCategory:"data"},{type:"LAMBDA",label:"Lambda 脚本 (旧)",description:"已被 INLINE 取代",category:"SYSTEM",icon:wh,hidden:!0,viewCategory:"data"},{type:"SWITCH",label:"条件分支 (Switch)",description:"基于条件的逻辑分支 (Switch/Case)",category:"FLOW",icon:Ms,viewCategory:"control"},{type:"DECISION",label:"判断 (Decision,旧)",description:"基于条件的逻辑分支(旧版,推荐改用 Switch)",category:"FLOW",icon:Ms,hidden:!0,viewCategory:"control"},{type:"FORK_JOIN",label:"静态并行 (Fork)",description:"并行执行多个预定义任务分支",category:"FLOW",icon:Hr,viewCategory:"control"},{type:"FORK_JOIN_DYNAMIC",label:"动态并行 (Dynamic Fork)",description:"运行时动态生成并行分支",category:"FLOW",icon:Hr,viewCategory:"control"},{type:"DO_WHILE",label:"循环 (Do-While)",description:"循环执行直到满足条件",category:"FLOW",icon:Th,viewCategory:"control"},{type:"JOIN",label:"汇聚 (Join)",description:"等待所有并行分支执行完成",category:"FLOW",icon:Kr,viewCategory:"control"}],Zy=[{key:"CORE",label:"基础任务"},{key:"FLOW",label:"逻辑控制"},{key:"SYSTEM",label:"系统集成"}],Ur=({message:e,onConfirm:r,onCancel:t})=>{const n=q.useRef(null),{theme:o,themeColor:a}=oe();return q.useEffect(()=>{n.current?.focus({preventScroll:!0});const i=s=>{s.key==="Escape"&&t()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[t]),Gr.createPortal(d.jsx("div",{"data-mode":o,"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:d.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:[d.jsx("div",{style:{fontSize:"14px",color:"var(--text-primary)",marginBottom:"24px",lineHeight:"1.6"},children:e}),d.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"10px"},children:[d.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:"取消"}),d.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)},yr=({children:e,nodeId:r,selected:t=!1,isStartOrEnd:n=!1,isError:o=!1,hasWarning:a=!1,isDecision:i=!1,isHighlighted:s=!1,executionStatus:l,simRunning:u=!1,simDone:c=!1})=>{const{mode:f,removeNode:p}=oe(),[h,g]=q.useState(!1),v=k=>{k.stopPropagation(),g(!0)},m=f==="edit"&&!n,y=[i?"decision-node-wrapper":"node-wrapper-glass",t?"node-wrapper-selected":"",s?"node-wrapper-highlighted":"",u?"node-sim-running":"",c?"node-sim-done":""].filter(Boolean).join(" "),b=q.useMemo(()=>{if(f!=="run")return{};if(!l)return{opacity:.4};switch(l){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,l]);return d.jsxs("div",{className:y,style:{position:"relative",...b},children:[m&&d.jsx("button",{onClick:v,"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:"×"}),o&&d.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:"❗"}),!o&&a&&d.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&&d.jsx(Ur,{message:"确定要删除此任务吗?",onConfirm:()=>{p(r),g(!1)},onCancel:()=>g(!1)})]})},Qy=({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 d.jsx("div",{className:`execution-status-badge ${n}`,title:e,children:d.jsx("span",{className:"badge-icon",children:t})})},Eh=q.memo(Qy),ex=({icon:e,header:r,title:t,meta:n,color:o,status:a,isRunning:i,children:s,width:l="240px",border:u=!0})=>d.jsxs("div",{style:{display:"flex",flexDirection:"row",width:l,height:"100%",position:"relative",overflow:"hidden",border:u?"4px solid var(--border-primary)":"none",borderRadius:"8px"},children:[d.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:o},children:d.jsx(e,{size:20,strokeWidth:1.5})}),d.jsxs("div",{style:{flex:1,padding:"10px 14px",display:"flex",flexDirection:"column",justifyContent:"center",overflow:"hidden"},children:[d.jsx("div",{style:{fontSize:"14px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.5px",opacity:.7,marginBottom:"4px",color:o},children:r}),d.jsx("div",{style:{fontSize:"18px",fontWeight:600,color:"var(--text-primary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginBottom:"2px"},title:t,children:t}),n&&d.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)",fontStyle:"italic",lineHeight:"1.4",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},title:n,children:n}),s&&d.jsx("div",{style:{marginTop:"8px"},children:s})]}),i&&a&&d.jsx("div",{style:{position:"absolute",top:"8px",right:"8px"},children:d.jsx(Eh,{status:a})})]}),Jr=q.memo(ex),Ve=e=>{const r=e.layoutDirection||"TB",t=e.sourcePosition||(r==="LR"?O.Position.Right:O.Position.Bottom),n=e.targetPosition||(r==="LR"?O.Position.Left:O.Position.Top);return{layoutDirection:r,sourcePosition:t,targetPosition:n}},ir=e=>{const{mode:r,executionData:t}=oe(),n=r==="run"?t?.[e]:null,o=r==="run",a=n?.attempts.some(l=>l.iteration!==void 0&&l.iteration>1)??!1,i=n?.attempts[n.attempts.length-1],s=a?0:i?.retryCount??0;return{mode:r,execution:n,isRunning:o,retryCount:s}};function Fe(e,r){return e.length>r?e.slice(0,r)+"…":e}function xr(e,r,t,n){if(t==="business")return r.task?.description?.trim()||n;if(t==="standard")return n;const o=r.task;if(!o)return n;const a=o.inputParameters||{};switch(e){case"HTTP":case"HTTP_POLL":{const i=o.httpRequest||a.http_request;if(!i)return n;const s=(i.method||"GET").toUpperCase(),l=i.uri?Fe(String(i.uri),28):"";return l?`${s} ${l}`:s}case"SWITCH":{const i=o.caseExpression||a.expression,s=o.evaluatorType||a.evaluatorType;return i?Fe(i,35):s||n}case"DECISION":return o.caseValueParam?`param: ${o.caseValueParam}`:n;case"SIMPLE":return o.name?`worker: ${Fe(o.name,28)}`:n;case"INLINE":case"LAMBDA":{const i=o.evaluatorType||a.evaluatorType;return i?`${i} script`:n}case"SUB_WORKFLOW":{const i=o.subWorkflowParam;return i?`${i.name}${i.version?` v${i.version}`:""}`:n}case"DO_WHILE":{const i=o.loopCondition;return i?Fe(i,35):n}case"JSON_JQ_TRANSFORM":{const i=a.queryExpression||a.query_expression;return i?Fe(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=o.sink||a.sink;return i?`→ ${Fe(i,32)}`:n}case"KAFKA_PUBLISH":{const i=a.topic||a.kafka_request?.topic;return i?`topic: ${Fe(i,28)}`:n}case"START_WORKFLOW":{const i=o.startWorkflow?.name??a.startWorkflow?.name??a.start_workflow?.name;return i?`→ ${i}`:n}default:return n}}const rx=({id:e,data:r,selected:t})=>{const n=r.taskType||"SIMPLE",{sourcePosition:o,targetPosition:a}=Ve(r),{execution:i,isRunning:s,retryCount:l}=ir(r.taskReferenceName),u=oe(m=>m.viewMode),c=q.useMemo(()=>Ge.find(m=>m.type===n),[n]),f=c?.icon||Sh,p=n==="NOOP",h=r.isDynamicRuntime===!0,g=p?"var(--text-secondary)":"var(--color-accent)",v=q.useMemo(()=>{let m;return h?m=`Dynamic (${n})`:n==="SIMPLE"?m=r.label==="Worker Task"?"Execute on Worker":"Worker Task":n==="HTTP"?m="REST API Call":n==="JSON_JQ_TRANSFORM"?m="JQ Expression":n==="INLINE"||n==="LAMBDA"?m="Inline Script":n==="START_WORKFLOW"?m="Launch Workflow (no wait)":n==="DYNAMIC"?m="Dynamic Task Type":n==="HUMAN"?m="Human Approval":n==="NOOP"?m="No Operation":m=c?.label||n,xr(n,r,u,m)},[n,c,r,u,h]);return d.jsx(yr,{nodeId:e,selected:t,isError:r.isError,hasWarning:r.hasWarning,isHighlighted:r.isHighlighted,executionStatus:i?.status,simRunning:r.simRunning,simDone:r.simDone,children:d.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:[d.jsx(Jr,{icon:f,header:n,title:r.taskReferenceName,meta:v,color:g,status:i?.status,isRunning:s}),s&&l>0&&d.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:["×",l]}),h&&d.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:"动态"}),d.jsx(O.Handle,{type:"target",position:a,style:{background:"#fff"}}),d.jsx(O.Handle,{type:"source",position:o,style:{background:"#fff"}})]})})},tx=q.memo(rx),Nh=({title:e,label:r,defaultValue:t="",placeholder:n="",confirmText:o="确定",cancelText:a="取消",onConfirm:i,onCancel:s})=>{const{theme:l,themeColor:u}=oe(),[c,f]=q.useState(t),p=q.useRef(null);q.useEffect(()=>{p.current&&(p.current.focus({preventScroll:!0}),p.current.select());const g=v=>{v.key==="Escape"&&(v.stopPropagation(),s())};return window.addEventListener("keydown",g,!0),()=>window.removeEventListener("keydown",g,!0)},[s]);const h=()=>{const g=c.trim();g&&i(g)};return Gr.createPortal(d.jsx("div",{"data-mode":l,"data-brand":u,onClick:s,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:d.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:[d.jsx("div",{style:{fontSize:"15px",fontWeight:600,color:"var(--text-primary)",marginBottom:"16px"},children:e}),r&&d.jsx("div",{style:{fontSize:"12px",color:"var(--text-secondary)",marginBottom:"8px"},children:r}),d.jsx("input",{ref:p,type:"text",value:c,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)"}}),d.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"10px"},children:[d.jsx("button",{onClick:s,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}),d.jsx("button",{onClick:h,disabled:!c.trim(),style:{padding:"7px 18px",backgroundColor:c.trim()?"var(--color-accent)":"var(--bg-tertiary)",border:"none",borderRadius:"6px",color:c.trim()?"#ffffff":"var(--text-secondary)",cursor:c.trim()?"pointer":"not-allowed",fontSize:"13px",fontWeight:600,transition:"background-color 0.15s, color 0.15s"},children:o})]})]})}),document.body)},nx=({id:e,data:r,selected:t})=>{const{layoutDirection:n}=Ve(r),{mode:o,execution:a,isRunning:i}=ir(r.taskReferenceName),{addDecisionBranch:s,removeDecisionBranch:l,renameDecisionBranch:u,viewMode:c}=oe(),[f,p]=q.useState(!1),[h,g]=q.useState({type:"none"}),v=n==="LR"?O.Position.Left:O.Position.Top,m=Object.keys(r.decisionCases||r.task?.decisionCases||{}),x=()=>{p(!1),g({type:"add"})},y=(I,R)=>{I.stopPropagation(),g({type:"delete",branch:R})},b=(I,R)=>{I.stopPropagation(),p(!1),g({type:"rename",branch:R})},k=I=>{I&&s(e,I),g({type:"none"})},S=I=>{h.type==="rename"&&(I&&I!==h.branch&&u(e,h.branch,I),g({type:"none"}))},C=()=>{h.type==="delete"&&(l(e,h.branch),g({type:"none"}))},N=()=>g({type:"none"}),w=i?(I=>I&&{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"}[I]||"")(a?.status):"";return d.jsxs(yr,{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:[d.jsxs("div",{style:{position:"relative"},children:[d.jsx(O.Handle,{type:"target",position:v,style:{background:"#fff",[n==="LR"?"left":"top"]:"-5px"}}),i&&a?.status&&d.jsx("div",{style:{position:"absolute",top:0,right:0,zIndex:20},children:d.jsx(Eh,{status:a.status})}),d.jsx("div",{className:w,style:{width:"150px",height:"150px",background:i&&a?.status?void 0:"var(--bg-secondary)",border:t?"4px solid #fbbf24":i&&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)":i&&a?.status?void 0:"0 4px 12px rgba(0,0,0,0.15)",transition:"all 0.3s ease",cursor:"pointer"},onClick:()=>o==="edit"&&p(!f),children:d.jsxs("div",{style:{transform:"rotate(-45deg)",color:"#fff",textAlign:"center",padding:"10px",width:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},children:[d.jsx("div",{style:{fontSize:"14px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.5px",opacity:.7,marginBottom:"4px",color:"var(--color-accent)"},children:r.taskType}),d.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}),o==="edit"&&d.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:"+"}),i&&a?.startTime&&d.jsx("div",{style:{fontSize:"9px",opacity:.7,marginTop:"8px"},children:a.endTime?`${((a.endTime-a.startTime)/1e3).toFixed(1)}s`:"◌"})]})}),o==="edit"&&f&&d.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:[d.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:"分支管理"}),m.map(I=>d.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"5px 6px",borderRadius:"4px",gap:"4px"},children:[d.jsx("span",{style:{flex:1,fontSize:"12px",color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:I}),d.jsx("button",{onClick:R=>b(R,I),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:`重命名分支 "${I}"`,children:"✏"}),d.jsx("button",{onClick:R=>y(R,I),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:`删除分支 "${I}"`,children:"×"})]},I)),d.jsx("button",{onClick:x,style:{width:"100%",marginTop:"6px",padding:"8px",backgroundColor:"var(--color-accent)",border:"none",borderRadius:"4px",color:"#fff",cursor:"pointer",fontSize:"12px",fontWeight:"bold"},children:"+ 添加新分支"})]}),c==="developer"&&(()=>{const I=r.task?.caseExpression||r.task?.inputParameters?.expression,R=r.task?.caseValueParam;return!I&&!R?null:d.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:I?Fe(I,22):`param: ${R}`})})(),n==="TB"?d.jsxs(d.Fragment,{children:[d.jsx(O.Handle,{type:"source",position:O.Position.Bottom,style:{background:"#fff",bottom:"-5px"}}),d.jsx(O.Handle,{type:"source",position:O.Position.Left,id:"left",style:{background:"#fff",left:"-5px"}}),d.jsx(O.Handle,{type:"source",position:O.Position.Right,id:"right",style:{background:"#fff",right:"-5px"}})]}):d.jsxs(d.Fragment,{children:[d.jsx(O.Handle,{type:"source",position:O.Position.Right,style:{background:"#fff",right:"-5px"}}),d.jsx(O.Handle,{type:"source",position:O.Position.Top,id:"top",style:{background:"#fff",top:"-5px"}}),d.jsx(O.Handle,{type:"source",position:O.Position.Bottom,id:"bottom",style:{background:"#fff",bottom:"-5px"}})]})]}),h.type==="add"&&d.jsx(Nh,{title:"添加新分支",label:"分支条件值(Case Value)",defaultValue:`case_${m.length+1}`,placeholder:"例如:approved、rejected、pending",confirmText:"添加",onConfirm:k,onCancel:N}),h.type==="rename"&&d.jsx(Nh,{title:"重命名分支",label:`当前名称:${h.branch}`,defaultValue:h.branch,placeholder:"输入新的分支条件值",confirmText:"重命名",onConfirm:S,onCancel:N}),h.type==="delete"&&d.jsx(Ur,{message:`确定要删除分支 "${h.branch}" 及其下的所有任务吗?此操作不可撤销。`,onConfirm:C,onCancel:N})]})},ax=q.memo(nx),Ch="var(--color-accent)",Ih=q.memo(({id:e,data:r,selected:t})=>{const{layoutDirection:n,sourcePosition:o,targetPosition:a}=Ve(r),{mode:i,execution:s,isRunning:l}=ir(r.taskReferenceName),{addForkBranch:u}=oe(),c=O.useUpdateNodeInternals(),f=r.task?.forkTasks?.length||0;q.useEffect(()=>{c(e)},[f,e,c]);const p=r.isDynamic||r.taskType==="FORK_JOIN_DYNAMIC",h=oe(m=>m.viewMode),v=q.useMemo(()=>Ge.find(m=>m.type==="FORK_JOIN"),[])?.icon||Hr;return d.jsx(yr,{isHighlighted:r.isHighlighted,nodeId:e,selected:t,isError:r.isError,hasWarning:r.hasWarning,executionStatus:s?.status,simRunning:r.simRunning,simDone:r.simDone,children:d.jsxs("div",{className:`fork-node ${p?"dynamic":"static"}`,style:{borderRadius:"8px",background:"var(--bg-secondary)",position:"relative"},children:[d.jsx(Jr,{icon:v,header:p?"DYNAMIC FORK":"FORK",title:r.taskReferenceName,meta:xr(r.taskType,r,h,p?"Dynamic Parallel Execution":"Parallel Execution"),color:Ch,status:s?.status,isRunning:l}),i==="edit"&&!p&&d.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:m=>{m.stopPropagation(),u(e)},title:"添加分支",children:"+"}),d.jsx(O.Handle,{type:"target",position:a,style:{background:"#fff"}}),!p&&(r.task?.forkTasks||[]).map((m,x,y)=>{if(i!=="edit"&&(!m||m.length===0))return null;const b=i!=="edit"?y.filter(N=>N&&N.length>0):y,k=b.length,C=(b.indexOf(m)+1)/(k+1)*100;return d.jsx(O.Handle,{id:`branch_${x}`,type:"source",position:o,style:{background:"#fff",[n==="LR"?"top":"left"]:`${C}%`,[n==="LR"?"left":"top"]:void 0,[n==="LR"?"right":"bottom"]:"-4px",zIndex:10}},`branch_${x}`)}),!p&&(!r.task?.forkTasks||r.task.forkTasks.length===0)&&d.jsx(O.Handle,{type:"source",position:o,style:{background:"#fff"}}),p&&d.jsx(O.Handle,{type:"source",position:o,style:{background:"#fff"}})]})})});Ih.displayName="ForkNode";const Rh=q.memo(({id:e,data:r,selected:t})=>{const{layoutDirection:n,sourcePosition:o,targetPosition:a}=Ve(r),{execution:i,isRunning:s}=ir(r.taskReferenceName),l=oe(f=>f.viewMode),c=q.useMemo(()=>Ge.find(f=>f.type==="JOIN"),[])?.icon||Kr;return d.jsx(yr,{isHighlighted:r.isHighlighted,nodeId:e,selected:t,isError:r.isError,hasWarning:r.hasWarning,executionStatus:i?.status,simRunning:r.simRunning,simDone:r.simDone,children:d.jsxs("div",{style:{borderRadius:"8px",background:"var(--bg-secondary)",position:"relative"},children:[d.jsx(Jr,{icon:c,header:r.taskType==="EXCLUSIVE_JOIN"?"EXCLUSIVE JOIN":"JOIN",title:r.taskReferenceName,meta:xr(r.taskType,r,l,r.taskType==="EXCLUSIVE_JOIN"?"Wait for any task":"Wait for tasks"),color:Ch,status:i?.status,isRunning:s}),d.jsx(O.Handle,{type:"target",position:a,style:{background:"#fff"}}),n==="TB"&&d.jsxs(d.Fragment,{children:[d.jsx(O.Handle,{type:"target",position:O.Position.Left,id:"left",style:{background:"#fff"}}),d.jsx(O.Handle,{type:"target",position:O.Position.Right,id:"right",style:{background:"#fff"}})]}),n==="LR"&&d.jsxs(d.Fragment,{children:[d.jsx(O.Handle,{type:"target",position:O.Position.Top,id:"top",style:{background:"#fff"}}),d.jsx(O.Handle,{type:"target",position:O.Position.Bottom,id:"bottom",style:{background:"#fff"}})]}),d.jsx(O.Handle,{type:"source",position:o,style:{background:"#fff"}})]})})});Rh.displayName="JoinNode";const jh={ForkNode:Ih,JoinNode:Rh},ox=({id:e,data:r,selected:t})=>{const{sourcePosition:n,targetPosition:o}=Ve(r),{execution:a,isRunning:i}=ir(r.taskReferenceName),{executionData:s,selectTaskAction:l,mode:u,viewMode:c,removeNode:f}=oe(),[p,h]=q.useState(!1),g=r.task,v=g?.loopOver||[],x=q.useMemo(()=>Ge.find(w=>w.type==="DO_WHILE"),[])?.icon||Th,y=q.useMemo(()=>{if(!i||!s||v.length===0)return 0;let w=0;return v.forEach(I=>{const R=s[I.taskReferenceName];R?.totalIterations?w=Math.max(w,R.totalIterations):R?.attempts.some(B=>(B.iteration??0)>0)&&(w=Math.max(w,R.attempts.length))}),w},[i,s,v]),b=r.loopCondition||g?.loopCondition||"",k=q.useMemo(()=>{const w=b?b.length>35?b.slice(0,35)+"…":b:"循环直到条件满足";return xr("DO_WHILE",r,c,w)},[r,c,b]),S=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)",C=t?`2px solid ${S}`:`1.5px dashed ${i&&a?.status?S:"var(--color-accent)"}`,N=u==="edit",A=c==="developer"&&b;return d.jsxs("div",{style:{width:"100%",height:"100%",border:C,borderRadius:"10px",background:"transparent",display:"flex",flexDirection:"column",position:"relative",overflow:"visible",boxSizing:"border-box",pointerEvents:"none"},children:[N&&d.jsx("button",{onClick:w=>{w.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&&d.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&&d.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:"⚠️"}),d.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:[d.jsx("div",{style:{color:"var(--color-accent)",display:"flex",alignItems:"center",flexShrink:0},children:d.jsx(x,{size:14})}),d.jsxs("div",{style:{flex:1,minWidth:0},children:[d.jsx("div",{style:{fontSize:"9px",fontWeight:700,color:"var(--color-accent)",letterSpacing:"0.08em",textTransform:"uppercase"},children:"DO WHILE"}),d.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.taskReferenceName}),(c==="business"||c==="developer")&&k&&d.jsx("div",{style:{fontSize:"9px",color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:"1px",fontStyle:"italic"},children:k})]}),i&&y>0&&d.jsxs("div",{onClick:()=>l(g||null),style:{padding:"2px 8px",borderRadius:"12px",background:"var(--color-accent)",color:"#fff",fontSize:"10px",fontWeight:700,cursor:"pointer",flexShrink:0},children:["×",y]}),i&&a?.status&&d.jsx("div",{style:{width:"8px",height:"8px",borderRadius:"50%",background:S,flexShrink:0}})]}),A&&d.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]}),d.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"}}),d.jsx(O.Handle,{type:"target",position:o,style:{background:"var(--color-accent)",zIndex:10}}),d.jsx(O.Handle,{type:"source",position:n,style:{background:"var(--color-accent)",zIndex:10}}),p&&d.jsx(Ur,{message:"确定要删除此循环任务吗?循环体内的任务也会一并删除。",onConfirm:()=>{f(e),h(!1)},onCancel:()=>h(!1)})]})},ix=q.memo(ox),sx="var(--color-accent)",cx=({id:e,data:r,selected:t})=>{const{sourcePosition:n,targetPosition:o}=Ve(r),{execution:a,isRunning:i}=ir(r.taskReferenceName),s=oe(p=>p.viewMode),u=q.useMemo(()=>Ge.find(p=>p.type==="SUB_WORKFLOW"),[])?.icon||Kr,c=r.task?.subWorkflowParam?.name||r.subWorkflowName||"Unknown",f=r.task?.subWorkflowParam?.version;return d.jsx(yr,{nodeId:e,selected:t,isError:r.isError,hasWarning:r.hasWarning,isHighlighted:r.isHighlighted,executionStatus:a?.status,simRunning:r.simRunning,simDone:r.simDone,children:d.jsxs("div",{style:{borderRadius:"8px",background:"var(--bg-secondary)",position:"relative"},children:[d.jsx(Jr,{icon:u,header:"SUB WORKFLOW",title:r.taskReferenceName,meta:xr("SUB_WORKFLOW",r,s,`Flow: ${c} (v${f})`),color:sx,status:a?.status,isRunning:i}),d.jsx(O.Handle,{type:"target",position:o,style:{background:"#fff"}}),d.jsx(O.Handle,{type:"source",position:n,style:{background:"#fff"}})]})})},ux=q.memo(cx),lx=({data:e})=>{const t=(e.layoutDirection||"TB")==="LR";return d.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:[d.jsx(Jy,{size:16}),e.label&&e.label!=="+"&&d.jsx("span",{style:{fontSize:"12px",fontWeight:500},children:e.label}),d.jsx(O.Handle,{type:"target",position:t?O.Position.Left:O.Position.Top,style:{opacity:0}}),d.jsx("style",{dangerouslySetInnerHTML:{__html:`
|
|
12
|
+
execute($.input);`}):d.type==="DYNAMIC"?(d.dynamicTaskNameParam="taskToExecute",d.inputParameters={taskToExecute:"${workflow.input.taskName}"}):d.type==="HUMAN"?d.humanTaskDef={userFormTemplate:"",assignmentCompletionStrategy:"LEAVE_OPEN"}:d.type==="START_WORKFLOW"?d.inputParameters={startWorkflow:{name:"",version:1,input:{},correlationId:""}}:d.type==="NOOP"&&(d.inputParameters={}),o.isWorkflowStart)c.tasks.unshift(d);else if(o.isLoopBodyStart){const y=je(c.tasks,t);y&&(y.loopOver||(y.loopOver=[]),y.loopOver.unshift(d))}else o.branchCase!==void 0||o.forkIndex!==void 0||o.isLoopAdd?or(c.tasks,t,o,d):c.tasks.length===0?c.tasks.push(d):Le(c.tasks,t,d);Ee(c.tasks);const{nodes:f,edges:p,taskMap:h}=Te(c,u,{hideEmptyBranches:n().mode!=="edit"}),{nodes:g,edges:m}=Se(f,p,{direction:u,mode:n().mode}),v=Oe(c);e({workflowDef:c,nodes:g,edges:m,taskMap:h,validationResults:v})},removeNode:r=>{const{workflowDef:t,layoutDirection:s,nodes:a}=n();if(!t)return;const o=JSON.parse(JSON.stringify(t)),i=sr(o.tasks,r);if(i){const g=a.find(m=>m.id===r)?.data?.taskType;if(g==="FORK_JOIN"||g==="FORK_JOIN_DYNAMIC"){const m=Eh(i,r);m&&We(o.tasks,m)}else if(g==="JOIN"||g==="EXCLUSIVE_JOIN"){const m=Nh(i,r);m&&We(o.tasks,m)}}We(o.tasks,r),Ee(o.tasks);const{nodes:u,edges:c,taskMap:d}=Te(o,s,{hideEmptyBranches:n().mode!=="edit"}),{nodes:f,edges:p}=Se(u,c,{direction:s,mode:n().mode}),h=Oe(o);e({workflowDef:o,nodes:f,edges:p,taskMap:d,validationResults:h})},addLoopTask:(r,t)=>{const{workflowDef:s,layoutDirection:a}=n();if(!s)return;const o=JSON.parse(JSON.stringify(s)),i=je(o.tasks,r);if(i&&i.type==="DO_WHILE"){i.loopOver||(i.loopOver=[]);const u={name:`new_${t.toLowerCase()}`,taskReferenceName:`${r}_sub_${Date.now()}`,type:t,inputParameters:{}};i.loopOver.push(u),Ee(o.tasks);const{nodes:c,edges:d,taskMap:f}=Te(o,a,{hideEmptyBranches:n().mode!=="edit"}),{nodes:p,edges:h}=Se(c,d,{direction:a,mode:n().mode}),g=Oe(o);e({workflowDef:o,nodes:p,edges:h,taskMap:f,validationResults:g})}},removeLoopTask:(r,t)=>{const{workflowDef:s,layoutDirection:a}=n();if(!s)return;const o=JSON.parse(JSON.stringify(s)),i=je(o.tasks,r);if(i&&i.type==="DO_WHILE"&&i.loopOver){const u=sr(i.loopOver,t);if(u){const m=u.find(v=>v.taskReferenceName===t);if(m?.type==="FORK_JOIN"||m?.type==="FORK_JOIN_DYNAMIC"){const v=Eh(u,t);v&&We(i.loopOver,v)}else if(m?.type==="JOIN"||m?.type==="EXCLUSIVE_JOIN"){const v=Nh(u,t);v&&We(i.loopOver,v)}}We(i.loopOver,t),Ee(o.tasks);const{nodes:c,edges:d,taskMap:f}=Te(o,a,{hideEmptyBranches:n().mode!=="edit"}),{nodes:p,edges:h}=Se(c,d,{direction:a,mode:n().mode}),g=Oe(o);e({workflowDef:o,nodes:p,edges:h,taskMap:f,validationResults:g})}},addDecisionBranch:(r,t)=>{const{workflowDef:s,layoutDirection:a}=n();if(!s)return;const o=JSON.parse(JSON.stringify(s)),i=je(o.tasks,r);if(i&&(i.type==="DECISION"||i.type==="SWITCH")){t==="default"?i.defaultCase||(i.defaultCase=[]):(i.decisionCases||(i.decisionCases={}),i.decisionCases[t]||(i.decisionCases[t]=[])),Ee(o.tasks);const{nodes:u,edges:c,taskMap:d}=Te(o,a,{hideEmptyBranches:n().mode!=="edit"}),{nodes:f,edges:p}=Se(u,c,{direction:a,mode:n().mode}),h=Oe(o);e({workflowDef:o,nodes:f,edges:p,taskMap:d,validationResults:h})}},removeDecisionBranch:(r,t)=>{const{workflowDef:s,layoutDirection:a}=n();if(!s)return;const o=JSON.parse(JSON.stringify(s)),i=je(o.tasks,r);if(i&&(i.type==="DECISION"||i.type==="SWITCH")){t==="default"?i.defaultCase=[]:i.decisionCases&&delete i.decisionCases[t],Ee(o.tasks);const{nodes:u,edges:c,taskMap:d}=Te(o,a,{hideEmptyBranches:n().mode!=="edit"}),{nodes:f,edges:p}=Se(u,c,{direction:a,mode:n().mode}),h=Oe(o);e({workflowDef:o,nodes:f,edges:p,taskMap:d,validationResults:h})}},renameDecisionBranch:(r,t,s)=>{const{workflowDef:a,layoutDirection:o}=n();if(!a||!s.trim()||t===s)return;const i=JSON.parse(JSON.stringify(a)),u=je(i.tasks,r);if(u&&(u.type==="DECISION"||u.type==="SWITCH")){if(!u.decisionCases||!u.decisionCases[t])return;u.decisionCases[s.trim()]=u.decisionCases[t],delete u.decisionCases[t],Ee(i.tasks);const{nodes:c,edges:d,taskMap:f}=Te(i,o,{hideEmptyBranches:n().mode!=="edit"}),{nodes:p,edges:h}=Se(c,d,{direction:o,mode:n().mode}),g=Oe(i);e({workflowDef:i,nodes:p,edges:h,taskMap:f,validationResults:g})}},addForkBranch:r=>{const{workflowDef:t,layoutDirection:s}=n();if(!t)return;const a=JSON.parse(JSON.stringify(t)),o=je(a.tasks,r);if(o&&o.type==="FORK_JOIN"){o.forkTasks||(o.forkTasks=[]),o.forkTasks.push([]),Ee(a.tasks);const{nodes:i,edges:u,taskMap:c}=Te(a,s,{hideEmptyBranches:n().mode!=="edit"}),{nodes:d,edges:f}=Se(i,u,{direction:s,mode:n().mode}),p=Oe(a);e({workflowDef:a,nodes:d,edges:f,taskMap:c,validationResults:p})}},copyTask:r=>e({copiedTask:r}),pasteTask:r=>{const{workflowDef:t,layoutDirection:s,selectedTask:a}=n();if(!t)return;const o=JSON.parse(JSON.stringify(t)),u=`_copy_${Date.now()}`,c=JSON.parse(JSON.stringify(r)),d=x=>{x.taskReferenceName=`${x.taskReferenceName}${u}`,x.decisionCases&&Object.values(x.decisionCases).forEach(b=>b.forEach(d)),x.defaultCase&&x.defaultCase.forEach(d),x.forkTasks&&x.forkTasks.forEach(b=>b.forEach(d)),x.loopOver&&x.loopOver.forEach(d)};d(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):(Le(o.tasks,f,c),Le(o.tasks,c.taskReferenceName,x))}else o.tasks.length===0?o.tasks.push(c):Le(o.tasks,f,c);Ee(o.tasks);const{nodes:p,edges:h,taskMap:g}=Te(o,s,{hideEmptyBranches:n().mode!=="edit"}),{nodes:m,edges:v}=Se(p,h,{direction:s,mode:n().mode}),y=Oe(o);e({workflowDef:o,nodes:m,edges:v,taskMap:g,validationResults:y})},flashNodes:r=>{if(r.length===0)return;const t=n().__flashTimeout;t&&clearTimeout(t);const s=new Set(r),a={};n().nodes.forEach(i=>{s.has(i.id)&&(a[i.id]=i.selected??!1)}),e(i=>({nodes:i.nodes.map(u=>s.has(u.id)?{...u,selected:!0}:u)}));const o=setTimeout(()=>{e(i=>({nodes:i.nodes.map(u=>s.has(u.id)?{...u,selected:a[u.id]??!1}:u)}))},2500);n().__flashTimeout=o},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:t,isSimRunning:s}=n();if(s)return;const a=t.filter(f=>!["plusNode","dynamicPlaceholderNode"].includes(f.type??"")).map(f=>f.id),o=r.map(f=>({source:f.source,target:f.target})),i=Jy(a,o);e({isSimRunning:!0,simState:{}});const u={timer:null};n().__simHandle=u;let c=0;const d=()=>{if(c>=i.length||!n().isSimRunning){e({isSimRunning:!1});return}const f=i[c];e(p=>{const h={...p.simState};return f.forEach(g=>h[g]="running"),{simState:h}}),u.timer=setTimeout(()=>{n().isSimRunning&&(e(p=>{const h={...p.simState};return f.forEach(g=>h[g]="done"),{simState:h}}),c++,u.timer=setTimeout(d,280))},700)};d()},stopSimulation:()=>{const r=n().__simHandle;r?.timer&&clearTimeout(r.timer),e({isSimRunning:!1,simState:{}})},createBlankWorkflow:r=>{const t={name:r||"new_workflow",description:"",tasks:[],version:1,schemaVersion:2};n().setWorkflow(t),e({mode:"edit"})},applyAIGeneratedWorkflow:r=>{const{tasks:t,...s}=r,a={...s,name:r.name||"AI_Generated_Workflow",tasks:t||[],version:r.version||1,schemaVersion:2};n().setWorkflow(a)},setShowRunPanel:r=>e({showRunPanel:r}),setShowAnalysisPanel:r=>e({showAnalysisPanel:r}),setRunState:(r,t,s)=>{e({runState:r,pendingExecutionId:t!==void 0?t:n().pendingExecutionId,executionError:s!==void 0?s:n().executionError})},switchToEditAndFocusParam:(r,t)=>{const{workflowDef:s,layoutDirection:a,taskMap:o}=n();if(!s)return;e({mode:"edit",focusedParamKey:t??null});const{nodes:i,edges:u,taskMap:c}=Te(s,a,{hideEmptyBranches:!1}),{nodes:d,edges:f}=Se(i,u,{direction:a,mode:"edit"});e({nodes:d,edges:f,taskMap:c});const p=o[r]||c[r];p&&e({selectedTask:{...p},isDetailPanelOpen:!0,showAnalysisPanel:!1})}}),{partialize:e=>({workflowDef:e.workflowDef,layoutDirection:e.layoutDirection,nodes:e.nodes.map(n=>Object.assign({},n,{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,n)=>JSON.stringify(e.workflowDef)===JSON.stringify(n.workflowDef)}),{name:"conductor-ui-prefs",version:1,storage:tt(()=>localStorage),migrate:(e,n)=>(n===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 Gy=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Vy=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(n,r,t)=>t?t.toUpperCase():r.toLowerCase()),Ih=e=>{const n=Vy(e);return n.charAt(0).toUpperCase()+n.slice(1)},Rh=(...e)=>e.filter((n,r,t)=>!!n&&n.trim()!==""&&t.indexOf(n)===r).join(" ").trim(),Yy=e=>{for(const n in e)if(n.startsWith("aria-")||n==="role"||n==="title")return!0};var Xy={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 Zy=O.forwardRef(({color:e="currentColor",size:n=24,strokeWidth:r=2,absoluteStrokeWidth:t,className:s="",children:a,iconNode:o,...i},u)=>O.createElement("svg",{ref:u,...Xy,width:n,height:n,stroke:e,strokeWidth:t?Number(r)*24/Number(n):r,className:Rh("lucide",s),...!a&&!Yy(i)&&{"aria-hidden":"true"},...i},[...o.map(([c,d])=>O.createElement(c,d)),...Array.isArray(a)?a:[a]]));const we=(e,n)=>{const r=O.forwardRef(({className:t,...s},a)=>O.createElement(Zy,{ref:a,iconNode:n,className:Rh(`lucide-${Gy(Ih(e))}`,`lucide-${e}`,t),...s}));return r.displayName=Ih(e),r};const Oh=we("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 Qy=we("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 ex=we("clock",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const Ph=we("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 rx=we("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 Gr=we("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 Vr=we("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 tx=we("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 nx=we("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 ax=we("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);const sx=we("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 ox=we("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const Ah=we("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 Ki=we("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 ix=we("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);const lx=we("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 cx=we("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"}]]),dx={business:["business"],standard:["business","control"],developer:["business","control","data"]},He=[{type:"SIMPLE",label:"任务节点 (Worker)",description:"在远程 Worker 上执行的任务",category:"CORE",icon:Oh,viewCategory:"business"},{type:"SUB_WORKFLOW",label:"子工作流 (Sub Workflow)",description:"调用并执行另一个工作流",category:"CORE",icon:Vr,viewCategory:"business"},{type:"START_WORKFLOW",label:"启动工作流 (Start Workflow)",description:"启动另一个工作流(不等待结果)",category:"SYSTEM",icon:sx,viewCategory:"business"},{type:"HTTP",label:"HTTP 请求",description:"发起 REST/HTTP 调用",category:"SYSTEM",icon:tx,viewCategory:"business"},{type:"INLINE",label:"内联脚本 (Inline)",description:"执行内联脚本(JS/Python/GraalJS)",category:"SYSTEM",icon:Ph,viewCategory:"data"},{type:"JSON_JQ_TRANSFORM",label:"JSON 转换 (JQ)",description:"使用 JQ 表达式转换 JSON 数据",category:"SYSTEM",icon:ix,viewCategory:"data"},{type:"KAFKA_PUBLISH",label:"Kafka 推送",description:"向 Kafka 主题推送消息",category:"SYSTEM",icon:nx,viewCategory:"data"},{type:"EVENT",label:"事件 (Event)",description:"向外部队列系统发布事件",category:"SYSTEM",icon:cx,viewCategory:"data"},{type:"WAIT",label:"等待 (Wait)",description:"暂停流程,直到特定时间或时长",category:"SYSTEM",icon:ex,viewCategory:"control"},{type:"SET_VARIABLE",label:"设置变量 (Set Variable)",description:"设置工作流上下文变量",category:"SYSTEM",icon:rx,viewCategory:"data"},{type:"TERMINATE",label:"终止 (Terminate)",description:"提前结束工作流执行",category:"SYSTEM",icon:Qy,viewCategory:"control"},{type:"HUMAN",label:"人工审批 (Human)",description:"等待人工审核或表单提交",category:"SYSTEM",icon:lx,viewCategory:"business"},{type:"DYNAMIC",label:"动态任务 (Dynamic)",description:"运行时动态决定任务类型",category:"SYSTEM",icon:Ki,viewCategory:"data"},{type:"NOOP",label:"空操作 (Noop)",description:"占位符任务,无实际操作",category:"SYSTEM",icon:ax,viewCategory:"data"},{type:"LAMBDA",label:"Lambda 脚本 (旧)",description:"已被 INLINE 取代",category:"SYSTEM",icon:Ph,hidden:!0,viewCategory:"data"},{type:"SWITCH",label:"条件分支 (Switch)",description:"基于条件的逻辑分支 (Switch/Case)",category:"FLOW",icon:Ki,viewCategory:"control"},{type:"DECISION",label:"判断 (Decision,旧)",description:"基于条件的逻辑分支(旧版,推荐改用 Switch)",category:"FLOW",icon:Ki,hidden:!0,viewCategory:"control"},{type:"FORK_JOIN",label:"静态并行 (Fork)",description:"并行执行多个预定义任务分支",category:"FLOW",icon:Gr,viewCategory:"control"},{type:"FORK_JOIN_DYNAMIC",label:"动态并行 (Dynamic Fork)",description:"运行时动态生成并行分支",category:"FLOW",icon:Gr,viewCategory:"control"},{type:"DO_WHILE",label:"循环 (Do-While)",description:"循环执行直到满足条件",category:"FLOW",icon:Ah,viewCategory:"control"},{type:"JOIN",label:"汇聚 (Join)",description:"等待所有并行分支执行完成",category:"FLOW",icon:Vr,viewCategory:"control"}],ux=[{key:"CORE",label:"基础任务"},{key:"FLOW",label:"逻辑控制"},{key:"SYSTEM",label:"系统集成"}],Yr=({message:e,onConfirm:n,onCancel:r})=>{const t=O.useRef(null),{theme:s,themeColor:a}=oe();return O.useEffect(()=>{t.current?.focus({preventScroll:!0});const o=i=>{i.key==="Escape"&&r()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[r]),Qr.createPortal(l.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: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:t,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:"取消"}),l.jsx("button",{onClick:n,style:{padding:"7px 18px",backgroundColor:"var(--color-accent)",border:"none",borderRadius:"6px",color:"#ffffff",cursor:"pointer",fontSize:"13px",fontWeight:600},children:"确定"})]})]})}),document.body)},kr=({children:e,nodeId:n,selected:r=!1,isStartOrEnd:t=!1,isError:s=!1,hasWarning:a=!1,isDecision:o=!1,isHighlighted:i=!1,executionStatus:u,simRunning:c=!1,simDone:d=!1,proposalStatus:f})=>{const{mode:p,removeNode:h}=oe(),[g,m]=O.useState(!1),v=w=>{w.stopPropagation(),m(!0)},y=p==="edit"&&!t,b=[o?"decision-node-wrapper":"node-wrapper-glass",r?"node-wrapper-selected":"",i?"node-wrapper-highlighted":"",c?"node-sim-running":"",d?"node-sim-done":"",f?`node-proposal-${f}`:""].filter(Boolean).join(" "),k=O.useMemo(()=>{if(p!=="run")return{};if(!u)return{opacity:.4};switch(u){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{}}},[p,u]);return l.jsxs("div",{className:b,style:{position:"relative",...k},children:[y&&l.jsx("button",{onClick:v,"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:"⚠️"}),f&&l.jsx("div",{className:`node-proposal-badge node-proposal-badge-${f}`,children:f==="added"?"+":f==="modified"?"~":"−"}),e,g&&l.jsx(Yr,{message:"确定要删除此任务吗?",onConfirm:()=>{h(n),m(!1)},onCancel:()=>m(!1)})]})},fx=({status:e})=>{const n=()=>{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:t}=n();return l.jsx("div",{className:`execution-status-badge ${t}`,title:e,children:l.jsx("span",{className:"badge-icon",children:r})})},Lh=O.memo(fx),px=/[一-龥]/,hx=({icon:e,header:n,title:r,meta:t,color:s,status:a,isRunning:o,children:i,width:u="240px",border:c=!0})=>l.jsxs("div",{style:{display:"flex",flexDirection:"row",width:u,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:"11px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.5px",opacity:.7,marginBottom:"4px",color:s,...px.test(n)&&{letterSpacing:"0.3px",fontSize:"12px"}},children:n}),l.jsx("div",{style:{fontSize:"18px",fontWeight:600,color:"var(--text-primary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginBottom:"2px"},title:r,children:r}),t&&l.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)",fontStyle:"italic",lineHeight:"1.4",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},title:t,children:t}),i&&l.jsx("div",{style:{marginTop:"8px"},children:i})]}),o&&a&&l.jsx("div",{style:{position:"absolute",top:"8px",right:"8px"},children:l.jsx(Lh,{status:a})})]}),Xr=O.memo(hx),Xe=e=>{const n=e.layoutDirection||"TB",r=e.sourcePosition||(n==="LR"?A.Position.Right:A.Position.Bottom),t=e.targetPosition||(n==="LR"?A.Position.Left:A.Position.Top);return{layoutDirection:n,sourcePosition:r,targetPosition:t}},ir=e=>{const{mode:n,executionData:r}=oe(),t=n==="run"?r?.[e]:null,s=n==="run",a=t?.attempts.some(u=>u.iteration!==void 0&&u.iteration>1)??!1,o=t?.attempts[t.attempts.length-1],i=a?0:o?.retryCount??0;return{mode:n,execution:t,isRunning:s,retryCount:i}};function Ke(e,n){return e.length>n?e.slice(0,n)+"…":e}function _r(e,n,r,t){if(r==="business")return n.task?.description?.trim()||t;if(r==="standard")return t;const s=n.task;if(!s)return t;const a=s.inputParameters||{};switch(e){case"HTTP":case"HTTP_POLL":{const o=s.httpRequest||a.http_request;if(!o)return t;const i=(o.method||"GET").toUpperCase(),u=o.uri?Ke(String(o.uri),28):"";return u?`${i} ${u}`:i}case"SWITCH":{const o=s.caseExpression||a.expression,i=s.evaluatorType||a.evaluatorType;return o?Ke(o,35):i||t}case"DECISION":return s.caseValueParam?`param: ${s.caseValueParam}`:t;case"SIMPLE":return s.name?`worker: ${Ke(s.name,28)}`:t;case"INLINE":case"LAMBDA":{const o=s.evaluatorType||a.evaluatorType;return o?`${o} script`:t}case"SUB_WORKFLOW":{const o=s.subWorkflowParam;return o?`${o.name}${o.version?` v${o.version}`:""}`:t}case"DO_WHILE":{const o=s.loopCondition;return o?Ke(o,35):t}case"JSON_JQ_TRANSFORM":{const o=a.queryExpression||a.query_expression;return o?Ke(o,35):t}case"SET_VARIABLE":{const o=Object.keys(a);return o.length?`set: ${o.slice(0,2).join(", ")}${o.length>2?"…":""}`:t}case"EVENT":{const o=s.sink||a.sink;return o?`→ ${Ke(o,32)}`:t}case"KAFKA_PUBLISH":{const o=a.topic||a.kafka_request?.topic;return o?`topic: ${Ke(o,28)}`:t}case"START_WORKFLOW":{const o=s.startWorkflow?.name??a.startWorkflow?.name??a.start_workflow?.name;return o?`→ ${o}`:t}default:return t}}function lr(e,n){if(n!=="business")return e;const r=He.find(t=>t.type===e);return r?r.label.replace(/\s*\([^)]+\)$/,""):e==="JOIN"?"汇聚":e==="EXCLUSIVE_JOIN"?"排他汇聚":e}const gx=({id:e,data:n,selected:r})=>{const t=n.taskType||"SIMPLE",{sourcePosition:s,targetPosition:a}=Xe(n),{execution:o,isRunning:i,retryCount:u}=ir(n.taskReferenceName),c=oe(v=>v.viewMode),d=O.useMemo(()=>He.find(v=>v.type===t),[t]),f=d?.icon||Oh,p=t==="NOOP",h=n.isDynamicRuntime===!0,g=p?"var(--text-secondary)":"var(--color-accent)",m=O.useMemo(()=>{let v;return h?v=`Dynamic (${t})`:t==="SIMPLE"?v=n.label==="Worker Task"?"Execute on Worker":"Worker Task":t==="HTTP"?v="REST API Call":t==="JSON_JQ_TRANSFORM"?v="JQ Expression":t==="INLINE"||t==="LAMBDA"?v="Inline Script":t==="START_WORKFLOW"?v="Launch Workflow (no wait)":t==="DYNAMIC"?v="Dynamic Task Type":t==="HUMAN"?v="Human Approval":t==="NOOP"?v="No Operation":v=d?.label||t,_r(t,n,c,v)},[t,d,n,c,h]);return l.jsx(kr,{nodeId:e,selected:r,isError:n.isError,hasWarning:n.hasWarning,isHighlighted:n.isHighlighted,executionStatus:o?.status,simRunning:n.simRunning,simDone:n.simDone,proposalStatus:n.proposalStatus,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(Xr,{icon:f,header:lr(t,c),title:n.taskReferenceName,meta:m,color:g,status:o?.status,isRunning:i}),i&&u>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:["×",u]}),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"}})]})})},mx=O.memo(gx),qh=({title:e,label:n,defaultValue:r="",placeholder:t="",confirmText:s="确定",cancelText:a="取消",onConfirm:o,onCancel:i})=>{const{theme:u,themeColor:c}=oe(),[d,f]=O.useState(r),p=O.useRef(null);O.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=d.trim();g&&o(g)};return Qr.createPortal(l.jsx("div",{"data-mode":u,"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}),n&&l.jsx("div",{style:{fontSize:"12px",color:"var(--text-secondary)",marginBottom:"8px"},children:n}),l.jsx("input",{ref:p,type:"text",value:d,placeholder:t,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:!d.trim(),style:{padding:"7px 18px",backgroundColor:d.trim()?"var(--color-accent)":"var(--bg-tertiary)",border:"none",borderRadius:"6px",color:d.trim()?"#ffffff":"var(--text-secondary)",cursor:d.trim()?"pointer":"not-allowed",fontSize:"13px",fontWeight:600,transition:"background-color 0.15s, color 0.15s"},children:s})]})]})}),document.body)},vx=({id:e,data:n,selected:r})=>{const{layoutDirection:t}=Xe(n),{mode:s,execution:a,isRunning:o}=ir(n.taskReferenceName),{addDecisionBranch:i,removeDecisionBranch:u,renameDecisionBranch:c,viewMode:d}=oe(),[f,p]=O.useState(!1),[h,g]=O.useState({type:"none"}),m=t==="LR"?A.Position.Left:A.Position.Top,v=Object.keys(n.decisionCases||n.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"&&(u(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(kr,{nodeId:e,selected:r,isError:n.isError,hasWarning:n.hasWarning,isDecision:!0,isHighlighted:n.isHighlighted,executionStatus:a?.status,simRunning:n.simRunning,simDone:n.simDone,proposalStatus:n.proposalStatus,children:[l.jsxs("div",{style:{position:"relative"},children:[l.jsx(A.Handle,{type:"target",position:m,style:{background:"#fff",[t==="LR"?"left":"top"]:"-5px"}}),o&&a?.status&&l.jsx("div",{style:{position:"absolute",top:0,right:0,zIndex:20},children:l.jsx(Lh,{status:a.status})}),l.jsx("div",{className:T,style:{width:"150px",height:"150px",background:o&&a?.status?void 0:"var(--bg-secondary)",border:r?"4px solid #fbbf24":o&&a?.status?void 0:"4px solid var(--border-primary)",transform:"rotate(45deg)",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:r?"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:lr(n.taskType,d)}),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:n.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:"+ 添加新分支"})]}),d==="developer"&&(()=>{const C=n.task?.caseExpression||n.task?.inputParameters?.expression,S=n.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?Ke(C,22):`param: ${S}`})})(),t==="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(qh,{title:"添加新分支",label:"分支条件值(Case Value)",defaultValue:`case_${v.length+1}`,placeholder:"例如:approved、rejected、pending",confirmText:"添加",onConfirm:k,onCancel:N}),h.type==="rename"&&l.jsx(qh,{title:"重命名分支",label:`当前名称:${h.branch}`,defaultValue:h.branch,placeholder:"输入新的分支条件值",confirmText:"重命名",onConfirm:w,onCancel:N}),h.type==="delete"&&l.jsx(Yr,{message:`确定要删除分支 "${h.branch}" 及其下的所有任务吗?此操作不可撤销。`,onConfirm:j,onCancel:N})]})},yx=O.memo(vx),Dh="var(--color-accent)",Mh=O.memo(({id:e,data:n,selected:r})=>{const{layoutDirection:t,sourcePosition:s,targetPosition:a}=Xe(n),{mode:o,execution:i,isRunning:u}=ir(n.taskReferenceName),{addForkBranch:c}=oe(),d=A.useUpdateNodeInternals(),f=n.task?.forkTasks?.length||0;O.useEffect(()=>{d(e)},[f,e,d]);const p=n.isDynamic||n.taskType==="FORK_JOIN_DYNAMIC",h=oe(v=>v.viewMode),m=O.useMemo(()=>He.find(v=>v.type==="FORK_JOIN"),[])?.icon||Gr;return l.jsx(kr,{isHighlighted:n.isHighlighted,nodeId:e,selected:r,isError:n.isError,hasWarning:n.hasWarning,executionStatus:i?.status,simRunning:n.simRunning,simDone:n.simDone,proposalStatus:n.proposalStatus,children:l.jsxs("div",{className:`fork-node ${p?"dynamic":"static"}`,style:{borderRadius:"8px",background:"var(--bg-secondary)",position:"relative"},children:[l.jsx(Xr,{icon:m,header:lr(p?"FORK_JOIN_DYNAMIC":"FORK_JOIN",h),title:n.taskReferenceName,meta:_r(n.taskType,n,h,p?"Dynamic Parallel Execution":"Parallel Execution"),color:Dh,status:i?.status,isRunning:u}),o==="edit"&&!p&&l.jsx("div",{style:{position:"absolute",...t==="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&&(n.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",[t==="LR"?"top":"left"]:`${j}%`,[t==="LR"?"left":"top"]:void 0,[t==="LR"?"right":"bottom"]:"-4px",zIndex:10}},`branch_${y}`)}),!p&&(!n.task?.forkTasks||n.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"}})]})})});Mh.displayName="ForkNode";const Wh=O.memo(({id:e,data:n,selected:r})=>{const{layoutDirection:t,sourcePosition:s,targetPosition:a}=Xe(n),{execution:o,isRunning:i}=ir(n.taskReferenceName),u=oe(f=>f.viewMode),d=O.useMemo(()=>He.find(f=>f.type==="JOIN"),[])?.icon||Vr;return l.jsx(kr,{isHighlighted:n.isHighlighted,nodeId:e,selected:r,isError:n.isError,hasWarning:n.hasWarning,executionStatus:o?.status,simRunning:n.simRunning,simDone:n.simDone,proposalStatus:n.proposalStatus,children:l.jsxs("div",{style:{borderRadius:"8px",background:"var(--bg-secondary)",position:"relative"},children:[l.jsx(Xr,{icon:d,header:lr(n.taskType==="EXCLUSIVE_JOIN"?"EXCLUSIVE_JOIN":"JOIN",u),title:n.taskReferenceName,meta:_r(n.taskType,n,u,n.taskType==="EXCLUSIVE_JOIN"?"Wait for any task":"Wait for tasks"),color:Dh,status:o?.status,isRunning:i}),l.jsx(A.Handle,{type:"target",position:a,style:{background:"#fff"}}),t==="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"}})]}),t==="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"}})]})})});Wh.displayName="JoinNode";const Bh={ForkNode:Mh,JoinNode:Wh},xx=({id:e,data:n,selected:r})=>{const{sourcePosition:t,targetPosition:s}=Xe(n),{execution:a,isRunning:o}=ir(n.taskReferenceName),{executionData:i,selectTaskAction:u,mode:c,viewMode:d,removeNode:f}=oe(),[p,h]=O.useState(!1),g=n.task,m=g?.loopOver||[],y=O.useMemo(()=>He.find(T=>T.type==="DO_WHILE"),[])?.icon||Ah,x=O.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(D=>(D.iteration??0)>0)&&(T=Math.max(T,S.attempts.length))}),T},[o,i,m]),b=n.loopCondition||g?.loopCondition||"",k=O.useMemo(()=>{const T=b?b.length>35?b.slice(0,35)+"…":b:"循环直到条件满足";return _r("DO_WHILE",n,d,T)},[n,d,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=r?`2px solid ${w}`:`1.5px dashed ${o&&a?.status?w:"var(--color-accent)"}`,N=c==="edit",L=d==="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:"×"}),n.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:"❗"}),!n.isError&&n.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:"⚠️"}),n.proposalStatus&&l.jsx("div",{className:`node-proposal-badge node-proposal-badge-${n.proposalStatus}`,style:{pointerEvents:"auto"},children:n.proposalStatus==="added"?"+":n.proposalStatus==="modified"?"~":"−"}),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:lr("DO_WHILE",d)}),l.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n.taskReferenceName}),(d==="business"||d==="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:()=>u(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:t,style:{background:"var(--color-accent)",zIndex:10}}),p&&l.jsx(Yr,{message:"确定要删除此循环任务吗?循环体内的任务也会一并删除。",onConfirm:()=>{f(e),h(!1)},onCancel:()=>h(!1)})]})},bx=O.memo(xx),kx="var(--color-accent)",_x=({id:e,data:n,selected:r})=>{const{sourcePosition:t,targetPosition:s}=Xe(n),{execution:a,isRunning:o}=ir(n.taskReferenceName),i=oe(p=>p.viewMode),c=O.useMemo(()=>He.find(p=>p.type==="SUB_WORKFLOW"),[])?.icon||Vr,d=n.task?.subWorkflowParam?.name||n.subWorkflowName||"Unknown",f=n.task?.subWorkflowParam?.version;return l.jsx(kr,{nodeId:e,selected:r,isError:n.isError,hasWarning:n.hasWarning,isHighlighted:n.isHighlighted,executionStatus:a?.status,simRunning:n.simRunning,simDone:n.simDone,proposalStatus:n.proposalStatus,children:l.jsxs("div",{style:{borderRadius:"8px",background:"var(--bg-secondary)",position:"relative"},children:[l.jsx(Xr,{icon:c,header:lr("SUB_WORKFLOW",i),title:n.taskReferenceName,meta:_r("SUB_WORKFLOW",n,i,`Flow: ${d} (v${f})`),color:kx,status:a?.status,isRunning:o}),l.jsx(A.Handle,{type:"target",position:s,style:{background:"#fff"}}),l.jsx(A.Handle,{type:"source",position:t,style:{background:"#fff"}})]})})},Sx=O.memo(_x),wx=({data:e})=>{const r=(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(ox,{size:16}),e.label&&e.label!=="+"&&l.jsx("span",{style:{fontSize:"12px",fontWeight:500},children:e.label}),l.jsx(A.Handle,{type:"target",position:r?A.Position.Left:A.Position.Top,style:{opacity:0}}),l.jsx("style",{dangerouslySetInnerHTML:{__html:`
|
|
10
13
|
.plus-node-container:hover {
|
|
11
14
|
transform: scale(1.1);
|
|
12
15
|
background: var(--color-accent);
|
|
@@ -14,21 +17,53 @@ execute($.input);`}):c.type==="DYNAMIC"?(c.dynamicTaskNameParam="taskToExecute",
|
|
|
14
17
|
border-style: solid;
|
|
15
18
|
box-shadow: 0 0 10px var(--color-accent);
|
|
16
19
|
}
|
|
17
|
-
`}})]})},
|
|
20
|
+
`}})]})},Tx=O.memo(wx),Ex=({data:e})=>{const{sourcePosition:n,targetPosition:r}=Xe(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(Gr,{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:r,style:{background:"var(--color-accent)",width:8,height:8}}),l.jsx(A.Handle,{type:"source",position:n,style:{background:"var(--color-accent)",width:8,height:8}})]})},Nx=O.memo(Ex),Cx=({onSelect:e,onCancel:n})=>{const[r,t]=O.useState("CORE");O.useEffect(()=>{const a=o=>{o.key==="Escape"&&n()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[n]);const s=He.filter(a=>a.category===r&&!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:n,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:ux.map(a=>l.jsx("button",{onClick:()=>t(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))})]}),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:n,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:`
|
|
18
21
|
@keyframes fadeIn {
|
|
19
22
|
from { opacity: 0; }
|
|
20
23
|
to { opacity: 1; }
|
|
21
24
|
}
|
|
22
|
-
`})]})},
|
|
25
|
+
`})]})},jx=()=>{const{executionData:e,loadSampleExecution:n,importExecutionJSON:r,workflowInstance:t,setSelectedTask:s,nodes:a}=oe(),{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);r(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:n,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 u=Object.values(e),c=u.filter(g=>g.status==="COMPLETED").length,d=u.filter(g=>g.status==="FAILED"||g.status==="FAILED_WITH_TERMINAL_ERROR"||g.status==="TIMED_OUT"),f=d.length,p=u.filter(g=>g.status==="IN_PROGRESS"||g.status==="SCHEDULED").length,h=O.useCallback(()=>{if(f===0)return;const g=new Set(d.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})},[d,a,o,f]);return l.jsxs("div",{className:"execution-status-bar",children:[t&&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:t.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:t?.status==="COMPLETED"?"var(--status-completed)":"var(--status-in-progress)"},children:t?.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"})})]})},Fh=({isOpen:e,onClose:n,theme:r="dark",onTaskSelect:t})=>{const{validationResults:s,setSelectedTask:a,taskMap:o}=oe(),{errors:i,warnings:u}=s||{errors:[],warnings:[]},c=g=>{if(g&&g!=="UNKNOWN"){const m=o[g];m&&(t?t(m):a(m))}},d="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:d,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:`
|
|
23
26
|
@keyframes fadeInSlide {
|
|
24
27
|
from { opacity: 0; transform: translateY(-10px); }
|
|
25
28
|
to { opacity: 1; transform: translateY(0); }
|
|
26
29
|
}
|
|
27
30
|
.health-item:hover {
|
|
28
|
-
background-color: ${
|
|
31
|
+
background-color: ${r==="light"?"#f1f5f9":"rgba(255,255,255,0.05)"};
|
|
29
32
|
}
|
|
30
|
-
`}),d.jsxs("div",{style:{padding:"16px",borderBottom:`1px solid ${p}`,display:"flex",justifyContent:"space-between",alignItems:"center",backgroundColor:"rgba(0,0,0,0.02)"},children:[d.jsxs("div",{style:{fontWeight:"bold",fontSize:"14px",display:"flex",alignItems:"center",gap:"8px"},children:[d.jsx("span",{children:"🩺"})," 工作流体检报告"]}),d.jsx("button",{onClick:r,style:{background:"none",border:"none",color:h,cursor:"pointer",fontSize:"18px"},children:"✕"})]}),d.jsx("div",{style:{flex:1,overflowY:"auto",padding:"8px"},children:s.length===0&&l.length===0?d.jsxs("div",{style:{padding:"32px 16px",textAlign:"center",color:"#10b981"},children:[d.jsx("div",{style:{fontSize:"32px",marginBottom:"12px"},children:"✅"}),d.jsx("div",{style:{fontWeight:"bold"},children:"未发现问题"}),d.jsx("div",{style:{fontSize:"12px",opacity:.7,marginTop:"4px"},children:"工作流逻辑看起来很完美"})]}):d.jsxs(d.Fragment,{children:[s.map((g,v)=>d.jsxs("div",{className:"health-item",role:"button",tabIndex:g.ref?0:void 0,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&u(g.ref)},onClick:()=>u(g.ref),style:{padding:"12px",borderRadius:"8px",marginBottom:"4px",cursor:g.ref?"pointer":"default",borderLeft:"4px solid #ef4444",transition:"background 0.2s"},children:[d.jsxs("div",{style:{fontSize:"12px",color:"#ef4444",fontWeight:"bold",marginBottom:"2px"},children:["ERROR ",g.ref!=="UNKNOWN"&&`[${g.ref}]`]}),d.jsx("div",{style:{fontSize:"13px",color:f},children:g.message})]},`err-${v}`)),l.map((g,v)=>d.jsxs("div",{className:"health-item",role:"button",tabIndex:g.ref?0:void 0,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&u(g.ref)},onClick:()=>u(g.ref),style:{padding:"12px",borderRadius:"8px",marginBottom:"4px",cursor:g.ref?"pointer":"default",borderLeft:"4px solid #f59e0b",transition:"background 0.2s"},children:[d.jsxs("div",{style:{fontSize:"12px",color:"#f59e0b",fontWeight:"bold",marginBottom:"2px"},children:["WARNING ",g.ref!=="UNKNOWN"&&`[${g.ref}]`]}),d.jsx("div",{style:{fontSize:"13px",color:f},children:g.message})]},`warn-${v}`))]})}),d.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:[d.jsxs("span",{children:["共 ",s.length," 个错误, ",l.length," 个警告"]}),s.length>0&&d.jsx("span",{style:{color:"#ef4444"},children:"无法保存/导出"})]})]}):null},vx=({id:e,source:r,target:t,sourceX:n,sourceY:o,targetX:a,targetY:i,sourcePosition:s,targetPosition:l,style:u={},markerEnd:c,data:f})=>{const[p,h]=q.useState(!1),g=q.useRef(null),v=()=>{const N=f?.edgeType||"default",A={sourceX:n,sourceY:o,sourcePosition:s,targetX:a,targetY:i,targetPosition:l};switch(N){case"step":case"smoothstep":return O.getSmoothStepPath(A);case"straight":return O.getStraightPath(A);default:return O.getBezierPath(A)}},[m,x,y]=v(),b=N=>{N.stopPropagation(),N.preventDefault();const A=new CustomEvent("edgeAddNode",{detail:{id:e,source:r,target:t,edgeData:f}});window.dispatchEvent(A)},k=()=>{g.current&&clearTimeout(g.current),h(!0)},S=()=>{g.current=setTimeout(()=>{h(!1)},100)},C=f?.mode==="edit";return d.jsxs(d.Fragment,{children:[d.jsx(O.BaseEdge,{path:m,markerEnd:c,style:{...u,strokeWidth:p?4:2,stroke:p?"#fbbf24":u?.stroke,transition:"stroke 0.2s, stroke-width 0.2s",pointerEvents:"none"}}),d.jsx("path",{d:m,fill:"none",stroke:"transparent",strokeWidth:20,style:{cursor:C?"pointer":"default",pointerEvents:"all"},onMouseEnter:k,onMouseLeave:S}),C&&p&&d.jsx(O.EdgeLabelRenderer,{children:d.jsxs("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${x}px,${y}px)`,fontSize:12,pointerEvents:"all",zIndex:2e3,display:"flex",flexDirection:"column",alignItems:"center"},className:"nodrag nopan",onMouseEnter:k,onMouseLeave:S,children:[f?.label&&d.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}),d.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:"+"})]})})]})},Pe=({onClick:e,icon:r,label:t,title:n,disabled:o=!1,active:a=!1,variant:i="default",style:s})=>{let l="var(--bg-tertiary)",u="var(--text-primary)",c="1px solid var(--border-primary)";return i==="primary"?(l="var(--color-accent)",u="#fff",c="none"):i==="danger"?(l=o?"rgba(239, 68, 68, 0.1)":"var(--status-failed)",u=o?"var(--text-secondary)":"#fff",c="none"):a&&(l="var(--bg-secondary)",u="var(--color-accent)",c="1px solid var(--color-accent)"),d.jsxs("button",{onClick:e,disabled:o,title:n,"aria-label":n||t,"aria-pressed":a,"aria-disabled":o,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:t?"6px":"0",background:l,color:u,border:c,borderRadius:"6px",padding:t?"6px 12px":"8px",cursor:o?"not-allowed":"pointer",opacity:o?.5:1,fontSize:"13px",fontWeight:500,transition:"all 0.2s",minWidth:t?"auto":"32px",height:"32px",boxShadow:i==="default"?"0 1px 2px rgba(0,0,0,0.05)":"none",...s},children:[r&&d.jsx("span",{style:{fontSize:"14px",display:"flex"},children:r}),t&&d.jsx("span",{children:t})]})},mx=()=>{const{zoomIn:e,zoomOut:r,fitView:t}=O.useReactFlow();return d.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"10px"},children:d.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:[d.jsx(Pe,{icon:"➕",title:"放大",onClick:()=>e()}),d.jsx(Pe,{icon:"➖",title:"缩小",onClick:()=>r()}),d.jsx(Pe,{icon:"⤢",title:"适应屏幕",onClick:()=>t({duration:600})})]})})},yx=({onShowHealthCheck:e,showHealthCheck:r,onShowSettings:t,executionActions:n})=>{const{mode:o,validationResults:a,workflowInstance:i,workflowDef:s}=oe(),l=oe.temporal,{undo:u,redo:c,pastStates:f,futureStates:p}=Vr(l,w=>w),[h,g]=q.useState(!1),v=q.useRef(null);q.useEffect(()=>{if(!h)return;const w=I=>{v.current&&!v.current.contains(I.target)&&g(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[h]);const m=(a?.errors?.length||0)>0,x=i?.status,y=i?.workflowId??"",b=x==="RUNNING",k=x==="PAUSED",S=x==="FAILED"||x==="TIMED_OUT"||x==="TERMINATED",C=x==="COMPLETED",N=s?.restartable===!0&&(S||C),A=n?.allowOperations!==!1;return d.jsxs("div",{className:"action-bar",style:{display:"flex",gap:"8px",alignItems:"center"},children:[o==="edit"&&d.jsxs(d.Fragment,{children:[d.jsx(Pe,{icon:"↺",title:"撤销 (Cmd+Z)",onClick:()=>u(),disabled:f.length===0}),d.jsx(Pe,{icon:"↻",title:"重做 (Cmd+Shift+Z)",onClick:()=>c(),disabled:p.length===0}),d.jsx("div",{style:{width:"1px",height:"20px",background:"var(--border-primary)",margin:"0 4px",alignSelf:"center"}}),d.jsx(Pe,{icon:"🩺",label:m?`错误 (${a.errors.length})`:"诊断",title:"流程健康检查",onClick:e,active:r,variant:m?"danger":"secondary"}),d.jsx(Pe,{icon:"⚙️",label:"配置",title:"工作流全局配置",onClick:()=>t?.()})]}),o==="run"&&i&&n&&d.jsxs(d.Fragment,{children:[k&&n.onResume&&d.jsx(Pe,{icon:d.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:d.jsx("path",{d:"M4 3l9 5-9 5z"})}),label:"继续",title:A?"继续执行工作流":"操作权限受限",onClick:()=>A&&n.onResume(y),disabled:!A,variant:"primary"}),b&&n.onPause&&d.jsx(Pe,{icon:d.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:[d.jsx("rect",{x:"4",y:"3",width:"3",height:"10",rx:"1"}),d.jsx("rect",{x:"9",y:"3",width:"3",height:"10",rx:"1"})]}),label:"暂停",title:A?"暂停工作流执行":"操作权限受限",onClick:()=>A&&n.onPause(y),disabled:!A}),(b||k)&&n.onTerminate&&d.jsx(Pe,{icon:d.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:d.jsx("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"})}),label:"终止",title:A?"终止工作流执行":"操作权限受限",onClick:()=>A&&n.onTerminate(y),disabled:!A,variant:"danger"}),S&&n.onRetry&&d.jsx(Pe,{icon:d.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[d.jsx("path",{d:"M13 2v4h-4"}),d.jsx("path",{d:"M13 6A7 7 0 1 1 9.5 2.5"})]}),label:"重试",title:A?"重试失败的工作流":"操作权限受限",onClick:()=>A&&n.onRetry(y),disabled:!A,variant:"primary"}),N&&n.onRestart&&d.jsxs("div",{ref:v,style:{position:"relative",display:"flex"},children:[d.jsxs("button",{disabled:!A,onClick:()=>A&&n.onRestart(y,{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:[d.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[d.jsx("path",{d:"M3 14v-4h4"}),d.jsx("path",{d:"M3 10A7 7 0 1 1 6.5 13.5"})]}),"重启"]}),d.jsx("button",{disabled:!A,onClick:()=>A&&g(w=>!w),title:A?"展开重启版本选项":"操作权限受限",style:{display:"flex",alignItems:"center",justifyContent:"center",background:A&&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:A?"pointer":"not-allowed",opacity:A?1:.5,height:"32px",width:"22px",fontSize:"10px"},children:d.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",children:d.jsx("path",{d:"M1 3l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",fill:"none"})})}),h&&d.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:[d.jsx("div",{style:{padding:"6px 12px 4px",fontSize:"11px",color:"var(--text-secondary)",fontWeight:600,letterSpacing:"0.5px",textTransform:"uppercase"},children:"选择版本"}),d.jsxs("button",{onClick:()=>{n.onRestart(y,{useLatestDef:!0}),g(!1)},style:Ph,onMouseEnter:w=>w.currentTarget.style.background="var(--bg-secondary)",onMouseLeave:w=>w.currentTarget.style.background="transparent",children:[d.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[d.jsx("circle",{cx:"8",cy:"8",r:"6"}),d.jsx("path",{d:"M8 5v3l2 1"})]}),d.jsxs("div",{children:[d.jsx("div",{style:{fontWeight:600,fontSize:"13px"},children:"当前版本"}),d.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:"使用最新工作流定义"})]})]}),d.jsxs("button",{onClick:()=>{n.onRestart(y,{useLatestDef:!1}),g(!1)},style:Ph,onMouseEnter:w=>w.currentTarget.style.background="var(--bg-secondary)",onMouseLeave:w=>w.currentTarget.style.background="transparent",children:[d.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[d.jsx("rect",{x:"3",y:"2",width:"10",height:"12",rx:"1"}),d.jsx("path",{d:"M6 6h4M6 9h3"})]}),d.jsxs("div",{children:[d.jsx("div",{style:{fontWeight:600,fontSize:"13px"},children:"执行版本"}),d.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:"使用本次运行时的定义"})]})]})]})]})]})]})},Ph={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"},xx=[{id:"basic",label:"基本信息"},{id:"timeout",label:"超时与容错"},{id:"params",label:"参数配置"},{id:"advanced",label:"高级设置"}],bx=({isOpen:e,onClose:r})=>{const{workflowDef:t,updateWorkflowProperties:n,mode:o}=oe(),[a,i]=q.useState(t),[s,l]=q.useState("basic"),u=o!=="edit";q.useEffect(()=>{t&&i(t)},[t,e]);const c=q.useCallback(D=>{D.key==="Escape"&&r()},[r]);if(q.useEffect(()=>{if(e)return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[e,c]),!e||!a)return null;const f="var(--text-primary)",p="var(--glass-border)",h="var(--bg-tertiary)",g="var(--text-secondary)",v=(D,L)=>{if(!a||u)return;const F={...a,[D]:L};i(F),n({[D]:L})},m=(D,L,F)=>{if(!a||u)return;const V={...a[D]||{},[L]:F};i(Z=>({...Z,[D]:V})),n({[D]:V})},x=(D,L)=>{if(!(!a||u))try{const F=JSON.parse(L),W={...a,[D]:F};i(W),n({[D]:F})}catch{i(F=>({...F,[`_${D}_str`]:L}))}},y={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=(D,L,F="text",W)=>d.jsxs("div",{style:{marginBottom:"20px"},children:[d.jsx("label",{style:b,children:D.toUpperCase()}),d.jsx("input",{className:"wsp-input",type:F,value:a?.[L]??"",onChange:V=>v(L,F==="number"?V.target.value===""?0:parseInt(V.target.value):V.target.value),disabled:u||W?.readOnly,placeholder:W?.placeholder,style:{...y,opacity:u||W?.readOnly?.6:1}})]}),S=(D,L,F=!1,W=6)=>{const V=a?.[`_${L}_str`]!==void 0?a[`_${L}_str`]:typeof a?.[L]=="object"?JSON.stringify(a[L],null,2):a?.[L];return d.jsxs("div",{style:{marginBottom:"20px"},children:[d.jsxs("label",{style:b,children:[D.toUpperCase()," ",F&&"(JSON)"]}),d.jsx("textarea",{className:"wsp-input",value:V||"",onChange:Z=>F?x(L,Z.target.value):v(L,Z.target.value),rows:W,disabled:u,style:{...y,fontSize:"13px",fontFamily:F?"var(--font-mono)":"inherit",resize:"vertical",opacity:u?.6:1}})]})},C=(D,L,F)=>d.jsxs("div",{style:{marginBottom:"20px"},children:[d.jsx("label",{style:b,children:D.toUpperCase()}),d.jsx("select",{className:"wsp-input",value:a?.[L]??F[0]?.value,onChange:W=>v(L,W.target.value),disabled:u,style:{...y,opacity:u?.6:1,cursor:u?"not-allowed":"pointer"},children:F.map(W=>d.jsx("option",{value:W.value,children:W.label},W.value))})]}),N=(D,L)=>{const F=!!a?.[L];return d.jsxs("div",{style:{marginBottom:"20px",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[d.jsx("label",{style:{fontSize:"13px",color:f},children:D}),d.jsx("button",{type:"button",role:"switch","aria-checked":F,onClick:()=>!u&&v(L,!F),disabled:u,style:{width:"44px",height:"24px",borderRadius:"12px",border:"none",background:F?"var(--color-accent)":"var(--border-primary)",position:"relative",cursor:u?"not-allowed":"pointer",transition:"background 0.2s",opacity:u?.6:1,flexShrink:0},children:d.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)"}})})]})},A=()=>d.jsxs(d.Fragment,{children:[d.jsxs("div",{style:{display:"grid",gridTemplateColumns:"3fr 1fr",gap:"20px"},children:[k("工作流名称","name"),k("版本号","version","number")]}),S("描述信息","description",!1,3),k("负责人邮箱","ownerEmail","text",{placeholder:"owner@example.com"}),k("Schema 版本","schemaVersion","number",{readOnly:!0})]}),w=()=>d.jsxs(d.Fragment,{children:[C("超时策略","timeoutPolicy",[{value:"ALERT_ONLY",label:"ALERT_ONLY — 仅告警"},{value:"TIME_OUT_WF",label:"TIME_OUT_WF — 超时终止"}]),d.jsxs("div",{children:[k("超时秒数","timeoutSeconds","number",{placeholder:"0 表示不超时"}),a?.timeoutPolicy==="ALERT_ONLY"&&d.jsx("p",{style:{fontSize:"11px",color:g,marginTop:"-12px",marginBottom:"20px"},children:"当前策略为 ALERT_ONLY,超时仅触发告警,不会终止工作流。"})]}),k("失败补偿工作流","failureWorkflow","text",{placeholder:"输入补偿工作流名称"}),N("允许重启 (restartable)","restartable")]}),I=()=>d.jsxs(d.Fragment,{children:[S("输入参数声明 (inputParameters)","inputParameters",!0),S("输出参数映射 (outputParameters)","outputParameters",!0),S("默认输入模板 (inputTemplate)","inputTemplate",!0),S("工作流级变量 (variables)","variables",!0)]}),R=()=>d.jsxs(d.Fragment,{children:[N("启用状态监听 (workflowStatusListenerEnabled)","workflowStatusListenerEnabled"),a?.workflowStatusListenerEnabled&&k("状态事件目标 (Listener Sink)","workflowStatusListenerSink","text",{placeholder:"conductor:workflow_status_event"}),d.jsxs("div",{style:{borderTop:`1px solid ${p}`,marginTop:"8px",paddingTop:"20px"},children:[N("强制 Schema 校验 (enforceSchema)","enforceSchema"),a?.enforceSchema&&d.jsxs(d.Fragment,{children:[S("输入 Schema (inputSchema)","inputSchema",!0,4),S("输出 Schema (outputSchema)","outputSchema",!0,4)]})]}),d.jsxs("div",{style:{borderTop:`1px solid ${p}`,marginTop:"8px",paddingTop:"20px"},children:[d.jsx("label",{style:{...b,marginBottom:"16px"},children:"并发限流 (RATE LIMIT)"}),d.jsxs("div",{style:{display:"grid",gridTemplateColumns:"2fr 1fr",gap:"20px"},children:[d.jsxs("div",{children:[d.jsx("label",{style:b,children:"RATE LIMIT KEY"}),d.jsx("input",{className:"wsp-input",type:"text",value:a?.rateLimitConfig?.rateLimitKey??"",onChange:D=>m("rateLimitConfig","rateLimitKey",D.target.value),disabled:u,placeholder:"限流键",style:{...y,opacity:u?.6:1}})]}),d.jsxs("div",{children:[d.jsx("label",{style:b,children:"并发上限"}),d.jsx("input",{className:"wsp-input",type:"number",value:a?.rateLimitConfig?.concurrentExecLimit??"",onChange:D=>m("rateLimitConfig","concurrentExecLimit",D.target.value===""?0:parseInt(D.target.value)),disabled:u,placeholder:"0",style:{...y,opacity:u?.6:1}})]})]})]})]}),B=()=>{switch(s){case"basic":return A();case"timeout":return w();case"params":return I();case"advanced":return R()}};return d.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:d.jsxs("div",{onClick:D=>D.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:[d.jsxs("div",{style:{padding:"24px 32px 0 32px",background:"var(--bg-highlight)"},children:[d.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px"},children:[d.jsxs("div",{children:[d.jsx("h2",{style:{margin:0,fontSize:"20px",color:f},children:"工作流全局配置"}),d.jsx("p",{style:{margin:"4px 0 0 0",fontSize:"12px",color:g},children:u?"当前为只读模式":"配置工作流级属性,所有更改将实时保存"})]}),d.jsx("button",{className:"wsp-close",onClick:r,"aria-label":"关闭",style:{background:"none",border:"none",color:f,fontSize:"24px",cursor:"pointer",opacity:.6},children:"✕"})]}),d.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${p}`},children:xx.map(D=>d.jsx("button",{className:"wsp-tab",onClick:()=>l(D.id),style:{padding:"10px 20px",fontSize:"13px",fontWeight:s===D.id?600:400,color:s===D.id?"var(--color-accent)":g,background:"none",border:"none",borderBottom:s===D.id?"2px solid var(--color-accent)":"2px solid transparent",cursor:"pointer",transition:"all 0.2s",marginBottom:"-1px"},children:D.label},D.id))})]}),d.jsx("div",{style:{flex:1,overflowY:"auto",padding:"28px 32px"},children:B()}),d.jsx("div",{style:{padding:"20px 32px",borderTop:`1px solid ${p}`,background:"var(--bg-highlight)",display:"flex",justifyContent:"flex-end"},children:d.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:"完成并关闭"})})]})})},kx=({onRequestImport:e})=>{const{createBlankWorkflow:r}=oe(),[t,n]=q.useState(""),o=()=>{r(t||void 0),oe.temporal.getState().clear()},a=()=>{r(t||void 0),oe.temporal.getState().clear(),window.dispatchEvent(new CustomEvent("open-ai-chat"))};return d.jsxs("div",{className:"empty-state-panel",children:[d.jsx("h2",{className:"empty-state-title",children:"创建新工作流"}),d.jsx("p",{className:"empty-state-subtitle",children:"从空白画布开始设计,或让 AI 帮你生成完整流程"}),d.jsx("input",{className:"empty-state-name-input",type:"text",placeholder:"工作流名称(可选)",value:t,onChange:i=>n(i.target.value),onKeyDown:i=>{i.key==="Enter"&&o()}}),d.jsxs("div",{className:"empty-state-actions",children:[d.jsxs("button",{className:"empty-state-btn primary",onClick:o,children:[d.jsx("span",{className:"empty-state-btn-icon",children:"📄"}),"空白工作流"]}),d.jsxs("button",{className:"empty-state-btn",onClick:a,children:[d.jsx("span",{className:"empty-state-btn-icon",children:"✨"}),"AI 生成"]}),e&&d.jsxs("button",{className:"empty-state-btn",onClick:e,children:[d.jsx("span",{className:"empty-state-btn-icon",children:"📤"}),"导入 JSON"]})]})]})},_x={success:{bg:"#10b981",text:"#fff"},error:{bg:"#ef4444",text:"#fff"},info:{bg:"var(--color-accent)",text:"#fff"}},Sx=({messages:e,onDismiss:r})=>e.length===0?null:d.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=>d.jsx(wx,{message:t,onDismiss:r},t.id))}),wx=({message:e,onDismiss:r})=>{const t=_x[e.type||"info"];return q.useEffect(()=>{const n=setTimeout(()=>r(e.id),2500);return()=>clearTimeout(n)},[e.id,r]),d.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})},Ah=["shift","alt","meta","mod","ctrl","control"],Tx={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 ze(e){return(Tx[e.trim()]||e.trim()).toLowerCase().replace(/key|digit|numpad/,"")}function qh(e){return Ah.includes(e)}function Ws(e,r=","){return e.toLowerCase().split(r)}function Bs(e,r="+",t=">",n=!1,o){let a=[],i=!1;e=e.trim(),e.includes(t)?(i=!0,a=e.toLocaleLowerCase().split(t).map(u=>ze(u))):a=e.toLocaleLowerCase().split(r).map(u=>ze(u));const s={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},l=a.filter(u=>!Ah.includes(u));return{...s,keys:l,description:o,isSequence:i,hotkey:e}}typeof document<"u"&&(document.addEventListener("keydown",e=>{e.code!==void 0&&Lh([ze(e.code)])}),document.addEventListener("keyup",e=>{e.code!==void 0&&Dh([ze(e.code)])})),typeof window<"u"&&(window.addEventListener("blur",()=>{We.clear()}),window.addEventListener("contextmenu",()=>{setTimeout(()=>{We.clear()},0)}));const We=new Set;function Fs(e){return Array.isArray(e)}function Ex(e,r=","){return(Fs(e)?e:e.split(r)).every(t=>We.has(t.trim().toLowerCase()))}function Lh(e){const r=Array.isArray(e)?e:[e];We.has("meta")&&We.forEach(t=>!qh(t)&&We.delete(t.toLowerCase())),r.forEach(t=>We.add(t.toLowerCase()))}function Dh(e){const r=Array.isArray(e)?e:[e];e==="meta"?We.clear():r.forEach(t=>We.delete(t.toLowerCase()))}function Nx(e,r,t){(typeof t=="function"&&t(e,r)||t===!0)&&e.preventDefault()}function Cx(e,r,t){return typeof t=="function"?t(e,r):t===!0||t===void 0}const Ix=["input","textarea","select","searchbox","slider","spinbutton","menuitem","menuitemcheckbox","menuitemradio","option","radio","textbox"];function Rx(e){return Mh(e,Ix)}function Mh(e,r=!1){const{target:t,composed:n}=e;let o,a;return jx(t)&&n?(o=e.composedPath()[0]&&e.composedPath()[0].tagName,a=e.composedPath()[0]&&e.composedPath()[0].role):(o=t&&t.tagName,a=t&&t.role),Fs(r)?!!(o&&r&&r.some(i=>i.toLowerCase()===o.toLowerCase()||i===a)):!!(o&&r&&r)}function jx(e){return!!e.tagName&&!e.tagName.startsWith("-")&&e.tagName.includes("-")}function Ox(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 Px=(e,r,t=!1)=>{const{alt:n,meta:o,mod:a,shift:i,ctrl:s,keys:l,useKey:u}=r,{code:c,key:f,ctrlKey:p,metaKey:h,shiftKey:g,altKey:v}=e,m=ze(c);if(u&&l?.length===1&&l.includes(f))return!0;if(!l?.includes(m)&&!["ctrl","control","unknown","meta","alt","shift","os"].includes(m))return!1;if(!t){if(n!==v&&m!=="alt"||i!==g&&m!=="shift")return!1;if(a){if(!h&&!p)return!1}else if(o!==h&&m!=="meta"&&m!=="os"||s!==p&&m!=="ctrl"&&m!=="control")return!1}return l&&l.length===1&&l.includes(m)?!0:l?Ex(l):!l},Ax=q.createContext(void 0),qx=()=>q.useContext(Ax);function Wh(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&&Wh(e[n],r[n]),!0):e===r}const Lx=q.createContext({hotkeys:[],activeScopes:[],toggleScope:()=>{},enableScope:()=>{},disableScope:()=>{}}),Dx=()=>q.useContext(Lx);function Mx(e){const r=q.useRef(void 0);return Wh(r.current,e)||(r.current=e),r.current}const Bh=e=>{e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation()},Wx=typeof window<"u"?q.useLayoutEffect:q.useEffect;function sr(e,r,t,n){const o=q.useRef(null),a=q.useRef(!1),i=Array.isArray(t)?Array.isArray(n)?void 0:n:t,s=Fs(e)?e.join(i?.delimiter):e,l=Array.isArray(t)?t:Array.isArray(n)?n:void 0,u=q.useCallback(r,l??[]),c=q.useRef(u);l?c.current=u:c.current=r;const f=Mx(i),{activeScopes:p}=Dx(),h=qx();return Wx(()=>{if(f?.enabled===!1||!Ox(p,f?.scopes))return;let g=[],v;const m=(k,S=!1)=>{if(!(Rx(k)&&!Mh(k,f?.enableOnFormTags))){if(o.current!==null){const C=o.current.getRootNode();if((C instanceof Document||C instanceof ShadowRoot)&&C.activeElement!==o.current&&!o.current.contains(C.activeElement)){Bh(k);return}}k.target?.isContentEditable&&!f?.enableOnContentEditable||Ws(s,f?.delimiter).forEach(C=>{if(C.includes(f?.splitKey??"+")&&C.includes(f?.sequenceSplitKey??">")){console.warn(`Hotkey ${C} contains both ${f?.splitKey??"+"} and ${f?.sequenceSplitKey??">"} which is not supported.`);return}const N=Bs(C,f?.splitKey,f?.sequenceSplitKey,f?.useKey,f?.description);if(N.isSequence){v=setTimeout(()=>{g=[]},f?.sequenceTimeoutMs??1e3);const A=N.useKey?k.key:ze(k.code);if(qh(A.toLowerCase()))return;g.push(A);const w=N.keys?.[g.length-1];if(A!==w){g=[],v&&clearTimeout(v);return}g.length===N.keys?.length&&(c.current(k,N),v&&clearTimeout(v),g=[])}else if(Px(k,N,f?.ignoreModifiers)||N.keys?.includes("*")){if(f?.ignoreEventWhen?.(k)||S&&a.current)return;if(Nx(k,N,f?.preventDefault),!Cx(k,N,f?.enabled)){Bh(k);return}c.current(k,N),S||(a.current=!0)}})}},x=k=>{k.code!==void 0&&(Lh(ze(k.code)),(f?.keydown===void 0&&f?.keyup!==!0||f?.keydown)&&m(k))},y=k=>{k.code!==void 0&&(Dh(ze(k.code)),a.current=!1,f?.keyup&&m(k,!0))},b=o.current||i?.document||document;return b.addEventListener("keyup",y,i?.eventListenerOptions),b.addEventListener("keydown",x,i?.eventListenerOptions),h&&Ws(s,f?.delimiter).forEach(k=>h.addHotkey(Bs(k,f?.splitKey,f?.sequenceSplitKey,f?.useKey,f?.description))),()=>{b.removeEventListener("keyup",y,i?.eventListenerOptions),b.removeEventListener("keydown",x,i?.eventListenerOptions),h&&Ws(s,f?.delimiter).forEach(k=>h.removeHotkey(Bs(k,f?.splitKey,f?.sequenceSplitKey,f?.useKey,f?.description))),g=[],v&&clearTimeout(v)}},[s,f,p]),o}const Bx=e=>{const{mode:r,removeNode:t,selectedTask:n,pasteTask:o}=oe(),a=oe.temporal,{undo:i,redo:s}=Vr(a,p=>p),l=e?.confirm||(p=>Promise.resolve(window.confirm(p))),u=e?.showToast,c=p=>{const h=p.target;return h.tagName==="INPUT"||h.tagName==="TEXTAREA"||h.isContentEditable},f=()=>{requestAnimationFrame(()=>{const p=oe.getState(),{nodes:h,edges:g}=be(p.nodes,p.edges,{direction:p.layoutDirection,mode:p.mode});oe.setState({nodes:h,edges:g})})};return sr("mod+z",p=>{r==="edit"&&(c(p)||(p.preventDefault(),i(),f()))},[r,i]),sr(["mod+shift+z","mod+y"],p=>{r==="edit"&&(c(p)||(p.preventDefault(),s(),f()))},[r,s]),sr("delete, backspace",p=>{r!=="edit"||!n||c(p)||(p.preventDefault(),l("确定要删除此任务吗?").then(h=>{h&&t(n.taskReferenceName)}))},[r,n,t,l]),sr("mod+c",p=>{if(!(r!=="edit"||!n)&&!c(p)){if(n.type==="JOIN"){u?.("JOIN 任务不能独立复制","error");return}p.preventDefault();try{localStorage.setItem("conductor-clipboard",JSON.stringify(n)),u?.("任务已复制","success")}catch{u?.("复制失败","error")}}},[r,n,u]),sr("mod+v",p=>{if(r==="edit"&&!c(p)){p.preventDefault();try{const h=localStorage.getItem("conductor-clipboard");if(h){const g=JSON.parse(h);o(g),u?.("任务已粘贴","success")}}catch{u?.("粘贴失败","error")}}},[r,o,u]),sr("mod+s",p=>{p.preventDefault();const h=oe.getState().workflowDef;h&&e?.onSave&&e.onSave(h)},[e?.onSave]),{}},Fx=()=>{const[e,r]=q.useState(null),t=q.useCallback(a=>new Promise(i=>{r({message:a,resolve:i})}),[]),n=q.useCallback(()=>{e?.resolve(!0),r(null)},[e]),o=q.useCallback(()=>{e?.resolve(!1),r(null)},[e]);return{confirm:t,confirmState:e,handleConfirm:n,handleCancel:o}},zx=()=>{const[e,r]=q.useState([]),t=q.useCallback((o,a="info")=>{const i=Date.now().toString();r(s=>[...s,{id:i,text:o,type:a}])},[]),n=q.useCallback(o=>{r(a=>a.filter(i=>i.id!==o))},[]);return{toasts:e,showToast:t,dismissToast:n}},$x={taskNode:tx,decisionNode:ax,forkNode:jh.ForkNode,joinNode:jh.JoinNode,loopNode:ix,subWorkflowNode:ux,plusNode:dx,dynamicPlaceholderNode:px},Hx={addableEdge:vx},Kx=({onNodeClick:e,searchQuery:r="",onSave:t,onRequestImport:n,executionActions:o})=>{const{nodes:a,edges:i,onNodesChange:s,onEdgesChange:l,onConnect:u,mode:c,viewMode:f,selectedTask:p,setSelectedTask:h,theme:g,edgeType:v,addNode:m,nodesLocked:x,executionData:y,validationResults:b,setIsDetailPanelOpen:k,workflowDef:S,dynamicRuntimeTasksByFork:C,layoutDirection:N,simState:A,workflowLoadKey:w}=oe(),I=q.useMemo(()=>{if(c==="run"||c==="edit")return new Set(a.map(J=>J.id));const ne=Xy[f],G=new Set;return a.forEach(J=>{if(J.type==="plusNode"||J.type==="dynamicPlaceholderNode"){G.add(J.id);return}if(J.parentId)return;const $=Ge.find(X=>X.type===J.data.taskType)?.viewCategory??"business";ne.includes($)&&G.add(J.id)}),a.forEach(J=>{J.parentId&&G.has(J.parentId)&&G.add(J.id)}),G},[a,f,c]),R=q.useCallback(ne=>{if(I.size===a.length)return ne;const G={};ne.forEach($=>{G[$.source]||(G[$.source]=[]),G[$.source].push($)});const J=[],H=new Set;return ne.forEach($=>{if(!I.has($.source))return;if(I.has($.target)){const ue=`${$.source}->${$.target}`;H.has(ue)||(H.add(ue),J.push($));return}const X=[{to:$.target,label:$.label}],de=new Set;for(;X.length;){const ue=X.shift();if(!de.has(ue.to)){if(de.add(ue.to),I.has(ue.to)){const he=`${$.source}->${ue.to}`;H.has(he)||(H.add(he),J.push({...$,id:he,target:ue.to,label:ue.label??$.label}));continue}(G[ue.to]??[]).forEach(he=>X.push({to:he.target,label:ue.label??he.label}))}}}),J},[I,a.length]),{fitView:B}=O.useReactFlow(),[D,L]=q.useState(!1),[F,W]=q.useState(null),[V,Z]=q.useState(!1),[le,se]=q.useState(!1),{confirm:_,confirmState:Y,handleConfirm:K,handleCancel:E}=Fx(),{toasts:j,showToast:M,dismissToast:P}=zx();Bx({confirm:_,showToast:M,onSave:t}),q.useEffect(()=>{if(p){const ne=a.find(G=>G.data.taskReferenceName===p.taskReferenceName);ne&&B({nodes:[ne],duration:800,padding:.5})}},[p?.taskReferenceName,B]),q.useEffect(()=>{const ne=()=>{B({duration:800})};return window.addEventListener("workflow-zoom-to-fit",ne),()=>window.removeEventListener("workflow-zoom-to-fit",ne)},[B]),q.useEffect(()=>{if(w===0)return;const ne=setTimeout(()=>{B({duration:600,padding:.12})},50);return()=>clearTimeout(ne)},[w,B]),q.useEffect(()=>{const ne=H=>{e&&H.detail&&H.detail.task&&e(H.detail.task)},G=H=>{if(c==="edit"){const{loopId:$,afterRef:X}=H.detail;W(X?{sourceId:X,edgeData:{}}:{sourceId:$,edgeData:{isLoopAdd:!0}}),L(!0)}},J=H=>{c==="edit"&&(W({sourceId:H.detail.source,targetId:H.detail.target,edgeId:H.detail.id,edgeData:H.detail.edgeData}),L(!0))};return document.addEventListener("miniTaskClick",ne),document.addEventListener("loopAddNodeRequested",G),window.addEventListener("edgeAddNode",J),()=>{document.removeEventListener("miniTaskClick",ne),document.removeEventListener("loopAddNodeRequested",G),window.removeEventListener("edgeAddNode",J)}},[c,e]);const z=q.useCallback(ne=>{if(F){const{sourceId:G,targetId:J,edgeId:H,edgeData:$}=F;m({data:{label:`New ${ne}`,taskReferenceName:`${ne.toLowerCase()}_${Date.now()}`,taskType:ne}},G,J,H,$)}L(!1),W(null)},[F,m]),ee=q.useMemo(()=>{const ne={extraNodes:[],extraEdges:[],removedEdgeIds:new Set,removedNodeIds:new Set};if(c!=="run")return ne;const G=a.filter(U=>U.type==="forkNode"&&U.data.taskType==="FORK_JOIN_DYNAMIC");if(!G.length)return ne;const J=[],H=[],$=new Set,X=new Set,de=N==="LR",ue=47,he=120,T={animated:!0,style:{stroke:"#10b981",strokeDasharray:"4,4"},markerEnd:{type:O.MarkerType.ArrowClosed,color:"#10b981"}};for(const U of G){const Q=C[U.id]||[],te=`${U.id}_dynamic_placeholder`,re=a.find(fe=>fe.id===te),ge=i.find(fe=>fe.target===te),ve=i.find(fe=>fe.source===te);let ce,ye;if(ve)ce=ve.target,ye=a.find(fe=>fe.id===ce);else{const fe=a.indexOf(U);if(ye=a.slice(fe).find(Ie=>Ie.type==="joinNode"),!ye)continue;ce=ye.id}if(!ye||(ve&&$.add(ve.id),ge&&$.add(ge.id),X.add(te),!Q.length))continue;const $e=Q.length,Ce=re?re.position.x+110:(U.position.x+ye.position.x)/2,Xe=re?re.position.y+35:(U.position.y+ye.position.y)/2;Q.forEach((fe,Ie)=>{const kr=`dynamic_rt_${fe.referenceTaskName}`,pb=de?Ce-he:U.position.x+(Ie-($e-1)/2)*280,hb=de?Xe-ue+(Ie-($e-1)/2)*110:Xe-ue;J.push({id:kr,type:"taskNode",data:{label:fe.referenceTaskName,task:{name:fe.referenceTaskName,taskReferenceName:fe.referenceTaskName,type:fe.taskType||"SIMPLE"},taskReferenceName:fe.referenceTaskName,taskType:fe.taskType||"SIMPLE",isDynamicRuntime:!0,layoutDirection:N},position:{x:pb,y:hb}}),H.push({id:`e-${U.id}-${kr}`,source:U.id,target:kr,...T}),H.push({id:`e-${kr}-${ce}`,source:kr,target:ce,...T})})}return{extraNodes:J,extraEdges:H,removedEdgeIds:$,removedNodeIds:X}},[c,C,a,i,N]),ae=q.useMemo(()=>[...R(i.filter(J=>!ee.removedEdgeIds.has(J.id))).map(J=>{const H=J.id.includes("loop-back"),$=g==="light"?"#64748b":"#94a3b8";let de={...{...J.style,stroke:$,strokeWidth:2,strokeDasharray:H?"5,5":void 0}},ue=!1;if(c==="run"&&y){const Q=y[J.source]?.status,te=y[J.target]?.status,re=Q==="COMPLETED";re&&te==="COMPLETED"?(de={...de,stroke:"var(--status-completed)",strokeWidth:4},ue=!1):re&&te==="IN_PROGRESS"&&(de={...de,stroke:"var(--status-in-progress)",strokeWidth:4},ue=!0)}const he=J.source.endsWith("_dynamic_placeholder")||J.target.endsWith("_dynamic_placeholder"),T=J.source==="__workflow_start__"||J.source.startsWith("__loop_start__");return{...J,type:c==="edit"&&!H&&!he&&!T?"addableEdge":v,data:{...J.data,mode:c,edgeType:v,label:J.label},markerEnd:{type:O.MarkerType.ArrowClosed,width:20,height:20,color:de.stroke},style:de,animated:ue}}),...ee.extraEdges],[i,v,g,c,y,ee,R]);return d.jsxs("div",{style:{width:"100%",height:"100%",position:"relative",background:"var(--bg-secondary)"},children:[d.jsxs(O,{nodes:q.useMemo(()=>{const ne=new Set(b.errors.filter($=>$.type==="TASK").map($=>$.ref)),G=new Set(b.warnings.filter($=>$.type==="TASK").map($=>$.ref)),J=r.toLowerCase();return a.filter($=>!ee.removedNodeIds.has($.id)&&I.has($.id)).map($=>{const X=$.data.taskReferenceName,de=A[X];return{...$,selected:p?.taskReferenceName===X,data:{...$.data,isError:c==="edit"&&ne.has(X),hasWarning:c==="edit"&&G.has(X),isHighlighted:r?$.data.label.toLowerCase().includes(J)||$.data.taskReferenceName.toLowerCase().includes(J):!1,simRunning:de==="running",simDone:de==="done"}}}).concat(ee.extraNodes.map($=>({...$,data:{...$.data,isError:!1,hasWarning:!1,isHighlighted:!1}})))},[a,b,r,p,ee,I,A,c]),edges:ae,onNodesChange:s,onEdgesChange:l,onConnect:u,nodeTypes:$x,edgeTypes:Hx,onNodeClick:(ne,G)=>{if(G.type==="plusNode"){W({sourceId:G.data.parentRef,edgeData:G.data.edgeData||{}}),L(!0);return}if(G.type==="loopNode"){const H=G.data.task||null;h(H),e&&e(H);return}const J=G.data.task||null;h(J),e&&e(J)},onPaneClick:()=>{h(null),c!=="run"&&k(!1)},fitView:!0,nodesDraggable:!x,nodesConnectable:!x,elementsSelectable:!0,minZoom:.2,maxZoom:2,children:[d.jsx(O.Background,{color:"var(--border-primary)",gap:20}),d.jsx(O.Panel,{position:"bottom-left",style:{marginBottom:"20px",marginLeft:"20px",zIndex:1e3},children:d.jsx(mx,{})}),c==="run"&&d.jsx(O.Panel,{position:"bottom-center",children:d.jsx(gx,{})}),d.jsx(Oh,{isOpen:V,onClose:()=>Z(!1),theme:g,onTaskSelect:ne=>{h(ne)}}),d.jsx("div",{style:{position:"absolute",top:20,right:20,zIndex:1e3},children:d.jsx(yx,{onShowHealthCheck:()=>Z(!V),showHealthCheck:V,onShowSettings:()=>se(!0),executionActions:o})})]}),!S&&d.jsx(kx,{onRequestImport:n}),S&&a.length===0&&c==="edit"&&d.jsx("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:10,display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:d.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:{}}),L(!0)},children:[d.jsx("span",{style:{fontSize:"20px",lineHeight:1},children:"+"}),"添加第一个任务"]})}),D&&d.jsx(hx,{theme:g,onSelect:z,onCancel:()=>L(!1)}),d.jsx(bx,{isOpen:le,onClose:()=>se(!1)}),Y&&d.jsx(Ur,{message:Y.message,onConfirm:K,onCancel:E}),d.jsx(Sx,{messages:j,onDismiss:P})]})},Fh={apiKey:"",baseUrl:"https://api.openai.com/v1",model:"gpt-4o"},Ux=async(e,r={},t)=>{const n={...Fh,...r};if(!n.apiKey)throw new Error("Please configure AI API Key in settings.");const o=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(!o.ok){const i=await o.json();throw new Error(i.error?.message||"AI request failed")}return(await o.json()).choices[0].message.content},Jx=async(e,r={},t,n,o)=>{const a={...Fh,...r};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:o});if(!i.ok){const c=await i.json();throw new Error(c.error?.message||"AI request failed")}const s=i.body?.getReader();if(!s)throw new Error("ReadableStream not supported");const l=new TextDecoder;let u="";for(;;){const{done:c,value:f}=await s.read();if(c)break;const h=l.decode(f,{stream:!0}).split(`
|
|
31
|
-
|
|
33
|
+
`}),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:n,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&&u.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}`)),u.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," 个错误, ",u.length," 个警告"]}),i.length>0&&l.jsx("span",{style:{color:"#ef4444"},children:"无法保存/导出"})]})]}):null},Ix=({id:e,source:n,target:r,sourceX:t,sourceY:s,targetX:a,targetY:o,sourcePosition:i,targetPosition:u,style:c={},markerEnd:d,data:f})=>{const[p,h]=O.useState(!1),g=O.useRef(null),m=()=>{const N=f?.edgeType||"default",L={sourceX:t,sourceY:s,sourcePosition:i,targetX:a,targetY:o,targetPosition:u};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:n,target:r,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:d,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:"+"})]})})]})},qe=({onClick:e,icon:n,label:r,title:t,disabled:s=!1,active:a=!1,variant:o="default",style:i})=>{let u="var(--bg-tertiary)",c="var(--text-primary)",d="1px solid var(--border-primary)";return o==="primary"?(u="var(--color-accent)",c="#fff",d="none"):o==="danger"?(u=s?"rgba(239, 68, 68, 0.1)":"var(--status-failed)",c=s?"var(--text-secondary)":"#fff",d="none"):a&&(u="var(--bg-secondary)",c="var(--color-accent)",d="1px solid var(--color-accent)"),l.jsxs("button",{onClick:e,disabled:s,title:t,"aria-label":t||r,"aria-pressed":a,"aria-disabled":s,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:r?"6px":"0",background:u,color:c,border:d,borderRadius:"6px",padding:r?"6px 12px":"8px",cursor:s?"not-allowed":"pointer",opacity:s?.5:1,fontSize:"13px",fontWeight:500,transition:"all 0.2s",minWidth:r?"auto":"32px",height:"32px",boxShadow:o==="default"?"0 1px 2px rgba(0,0,0,0.05)":"none",...i},children:[n&&l.jsx("span",{style:{fontSize:"14px",display:"flex"},children:n}),r&&l.jsx("span",{children:r})]})},Rx=()=>{const{zoomIn:e,zoomOut:n,fitView:r}=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(qe,{icon:"➕",title:"放大",onClick:()=>e()}),l.jsx(qe,{icon:"➖",title:"缩小",onClick:()=>n()}),l.jsx(qe,{icon:"⤢",title:"适应屏幕",onClick:()=>r({duration:600})})]})})},Ox=({onShowHealthCheck:e,showHealthCheck:n,onShowSettings:r,executionActions:t})=>{const{mode:s,validationResults:a,workflowInstance:o,workflowDef:i}=oe(),u=oe.temporal,{undo:c,redo:d,pastStates:f,futureStates:p}=et(u,T=>T),[h,g]=O.useState(!1),m=O.useRef(null);O.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=t?.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(qe,{icon:"↺",title:"撤销 (Cmd+Z)",onClick:()=>c(),disabled:f.length===0}),l.jsx(qe,{icon:"↻",title:"重做 (Cmd+Shift+Z)",onClick:()=>d(),disabled:p.length===0}),l.jsx("div",{style:{width:"1px",height:"20px",background:"var(--border-primary)",margin:"0 4px",alignSelf:"center"}}),l.jsx(qe,{icon:"🩺",label:v?`错误 (${a.errors.length})`:"诊断",title:"流程健康检查",onClick:e,active:n,variant:v?"danger":"secondary"}),l.jsx(qe,{icon:"⚙️",label:"配置",title:"工作流全局配置",onClick:()=>r?.()})]}),s==="run"&&o&&t&&l.jsxs(l.Fragment,{children:[k&&t.onResume&&l.jsx(qe,{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&&t.onResume(x),disabled:!L,variant:"primary"}),b&&t.onPause&&l.jsx(qe,{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&&t.onPause(x),disabled:!L}),(b||k)&&t.onTerminate&&l.jsx(qe,{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&&t.onTerminate(x),disabled:!L,variant:"danger"}),w&&t.onRetry&&l.jsx(qe,{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&&t.onRetry(x),disabled:!L,variant:"primary"}),N&&t.onRestart&&l.jsxs("div",{ref:m,style:{position:"relative",display:"flex"},children:[l.jsxs("button",{disabled:!L,onClick:()=>L&&t.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:()=>{t.onRestart(x,{useLatestDef:!0}),g(!1)},style:$h,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:()=>{t.onRestart(x,{useLatestDef:!1}),g(!1)},style:$h,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:"使用本次运行时的定义"})]})]})]})]})]})]})},$h={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"},zh=[{id:"business",label:"业务",title:"仅展示核心业务节点"},{id:"standard",label:"标准",title:"业务 + 控制流节点"},{id:"developer",label:"全开发",title:"展示所有节点(含数据转换)"}];function Px(){const e=oe(a=>a.viewMode),n=oe(a=>a.setViewMode),r=O.useRef([]),[t,s]=O.useState({x:3,w:0});return O.useEffect(()=>{const a=zh.findIndex(i=>i.id===e),o=r.current[a];o&&s({x:o.offsetLeft,w:o.offsetWidth})},[e]),l.jsxs("div",{className:"mode-slider",role:"group","aria-label":"视图模式",children:[l.jsx("div",{className:"mode-slider-knob",style:{width:t.w,transform:`translateX(${t.x-3}px)`}}),zh.map((a,o)=>l.jsxs("button",{ref:i=>{r.current[o]=i},className:`mode-slider-opt${e===a.id?" active":""}`,onClick:()=>n(a.id),title:a.title,"aria-pressed":e===a.id,children:[l.jsx("span",{className:"mode-dot"}),a.label]},a.id))]})}function Zr(e){return!e||e.length===0?[]:typeof e[0]=="string"?e.map(n=>({name:n})):e}const Ax=[{id:"basic",label:"基本信息"},{id:"timeout",label:"超时与容错"},{id:"params",label:"参数配置"},{id:"advanced",label:"高级设置"}],Lx=({isOpen:e,onClose:n})=>{const{workflowDef:r,updateWorkflowProperties:t,mode:s}=oe(),[a,o]=O.useState(r),[i,u]=O.useState("basic"),c=s!=="edit";O.useEffect(()=>{r&&o(r)},[r,e]);const d=O.useCallback(I=>{I.key==="Escape"&&n()},[n]);if(O.useEffect(()=>{if(e)return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[e,d]),!e||!a)return null;const f="var(--text-primary)",p="var(--glass-border)",h="var(--bg-tertiary)",g="var(--text-secondary)",m=(I,P)=>{if(!a||c)return;const F={...a,[I]:P};o(F),t({[I]:P})},v=(I,P,F)=>{if(!a||c)return;const K={...a[I]||{},[P]:F};o(V=>({...V,[I]:K})),t({[I]:K})},y=(I,P)=>{if(!(!a||c))try{const F=JSON.parse(P),W={...a,[I]:F};o(W),t({[I]:F})}catch{o(F=>({...F,[`_${I}_str`]:P}))}},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,P,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?.[P]??"",onChange:K=>m(P,F==="number"?K.target.value===""?0:parseInt(K.target.value):K.target.value),disabled:c||W?.readOnly,placeholder:W?.placeholder,style:{...x,opacity:c||W?.readOnly?.6:1}})]}),w=(I,P,F=!1,W=6)=>{const K=a?.[`_${P}_str`]!==void 0?a[`_${P}_str`]:typeof a?.[P]=="object"?JSON.stringify(a[P],null,2):a?.[P];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:K||"",onChange:V=>F?y(P,V.target.value):m(P,V.target.value),rows:W,disabled:c,style:{...x,fontSize:"13px",fontFamily:F?"var(--font-mono)":"inherit",resize:"vertical",opacity:c?.6:1}})]})},j=(I,P,F)=>l.jsxs("div",{style:{marginBottom:"20px"},children:[l.jsx("label",{style:b,children:I.toUpperCase()}),l.jsx("select",{className:"wsp-input",value:a?.[P]??F[0]?.value,onChange:W=>m(P,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,P)=>{const F=!!a?.[P];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(P,!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=Zr(a?.inputParameters),P=te=>{c||m("inputParameters",te)},F=()=>{const te=[...I,{name:`param_${I.length+1}`,type:"string",required:!1}];P(te)},W=te=>{const re=I.filter((q,G)=>G!==te);P(re)},K=(te,re,q)=>{const G=I.map((ie,R)=>R===te?{...ie,[re]:q}:ie);P(G)},V={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((te,re)=>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:V,placeholder:"参数名",value:te.name,onChange:q=>K(re,"name",q.target.value),disabled:c}),l.jsx("select",{style:{...V,cursor:c?"not-allowed":"pointer"},value:te.type??"string",onChange:q=>K(re,"type",q.target.value),disabled:c,children:["string","number","boolean","object","array"].map(q=>l.jsx("option",{value:q,children:q},q))}),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:!!te.required,onChange:q=>K(re,"required",q.target.checked),disabled:c,style:{accentColor:"var(--color-accent)"}}),"必填"]}),!c&&l.jsx("button",{onClick:()=>W(re),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:V,placeholder:"说明(可选)",value:te.description??"",onChange:q=>K(re,"description",q.target.value),disabled:c}),l.jsx("input",{style:V,placeholder:`示例值(如 ${te.type==="number"?"42":te.type==="boolean"?"true":'"value"'})`,value:te.example!==void 0?typeof te.example=="object"?JSON.stringify(te.example):String(te.example):"",onChange:q=>{let G=q.target.value;try{G=JSON.parse(q.target.value)}catch{}K(re,"example",G)},disabled:c})]})]},re))})]}),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}})]})]})]})]}),D=()=>{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:n,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:n,"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:Ax.map(I=>l.jsx("button",{className:"wsp-tab",onClick:()=>u(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:D()}),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:n,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:"完成并关闭"})})]})})},qx=({onRequestImport:e})=>{const{createBlankWorkflow:n}=oe(),[r,t]=O.useState(""),s=()=>{n(r||void 0),oe.temporal.getState().clear()},a=()=>{n(r||void 0),oe.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:r,onChange:o=>t(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"]})]})]})},Dx={success:{bg:"#10b981",text:"#fff"},error:{bg:"#ef4444",text:"#fff"},info:{bg:"var(--color-accent)",text:"#fff"}},Mx=({messages:e,onDismiss:n})=>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(r=>l.jsx(Wx,{message:r,onDismiss:n},r.id))}),Wx=({message:e,onDismiss:n})=>{const r=Dx[e.type||"info"];return O.useEffect(()=>{const t=setTimeout(()=>n(e.id),2500);return()=>clearTimeout(t)},[e.id,n]),l.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:()=>n(e.id),children:e.text})},Hh=["shift","alt","meta","mod","ctrl","control"],Bx={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 Ue(e){return(Bx[e.trim()]||e.trim()).toLowerCase().replace(/key|digit|numpad/,"")}function Kh(e){return Hh.includes(e)}function Ui(e,n=","){return e.toLowerCase().split(n)}function Ji(e,n="+",r=">",t=!1,s){let a=[],o=!1;e=e.trim(),e.includes(r)?(o=!0,a=e.toLocaleLowerCase().split(r).map(c=>Ue(c))):a=e.toLocaleLowerCase().split(n).map(c=>Ue(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:t},u=a.filter(c=>!Hh.includes(c));return{...i,keys:u,description:s,isSequence:o,hotkey:e}}typeof document<"u"&&(document.addEventListener("keydown",e=>{e.code!==void 0&&Uh([Ue(e.code)])}),document.addEventListener("keyup",e=>{e.code!==void 0&&Jh([Ue(e.code)])})),typeof window<"u"&&(window.addEventListener("blur",()=>{$e.clear()}),window.addEventListener("contextmenu",()=>{setTimeout(()=>{$e.clear()},0)}));const $e=new Set;function Gi(e){return Array.isArray(e)}function Fx(e,n=","){return(Gi(e)?e:e.split(n)).every(r=>$e.has(r.trim().toLowerCase()))}function Uh(e){const n=Array.isArray(e)?e:[e];$e.has("meta")&&$e.forEach(r=>!Kh(r)&&$e.delete(r.toLowerCase())),n.forEach(r=>$e.add(r.toLowerCase()))}function Jh(e){const n=Array.isArray(e)?e:[e];e==="meta"?$e.clear():n.forEach(r=>$e.delete(r.toLowerCase()))}function $x(e,n,r){(typeof r=="function"&&r(e,n)||r===!0)&&e.preventDefault()}function zx(e,n,r){return typeof r=="function"?r(e,n):r===!0||r===void 0}const Hx=["input","textarea","select","searchbox","slider","spinbutton","menuitem","menuitemcheckbox","menuitemradio","option","radio","textbox"];function Kx(e){return Gh(e,Hx)}function Gh(e,n=!1){const{target:r,composed:t}=e;let s,a;return Ux(r)&&t?(s=e.composedPath()[0]&&e.composedPath()[0].tagName,a=e.composedPath()[0]&&e.composedPath()[0].role):(s=r&&r.tagName,a=r&&r.role),Gi(n)?!!(s&&n&&n.some(o=>o.toLowerCase()===s.toLowerCase()||o===a)):!!(s&&n&&n)}function Ux(e){return!!e.tagName&&!e.tagName.startsWith("-")&&e.tagName.includes("-")}function Jx(e,n){return e.length===0&&n?(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):n?e.some(r=>n.includes(r))||e.includes("*"):!0}const Gx=(e,n,r=!1)=>{const{alt:t,meta:s,mod:a,shift:o,ctrl:i,keys:u,useKey:c}=n,{code:d,key:f,ctrlKey:p,metaKey:h,shiftKey:g,altKey:m}=e,v=Ue(d);if(c&&u?.length===1&&u.includes(f))return!0;if(!u?.includes(v)&&!["ctrl","control","unknown","meta","alt","shift","os"].includes(v))return!1;if(!r){if(t!==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 u&&u.length===1&&u.includes(v)?!0:u?Fx(u):!u},Vx=O.createContext(void 0),Yx=()=>O.useContext(Vx);function Vh(e,n){return e&&n&&typeof e=="object"&&typeof n=="object"?Object.keys(e).length===Object.keys(n).length&&Object.keys(e).reduce((r,t)=>r&&Vh(e[t],n[t]),!0):e===n}const Xx=O.createContext({hotkeys:[],activeScopes:[],toggleScope:()=>{},enableScope:()=>{},disableScope:()=>{}}),Zx=()=>O.useContext(Xx);function Qx(e){const n=O.useRef(void 0);return Vh(n.current,e)||(n.current=e),n.current}const Yh=e=>{e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation()},eb=typeof window<"u"?O.useLayoutEffect:O.useEffect;function cr(e,n,r,t){const s=O.useRef(null),a=O.useRef(!1),o=Array.isArray(r)?Array.isArray(t)?void 0:t:r,i=Gi(e)?e.join(o?.delimiter):e,u=Array.isArray(r)?r:Array.isArray(t)?t:void 0,c=O.useCallback(n,u??[]),d=O.useRef(c);u?d.current=c:d.current=n;const f=Qx(o),{activeScopes:p}=Zx(),h=Yx();return eb(()=>{if(f?.enabled===!1||!Jx(p,f?.scopes))return;let g=[],m;const v=(k,w=!1)=>{if(!(Kx(k)&&!Gh(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)){Yh(k);return}}k.target?.isContentEditable&&!f?.enableOnContentEditable||Ui(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=Ji(j,f?.splitKey,f?.sequenceSplitKey,f?.useKey,f?.description);if(N.isSequence){m=setTimeout(()=>{g=[]},f?.sequenceTimeoutMs??1e3);const L=N.useKey?k.key:Ue(k.code);if(Kh(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&&(d.current(k,N),m&&clearTimeout(m),g=[])}else if(Gx(k,N,f?.ignoreModifiers)||N.keys?.includes("*")){if(f?.ignoreEventWhen?.(k)||w&&a.current)return;if($x(k,N,f?.preventDefault),!zx(k,N,f?.enabled)){Yh(k);return}d.current(k,N),w||(a.current=!0)}})}},y=k=>{k.code!==void 0&&(Uh(Ue(k.code)),(f?.keydown===void 0&&f?.keyup!==!0||f?.keydown)&&v(k))},x=k=>{k.code!==void 0&&(Jh(Ue(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&&Ui(i,f?.delimiter).forEach(k=>h.addHotkey(Ji(k,f?.splitKey,f?.sequenceSplitKey,f?.useKey,f?.description))),()=>{b.removeEventListener("keyup",x,o?.eventListenerOptions),b.removeEventListener("keydown",y,o?.eventListenerOptions),h&&Ui(i,f?.delimiter).forEach(k=>h.removeHotkey(Ji(k,f?.splitKey,f?.sequenceSplitKey,f?.useKey,f?.description))),g=[],m&&clearTimeout(m)}},[i,f,p]),s}const rb=e=>{const{mode:n,removeNode:r,selectedTask:t,pasteTask:s}=oe(),a=oe.temporal,{undo:o,redo:i}=et(a,p=>p),u=e?.confirm||(p=>Promise.resolve(window.confirm(p))),c=e?.showToast,d=p=>{const h=p.target;return h.tagName==="INPUT"||h.tagName==="TEXTAREA"||h.isContentEditable},f=()=>{requestAnimationFrame(()=>{const p=oe.getState(),{nodes:h,edges:g}=Se(p.nodes,p.edges,{direction:p.layoutDirection,mode:p.mode});oe.setState({nodes:h,edges:g})})};return cr("mod+z",p=>{n==="edit"&&(d(p)||(p.preventDefault(),o(),f()))},[n,o]),cr(["mod+shift+z","mod+y"],p=>{n==="edit"&&(d(p)||(p.preventDefault(),i(),f()))},[n,i]),cr("delete, backspace",p=>{n!=="edit"||!t||d(p)||(p.preventDefault(),u("确定要删除此任务吗?").then(h=>{h&&r(t.taskReferenceName)}))},[n,t,r,u]),cr("mod+c",p=>{if(!(n!=="edit"||!t)&&!d(p)){if(t.type==="JOIN"){c?.("JOIN 任务不能独立复制","error");return}p.preventDefault();try{localStorage.setItem("conductor-clipboard",JSON.stringify(t)),c?.("任务已复制","success")}catch{c?.("复制失败","error")}}},[n,t,c]),cr("mod+v",p=>{if(n==="edit"&&!d(p)){p.preventDefault();try{const h=localStorage.getItem("conductor-clipboard");if(h){const g=JSON.parse(h);s(g),c?.("任务已粘贴","success")}}catch{c?.("粘贴失败","error")}}},[n,s,c]),cr("mod+s",p=>{p.preventDefault();const h=oe.getState().workflowDef;h&&e?.onSave&&e.onSave(h)},[e?.onSave]),{}},tb=()=>{const[e,n]=O.useState(null),r=O.useCallback(a=>new Promise(o=>{n({message:a,resolve:o})}),[]),t=O.useCallback(()=>{e?.resolve(!0),n(null)},[e]),s=O.useCallback(()=>{e?.resolve(!1),n(null)},[e]);return{confirm:r,confirmState:e,handleConfirm:t,handleCancel:s}},nb=()=>{const[e,n]=O.useState([]),r=O.useCallback((s,a="info")=>{const o=Date.now().toString();n(i=>[...i,{id:o,text:s,type:a}])},[]),t=O.useCallback(s=>{n(a=>a.filter(o=>o.id!==s))},[]);return{toasts:e,showToast:r,dismissToast:t}},Vi={id:"welcome",role:"assistant",content:`你好!我是 AI 工作流助手。
|
|
34
|
+
|
|
35
|
+
我可以帮你:
|
|
36
|
+
- 🆕 **从零创建**工作流(描述业务场景即可)
|
|
37
|
+
- ➕ **添加/修改/删除**任务节点
|
|
38
|
+
- 🔀 **重构拓扑**(如串行改并行)
|
|
39
|
+
- 🔍 **诊断问题**和优化建议
|
|
40
|
+
|
|
41
|
+
直接告诉我你想做什么吧!`,timestamp:Date.now()},ab=()=>(e,n)=>({config:{provider:"auto",apiKey:""},messages:[Vi],isStreaming:!1,streamingText:"",chatPanelOpen:!0,pendingProposal:null,pendingPlan:null,pendingRepair:null,followUpChips:null,undoStack:[],pendingClarification:null,pendingRecommendation:null,pendingAutoSend:null,toolStatus:"",retryInput:null,timelineEntries:[],metrics:{totalProposals:0,acceptedProposals:0,rejectedProposals:0,totalPromptTokens:0,totalCompletionTokens:0},setConfig:r=>e(t=>({config:{...t.config,...r}})),addMessage:r=>{const t=`msg_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,s={...r,id:t,timestamp:Date.now()};return e(a=>({messages:[...a.messages,s]})),t},updateMessage:(r,t)=>e(s=>({messages:s.messages.map(a=>a.id===r?{...a,content:t}:a)})),setStreaming:r=>e({isStreaming:r}),setStreamingText:r=>e({streamingText:r}),appendStreamingText:r=>e(t=>({streamingText:t.streamingText+r})),clearMessages:()=>e({messages:[Vi],streamingText:"",isStreaming:!1,pendingProposal:null,pendingPlan:null,pendingRepair:null,followUpChips:null,pendingClarification:null,pendingRecommendation:null,pendingAutoSend:null,toolStatus:"",retryInput:null,timelineEntries:[]}),setChatPanelOpen:r=>e({chatPanelOpen:r}),toggleChatPanel:()=>e(r=>({chatPanelOpen:!r.chatPanelOpen})),setProposal:r=>{const t=`prop_${Date.now()}`,s=oe.getState().workflowDef,a=JSON.stringify(s);return e(o=>({pendingProposal:{...r,id:t,baselineHash:a},metrics:{...o.metrics,totalProposals:o.metrics.totalProposals+1}})),t},clearProposal:()=>e({pendingProposal:null}),recordAccept:()=>e(r=>({metrics:{...r.metrics,acceptedProposals:r.metrics.acceptedProposals+1},pendingProposal:null})),recordReject:()=>e(r=>({metrics:{...r.metrics,rejectedProposals:r.metrics.rejectedProposals+1},pendingProposal:null})),getMetrics:()=>n().metrics,recordUsage:r=>e(t=>({metrics:{...t.metrics,totalPromptTokens:t.metrics.totalPromptTokens+(r.promptTokens??0),totalCompletionTokens:t.metrics.totalCompletionTokens+(r.completionTokens??0)}})),setFollowUpChips:r=>e({followUpChips:r}),clearFollowUpChips:()=>e({followUpChips:null}),setPlan:r=>{const t=`plan_${Date.now()}`;return e({pendingPlan:{...r,id:t}}),t},clearPlan:()=>e({pendingPlan:null}),setRepair:r=>{const t=`repair_${Date.now()}`;return e({pendingRepair:{...r,id:t}}),t},clearRepair:()=>e({pendingRepair:null}),pushUndo:r=>e(t=>({undoStack:[...t.undoStack.slice(-4),r]})),popUndo:()=>{const r=n().undoStack;if(r.length===0)return null;const t=r[r.length-1];return e({undoStack:r.slice(0,-1)}),t},clearUndo:()=>e({undoStack:[]}),canUndo:()=>n().undoStack.length>0,setClarification:r=>{const t=`clarif_${Date.now()}`;return e({pendingClarification:{...r,id:t}}),t},clearClarification:()=>e({pendingClarification:null}),setRecommendation:r=>{const t=`rec_${Date.now()}`;return e({pendingRecommendation:{...r,id:t}}),t},clearRecommendation:()=>e({pendingRecommendation:null}),setPendingAutoSend:r=>e({pendingAutoSend:r}),setToolStatus:r=>e({toolStatus:r}),setRetryInput:r=>e({retryInput:r}),addTimelineEntry:(r,t="done")=>e(s=>({timelineEntries:[...s.timelineEntries,{id:`tl_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,label:r,icon:t}]})),clearTimeline:()=>e({timelineEntries:[]}),hydrateFromDraft:(r,t)=>e({messages:r.length>0?r:[Vi],pendingProposal:t})});function sb(e="ai-workflow-config"){const n=ab();return e===!1?rt()(n):rt()(rl(n,{name:e,storage:tt(()=>localStorage),partialize:r=>({config:{...r.config,apiKey:""},metrics:r.metrics})}))}const ob=sb(),ib=O.createContext(null);function lb(){return O.useContext(ib)}const cb={taskNode:mx,decisionNode:yx,forkNode:Bh.ForkNode,joinNode:Bh.JoinNode,loopNode:bx,subWorkflowNode:Sx,plusNode:Tx,dynamicPlaceholderNode:Nx},db={addableEdge:Ix},ub=({onNodeClick:e,searchQuery:n="",onSave:r,onRequestImport:t,executionActions:s})=>{const{nodes:a,edges:o,onNodesChange:i,onEdgesChange:u,onConnect:c,mode:d,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}=oe(),C=O.useMemo(()=>{if(d==="run"||d==="edit")return new Set(a.map(H=>H.id));const z=dx[f],Z=new Set;return a.forEach(H=>{if(H.type==="plusNode"||H.type==="dynamicPlaceholderNode"){Z.add(H.id);return}if(H.parentId)return;const Y=He.find(ge=>ge.type===H.data.taskType)?.viewCategory??"business";z.includes(Y)&&Z.add(H.id)}),a.forEach(H=>{H.parentId&&Z.has(H.parentId)&&Z.add(H.id)}),Z},[a,f,d]),S=O.useCallback(z=>{if(C.size===a.length)return z;const Z={};z.forEach(Y=>{Z[Y.source]||(Z[Y.source]=[]),Z[Y.source].push(Y)});const H=[],ne=new Set;return z.forEach(Y=>{if(!C.has(Y.source))return;if(C.has(Y.target)){const pe=`${Y.source}->${Y.target}`;ne.has(pe)||(ne.add(pe),H.push(Y));return}const ge=[{to:Y.target,label:Y.label}],ae=new Set;for(;ge.length;){const pe=ge.shift();if(!ae.has(pe.to)){if(ae.add(pe.to),C.has(pe.to)){const me=`${Y.source}->${pe.to}`;ne.has(me)||(ne.add(me),H.push({...Y,id:me,target:pe.to,label:pe.label??Y.label}));continue}(Z[pe.to]??[]).forEach(me=>ge.push({to:me.target,label:pe.label??me.label}))}}}),H},[C,a.length]),I=(lb()?.aiStore??ob)(z=>z.pendingProposal),P=O.useMemo(()=>{if(!I)return null;try{const{nodes:z,edges:Z}=Te(I.proposedDef,N,{hideEmptyBranches:!1}),{nodes:H,edges:ne}=Se(z,Z,{direction:N,mode:"edit"}),Y=new Set(I.diff.added),ge=new Set(I.diff.modified),ae=new Set(I.diff.removed),pe=new Map(a.map(ce=>[ce.data?.taskReferenceName,ce])),me=H.filter(ce=>ce.type!=="plusNode").map(ce=>{const E=ce.data?.taskReferenceName,J=Y.has(E)?"added":ge.has(E)?"modified":void 0;return{...ce,draggable:!1,selectable:!1,data:{...ce.data,proposalStatus:J,layoutDirection:N}}}),Ne=[...ae].map(ce=>pe.get(ce)).filter(ce=>ce!=null).map(ce=>({...ce,draggable:!1,selectable:!1,data:{...ce.data,proposalStatus:"removed"}}));return{nodes:[...me,...Ne],edges:ne}}catch{return null}},[I,a,N]),{fitView:F}=A.useReactFlow(),[W,K]=O.useState(!1),[V,te]=O.useState(null),[re,q]=O.useState(!1),[G,ie]=O.useState(!1),{confirm:R,confirmState:M,handleConfirm:_,handleCancel:B}=tb(),{toasts:$,showToast:X,dismissToast:U}=nb();rb({confirm:R,showToast:X,onSave:r}),O.useEffect(()=>{if(p){const z=a.find(Z=>Z.data.taskReferenceName===p.taskReferenceName);z&&F({nodes:[z],duration:800,padding:.5})}},[p?.taskReferenceName,F]),O.useEffect(()=>{const z=()=>{F({duration:800})};return window.addEventListener("workflow-zoom-to-fit",z),()=>window.removeEventListener("workflow-zoom-to-fit",z)},[F]),O.useEffect(()=>{if(T===0)return;const z=setTimeout(()=>{F({duration:600,padding:.12})},50);return()=>clearTimeout(z)},[T,F]),O.useEffect(()=>{const z=ne=>{e&&ne.detail&&ne.detail.task&&e(ne.detail.task)},Z=ne=>{if(d==="edit"){const{loopId:Y,afterRef:ge}=ne.detail;te(ge?{sourceId:ge,edgeData:{}}:{sourceId:Y,edgeData:{isLoopAdd:!0}}),K(!0)}},H=ne=>{d==="edit"&&(te({sourceId:ne.detail.source,targetId:ne.detail.target,edgeId:ne.detail.id,edgeData:ne.detail.edgeData}),K(!0))};return document.addEventListener("miniTaskClick",z),document.addEventListener("loopAddNodeRequested",Z),window.addEventListener("edgeAddNode",H),()=>{document.removeEventListener("miniTaskClick",z),document.removeEventListener("loopAddNodeRequested",Z),window.removeEventListener("edgeAddNode",H)}},[d,e]);const le=O.useCallback(z=>{if(V){const{sourceId:Z,targetId:H,edgeId:ne,edgeData:Y}=V;v({data:{label:`New ${z}`,taskReferenceName:`${z.toLowerCase()}_${Date.now()}`,taskType:z}},Z,H,ne,Y)}K(!1),te(null)},[V,v]),Q=O.useMemo(()=>{const z={extraNodes:[],extraEdges:[],removedEdgeIds:new Set,removedNodeIds:new Set};if(d!=="run")return z;const Z=a.filter(ce=>ce.type==="forkNode"&&ce.data.taskType==="FORK_JOIN_DYNAMIC");if(!Z.length)return z;const H=[],ne=[],Y=new Set,ge=new Set,ae=N==="LR",pe=47,me=120,Ne={animated:!0,style:{stroke:"#10b981",strokeDasharray:"4,4"},markerEnd:{type:A.MarkerType.ArrowClosed,color:"#10b981"}};for(const ce of Z){const E=j[ce.id]||[],J=`${ce.id}_dynamic_placeholder`,se=a.find(ye=>ye.id===J),ue=o.find(ye=>ye.target===J),de=o.find(ye=>ye.source===J);let ve,xe;if(de)ve=de.target,xe=a.find(ye=>ye.id===ve);else{const ye=a.indexOf(ce);if(xe=a.slice(ye).find(dr=>dr.type==="joinNode"),!xe)continue;ve=xe.id}if(!xe||(de&&Y.add(de.id),ue&&Y.add(ue.id),ge.add(J),!E.length))continue;const fe=E.length,_e=se?se.position.x+110:(ce.position.x+xe.position.x)/2,wr=se?se.position.y+35:(ce.position.y+xe.position.y)/2;E.forEach((ye,dr)=>{const Tr=`dynamic_rt_${ye.referenceTaskName}`,$b=ae?_e-me:ce.position.x+(dr-(fe-1)/2)*280,zb=ae?wr-pe+(dr-(fe-1)/2)*110:wr-pe;H.push({id:Tr,type:"taskNode",data:{label:ye.referenceTaskName,task:{name:ye.referenceTaskName,taskReferenceName:ye.referenceTaskName,type:ye.taskType||"SIMPLE"},taskReferenceName:ye.referenceTaskName,taskType:ye.taskType||"SIMPLE",isDynamicRuntime:!0,layoutDirection:N},position:{x:$b,y:zb}}),ne.push({id:`e-${ce.id}-${Tr}`,source:ce.id,target:Tr,...Ne}),ne.push({id:`e-${Tr}-${ve}`,source:Tr,target:ve,...Ne})})}return{extraNodes:H,extraEdges:ne,removedEdgeIds:Y,removedNodeIds:ge}},[d,j,a,o,N]),ee=O.useMemo(()=>[...S(o.filter(H=>!Q.removedEdgeIds.has(H.id))).map(H=>{const ne=H.id.includes("loop-back"),Y=g==="light"?"#64748b":"#94a3b8";let ae={...{...H.style,stroke:Y,strokeWidth:2,strokeDasharray:ne?"5,5":void 0}},pe=!1;if(d==="run"&&x){const E=x[H.source]?.status,J=x[H.target]?.status,se=E==="COMPLETED";se&&J==="COMPLETED"?(ae={...ae,stroke:"var(--status-completed)",strokeWidth:4},pe=!1):se&&J==="IN_PROGRESS"&&(ae={...ae,stroke:"var(--status-in-progress)",strokeWidth:4},pe=!0)}const me=H.source.endsWith("_dynamic_placeholder")||H.target.endsWith("_dynamic_placeholder"),Ne=H.source==="__workflow_start__"||H.source.startsWith("__loop_start__");return{...H,type:d==="edit"&&!ne&&!me&&!Ne?"addableEdge":m,data:{...H.data,mode:d,edgeType:m,label:H.label},markerEnd:{type:A.MarkerType.ArrowClosed,width:20,height:20,color:ae.stroke},style:ae,animated:pe}}),...Q.extraEdges],[o,m,g,d,x,Q,S]);return l.jsxs("div",{style:{width:"100%",height:"100%",position:"relative",background:"var(--bg-secondary)"},children:[l.jsxs(A,{nodes:O.useMemo(()=>{if(P)return P.nodes;const z=new Set(b.errors.filter(Y=>Y.type==="TASK").map(Y=>Y.ref)),Z=new Set(b.warnings.filter(Y=>Y.type==="TASK").map(Y=>Y.ref)),H=n.toLowerCase();return a.filter(Y=>!Q.removedNodeIds.has(Y.id)&&C.has(Y.id)).map(Y=>{const ge=Y.data.taskReferenceName,ae=L[ge];return{...Y,selected:p?.taskReferenceName===ge,data:{...Y.data,isError:d==="edit"&&z.has(ge),hasWarning:d==="edit"&&Z.has(ge),isHighlighted:n?Y.data.label.toLowerCase().includes(H)||Y.data.taskReferenceName.toLowerCase().includes(H):!1,simRunning:ae==="running",simDone:ae==="done"}}}).concat(Q.extraNodes.map(Y=>({...Y,data:{...Y.data,isError:!1,hasWarning:!1,isHighlighted:!1}})))},[a,b,n,p,Q,C,L,d,P]),edges:P?.edges??ee,onNodesChange:i,onEdgesChange:u,onConnect:c,nodeTypes:cb,edgeTypes:db,onNodeClick:(z,Z)=>{if(Z.type==="plusNode"){te({sourceId:Z.data.parentRef,edgeData:Z.data.edgeData||{}}),K(!0);return}if(Z.type==="loopNode"){const ne=Z.data.task||null;h(ne),e&&e(ne);return}const H=Z.data.task||null;h(H),e&&e(H)},onPaneClick:()=>{h(null),d!=="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(Rx,{})}),d==="run"&&l.jsx(A.Panel,{position:"bottom-center",children:l.jsx(jx,{})}),l.jsx(Fh,{isOpen:re,onClose:()=>q(!1),theme:g,onTaskSelect:z=>{h(z)}}),d!=="run"&&l.jsx(A.Panel,{position:"top-center",style:{marginTop:"14px"},children:l.jsx(Px,{})}),l.jsx("div",{style:{position:"absolute",top:20,right:20,zIndex:1e3},children:l.jsx(Ox,{onShowHealthCheck:()=>q(!re),showHealthCheck:re,onShowSettings:()=>ie(!0),executionActions:s})})]}),!w&&!I&&l.jsx(qx,{onRequestImport:t}),w&&a.length===0&&d==="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:()=>{te({sourceId:"start",targetId:"end",edgeId:"new",edgeData:{}}),K(!0)},children:[l.jsx("span",{style:{fontSize:"20px",lineHeight:1},children:"+"}),"添加第一个任务"]})}),W&&l.jsx(Cx,{theme:g,onSelect:le,onCancel:()=>K(!1)}),l.jsx(Lx,{isOpen:G,onClose:()=>ie(!1)}),M&&l.jsx(Yr,{message:M.message,onConfirm:_,onCancel:B}),l.jsx(Mx,{messages:$,onDismiss:U})]})},Xh={apiKey:"",baseUrl:"https://api.openai.com/v1",model:"gpt-4o"},Zh=async(e,n={},r)=>{const t={...Xh,...n};if(!t.apiKey)throw new Error("Please configure AI API Key in settings.");const s=await fetch(`${t.baseUrl}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.apiKey}`},body:JSON.stringify({model:t.model,messages:e,temperature:.7,stream:!1}),signal:r});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},fb=async(e,n={},r,t,s)=>{const a={...Xh,...n};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 d=await o.json();throw new Error(d.error?.message||"AI request failed")}const i=o.body?.getReader();if(!i)throw new Error("ReadableStream not supported");const u=new TextDecoder;let c="";for(;;){const{done:d,value:f}=await i.read();if(d)break;const h=u.decode(f,{stream:!0}).split(`
|
|
42
|
+
`).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,r(y))}catch{console.warn("[AI SSE] malformed chunk:",m)}}}return c},pb=(e,n,r,t,s)=>`
|
|
43
|
+
You are a Netflix Conductor expert. Generate a complete "inputParameters" JSON object for the following task.
|
|
44
|
+
|
|
45
|
+
Task Type: ${e}
|
|
46
|
+
Task Reference Name: ${n}
|
|
47
|
+
Current inputParameters (may be incomplete): ${JSON.stringify(s,null,2)}
|
|
48
|
+
|
|
49
|
+
Available workflow input parameters (accessible via \${workflow.input.XXX}):
|
|
50
|
+
${r.length>0?r.map(a=>` - ${a}`).join(`
|
|
51
|
+
`):" (none defined)"}
|
|
52
|
+
|
|
53
|
+
Upstream tasks (accessible via \${taskRef.output.XXX}):
|
|
54
|
+
${t.length>0?t.map(a=>` - ${a.ref} (type: ${a.type})`).join(`
|
|
55
|
+
`):" (no upstream tasks)"}
|
|
56
|
+
|
|
57
|
+
Rules:
|
|
58
|
+
1. Use JSONPath expressions like \${workflow.input.fieldName} or \${taskRef.output.result} for dynamic values.
|
|
59
|
+
2. For HTTP tasks, include uri, method, headers (Content-Type), and body if applicable.
|
|
60
|
+
3. For SIMPLE tasks, map likely upstream outputs to input fields.
|
|
61
|
+
4. For INLINE tasks, provide a meaningful expression or scriptExpression.
|
|
62
|
+
5. Keep the result focused — only include parameters that make sense for this task type.
|
|
63
|
+
6. Return ONLY the JSON object (no explanation, no markdown code block).
|
|
64
|
+
|
|
65
|
+
Return format: { "paramKey": "paramValue", ... }
|
|
66
|
+
`,hb=async(e,n,r,t,s,a={})=>{const o=pb(e,n,r,t,s),u=(await Zh([{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(u)},gb=`
|
|
32
67
|
You are an expert in Netflix Conductor Workflow modeling.
|
|
33
68
|
Your goal is to help users design JSON-based workflows.
|
|
34
69
|
|
|
@@ -40,11 +75,11 @@ CONSTRANTS:
|
|
|
40
75
|
5. For FORK_JOIN, ensure a corresponding JOIN task follows.
|
|
41
76
|
|
|
42
77
|
Provide clear, enterprise-grade logic with proper error handling paths.
|
|
43
|
-
`,
|
|
44
|
-
${JSON.stringify({name:
|
|
78
|
+
`,mb=(e,n)=>{const r=n?`当前工作流(JSON):
|
|
79
|
+
${JSON.stringify({name:n.name,tasks:n.tasks.map(t=>({ref:t.taskReferenceName,type:t.type,name:t.name}))},null,2)}`:"当前工作流:尚未定义。";return`
|
|
45
80
|
用户请求:${e}
|
|
46
81
|
|
|
47
|
-
${
|
|
82
|
+
${r}
|
|
48
83
|
|
|
49
84
|
请用中文回答,简明说明你将做什么修改,并在回答末尾(如果有工作流变更)输出一个结构化 diff 块,格式如下:
|
|
50
85
|
|
|
@@ -71,17 +106,17 @@ ${t}
|
|
|
71
106
|
|
|
72
107
|
如果是全量生成新工作流,使用 kind="replace" 并在 diff-json 中加入 "payload": {...完整工作流JSON...}。
|
|
73
108
|
如果不涉及工作流变更(仅解释/回答),则不需要输出 diff-json 块。
|
|
74
|
-
`},
|
|
109
|
+
`},vb=(e,n)=>`
|
|
75
110
|
Context: I am configuring a Conductor task in a workflow.
|
|
76
111
|
Task Reference Name: ${e.taskReferenceName}
|
|
77
112
|
Task Type: ${e.type}
|
|
78
113
|
|
|
79
114
|
Full Workflow Structure for reference:
|
|
80
|
-
${JSON.stringify(
|
|
115
|
+
${JSON.stringify(n,null,2)}
|
|
81
116
|
|
|
82
117
|
Requirement: Suggest 3 meaningful 'inputParameters' or JSONPath expressions for this task based on the workflow context.
|
|
83
118
|
Return the suggestions as a JSON array of objects with { label, value, description }.
|
|
84
|
-
`,
|
|
85
|
-
`).length," 行"]}),d.jsxs("span",{children:[l.length," 字符"]}),l!==r&&d.jsx("span",{style:{color:"#f59e0b",fontWeight:600},children:"● 未保存"})]})]}),document.body)},Qx=[{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:"当前工作流状态"}],eb=({task:e,isOpen:r=!0,onClose:t,aiConfig:n})=>{const{mode:o,updateTask:a,checkTaskRefUniqueness:i}=oe(),[s,l]=q.useState(e),[u,c]=q.useState(e?.taskReferenceName??null),[f,p]=q.useState(null),[h,g]=q.useState(!1),[v,m]=q.useState(null),[x,y]=q.useState(()=>e?.type==="WAIT"&&e.inputParameters?.until?"until":"duration"),[b,k]=q.useState(()=>e?.type==="DO_WHILE"&&e.inputParameters?.items?"items":"condition"),[S,C]=q.useState(()=>!e||e.type!=="FORK_JOIN_DYNAMIC"?"classic":e.forkTaskWorkflow?"workflow":e.forkTaskType?"task":"classic"),[N,A]=q.useState(!1),[w,I]=q.useState(),[R,B]=q.useState([]),[D,L]=q.useState(()=>()=>{}),[F,W]=q.useState(null),V=(T,U,Q,te)=>{W({title:T,value:U,language:Q,onSave:te})},Z=[{label:"引用工作流输入",value:"${workflow.input.data}",description:"引用工作流启动时传入的原始数据"},{label:"引用前序任务输出",value:"${previous_task.output.result}",description:"引用上一个节点的计算结果"},{label:"环境变量",value:"${workflow.variables.api_key}",description:"引用工作流定义的全局变量"}],le=async(T,U)=>{const Q=T.currentTarget.getBoundingClientRect();I(Q),L(()=>U),B([]),A(!0);const te=n?.apiKey||localStorage.getItem("AI_API_KEY")||"";if(!te){B(Z);return}try{const re=n?.baseUrl||localStorage.getItem("AI_BASE_URL")||"",ge=n?.model||localStorage.getItem("AI_MODEL")||"",ve={apiKey:te};re&&(ve.baseUrl=re),ge&&(ve.model=ge);const{workflowDef:ce}=oe.getState(),ye=Yx(se,ce),Ce=(await Ux([{role:"system",content:"You are a Conductor workflow expert. Return only valid JSON."},{role:"user",content:ye}],ve)).match(/\[[\s\S]*\]/);if(Ce){const Xe=JSON.parse(Ce[0]);B(Xe)}else B(Z)}catch{B(Z)}};if(q.useEffect(()=>{e&&(l(e),c(e.taskReferenceName),p(null),e.type==="WAIT"&&y(e.inputParameters?.until?"until":"duration"),e.type==="DO_WHILE"&&k(e.inputParameters?.items?"items":"condition"),e.type==="FORK_JOIN_DYNAMIC"&&(e.forkTaskWorkflow?C("workflow"):e.forkTaskType?C("task"):C("classic")))},[e]),!e&&!s)return null;const se=e||s,_=s&&e&&u===e.taskReferenceName?s:se,Y=r&&e?"panel-enter-active":"panel-exit",K=o==="edit",E="var(--text-primary)",j="var(--glass-border)",M="var(--bg-tertiary)",P="var(--text-secondary)",z=(T,U)=>{const Q={..._,[T]:U};l(Q),a(_.taskReferenceName,{[T]:U})},ee=(T,U,Q)=>{const re={..._[T]||{},[U]:Q},ge={..._,[T]:re};l(ge),a(_.taskReferenceName,{[T]:re})},ae=(T,U)=>{const Q=_.inputParameters||{},re={...Q.http_request||_.httpRequest||{},[T]:U},ve={inputParameters:{...Q,http_request:re}};_.httpRequest&&(ve.httpRequest=re);const ce={..._,...ve};l(ce),a(_.taskReferenceName,ve)},ie=(T,U)=>{const te={inputParameters:{..._.inputParameters,[T]:U}},re={..._,...te};l(re),a(_.taskReferenceName,te)},ne=T=>{if(!v)return;const U=v.selectionStart??0,Q=v.selectionEnd??0,te=v.value,re=te.substring(0,U)+T+te.substring(Q),ge=v.getAttribute("data-field");ge&&z(ge,re),g(!1)},G=(T,U,Q,te)=>d.jsxs("div",{style:{marginBottom:"24px",padding:"16px",borderRadius:"12px",background:`${Q}10`,border:`1px solid ${Q}30`,boxShadow:"0 4px 12px rgba(0,0,0,0.05)"},children:[d.jsxs("div",{style:{fontSize:"12px",fontWeight:"bold",marginBottom:"16px",color:Q,display:"flex",alignItems:"center",gap:"8px"},children:[d.jsx("span",{children:U})," ",T]}),te]}),J=(T,U,Q="text",te)=>{const re=U==="taskReferenceName",ge=re&&f!==null?f:_[U]??"",ve=re&&!i(ge,_.taskReferenceName);return d.jsxs("div",{style:{marginBottom:"16px"},children:[d.jsxs("label",{style:{display:"block",fontSize:"11px",color:P,marginBottom:"6px",fontWeight:"600",textTransform:"uppercase"},children:[T,re&&ve&&d.jsx("span",{style:{color:"#ef4444",marginLeft:"8px",textTransform:"none"},children:"⚠️ 已存在相同引用名"})]}),d.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center"},children:[d.jsx("input",{type:Q,value:ge,placeholder:te,onChange:ce=>{re?p(ce.target.value):z(U,Q==="number"?ce.target.value===""?void 0:Number(ce.target.value):ce.target.value)},onFocus:re?()=>{f===null&&p(_.taskReferenceName??"")}:void 0,onBlur:re?ce=>{const ye=ce.target.value.trim();p(null),ye&&ye!==_.taskReferenceName&&z("taskReferenceName",ye)}:void 0,onKeyDown:re?ce=>{ce.key==="Enter"&&ce.currentTarget.blur(),ce.stopPropagation()}:void 0,disabled:!K,style:{width:"100%",padding:`8px ${K&&!re?"32px":"12px"} 8px 12px`,borderRadius:"6px",border:`1px solid ${ve?"#ef4444":j}`,background:M,color:E,fontSize:"13px",outline:"none",opacity:K?1:.8,fontFamily:re?"monospace":"inherit"}}),K&&!re&&d.jsx("button",{className:"ai-hint-trigger",onClick:ce=>le(ce,ye=>z(U,ye)),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:"✨"})]})]})},H=(T,U,Q,te={})=>{const{rows:re=5,language:ge="text",style:ve,placeholder:ce,"data-field":ye}=te,$e={width:"100%",padding:"12px",borderRadius:"8px",border:`1px solid ${j}`,background:M,color:E,fontSize:"12px",fontFamily:"monospace",lineHeight:"1.5",resize:"vertical",...ve};return d.jsxs("div",{style:{marginBottom:"8px"},children:[d.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"4px"},children:[d.jsx("label",{style:{fontSize:"10px",color:P},children:T}),K&&d.jsx("button",{onClick:()=>V(T,U,ge,Ce=>{Q(Ce),W(null)}),title:"全屏编辑",style:{background:"none",border:"none",cursor:"pointer",fontSize:"14px",padding:"2px 4px",color:"var(--text-secondary)",opacity:.7,lineHeight:1},children:"⛶"})]}),d.jsx("textarea",{value:U,placeholder:ce,onChange:Ce=>Q(Ce.target.value),disabled:!K,rows:re,"data-field":ye,onFocus:Ce=>m(Ce.currentTarget),style:$e})]})},$=(T,U,Q,te="text",re)=>d.jsxs("div",{style:{marginBottom:"12px"},children:[d.jsx("label",{style:{display:"block",fontSize:"10px",color:P,marginBottom:"4px"},children:T}),d.jsx("input",{type:te,value:U??"",placeholder:re,onChange:ge=>Q(te==="number"?ge.target.value===""?void 0:Number(ge.target.value):ge.target.value),disabled:!K,style:{width:"100%",padding:"8px 10px",borderRadius:"6px",border:`1px solid ${j}`,background:M,color:E,fontSize:"12px",outline:"none"}})]}),X=(T,U,Q,te)=>d.jsxs("div",{style:{marginBottom:"12px"},children:[d.jsx("label",{style:{display:"block",fontSize:"10px",color:P,marginBottom:"4px"},children:T}),d.jsx("select",{value:Q,onChange:re=>te(re.target.value),disabled:!K,style:{width:"100%",padding:"8px 10px",borderRadius:"6px",border:`1px solid ${j}`,background:M,color:E,fontSize:"12px",outline:"none",cursor:"pointer"},children:U.map(re=>d.jsx("option",{value:re,children:re},re))})]}),de=(T,U,Q)=>d.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},children:[d.jsx("span",{style:{fontSize:"11px",color:P},children:T}),d.jsx("button",{onClick:()=>Q(!U),disabled:!K,style:{width:"36px",height:"20px",borderRadius:"10px",border:"none",cursor:"pointer",background:U?"var(--color-accent)":j,position:"relative",transition:"background 0.2s"},children:d.jsx("span",{style:{position:"absolute",top:"2px",left:U?"18px":"2px",width:"16px",height:"16px",borderRadius:"50%",background:"#fff",transition:"left 0.2s"}})})]}),ue=(T,U,Q)=>d.jsx("div",{style:{display:"flex",gap:"6px",marginBottom:"12px"},children:T.map(te=>d.jsx("button",{onClick:()=>Q(te.key),disabled:!K,style:{flex:1,padding:"6px",borderRadius:"6px",border:`1px solid ${j}`,cursor:"pointer",fontSize:"11px",fontWeight:U===te.key?"bold":"normal",background:U===te.key?"var(--color-accent)":M,color:U===te.key?"#fff":E},children:te.label},te.key))}),he=_.inputParameters?.http_request||_.httpRequest||{};return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:`detail-panel-container ${Y}`,style:{position:"absolute",right:0,top:0,bottom:0,width:"450px",zIndex:1200,display:"flex",flexDirection:"column",background:"var(--bg-primary)",borderLeft:`1px solid ${j}`,boxShadow:"-10px 0 30px rgba(0, 0, 0, 0.2)",overflowY:"hidden"},children:[d.jsxs("div",{style:{padding:"24px",borderBottom:`1px solid ${j}`,background:"var(--bg-secondary)",flexShrink:0},children:[d.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[d.jsx("div",{style:{background:"var(--color-accent)",color:"#fff",padding:"2px 8px",borderRadius:"4px",fontSize:"10px",fontWeight:"bold",letterSpacing:"1px"},children:_.type||"TASK"}),d.jsx("button",{onClick:t,style:{background:"none",border:"none",color:E,cursor:"pointer",fontSize:"20px"},children:"✕"})]}),K?d.jsx("input",{value:_.name||"",onChange:T=>z("name",T.target.value),placeholder:"任务名称",style:{display:"block",width:"100%",fontSize:"22px",fontWeight:"bold",background:"transparent",border:"none",color:E,outline:"none",borderBottom:"2px dashed var(--color-accent)"}}):d.jsx("div",{style:{fontSize:"22px",fontWeight:"bold"},children:_.name}),d.jsxs("div",{style:{fontSize:"12px",color:P,marginTop:"8px",fontFamily:"monospace",opacity:.8},children:["REF: ",_.taskReferenceName]})]}),d.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"24px",background:"var(--bg-primary)"},children:[_.type==="HTTP"&&G("HTTP 请求配置","🌐","var(--color-accent)",d.jsxs(d.Fragment,{children:[d.jsxs("div",{style:{display:"flex",gap:"8px",marginBottom:"12px"},children:[d.jsx("select",{value:he.method||"GET",onChange:T=>ae("method",T.target.value),disabled:!K,style:{width:"90px",padding:"10px",borderRadius:"8px",background:M,color:E,border:`1px solid ${j}`,cursor:"pointer"},children:["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"].map(T=>d.jsx("option",{value:T,children:T},T))}),d.jsx("input",{placeholder:"URI (支持 ${workflow.input.uri})",value:he.uri||"",onChange:T=>ae("uri",T.target.value),disabled:!K,style:{flex:1,padding:"10px",borderRadius:"8px",background:M,color:E,border:`1px solid ${j}`}})]}),d.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px",marginBottom:"12px"},children:[d.jsxs("div",{children:[d.jsx("label",{style:{display:"block",fontSize:"10px",color:P,marginBottom:"4px"},children:"CONTENT-TYPE"}),d.jsx("input",{placeholder:"application/json",value:he.contentType||"",onChange:T=>ae("contentType",T.target.value),disabled:!K,style:{width:"100%",padding:"8px",borderRadius:"6px",background:M,color:E,border:`1px solid ${j}`,fontSize:"12px"}})]}),d.jsxs("div",{children:[d.jsx("label",{style:{display:"block",fontSize:"10px",color:P,marginBottom:"4px"},children:"ACCEPT"}),d.jsx("input",{placeholder:"application/json",value:he.accept||"",onChange:T=>ae("accept",T.target.value),disabled:!K,style:{width:"100%",padding:"8px",borderRadius:"6px",background:M,color:E,border:`1px solid ${j}`,fontSize:"12px"}})]})]}),d.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px",marginBottom:"12px"},children:[d.jsxs("div",{children:[d.jsx("label",{style:{display:"block",fontSize:"10px",color:P,marginBottom:"4px"},children:"连接超时 (ms)"}),d.jsx("input",{type:"number",placeholder:"3000",value:he.connectionTimeOut??"",onChange:T=>ae("connectionTimeOut",T.target.value===""?void 0:Number(T.target.value)),disabled:!K,style:{width:"100%",padding:"8px",borderRadius:"6px",background:M,color:E,border:`1px solid ${j}`,fontSize:"12px"}})]}),d.jsxs("div",{children:[d.jsx("label",{style:{display:"block",fontSize:"10px",color:P,marginBottom:"4px"},children:"读取超时 (ms)"}),d.jsx("input",{type:"number",placeholder:"3000",value:he.readTimeOut??"",onChange:T=>ae("readTimeOut",T.target.value===""?void 0:Number(T.target.value)),disabled:!K,style:{width:"100%",padding:"8px",borderRadius:"6px",background:M,color:E,border:`1px solid ${j}`,fontSize:"12px"}})]})]}),d.jsxs("div",{style:{marginBottom:"12px"},children:[d.jsx("label",{style:{display:"block",fontSize:"10px",color:P,marginBottom:"4px"},children:"HEADERS (JSON)"}),d.jsx("textarea",{value:typeof he.headers=="object"?JSON.stringify(he.headers,null,2):"{}",onChange:T=>{try{ae("headers",JSON.parse(T.target.value))}catch{}},disabled:!K,rows:3,style:{width:"100%",padding:"8px",borderRadius:"8px",background:M,color:E,border:`1px solid ${j}`,fontSize:"11px",fontFamily:"monospace"}})]}),d.jsx("label",{style:{display:"block",fontSize:"10px",color:P,marginBottom:"4px"},children:"BODY (RAW/JSON)"}),d.jsx("textarea",{value:typeof he.body=="object"?JSON.stringify(he.body,null,2):he.body||"",onChange:T=>{let U=T.target.value;try{U=JSON.parse(T.target.value)}catch{}ae("body",U)},disabled:!K,rows:4,style:{width:"100%",padding:"8px",borderRadius:"8px",background:M,color:E,border:`1px solid ${j}`,fontSize:"11px",fontFamily:"monospace"}})]})),(_.type==="INLINE"||_.type==="LAMBDA")&&G("内联脚本配置 (Inline)","📜","var(--color-accent)",d.jsxs(d.Fragment,{children:[X("脚本引擎",["graaljs","javascript","value-param","python"],_.evaluatorType||"graaljs",T=>z("evaluatorType",T)),H(`EXPRESSION ${_.evaluatorType==="value-param"?"(值引用)":"(脚本)"}`,_.inputParameters?.expression||_.inputParameters?.scriptExpression||"",T=>{const U=_.inputParameters?.scriptExpression!==void 0?"scriptExpression":"expression";ie(U,T)},{rows:10,language:_.evaluatorType||"javascript",style:{background:"#000",color:"var(--color-accent)",border:"1px solid var(--color-accent)"}}),d.jsx("div",{style:{marginTop:"8px",fontSize:"10px",color:P,fontStyle:"italic"},children:"提示: 使用 $.input.key 访问输入参数,返回值作为任务输出。"})]})),_.type==="JSON_JQ_TRANSFORM"&&G("JQ 数据转换","🔍","var(--color-accent)",d.jsxs(d.Fragment,{children:[H("JQ QUERY EXPRESSION",_.inputParameters?.queryExpression||"",T=>ie("queryExpression",T),{rows:6,language:"jq",style:{color:"var(--color-accent)"}}),d.jsx("div",{style:{marginTop:"8px",fontSize:"10px",color:P},children:"输出字段: result(首个结果)、resultList(完整列表)"})]})),_.type==="SUB_WORKFLOW"&&G("子工作流配置","🏗️","var(--color-accent)",d.jsxs(d.Fragment,{children:[$("WORKFLOW NAME *",_.subWorkflowParam?.name||"",T=>ee("subWorkflowParam","name",T),"text","e.g. my_workflow"),$("VERSION",_.subWorkflowParam?.version??"",T=>ee("subWorkflowParam","version",T?parseInt(T):void 0),"number","1"),H("INPUT PARAMETERS MAPPING (JSON)",typeof _.inputParameters=="object"&&_.inputParameters!==null?JSON.stringify(_.inputParameters,null,2):"{}",T=>{try{z("inputParameters",JSON.parse(T))}catch{}},{rows:5,language:"json"}),d.jsxs("div",{style:{fontSize:"10px",color:P,marginTop:"4px"},children:["传递给子工作流的参数,支持 ","${workflow.input.xxx}"," 表达式"]})]})),_.type==="START_WORKFLOW"&&G("启动工作流配置","▶️","var(--color-accent)",d.jsxs(d.Fragment,{children:[d.jsxs("div",{style:{fontSize:"11px",color:P,marginBottom:"12px",padding:"8px",borderRadius:"6px",background:"rgba(255,165,0,0.1)",border:"1px solid rgba(255,165,0,0.3)"},children:["⚡ 注意:此任务启动目标工作流后立即继续,",d.jsx("b",{children:"不等待"}),"目标工作流完成。"]}),$("WORKFLOW NAME *",_.inputParameters?.startWorkflow?.name||"",T=>{const U={..._.inputParameters?.startWorkflow||{},name:T};ie("startWorkflow",U)},"text","e.g. target_workflow"),$("VERSION",_.inputParameters?.startWorkflow?.version??"",T=>{const U={..._.inputParameters?.startWorkflow||{},version:T?parseInt(T):void 0};ie("startWorkflow",U)},"number","1"),$("CORRELATION ID",_.inputParameters?.startWorkflow?.correlationId||"",T=>{const U={..._.inputParameters?.startWorkflow||{},correlationId:T};ie("startWorkflow",U)},"text","${workflow.correlationId}"),H("WORKFLOW INPUT (JSON)",typeof _.inputParameters?.startWorkflow?.input=="object"?JSON.stringify(_.inputParameters.startWorkflow.input,null,2):"{}",T=>{try{const U={..._.inputParameters?.startWorkflow||{},input:JSON.parse(T)};ie("startWorkflow",U)}catch{}},{rows:4,language:"json"})]})),_.type==="TERMINATE"&&G("终止状态配置","⏹️","var(--color-accent)",d.jsxs(d.Fragment,{children:[d.jsx("label",{style:{display:"block",fontSize:"10px",color:P,marginBottom:"4px"},children:"TERMINATION STATUS"}),d.jsx("div",{style:{display:"flex",gap:"8px",marginBottom:"16px"},children:["COMPLETED","FAILED"].map(T=>d.jsx("button",{onClick:()=>ie("terminationStatus",T),disabled:!K,style:{flex:1,padding:"8px",borderRadius:"6px",cursor:"pointer",background:(_.inputParameters?.terminationStatus||"COMPLETED")===T?"var(--color-accent)":M,color:(_.inputParameters?.terminationStatus||"COMPLETED")===T?"#fff":E,border:`1px solid ${j}`,fontWeight:"bold",fontSize:"11px"},children:T},T))}),$("TERMINATION REASON",_.inputParameters?.terminationReason||"",T=>ie("terminationReason",T),"text","终止原因..."),H("WORKFLOW OUTPUT (JSON)",typeof _.inputParameters?.workflowOutput=="object"?JSON.stringify(_.inputParameters.workflowOutput,null,2):"{}",T=>{try{ie("workflowOutput",JSON.parse(T))}catch{}},{rows:3,language:"json"})]})),_.type==="EVENT"&&G("事件发送配置","✉️","var(--color-accent)",d.jsxs(d.Fragment,{children:[$("EVENT SINK *",_.sink||"",T=>z("sink",T),"text","e.g. sqs:queue_name 或 conductor"),d.jsx("div",{style:{fontSize:"10px",color:P,marginTop:"4px",marginBottom:"8px"},children:"支持前缀: conductor | sqs | kafka | amqp | nats"}),de("异步完成 (asyncComplete)",!!_.asyncComplete,T=>z("asyncComplete",T))]})),_.type==="WAIT"&&G("等待状态配置","⏳","var(--color-accent)",d.jsxs(d.Fragment,{children:[ue([{key:"duration",label:"等待时长"},{key:"until",label:"等待到指定时间"}],x,T=>y(T)),x==="duration"?$("DURATION",_.inputParameters?.duration||"",T=>ie("duration",T),"text","e.g. 30s, 10m, 2 hours"):$("UNTIL (时间点)",_.inputParameters?.until||"",T=>ie("until",T),"text","e.g. 2025-06-15 09:00 GMT+00:00"),d.jsxs("div",{style:{fontSize:"11px",color:P,lineHeight:"1.6",marginTop:"8px"},children:["此任务会使工作流进入 ",d.jsx("b",{children:"IN_PROGRESS"})," 状态,直到时间满足或外部 API 触发完成。"]})]})),(_.type==="DECISION"||_.type==="SWITCH")&&G("条件分支配置","⚖️","var(--color-accent)",d.jsxs(d.Fragment,{children:[X("评估模式 (evaluatorType)",["value-param","javascript"],_.evaluatorType||"value-param",T=>z("evaluatorType",T)),(_.evaluatorType||"value-param")==="value-param"?$("CASE VALUE PARAM (参数名)",_.caseValueParam||"",T=>z("caseValueParam",T),"text","e.g. status"):d.jsx(d.Fragment,{children:H("CASE EXPRESSION (JS)",_.caseExpression||"",T=>z("caseExpression",T),{rows:4,language:"javascript",style:{color:"var(--color-accent)"}})}),d.jsx("div",{style:{fontSize:"10px",color:P,marginTop:"8px"},children:'分支可在图中通过右键节点→"添加分支"进行管理'})]})),_.type==="DO_WHILE"&&G("循环逻辑配置","🔄","var(--color-accent)",d.jsxs(d.Fragment,{children:[ue([{key:"condition",label:"条件循环"},{key:"items",label:"列表迭代"}],b,T=>k(T)),b==="condition"?d.jsxs(d.Fragment,{children:[H("LOOP CONDITION (JS) *",_.loopCondition||"",T=>z("loopCondition",T),{rows:4,language:"javascript",style:{color:"var(--color-accent)"}}),d.jsx("div",{style:{fontSize:"10px",color:P,marginTop:"4px"},children:"条件为 true 时继续循环,false 时退出"})]}):d.jsxs(d.Fragment,{children:[d.jsx("label",{style:{display:"block",fontSize:"10px",color:P,marginBottom:"4px"},children:"ITEMS (列表表达式)"}),d.jsx("input",{value:_.inputParameters?.items||"",onChange:T=>ie("items",T.target.value),disabled:!K,placeholder:"${workflow.input.myList}",style:{width:"100%",padding:"8px",borderRadius:"6px",border:`1px solid ${j}`,background:M,color:E,fontSize:"12px",outline:"none"}}),d.jsx("div",{style:{fontSize:"10px",color:P,marginTop:"4px"},children:"引用一个数组,对每个元素执行一次循环体"})]}),d.jsx("div",{style:{marginTop:"12px"},children:$("KEEP LAST N 次迭代",_.keepLastN??"",T=>z("keepLastN",T?parseInt(T):void 0),"number","0 = 保留全部")})]})),_.type==="FORK_JOIN_DYNAMIC"&&G("动态并行配置","⚡","var(--color-accent)",d.jsxs(d.Fragment,{children:[ue([{key:"classic",label:"经典模式"},{key:"task",label:"任务简化"},{key:"workflow",label:"工作流简化"}],S,T=>C(T)),S==="classic"&&d.jsxs(d.Fragment,{children:[$("DYNAMIC_FORK_TASKS_PARAM",_.dynamicForkTasksParam||"",T=>z("dynamicForkTasksParam",T),"text","e.g. dynamic_tasks"),$("DYNAMIC_FORK_TASKS_INPUT_PARAM",_.dynamicForkTasksInputParamName||"",T=>z("dynamicForkTasksInputParamName",T),"text","e.g. input"),d.jsx("div",{style:{fontSize:"10px",color:P},children:"经典模式:通过 inputParameters 传入 dynamicTasks 数组和 dynamicTasksInput 映射"})]}),S==="task"&&d.jsxs(d.Fragment,{children:[$("FORK TASK TYPE *",_.forkTaskType||"",T=>z("forkTaskType",T),"text","e.g. HTTP"),$("FORK TASK NAME (仅 SIMPLE 任务)",_.forkTaskName||"",T=>z("forkTaskName",T),"text","e.g. my_task"),$("FORK TASK INPUTS PARAM",_.forkTaskInputs||"",T=>z("forkTaskInputs",T),"text","e.g. inputs"),d.jsx("div",{style:{fontSize:"10px",color:P},children:"所有分支执行相同任务类型,每个元素作为一个分支输入"})]}),S==="workflow"&&d.jsxs(d.Fragment,{children:[$("FORK WORKFLOW NAME *",_.forkTaskWorkflow||"",T=>z("forkTaskWorkflow",T),"text","e.g. sub_workflow"),$("WORKFLOW VERSION",_.forkTaskWorkflowVersion||"",T=>z("forkTaskWorkflowVersion",T),"text","1"),$("FORK TASK INPUTS PARAM",_.forkTaskInputs||"",T=>z("forkTaskInputs",T),"text","e.g. inputs"),d.jsx("div",{style:{fontSize:"10px",color:P},children:"所有分支执行相同子工作流,每个元素作为一个子工作流输入"})]})]})),_.type==="DYNAMIC"&&G("动态任务配置","🎯","var(--color-accent)",d.jsxs(d.Fragment,{children:[$("DYNAMIC TASK NAME PARAM *",_.dynamicTaskNameParam||"",T=>z("dynamicTaskNameParam",T),"text","e.g. taskToExecute"),d.jsx("div",{style:{fontSize:"10px",color:P,marginTop:"4px"},children:'运行时从 inputParameters 的指定键中读取实际任务类型名(如 "HTTP"、"SIMPLE")'})]})),_.type==="HUMAN"&&G("人工审批配置","👤","var(--color-accent)",d.jsxs(d.Fragment,{children:[$("表单模板名 (userFormTemplate)",_.humanTaskDef?.userFormTemplate||"",T=>ee("humanTaskDef","userFormTemplate",T),"text","e.g. approval_form"),X("分配策略 (assignmentCompletionStrategy)",["LEAVE_OPEN","TERMINATE"],_.humanTaskDef?.assignmentCompletionStrategy||"LEAVE_OPEN",T=>ee("humanTaskDef","assignmentCompletionStrategy",T)),$("显示名称 (displayName)",_.humanTaskDef?.displayName||"",T=>ee("humanTaskDef","displayName",T),"text","审批任务")]})),_.type==="KAFKA_PUBLISH"&&G("Kafka 推送配置","📨","var(--color-accent)",d.jsxs(d.Fragment,{children:[$("BOOTSTRAP SERVERS *",_.inputParameters?.bootStrapServers||"",T=>ie("bootStrapServers",T),"text","localhost:9092"),$("TOPIC *",_.inputParameters?.topic||"",T=>ie("topic",T),"text","my_topic"),$("KEY (消息分区键)",_.inputParameters?.key||"",T=>ie("key",T),"text",""),H("VALUE (消息内容)",typeof _.inputParameters?.value=="object"?JSON.stringify(_.inputParameters.value,null,2):_.inputParameters?.value||"",T=>{let U=T;try{U=JSON.parse(T)}catch{}ie("value",U)},{rows:4,language:"json"}),H("HEADERS (JSON)",typeof _.inputParameters?.headers=="object"?JSON.stringify(_.inputParameters.headers,null,2):"{}",T=>{try{ie("headers",JSON.parse(T))}catch{}},{rows:3,language:"json"})]})),_.type==="SET_VARIABLE"&&G("变量配置","📦","var(--color-accent)",d.jsxs(d.Fragment,{children:[d.jsxs("div",{style:{fontSize:"11px",color:P,marginBottom:"12px"},children:["在 inputParameters 中定义要设置的变量名和值,后续任务通过 ","${workflow.variables.varName}"," 访问。"]}),H("VARIABLES (JSON)",typeof _.inputParameters=="object"&&_.inputParameters!==null?JSON.stringify(_.inputParameters,null,2):"{}",T=>{try{z("inputParameters",JSON.parse(T))}catch{}},{rows:6,language:"json"})]})),d.jsxs("div",{style:{marginTop:"32px",borderTop:`1px solid ${j}`,paddingTop:"24px"},children:[d.jsx("div",{style:{fontSize:"11px",fontWeight:"bold",marginBottom:"16px",opacity:.6,textTransform:"uppercase",letterSpacing:"1px"},children:"通用参数与属性"}),J("任务唯一引用名 (Reference Name)","taskReferenceName"),J("任务描述","description"),d.jsxs("div",{style:{marginBottom:"16px"},children:[d.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"},children:[d.jsxs("label",{style:{fontSize:"11px",color:P,fontWeight:"600",textTransform:"uppercase"},children:["输入参数 (inputParameters) ",d.jsx("span",{style:{opacity:.5,fontWeight:"normal"},children:"(JSON)"})]}),K&&d.jsxs("button",{onClick:()=>g(!h),title:"快捷表达式",style:{fontSize:"11px",background:h?"var(--color-accent)":"none",border:`1px solid ${j}`,borderRadius:"4px",padding:"2px 6px",cursor:"pointer",color:h?"#fff":P},children:["{}"," 快捷片段"]})]}),h&&d.jsx("div",{style:{marginBottom:"8px",padding:"8px",borderRadius:"6px",border:`1px solid ${j}`,background:"var(--bg-secondary)",display:"flex",flexWrap:"wrap",gap:"6px"},children:Qx.map(T=>d.jsx("button",{onClick:()=>ne(T.value),title:T.desc,style:{fontSize:"10px",padding:"3px 8px",borderRadius:"4px",border:`1px solid ${j}`,background:M,color:E,cursor:"pointer",fontFamily:"monospace"},children:T.label},T.value))}),H("",typeof _.inputParameters=="object"&&_.inputParameters!==null?JSON.stringify(_.inputParameters,null,2):_.inputParameters??"",T=>{try{z("inputParameters",JSON.parse(T))}catch{l(U=>({...U,inputParameters:T}))}},{rows:5,language:"json","data-field":"inputParameters",style:{outline:"none"}})]}),d.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[J("重试次数","retryCount","number"),J("超时限制 (秒)","timeoutSeconds","number")]}),d.jsxs("details",{style:{marginTop:"16px"},children:[d.jsx("summary",{style:{fontSize:"11px",cursor:"pointer",color:P,userSelect:"none",fontWeight:"600"},children:"▸ 执行控制(高级)"}),d.jsxs("div",{style:{marginTop:"12px"},children:[X("重试策略 (retryLogic)",["FIXED","EXPONENTIAL_BACKOFF","LINEAR_BACKOFF"],_.retryLogic||"FIXED",T=>z("retryLogic",T)),$("重试延迟 (秒)",_.retryDelaySeconds??"",T=>z("retryDelaySeconds",T?parseInt(T):void 0),"number","0"),X("超时策略 (timeoutPolicy)",["TIME_OUT_WF","ALERT_ONLY","RETRY","FAIL_WORKFLOW"],_.timeoutPolicy||"TIME_OUT_WF",T=>z("timeoutPolicy",T)),$("启动延迟 (秒)",_.startDelay??"",T=>z("startDelay",T?parseInt(T):void 0),"number","0"),de("可选任务 (optional) — 失败不影响工作流",!!_.optional,T=>z("optional",T)),de("异步完成 (asyncComplete)",!!_.asyncComplete,T=>z("asyncComplete",T))]})]})]}),d.jsx("div",{style:{marginTop:"48px",opacity:.6},children:d.jsxs("details",{children:[d.jsx("summary",{style:{fontSize:"11px",cursor:"pointer",marginBottom:"8px"},children:"查看完整 JSON (只读)"}),d.jsx("pre",{style:{background:"rgba(0,0,0,0.2)",padding:"16px",borderRadius:"8px",fontSize:"10px",overflow:"auto",border:`1px solid ${j}`,color:P},children:JSON.stringify(_,null,2)})]})})]}),K&&d.jsxs("div",{style:{padding:"24px",borderTop:`1px solid ${j}`,background:"var(--bg-secondary)",display:"flex",gap:"12px",flexShrink:0},children:[d.jsx("div",{style:{flex:1,fontSize:"11px",color:P,display:"flex",alignItems:"center"},children:"✅ 所有修改已实时同步"}),d.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:"完成退出"})]}),d.jsx(Xx,{isOpen:N,onClose:()=>A(!1),onSelect:D,suggestions:R,anchorRect:w})]}),F&&d.jsx(Zx,{title:F.title,value:F.value,language:F.language,onSave:F.onSave,onClose:()=>W(null)})]})},rb=q.memo(eb),tb={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)"},br=e=>tb[e??""]??"var(--text-secondary)",nb=(e,r)=>{if(!e)return"-";const t=(r??Date.now())-e;return t<1e3?`${t}ms`:`${(t/1e3).toFixed(2)}s`},zh=e=>e?new Date(e).toLocaleTimeString():"-",ab=({executionActions:e})=>{const{selectedTask:r,selectedTaskInstance:t,setSelectedTask:n,setSelectedTaskInstance:o,executionData:a,workflowInstance:i}=oe(),[s,l]=q.useState("summary"),u=q.useRef(null);q.useEffect(()=>{u.current?.scrollTo({top:0})},[s,r?.taskReferenceName]),q.useEffect(()=>{l("summary")},[r?.taskReferenceName]);const c=r?.taskReferenceName==="__workflow_global__",f=r?a?.[r.taskReferenceName]:null;if(!r||!f&&!c)return null;const p=f?.attempts??[],h=t??p[p.length-1],g=i?.workflowId??"",v=i?.status,m=f?.status,x=c?v:h?.status??m,y=c?i?.startTime:h?.startTime,b=c?i?.endTime:h?.endTime,k=c?i?.reasonForIncompletion:h?.reasonForIncompletion,S=c?i?.workflowId:h?.taskId,C=c?i?.input:h?.inputData,N=c?i?.output:h?.outputData,A=!c&&e?.onSkipTask&&(m==="SCHEDULED"||m==="IN_PROGRESS")&&(v==="RUNNING"||v==="PAUSED"),w=!c&&e?.onRerunFromTask&&(v==="FAILED"||v==="TERMINATED"||v==="COMPLETED"||v==="TIMED_OUT"),I=A||w,R=e?.allowOperations!==!1,B=()=>{n(null),o(null)},D="var(--glass-border)",L="var(--text-secondary)",F="var(--bg-tertiary)";return d.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 ${D}`,boxShadow:"-10px 0 30px rgba(0,0,0,0.2)",overflow:"hidden"},children:[d.jsxs("div",{style:{padding:"20px 24px",borderBottom:`1px solid ${D}`,background:"var(--bg-secondary)",flexShrink:0},children:[d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[d.jsx("div",{style:{background:"var(--color-accent)",color:"#fff",padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:"bold",letterSpacing:"1px",flexShrink:0},children:c?"WORKFLOW":r.type||"TASK"}),x&&d.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:5,padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:700,background:`${br(x)}18`,color:br(x),letterSpacing:"0.5px",flexShrink:0},children:["● ",x]}),d.jsx("div",{style:{flex:1}}),d.jsx("button",{onClick:B,style:{background:"none",border:"none",color:L,cursor:"pointer",fontSize:20,lineHeight:1,padding:4},children:"✕"})]}),d.jsx("div",{style:{fontSize:20,fontWeight:700,color:"var(--text-primary)",lineHeight:1.3},children:c?"工作流全局数据":r.name}),d.jsxs("div",{style:{fontSize:12,color:L,marginTop:6,fontFamily:"monospace",opacity:.8},children:["REF: ",r.taskReferenceName]})]}),p.length>1&&d.jsxs("div",{style:{padding:"12px 24px",borderBottom:`1px solid ${D}`,background:"var(--bg-secondary)",flexShrink:0},children:[d.jsxs("div",{style:{fontSize:11,fontWeight:600,color:L,marginBottom:8,textTransform:"uppercase",letterSpacing:"0.5px"},children:["执行记录(",p.length," 次",p.some(W=>W.iteration)?" / 迭代":"尝试",")"]}),d.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:p.map((W,V)=>{const Z=h?.taskId===W.taskId;return d.jsx("button",{onClick:()=>o(W),style:{padding:"4px 12px",borderRadius:20,fontSize:12,cursor:"pointer",border:`1px solid ${Z?"var(--color-accent)":D}`,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)})})]}),d.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${D}`,background:"var(--bg-secondary)",flexShrink:0},children:["summary","input","output"].map(W=>{const V={summary:"概览",input:"输入 JSON",output:"输出 JSON"},Z=s===W;return d.jsx("button",{onClick:()=>l(W),style:{padding:"10px 20px",background:"none",border:"none",borderBottom:`2px solid ${Z?"var(--color-accent)":"transparent"}`,color:Z?"var(--color-accent)":L,cursor:"pointer",fontSize:13,fontWeight:Z?600:400,fontFamily:"inherit",transition:"all 0.15s"},children:V[W]},W)})}),d.jsxs("div",{ref:u,style:{flex:1,overflowY:"auto",padding:24,background:"var(--bg-primary)"},children:[s==="summary"&&d.jsxs(d.Fragment,{children:[d.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,marginBottom:24},children:[{label:"总耗时",value:nb(y,b)},{label:"开始时间",value:zh(y)},{label:"结束时间",value:zh(b)},{label:c?"Workflow ID":"Task ID",value:d.jsx("span",{style:{fontSize:10,fontFamily:"monospace",opacity:.7,wordBreak:"break-all"},children:S??"-"})}].map(({label:W,value:V})=>d.jsxs("div",{style:{padding:"12px 14px",background:F,borderRadius:10,border:`1px solid ${D}`},children:[d.jsx("div",{style:{fontSize:10,color:L,textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:6,fontWeight:600},children:W}),d.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",fontSize:13},children:V})]},W))}),p.length>1&&d.jsxs("div",{style:{marginBottom:20,padding:"10px 14px",background:`${br(m)}10`,border:`1px solid ${br(m)}30`,borderRadius:8,fontSize:12,color:br(m),display:"flex",alignItems:"center",gap:8},children:[d.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[d.jsx("path",{d:"M13 2v4h-4"}),d.jsx("path",{d:"M13 6A7 7 0 1 1 9.5 2.5"})]}),"已重试 ",p.length-1," 次,共 ",p.length," 次尝试"]}),!c&&h?.workerId&&d.jsxs("div",{style:{marginBottom:20},children:[d.jsx("div",{style:{fontSize:10,color:L,textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:4,fontWeight:600},children:"Worker"}),d.jsx("div",{style:{fontSize:12,fontFamily:"monospace",color:"var(--text-primary)",opacity:.8},children:h.workerId})]}),k&&d.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:[d.jsx("strong",{children:"异常信息"}),d.jsx("div",{style:{marginTop:6,opacity:.9},children:k})]}),I&&d.jsxs("div",{style:{marginTop:24,paddingTop:20,borderTop:`1px solid ${D}`},children:[d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[d.jsx("div",{style:{fontSize:11,fontWeight:600,color:L,textTransform:"uppercase",letterSpacing:"0.5px"},children:"任务操作"}),!R&&d.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:[d.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[d.jsx("circle",{cx:"8",cy:"8",r:"6"}),d.jsx("path",{d:"M8 5v3M8 11v.5"})]}),"操作权限受限"]})]}),d.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[w&&d.jsxs("button",{disabled:!R,onClick:()=>R&&e.onRerunFromTask(g,r.taskReferenceName,h?.taskId),title:R?`从任务 ${r.taskReferenceName} 处重新运行工作流`:"操作权限受限",style:R?Ye:Hh,onMouseEnter:W=>!R||Object.assign(W.currentTarget.style,ob),onMouseLeave:W=>!R||Object.assign(W.currentTarget.style,Ye),children:[d.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[d.jsx("path",{d:"M3 14v-4h4"}),d.jsx("path",{d:"M3 10A7 7 0 1 1 6.5 13.5"})]}),"从此处重新运行"]}),A&&d.jsxs("button",{disabled:!R,onClick:()=>R&&e.onSkipTask(g,r.taskReferenceName,h?.taskId),title:R?`跳过任务 ${r.taskReferenceName}`:"操作权限受限",style:R?Ye:Hh,onMouseEnter:W=>!R||Object.assign(W.currentTarget.style,ib),onMouseLeave:W=>!R||Object.assign(W.currentTarget.style,Ye),children:[d.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:d.jsx("path",{d:"M4 4l8 8M12 4l-8 8"})}),"跳过此任务"]})]})]})]}),s==="input"&&d.jsx($h,{data:C}),s==="output"&&d.jsx($h,{data:N})]})]})},$h=({data:e})=>d.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)}),Ye={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"},ob={...Ye,borderColor:"var(--color-accent)",color:"var(--color-accent)",background:"var(--bg-primary)"},ib={...Ye,borderColor:"var(--status-failed)",color:"var(--status-failed)",background:"rgba(239,68,68,0.08)"},Hh={...Ye,opacity:.45,cursor:"not-allowed",border:"1px solid var(--border-primary)",background:"var(--bg-secondary)",color:"var(--text-secondary)"},sb={add:"新增",mod:"修改",del:"删除",replace:"替换"},cb={add:"+",mod:"~",del:"−"};function ub({diff:e,applied:r,onApply:t,onUndo:n}){const o=e.kind==="replace"?"add":e.kind;return d.jsxs("div",{className:"diff-card",children:[d.jsxs("div",{className:"diff-head",children:[d.jsx("span",{className:`diff-badge ${o}`,children:sb[e.kind]??e.kind}),d.jsx("span",{className:"diff-summary",children:e.summary})]}),e.rows&&e.rows.length>0&&d.jsx("div",{className:"diff-list",children:e.rows.map((a,i)=>d.jsxs("div",{className:`diff-row ${a.kind}`,children:[d.jsx("div",{className:"diff-marker",children:cb[a.kind]??"·"}),d.jsx("div",{className:"diff-desc",children:a.desc})]},i))}),d.jsx("div",{className:"diff-actions",children:r?d.jsxs(d.Fragment,{children:[d.jsxs("button",{className:"diff-btn applied",disabled:!0,children:[d.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:d.jsx("path",{d:"M3 8l3.5 3.5L13 5",strokeLinecap:"round",strokeLinejoin:"round"})}),"已应用"]}),d.jsxs("button",{className:"diff-btn undo",onClick:n,children:[d.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[d.jsx("path",{d:"M3.5 8a4.5 4.5 0 1 1 1.4 3.3",strokeLinecap:"round"}),d.jsx("path",{d:"M3 4.5L4.5 8L7 6.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),"撤销"]})]}):d.jsxs("button",{className:"diff-btn apply",onClick:t,children:[d.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:d.jsx("path",{d:"M3 8l3.5 3.5L13 5",strokeLinecap:"round",strokeLinejoin:"round"})}),"应用更改"]})})]})}function Kh(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=[],o=[];for(const a of r.patch)if(a.op==="patchTask"){const i=t.tasks.find(l=>l.taskReferenceName===a.ref);if(!i)continue;const s={};for(const l of Object.keys(a.set))s[l]=i[l];Object.assign(i,a.set),n.push({op:"patchTask",ref:a.ref,set:s}),o.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}),o.push({kind:"del",desc:`移除边 ${a.from} → ${a.to}`});else if(a.op==="removeEdge")t.edges=(t.edges??[]).filter(i=>!(i.from===a.from&&i.to===a.to)),n.push({op:"addEdge",from:a.from,to:a.to}),o.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(i=>{t.edges=t.edges.filter(s=>!(s.from===i.from&&s.to===i.to))}),a.extraEdges&&a.extraEdges.forEach(i=>t.edges.push(i)),n.push({op:"removeTask",ref:a.task.taskReferenceName}),o.push({kind:"del",desc:`移除 ${a.task.taskReferenceName}`});else if(a.op==="removeTask"){const i=t.tasks.findIndex(u=>u.taskReferenceName===a.ref);if(i<0)continue;const[s]=t.tasks.splice(i,1),l=(t.edges??[]).filter(u=>u.from===a.ref||u.to===a.ref);t.edges=(t.edges??[]).filter(u=>u.from!==a.ref&&u.to!==a.ref),n.push({op:"addTask",task:s,extraEdges:l}),o.push({kind:"add",desc:`恢复 ${a.ref}`})}else if(a.op==="insertAfter"){t.tasks.push(a.task),t.edges=t.edges??[];const i=t.edges.findIndex(s=>s.from===a.after&&s.to===a.edgeTo);i>=0&&t.edges.splice(i,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}),o.push({kind:"del",desc:`移除 ${a.task.taskReferenceName}(恢复直连边)`})}else if(a.op==="insertBefore"){t.tasks.push(a.task),t.edges=t.edges??[];const i=t.edges.filter(s=>s.to===a.before);t.edges=t.edges.filter(s=>s.to!==a.before),i.forEach(s=>t.edges.push({from:s.from,to:a.task.taskReferenceName,label:s.label})),t.edges.push({from:a.task.taskReferenceName,to:a.before}),n.push({op:"removeTask",ref:a.task.taskReferenceName}),o.push({kind:"del",desc:`移除 ${a.task.taskReferenceName}(恢复原有入边)`})}return{next:t,inverse:{kind:r.kind,summary:`撤销:${r.summary}`,rows:o,patch:n.reverse()}}}function lb(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 Uh={id:"1",role:"ai",content:"你好!我是您的流程助手。我可以帮你生成工作流框架、优化逻辑或提供参数配置建议。你想实现什么样的流程?"},Jh=e=>e.split(/(```[\s\S]*?```)/).map((t,n)=>{if(t.startsWith("```")&&t.endsWith("```")){const o=t.slice(3,-3),a=o.indexOf(`
|
|
86
|
-
`),
|
|
87
|
-
`&&r.push(d.jsx("br",{},o.index)),n=o.index+a.length}return n<e.length&&r.push(e.slice(n)),r},fb=({aiConfig:e})=>{const{workflowDef:r,setWorkflow:t,mode:n}=oe(),[o,a]=q.useState(!1),[i,s]=q.useState(""),[l,u]=q.useState(!1),[c,f]=q.useState([Uh]),[p,h]=q.useState(""),[g,v]=q.useState(null),m=q.useRef(null),x=q.useRef(null),y=q.useRef(null),b=q.useCallback(L=>{if(!L.diff||L.applied||!r)return;const{next:F,inverse:W}=Kh(r,L.diff);t(F),f(V=>V.map(Z=>Z.id===L.id?{...Z,applied:!0,inverse:W}:Z))},[r,t]),k=q.useCallback(L=>{if(!L.inverse||!L.applied||!r)return;const{next:F}=Kh(r,L.inverse);t(F),f(W=>W.map(V=>V.id===L.id?{...V,applied:!1,inverse:void 0}:V))},[r,t]),S=()=>{const L=x.current;L&&(L.style.height="auto",L.style.height=Math.min(L.scrollHeight,120)+"px")},C=()=>{const L=x.current;L&&(L.style.height="auto")};q.useEffect(()=>()=>{y.current?.abort()},[]),q.useEffect(()=>{const L=()=>a(!0);return window.addEventListener("open-ai-chat",L),()=>window.removeEventListener("open-ai-chat",L)},[]);const N=()=>{m.current?.scrollIntoView({behavior:"smooth"})};q.useEffect(()=>{o&&N()},[c,o,p]);const A=q.useCallback(L=>{const F=[{role:"system",content:Gx}];for(const V of c)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=Vx(L,r);return F.push({role:"user",content:W}),F},[c,r]),w=async L=>{const F=i.trim();if(!F||l)return;y.current?.abort();const W=new AbortController;y.current=W;const V={id:Date.now().toString(),role:"user",content:F};f(Z=>[...Z,V]),s(""),C(),u(!0),h("");try{const Z=e?.apiKey||localStorage.getItem("AI_API_KEY")||"",le=e?.baseUrl||localStorage.getItem("AI_BASE_URL")||"",se=e?.model||localStorage.getItem("AI_MODEL")||"";if(!Z){setTimeout(()=>{if(W.signal.aborted)return;const P={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:P}};f(ee=>[...ee,z]),u(!1)},800);return}const _={apiKey:Z};le&&(_.baseUrl=le),se&&(_.model=se);const Y=A(F),K=await Jx(Y,_,P=>{h(z=>z+P)},()=>{},W.signal);let j=lb(K);if(!j){const P=K.match(/```json\n([\s\S]*?)\n```/);if(P)try{const z=JSON.parse(P[1]);j={kind:"replace",summary:"应用 AI 生成的工作流",rows:[{kind:"add",desc:"全量替换为 AI 生成的工作流定义"}],payload:z}}catch{}}const M={id:(Date.now()+1).toString(),role:"ai",content:K,diff:j??void 0,applied:!1};f(P=>[...P,M]),h("")}catch(Z){if(Z.name==="AbortError")h(le=>{if(le){const se={id:(Date.now()+1).toString(),role:"ai",content:le};f(_=>[..._,se])}return""});else{const le={id:Date.now().toString(),role:"ai",content:`抱歉,目前无法连接到 AI 服务: ${Z.message}`};f(se=>[...se,le]),h("")}}finally{u(!1)}},I=()=>{y.current?.abort()},R=()=>{y.current?.abort(),f([Uh]),h(""),u(!1)},B=L=>{navigator.clipboard.writeText(L.content??""),v(L.id),setTimeout(()=>v(null),1500)},D=L=>{L.nativeEvent.isComposing||L.keyCode===229||L.key==="Enter"&&!L.shiftKey&&(L.preventDefault(),w())};return n!=="edit"?null:o?d.jsxs("div",{className:"ai-chat-panel",children:[d.jsxs("div",{className:"ai-header",children:[d.jsxs("div",{className:"ai-title",children:[d.jsx("span",{className:"ai-sparkles",children:"✨"}),"AI 助手"]}),d.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[d.jsx("button",{className:"ai-close",onClick:R,title:"清空对话",children:"🗑"}),d.jsx("button",{className:"ai-close",onClick:()=>a(!1),children:"×"})]})]}),d.jsxs("div",{className:"ai-messages",children:[c.map(L=>d.jsxs("div",{className:`message ${L.role}`,children:[d.jsx("div",{className:"message-content",children:L.thinking?d.jsxs("div",{className:"thinking-skeleton",children:[d.jsx("div",{className:"skeleton-line",style:{width:"80%"}}),d.jsx("div",{className:"skeleton-line",style:{width:"60%"}})]}):L.role==="ai"?Jh(L.content??""):L.content}),L.diff&&!L.thinking&&d.jsx(ub,{diff:L.diff,applied:L.applied??!1,onApply:()=>b(L),onUndo:()=>k(L)}),L.role==="ai"&&L.content&&d.jsx("button",{className:"copy-btn",onClick:()=>B(L),title:"复制",children:g===L.id?"✓":"📋"})]},L.id)),l&&p&&d.jsxs("div",{className:"message ai",style:{opacity:.9},children:[d.jsx("div",{className:"message-content",children:Jh(p)}),d.jsx("span",{className:"streaming-cursor",children:"▊"})]}),l&&!p&&d.jsxs("div",{className:"message ai thinking-skeleton",children:[d.jsx("div",{className:"skeleton-line",style:{width:"80%"}}),d.jsx("div",{className:"skeleton-line",style:{width:"60%"}}),d.jsx("div",{className:"skeleton-line",style:{width:"70%"}})]}),d.jsx("div",{ref:m})]}),d.jsx("div",{className:"ai-input-area",children:d.jsxs("div",{className:"ai-input-container",children:[d.jsx("textarea",{ref:x,className:"ai-input",placeholder:l?"AI 正在响应...":"描述您的需求…(Shift+Enter 换行)",value:i,onChange:L=>s(L.target.value),onInput:S,onKeyDown:D,disabled:l,rows:2}),l?d.jsx("button",{className:"ai-send stop",onClick:I,title:"停止生成",children:"⏹"}):d.jsx("button",{className:"ai-send",onClick:()=>w(),title:"发送",children:"🚀"})]})})]}):d.jsx("div",{className:"ai-chat-panel collapsed",onClick:()=>a(!0),children:d.jsx("div",{className:"ai-header",style:{borderBottom:"none"},children:d.jsxs("div",{className:"ai-title",children:[d.jsx("span",{className:"ai-sparkles",children:"✨"}),"AI 助手"]})})})},Gh=q.forwardRef(({workflowDef:e,readOnly:r=!1,theme:t="dark",themeColor:n="blue",layoutDirection:o="LR",searchQuery:a="",workflowExecution:i,onRequestImport:s,executionActions:l,aiConfig:u,viewMode:c="developer",onSave:f,onWorkflowChange:p,height:h="100%"},g)=>{const{setWorkflow:v,setTheme:m,setThemeColor:x,setLayoutDirection:y,setNodesLocked:b,selectedTask:k,setSelectedTask:S,edgeType:C,importExecutionJSON:N,setMode:A,setViewMode:w,isDetailPanelOpen:I,setIsDetailPanelOpen:R,selectTaskAction:B,workflowDef:D,isSimRunning:L,startSimulation:F,stopSimulation:W,mode:V}=oe(),[Z,le]=q.useState(!1),se=q.useCallback(()=>{if(!D)return;const K=new Blob([JSON.stringify(D,null,2)],{type:"application/json"}),E=URL.createObjectURL(K),j=document.createElement("a");j.href=E,j.download=`${D.name||"workflow"}.json`,j.click(),URL.revokeObjectURL(E)},[D]),_=q.useCallback(()=>{D&&navigator.clipboard.writeText(JSON.stringify(D,null,2))},[D]);q.useEffect(()=>{m(t),x(n),y(o),b(r||!!i)},[t,n,o,r,i,m,x,y,b]),q.useEffect(()=>{w(i?"developer":c)},[c,i,w]),q.useEffect(()=>{e&&(v(e,o),oe.temporal.getState().clear())},[e,v,o]),q.useEffect(()=>{i?N(i):A(r?"view":"edit")},[i,N,A,r]),q.useImperativeHandle(g,()=>({getWorkflowDef:()=>oe.getState().workflowDef,getValidationResults:()=>oe.getState().validationResults,save:()=>{const K=oe.getState().workflowDef;K&&f&&f(K)},createBlankWorkflow:K=>{oe.getState().createBlankWorkflow(K),oe.temporal.getState().clear()}}),[f]),q.useEffect(()=>{if(!p)return;let K=!0,E=oe.getState().workflowDef;return oe.subscribe(M=>{const P=M.workflowDef;if(P!==E){if(E=P,K){K=!1;return}P&&p(P)}})},[p]);const Y=K=>{i?S(K):B(K,!0)};return d.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:[d.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:[d.jsx("div",{style:{flex:1}}),V!=="run"&&D&&(L?d.jsxs("button",{onClick:W,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:[d.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"currentColor",children:d.jsx("rect",{x:"4",y:"4",width:"8",height:"8",rx:"1"})}),"停止"]}):d.jsxs("button",{onClick:F,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:[d.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"currentColor",children:d.jsx("path",{d:"M4 3l9 5-9 5z"})}),"模拟运行"]})),D&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{onClick:se,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:[d.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:d.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"]}),d.jsxs("button",{onClick:_,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:[d.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[d.jsx("rect",{x:"4",y:"4",width:"9",height:"10",rx:"1"}),d.jsx("path",{d:"M2 10V3a1 1 0 0 1 1-1h7",strokeLinecap:"round"})]}),"复制 DSL"]})]})]}),d.jsx("div",{className:"workflow-viewer",style:{flex:1,position:"relative",overflow:"hidden"},children:d.jsx(O.ReactFlowProvider,{children:d.jsx(Kx,{onNodeClick:Y,edgeType:C,theme:t,nodesLocked:r||!!i,searchQuery:a,onSave:f,onRequestImport:s,executionActions:l})})}),d.jsx(rb,{task:k,isOpen:I,onClose:()=>R(!1),theme:t,aiConfig:u}),d.jsx(Oh,{isOpen:Z,onClose:()=>le(!1),theme:t,onTaskSelect:K=>{B(K,!0)}}),i&&d.jsx(ab,{executionActions:l}),d.jsx(fb,{aiConfig:u})]})});Gh.displayName="WorkflowIDE",Le.WorkflowIDE=Gh,Object.defineProperty(Le,Symbol.toStringTag,{value:"Module"})}));
|
|
119
|
+
`,yb=({isOpen:e,onClose:n,onSelect:r,suggestions:t,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:n}),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:t.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%"}})]}):t.map((o,i)=>l.jsxs("div",{className:"suggestion-item",onClick:()=>{r(o.value),n()},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))})]})]})},xb=({title:e,value:n,language:r="text",placeholder:t="",onSave:s,onClose:a})=>{const{theme:o,themeColor:i}=oe(),[u,c]=O.useState(n),d=O.useRef(null);O.useEffect(()=>{d.current?.focus();const h=g=>{g.key==="Escape"&&(g.stopPropagation(),a()),(g.ctrlKey||g.metaKey)&&g.key==="s"&&(g.preventDefault(),g.stopPropagation(),s(u))};return window.addEventListener("keydown",h,!0),()=>window.removeEventListener("keydown",h,!0)},[u,s,a]);const p={javascript:"#f7df1e",js:"#f7df1e",json:"#89b4fa",jq:"#a6e3a1",groovy:"#4ec994",python:"#3572A5",text:"var(--text-secondary)"}[r.toLowerCase()]??"var(--text-secondary)";return Qr.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:r}),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(u),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:d,value:u,placeholder:t,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: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)"}}),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:[u.split(`
|
|
120
|
+
`).length," 行"]}),l.jsxs("span",{children:[u.length," 字符"]}),u!==n&&l.jsx("span",{style:{color:"#f59e0b",fontWeight:600},children:"● 未保存"})]})]}),document.body)},bb=[{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:"当前工作流状态"}],kb=({task:e,isOpen:n=!0,onClose:r,aiConfig:t})=>{const{mode:s,updateTask:a,checkTaskRefUniqueness:o}=oe(),[i,u]=O.useState(e),[c,d]=O.useState(e?.taskReferenceName??null),[f,p]=O.useState(null),[h,g]=O.useState(!1),[m,v]=O.useState(null),[y,x]=O.useState(()=>e?.type==="WAIT"&&e.inputParameters?.until?"until":"duration"),[b,k]=O.useState(()=>e?.type==="DO_WHILE"&&e.inputParameters?.items?"items":"condition"),[w,j]=O.useState(()=>!e||e.type!=="FORK_JOIN_DYNAMIC"?"classic":e.forkTaskWorkflow?"workflow":e.forkTaskType?"task":"classic"),[N,L]=O.useState(!1),[T,C]=O.useState(),[S,D]=O.useState([]),[I,P]=O.useState(()=>()=>{}),[F,W]=O.useState(null),[K,V]=O.useState(!1),[te,re]=O.useState(null),q=(E,J,se,ue)=>{W({title:E,value:J,language:se,onSave:ue})},G=[{label:"引用工作流输入",value:"${workflow.input.data}",description:"引用工作流启动时传入的原始数据"},{label:"引用前序任务输出",value:"${previous_task.output.result}",description:"引用上一个节点的计算结果"},{label:"环境变量",value:"${workflow.variables.api_key}",description:"引用工作流定义的全局变量"}],ie=async()=>{const E=t?.apiKey||localStorage.getItem("AI_API_KEY")||"";if(!E){alert("请先在设置中配置 AI API Key");return}if(M){V(!0);try{const{workflowDef:J,taskMap:se}=oe.getState(),ue=Zr(J?.inputParameters).map(fe=>fe.name),de=Object.values(se).filter(fe=>fe.taskReferenceName!==M.taskReferenceName).map(fe=>({ref:fe.taskReferenceName,type:fe.type,name:fe.name})).slice(0,10),ve={apiKey:E};t?.baseUrl&&(ve.baseUrl=t.baseUrl),t?.model&&(ve.model=t.model);const xe=await hb(M.type,M.taskReferenceName,ue,de,M.inputParameters??{},ve);re({generated:xe,original:M.inputParameters??{}})}catch(J){alert(`AI 生成失败:${J?.message||"未知错误"}`)}finally{V(!1)}}},R=async(E,J)=>{const se=E.currentTarget.getBoundingClientRect();C(se),P(()=>J),D([]),L(!0);const ue=t?.apiKey||localStorage.getItem("AI_API_KEY")||"";if(!ue){D(G);return}try{const de=t?.baseUrl||localStorage.getItem("AI_BASE_URL")||"",ve=t?.model||localStorage.getItem("AI_MODEL")||"",xe={apiKey:ue};de&&(xe.baseUrl=de),ve&&(xe.model=ve);const{workflowDef:fe}=oe.getState(),_e=vb(M,fe),ye=(await Zh([{role:"system",content:"You are a Conductor workflow expert. Return only valid JSON."},{role:"user",content:_e}],xe)).match(/\[[\s\S]*\]/);if(ye){const dr=JSON.parse(ye[0]);D(dr)}else D(G)}catch{D(G)}};if(O.useEffect(()=>{e&&(u(e),d(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=n&&e?"panel-enter-active":"panel-exit",$=s==="edit",X="var(--text-primary)",U="var(--glass-border)",le="var(--bg-tertiary)",Q="var(--text-secondary)",ee=(E,J)=>{const se={..._,[E]:J};u(se),a(_.taskReferenceName,{[E]:J})},he=(E,J,se)=>{const de={..._[E]||{},[J]:se},ve={..._,[E]:de};u(ve),a(_.taskReferenceName,{[E]:de})},z=(E,J)=>{const se=_.inputParameters||{},de={...se.http_request||_.httpRequest||{},[E]:J},xe={inputParameters:{...se,http_request:de}};_.httpRequest&&(xe.httpRequest=de);const fe={..._,...xe};u(fe),a(_.taskReferenceName,xe)},Z=(E,J)=>{const ue={inputParameters:{..._.inputParameters,[E]:J}},de={..._,...ue};u(de),a(_.taskReferenceName,ue)},H=E=>{if(!m)return;const J=m.selectionStart??0,se=m.selectionEnd??0,ue=m.value,de=ue.substring(0,J)+E+ue.substring(se),ve=m.getAttribute("data-field");ve&&ee(ve,de),g(!1)},ne=(E,J,se,ue)=>l.jsxs("div",{style:{marginBottom:"24px",padding:"16px",borderRadius:"12px",background:`${se}10`,border:`1px solid ${se}30`,boxShadow:"0 4px 12px rgba(0,0,0,0.05)"},children:[l.jsxs("div",{style:{fontSize:"12px",fontWeight:"bold",marginBottom:"16px",color:se,display:"flex",alignItems:"center",gap:"8px"},children:[l.jsx("span",{children:J})," ",E]}),ue]}),Y=(E,J,se="text",ue)=>{const de=J==="taskReferenceName",ve=de&&f!==null?f:_[J]??"",xe=de&&!o(ve,_.taskReferenceName);return l.jsxs("div",{style:{marginBottom:"16px"},children:[l.jsxs("label",{style:{display:"block",fontSize:"11px",color:Q,marginBottom:"6px",fontWeight:"600",textTransform:"uppercase"},children:[E,de&&xe&&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:se,value:ve,placeholder:ue,onChange:fe=>{de?p(fe.target.value):ee(J,se==="number"?fe.target.value===""?void 0:Number(fe.target.value):fe.target.value)},onFocus:de?()=>{f===null&&p(_.taskReferenceName??"")}:void 0,onBlur:de?fe=>{const _e=fe.target.value.trim();p(null),_e&&_e!==_.taskReferenceName&&ee("taskReferenceName",_e)}:void 0,onKeyDown:de?fe=>{fe.key==="Enter"&&fe.currentTarget.blur(),fe.stopPropagation()}:void 0,disabled:!$,style:{width:"100%",padding:`8px ${$&&!de?"32px":"12px"} 8px 12px`,borderRadius:"6px",border:`1px solid ${xe?"#ef4444":U}`,background:le,color:X,fontSize:"13px",outline:"none",opacity:$?1:.8,fontFamily:de?"monospace":"inherit"}}),$&&!de&&l.jsx("button",{className:"ai-hint-trigger",onClick:fe=>R(fe,_e=>ee(J,_e)),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:"✨"})]})]})},ge=(E,J,se,ue={})=>{const{rows:de=5,language:ve="text",style:xe,placeholder:fe,"data-field":_e}=ue,wr={width:"100%",padding:"12px",borderRadius:"8px",border:`1px solid ${U}`,background:le,color:X,fontSize:"12px",fontFamily:"monospace",lineHeight:"1.5",resize:"vertical",...xe};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:Q},children:E}),$&&l.jsx("button",{onClick:()=>q(E,J,ve,ye=>{se(ye),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:J,placeholder:fe,onChange:ye=>se(ye.target.value),disabled:!$,rows:de,"data-field":_e,onFocus:ye=>v(ye.currentTarget),style:wr})]})},ae=(E,J,se,ue="text",de)=>l.jsxs("div",{style:{marginBottom:"12px"},children:[l.jsx("label",{style:{display:"block",fontSize:"10px",color:Q,marginBottom:"4px"},children:E}),l.jsx("input",{type:ue,value:J??"",placeholder:de,onChange:ve=>se(ue==="number"?ve.target.value===""?void 0:Number(ve.target.value):ve.target.value),disabled:!$,style:{width:"100%",padding:"8px 10px",borderRadius:"6px",border:`1px solid ${U}`,background:le,color:X,fontSize:"12px",outline:"none"}})]}),pe=(E,J,se,ue)=>l.jsxs("div",{style:{marginBottom:"12px"},children:[l.jsx("label",{style:{display:"block",fontSize:"10px",color:Q,marginBottom:"4px"},children:E}),l.jsx("select",{value:se,onChange:de=>ue(de.target.value),disabled:!$,style:{width:"100%",padding:"8px 10px",borderRadius:"6px",border:`1px solid ${U}`,background:le,color:X,fontSize:"12px",outline:"none",cursor:"pointer"},children:J.map(de=>l.jsx("option",{value:de,children:de},de))})]}),me=(E,J,se)=>l.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},children:[l.jsx("span",{style:{fontSize:"11px",color:Q},children:E}),l.jsx("button",{onClick:()=>se(!J),disabled:!$,style:{width:"36px",height:"20px",borderRadius:"10px",border:"none",cursor:"pointer",background:J?"var(--color-accent)":U,position:"relative",transition:"background 0.2s"},children:l.jsx("span",{style:{position:"absolute",top:"2px",left:J?"18px":"2px",width:"16px",height:"16px",borderRadius:"50%",background:"#fff",transition:"left 0.2s"}})})]}),Ne=(E,J,se)=>l.jsx("div",{style:{display:"flex",gap:"6px",marginBottom:"12px"},children:E.map(ue=>l.jsx("button",{onClick:()=>se(ue.key),disabled:!$,style:{flex:1,padding:"6px",borderRadius:"6px",border:`1px solid ${U}`,cursor:"pointer",fontSize:"11px",fontWeight:J===ue.key?"bold":"normal",background:J===ue.key?"var(--color-accent)":le,color:J===ue.key?"#fff":X},children:ue.label},ue.key))}),ce=_.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 ${U}`,boxShadow:"-10px 0 30px rgba(0, 0, 0, 0.2)",overflowY:"hidden"},children:[l.jsxs("div",{style:{padding:"24px",borderBottom:`1px solid ${U}`,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:r,style:{background:"none",border:"none",color:X,cursor:"pointer",fontSize:"20px"},children:"✕"})]}),$?l.jsx("input",{value:_.name||"",onChange:E=>ee("name",E.target.value),placeholder:"任务名称",style:{display:"block",width:"100%",fontSize:"22px",fontWeight:"bold",background:"transparent",border:"none",color:X,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:Q,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"&&ne("HTTP 请求配置","🌐","var(--color-accent)",l.jsxs(l.Fragment,{children:[l.jsxs("div",{style:{display:"flex",gap:"8px",marginBottom:"12px"},children:[l.jsx("select",{value:ce.method||"GET",onChange:E=>z("method",E.target.value),disabled:!$,style:{width:"90px",padding:"10px",borderRadius:"8px",background:le,color:X,border:`1px solid ${U}`,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:ce.uri||"",onChange:E=>z("uri",E.target.value),disabled:!$,style:{flex:1,padding:"10px",borderRadius:"8px",background:le,color:X,border:`1px solid ${U}`}})]}),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:Q,marginBottom:"4px"},children:"CONTENT-TYPE"}),l.jsx("input",{placeholder:"application/json",value:ce.contentType||"",onChange:E=>z("contentType",E.target.value),disabled:!$,style:{width:"100%",padding:"8px",borderRadius:"6px",background:le,color:X,border:`1px solid ${U}`,fontSize:"12px"}})]}),l.jsxs("div",{children:[l.jsx("label",{style:{display:"block",fontSize:"10px",color:Q,marginBottom:"4px"},children:"ACCEPT"}),l.jsx("input",{placeholder:"application/json",value:ce.accept||"",onChange:E=>z("accept",E.target.value),disabled:!$,style:{width:"100%",padding:"8px",borderRadius:"6px",background:le,color:X,border:`1px solid ${U}`,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:Q,marginBottom:"4px"},children:"连接超时 (ms)"}),l.jsx("input",{type:"number",placeholder:"3000",value:ce.connectionTimeOut??"",onChange:E=>z("connectionTimeOut",E.target.value===""?void 0:Number(E.target.value)),disabled:!$,style:{width:"100%",padding:"8px",borderRadius:"6px",background:le,color:X,border:`1px solid ${U}`,fontSize:"12px"}})]}),l.jsxs("div",{children:[l.jsx("label",{style:{display:"block",fontSize:"10px",color:Q,marginBottom:"4px"},children:"读取超时 (ms)"}),l.jsx("input",{type:"number",placeholder:"3000",value:ce.readTimeOut??"",onChange:E=>z("readTimeOut",E.target.value===""?void 0:Number(E.target.value)),disabled:!$,style:{width:"100%",padding:"8px",borderRadius:"6px",background:le,color:X,border:`1px solid ${U}`,fontSize:"12px"}})]})]}),l.jsxs("div",{style:{marginBottom:"12px"},children:[l.jsx("label",{style:{display:"block",fontSize:"10px",color:Q,marginBottom:"4px"},children:"HEADERS (JSON)"}),l.jsx("textarea",{value:typeof ce.headers=="object"?JSON.stringify(ce.headers,null,2):"{}",onChange:E=>{try{z("headers",JSON.parse(E.target.value))}catch{}},disabled:!$,rows:3,style:{width:"100%",padding:"8px",borderRadius:"8px",background:le,color:X,border:`1px solid ${U}`,fontSize:"11px",fontFamily:"monospace"}})]}),l.jsx("label",{style:{display:"block",fontSize:"10px",color:Q,marginBottom:"4px"},children:"BODY (RAW/JSON)"}),l.jsx("textarea",{value:typeof ce.body=="object"?JSON.stringify(ce.body,null,2):ce.body||"",onChange:E=>{let J=E.target.value;try{J=JSON.parse(E.target.value)}catch{}z("body",J)},disabled:!$,rows:4,style:{width:"100%",padding:"8px",borderRadius:"8px",background:le,color:X,border:`1px solid ${U}`,fontSize:"11px",fontFamily:"monospace"}})]})),(_.type==="INLINE"||_.type==="LAMBDA")&&ne("内联脚本配置 (Inline)","📜","var(--color-accent)",l.jsxs(l.Fragment,{children:[pe("脚本引擎",["graaljs","javascript","value-param","python"],_.evaluatorType||"graaljs",E=>ee("evaluatorType",E)),ge(`EXPRESSION ${_.evaluatorType==="value-param"?"(值引用)":"(脚本)"}`,_.inputParameters?.expression||_.inputParameters?.scriptExpression||"",E=>{const J=_.inputParameters?.scriptExpression!==void 0?"scriptExpression":"expression";Z(J,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:Q,fontStyle:"italic"},children:"提示: 使用 $.input.key 访问输入参数,返回值作为任务输出。"})]})),_.type==="JSON_JQ_TRANSFORM"&&ne("JQ 数据转换","🔍","var(--color-accent)",l.jsxs(l.Fragment,{children:[ge("JQ QUERY EXPRESSION",_.inputParameters?.queryExpression||"",E=>Z("queryExpression",E),{rows:6,language:"jq",style:{color:"var(--color-accent)"}}),l.jsx("div",{style:{marginTop:"8px",fontSize:"10px",color:Q},children:"输出字段: result(首个结果)、resultList(完整列表)"})]})),_.type==="SUB_WORKFLOW"&&ne("子工作流配置","🏗️","var(--color-accent)",l.jsxs(l.Fragment,{children:[ae("WORKFLOW NAME *",_.subWorkflowParam?.name||"",E=>he("subWorkflowParam","name",E),"text","e.g. my_workflow"),ae("VERSION",_.subWorkflowParam?.version??"",E=>he("subWorkflowParam","version",E?parseInt(E):void 0),"number","1"),ge("INPUT PARAMETERS MAPPING (JSON)",typeof _.inputParameters=="object"&&_.inputParameters!==null?JSON.stringify(_.inputParameters,null,2):"{}",E=>{try{ee("inputParameters",JSON.parse(E))}catch{}},{rows:5,language:"json"}),l.jsxs("div",{style:{fontSize:"10px",color:Q,marginTop:"4px"},children:["传递给子工作流的参数,支持 ","${workflow.input.xxx}"," 表达式"]})]})),_.type==="START_WORKFLOW"&&ne("启动工作流配置","▶️","var(--color-accent)",l.jsxs(l.Fragment,{children:[l.jsxs("div",{style:{fontSize:"11px",color:Q,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:"不等待"}),"目标工作流完成。"]}),ae("WORKFLOW NAME *",_.inputParameters?.startWorkflow?.name||"",E=>{const J={..._.inputParameters?.startWorkflow||{},name:E};Z("startWorkflow",J)},"text","e.g. target_workflow"),ae("VERSION",_.inputParameters?.startWorkflow?.version??"",E=>{const J={..._.inputParameters?.startWorkflow||{},version:E?parseInt(E):void 0};Z("startWorkflow",J)},"number","1"),ae("CORRELATION ID",_.inputParameters?.startWorkflow?.correlationId||"",E=>{const J={..._.inputParameters?.startWorkflow||{},correlationId:E};Z("startWorkflow",J)},"text","${workflow.correlationId}"),ge("WORKFLOW INPUT (JSON)",typeof _.inputParameters?.startWorkflow?.input=="object"?JSON.stringify(_.inputParameters.startWorkflow.input,null,2):"{}",E=>{try{const J={..._.inputParameters?.startWorkflow||{},input:JSON.parse(E)};Z("startWorkflow",J)}catch{}},{rows:4,language:"json"})]})),_.type==="TERMINATE"&&ne("终止状态配置","⏹️","var(--color-accent)",l.jsxs(l.Fragment,{children:[l.jsx("label",{style:{display:"block",fontSize:"10px",color:Q,marginBottom:"4px"},children:"TERMINATION STATUS"}),l.jsx("div",{style:{display:"flex",gap:"8px",marginBottom:"16px"},children:["COMPLETED","FAILED"].map(E=>l.jsx("button",{onClick:()=>Z("terminationStatus",E),disabled:!$,style:{flex:1,padding:"8px",borderRadius:"6px",cursor:"pointer",background:(_.inputParameters?.terminationStatus||"COMPLETED")===E?"var(--color-accent)":le,color:(_.inputParameters?.terminationStatus||"COMPLETED")===E?"#fff":X,border:`1px solid ${U}`,fontWeight:"bold",fontSize:"11px"},children:E},E))}),ae("TERMINATION REASON",_.inputParameters?.terminationReason||"",E=>Z("terminationReason",E),"text","终止原因..."),ge("WORKFLOW OUTPUT (JSON)",typeof _.inputParameters?.workflowOutput=="object"?JSON.stringify(_.inputParameters.workflowOutput,null,2):"{}",E=>{try{Z("workflowOutput",JSON.parse(E))}catch{}},{rows:3,language:"json"})]})),_.type==="EVENT"&&ne("事件发送配置","✉️","var(--color-accent)",l.jsxs(l.Fragment,{children:[ae("EVENT SINK *",_.sink||"",E=>ee("sink",E),"text","e.g. sqs:queue_name 或 conductor"),l.jsx("div",{style:{fontSize:"10px",color:Q,marginTop:"4px",marginBottom:"8px"},children:"支持前缀: conductor | sqs | kafka | amqp | nats"}),me("异步完成 (asyncComplete)",!!_.asyncComplete,E=>ee("asyncComplete",E))]})),_.type==="WAIT"&&ne("等待状态配置","⏳","var(--color-accent)",l.jsxs(l.Fragment,{children:[Ne([{key:"duration",label:"等待时长"},{key:"until",label:"等待到指定时间"}],y,E=>x(E)),y==="duration"?ae("DURATION",_.inputParameters?.duration||"",E=>Z("duration",E),"text","e.g. 30s, 10m, 2 hours"):ae("UNTIL (时间点)",_.inputParameters?.until||"",E=>Z("until",E),"text","e.g. 2025-06-15 09:00 GMT+00:00"),l.jsxs("div",{style:{fontSize:"11px",color:Q,lineHeight:"1.6",marginTop:"8px"},children:["此任务会使工作流进入 ",l.jsx("b",{children:"IN_PROGRESS"})," 状态,直到时间满足或外部 API 触发完成。"]})]})),(_.type==="DECISION"||_.type==="SWITCH")&&ne("条件分支配置","⚖️","var(--color-accent)",l.jsxs(l.Fragment,{children:[pe("评估模式 (evaluatorType)",["value-param","javascript"],_.evaluatorType||"value-param",E=>ee("evaluatorType",E)),(_.evaluatorType||"value-param")==="value-param"?ae("CASE VALUE PARAM (参数名)",_.caseValueParam||"",E=>ee("caseValueParam",E),"text","e.g. status"):l.jsx(l.Fragment,{children:ge("CASE EXPRESSION (JS)",_.caseExpression||"",E=>ee("caseExpression",E),{rows:4,language:"javascript",style:{color:"var(--color-accent)"}})}),l.jsx("div",{style:{fontSize:"10px",color:Q,marginTop:"8px"},children:'分支可在图中通过右键节点→"添加分支"进行管理'})]})),_.type==="DO_WHILE"&&ne("循环逻辑配置","🔄","var(--color-accent)",l.jsxs(l.Fragment,{children:[Ne([{key:"condition",label:"条件循环"},{key:"items",label:"列表迭代"}],b,E=>k(E)),b==="condition"?l.jsxs(l.Fragment,{children:[ge("LOOP CONDITION (JS) *",_.loopCondition||"",E=>ee("loopCondition",E),{rows:4,language:"javascript",style:{color:"var(--color-accent)"}}),l.jsx("div",{style:{fontSize:"10px",color:Q,marginTop:"4px"},children:"条件为 true 时继续循环,false 时退出"})]}):l.jsxs(l.Fragment,{children:[l.jsx("label",{style:{display:"block",fontSize:"10px",color:Q,marginBottom:"4px"},children:"ITEMS (列表表达式)"}),l.jsx("input",{value:_.inputParameters?.items||"",onChange:E=>Z("items",E.target.value),disabled:!$,placeholder:"${workflow.input.myList}",style:{width:"100%",padding:"8px",borderRadius:"6px",border:`1px solid ${U}`,background:le,color:X,fontSize:"12px",outline:"none"}}),l.jsx("div",{style:{fontSize:"10px",color:Q,marginTop:"4px"},children:"引用一个数组,对每个元素执行一次循环体"})]}),l.jsx("div",{style:{marginTop:"12px"},children:ae("KEEP LAST N 次迭代",_.keepLastN??"",E=>ee("keepLastN",E?parseInt(E):void 0),"number","0 = 保留全部")})]})),_.type==="FORK_JOIN_DYNAMIC"&&ne("动态并行配置","⚡","var(--color-accent)",l.jsxs(l.Fragment,{children:[Ne([{key:"classic",label:"经典模式"},{key:"task",label:"任务简化"},{key:"workflow",label:"工作流简化"}],w,E=>j(E)),w==="classic"&&l.jsxs(l.Fragment,{children:[ae("DYNAMIC_FORK_TASKS_PARAM",_.dynamicForkTasksParam||"",E=>ee("dynamicForkTasksParam",E),"text","e.g. dynamic_tasks"),ae("DYNAMIC_FORK_TASKS_INPUT_PARAM",_.dynamicForkTasksInputParamName||"",E=>ee("dynamicForkTasksInputParamName",E),"text","e.g. input"),l.jsx("div",{style:{fontSize:"10px",color:Q},children:"经典模式:通过 inputParameters 传入 dynamicTasks 数组和 dynamicTasksInput 映射"})]}),w==="task"&&l.jsxs(l.Fragment,{children:[ae("FORK TASK TYPE *",_.forkTaskType||"",E=>ee("forkTaskType",E),"text","e.g. HTTP"),ae("FORK TASK NAME (仅 SIMPLE 任务)",_.forkTaskName||"",E=>ee("forkTaskName",E),"text","e.g. my_task"),ae("FORK TASK INPUTS PARAM",_.forkTaskInputs||"",E=>ee("forkTaskInputs",E),"text","e.g. inputs"),l.jsx("div",{style:{fontSize:"10px",color:Q},children:"所有分支执行相同任务类型,每个元素作为一个分支输入"})]}),w==="workflow"&&l.jsxs(l.Fragment,{children:[ae("FORK WORKFLOW NAME *",_.forkTaskWorkflow||"",E=>ee("forkTaskWorkflow",E),"text","e.g. sub_workflow"),ae("WORKFLOW VERSION",_.forkTaskWorkflowVersion||"",E=>ee("forkTaskWorkflowVersion",E),"text","1"),ae("FORK TASK INPUTS PARAM",_.forkTaskInputs||"",E=>ee("forkTaskInputs",E),"text","e.g. inputs"),l.jsx("div",{style:{fontSize:"10px",color:Q},children:"所有分支执行相同子工作流,每个元素作为一个子工作流输入"})]})]})),_.type==="DYNAMIC"&&ne("动态任务配置","🎯","var(--color-accent)",l.jsxs(l.Fragment,{children:[ae("DYNAMIC TASK NAME PARAM *",_.dynamicTaskNameParam||"",E=>ee("dynamicTaskNameParam",E),"text","e.g. taskToExecute"),l.jsx("div",{style:{fontSize:"10px",color:Q,marginTop:"4px"},children:'运行时从 inputParameters 的指定键中读取实际任务类型名(如 "HTTP"、"SIMPLE")'})]})),_.type==="HUMAN"&&ne("人工审批配置","👤","var(--color-accent)",l.jsxs(l.Fragment,{children:[ae("表单模板名 (userFormTemplate)",_.humanTaskDef?.userFormTemplate||"",E=>he("humanTaskDef","userFormTemplate",E),"text","e.g. approval_form"),pe("分配策略 (assignmentCompletionStrategy)",["LEAVE_OPEN","TERMINATE"],_.humanTaskDef?.assignmentCompletionStrategy||"LEAVE_OPEN",E=>he("humanTaskDef","assignmentCompletionStrategy",E)),ae("显示名称 (displayName)",_.humanTaskDef?.displayName||"",E=>he("humanTaskDef","displayName",E),"text","审批任务")]})),_.type==="KAFKA_PUBLISH"&&ne("Kafka 推送配置","📨","var(--color-accent)",l.jsxs(l.Fragment,{children:[ae("BOOTSTRAP SERVERS *",_.inputParameters?.bootStrapServers||"",E=>Z("bootStrapServers",E),"text","localhost:9092"),ae("TOPIC *",_.inputParameters?.topic||"",E=>Z("topic",E),"text","my_topic"),ae("KEY (消息分区键)",_.inputParameters?.key||"",E=>Z("key",E),"text",""),ge("VALUE (消息内容)",typeof _.inputParameters?.value=="object"?JSON.stringify(_.inputParameters.value,null,2):_.inputParameters?.value||"",E=>{let J=E;try{J=JSON.parse(E)}catch{}Z("value",J)},{rows:4,language:"json"}),ge("HEADERS (JSON)",typeof _.inputParameters?.headers=="object"?JSON.stringify(_.inputParameters.headers,null,2):"{}",E=>{try{Z("headers",JSON.parse(E))}catch{}},{rows:3,language:"json"})]})),_.type==="SET_VARIABLE"&&ne("变量配置","📦","var(--color-accent)",l.jsxs(l.Fragment,{children:[l.jsxs("div",{style:{fontSize:"11px",color:Q,marginBottom:"12px"},children:["在 inputParameters 中定义要设置的变量名和值,后续任务通过 ","${workflow.variables.varName}"," 访问。"]}),ge("VARIABLES (JSON)",typeof _.inputParameters=="object"&&_.inputParameters!==null?JSON.stringify(_.inputParameters,null,2):"{}",E=>{try{ee("inputParameters",JSON.parse(E))}catch{}},{rows:6,language:"json"})]})),l.jsxs("div",{style:{marginTop:"32px",borderTop:`1px solid ${U}`,paddingTop:"24px"},children:[l.jsx("div",{style:{fontSize:"11px",fontWeight:"bold",marginBottom:"16px",opacity:.6,textTransform:"uppercase",letterSpacing:"1px"},children:"通用参数与属性"}),Y("任务唯一引用名 (Reference Name)","taskReferenceName"),Y("任务描述","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:Q,fontWeight:"600",textTransform:"uppercase",flex:1},children:["输入参数 (inputParameters) ",l.jsx("span",{style:{opacity:.5,fontWeight:"normal"},children:"(JSON)"})]}),$&&l.jsxs("div",{style:{display:"flex",gap:"6px"},children:[l.jsxs("button",{onClick:ie,disabled:K,title:"AI 根据上下文自动生成 inputParameters",style:{fontSize:"11px",background:"linear-gradient(135deg, #6366f1, #8b5cf6)",border:"none",borderRadius:"4px",padding:"2px 8px",cursor:K?"not-allowed":"pointer",color:"#fff",fontWeight:600,display:"flex",alignItems:"center",gap:"4px",opacity:K?.7:1},children:[K?"⏳":"✨"," AI 填充"]}),l.jsxs("button",{onClick:()=>g(!h),title:"快捷表达式",style:{fontSize:"11px",background:h?"var(--color-accent)":"none",border:`1px solid ${U}`,borderRadius:"4px",padding:"2px 6px",cursor:"pointer",color:h?"#fff":Q},children:["{}"," 片段"]})]})]}),h&&l.jsx("div",{style:{marginBottom:"8px",padding:"8px",borderRadius:"6px",border:`1px solid ${U}`,background:"var(--bg-secondary)",display:"flex",flexWrap:"wrap",gap:"6px"},children:bb.map(E=>l.jsx("button",{onClick:()=>H(E.value),title:E.desc,style:{fontSize:"10px",padding:"3px 8px",borderRadius:"4px",border:`1px solid ${U}`,background:le,color:X,cursor:"pointer",fontFamily:"monospace"},children:E.label},E.value))}),te&&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:()=>{ee("inputParameters",te.generated),re(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:()=>re(null),style:{fontSize:"11px",background:"none",color:Q,border:`1px solid ${U}`,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:X,maxHeight:"180px",overflowY:"auto"},children:JSON.stringify(te.generated,null,2)})]}),ge("",typeof _.inputParameters=="object"&&_.inputParameters!==null?JSON.stringify(_.inputParameters,null,2):_.inputParameters??"",E=>{try{ee("inputParameters",JSON.parse(E))}catch{u(J=>({...J,inputParameters:E}))}},{rows:5,language:"json","data-field":"inputParameters",style:{outline:"none"}})]}),l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[Y("重试次数","retryCount","number"),Y("超时限制 (秒)","timeoutSeconds","number")]}),l.jsxs("details",{style:{marginTop:"16px"},children:[l.jsx("summary",{style:{fontSize:"11px",cursor:"pointer",color:Q,userSelect:"none",fontWeight:"600"},children:"▸ 执行控制(高级)"}),l.jsxs("div",{style:{marginTop:"12px"},children:[pe("重试策略 (retryLogic)",["FIXED","EXPONENTIAL_BACKOFF","LINEAR_BACKOFF"],_.retryLogic||"FIXED",E=>ee("retryLogic",E)),ae("重试延迟 (秒)",_.retryDelaySeconds??"",E=>ee("retryDelaySeconds",E?parseInt(E):void 0),"number","0"),pe("超时策略 (timeoutPolicy)",["TIME_OUT_WF","ALERT_ONLY","RETRY","FAIL_WORKFLOW"],_.timeoutPolicy||"TIME_OUT_WF",E=>ee("timeoutPolicy",E)),ae("启动延迟 (秒)",_.startDelay??"",E=>ee("startDelay",E?parseInt(E):void 0),"number","0"),me("可选任务 (optional) — 失败不影响工作流",!!_.optional,E=>ee("optional",E)),me("异步完成 (asyncComplete)",!!_.asyncComplete,E=>ee("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 ${U}`,color:Q},children:JSON.stringify(_,null,2)})]})})]}),$&&l.jsxs("div",{style:{padding:"24px",borderTop:`1px solid ${U}`,background:"var(--bg-secondary)",display:"flex",gap:"12px",flexShrink:0},children:[l.jsx("div",{style:{flex:1,fontSize:"11px",color:Q,display:"flex",alignItems:"center"},children:"✅ 所有修改已实时同步"}),l.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:"完成退出"})]}),l.jsx(yb,{isOpen:N,onClose:()=>L(!1),onSelect:I,suggestions:S,anchorRect:T})]}),F&&l.jsx(xb,{title:F.title,value:F.value,language:F.language,onSave:F.onSave,onClose:()=>W(null)})]})},_b=O.memo(kb),Sb={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)"},Sr=e=>Sb[e??""]??"var(--text-secondary)",wb=(e,n)=>{if(!e)return"-";const r=(n??Date.now())-e;return r<1e3?`${r}ms`:`${(r/1e3).toFixed(2)}s`},Qh=e=>e?new Date(e).toLocaleTimeString():"-",Tb=({executionActions:e})=>{const{selectedTask:n,selectedTaskInstance:r,setSelectedTask:t,setSelectedTaskInstance:s,executionData:a,workflowInstance:o}=oe(),[i,u]=O.useState("summary"),c=O.useRef(null);O.useEffect(()=>{c.current?.scrollTo({top:0})},[i,n?.taskReferenceName]),O.useEffect(()=>{u("summary")},[n?.taskReferenceName]);const d=n?.taskReferenceName==="__workflow_global__",f=n?a?.[n.taskReferenceName]:null;if(!n||!f&&!d)return null;const p=f?.attempts??[],h=r??p[p.length-1],g=o?.workflowId??"",m=o?.status,v=f?.status,y=d?m:h?.status??v,x=d?o?.startTime:h?.startTime,b=d?o?.endTime:h?.endTime,k=d?o?.reasonForIncompletion:h?.reasonForIncompletion,w=d?o?.workflowId:h?.taskId,j=d?o?.input:h?.inputData,N=d?o?.output:h?.outputData,L=!d&&e?.onSkipTask&&(v==="SCHEDULED"||v==="IN_PROGRESS")&&(m==="RUNNING"||m==="PAUSED"),T=!d&&e?.onRerunFromTask&&(m==="FAILED"||m==="TERMINATED"||m==="COMPLETED"||m==="TIMED_OUT"),C=L||T,S=e?.allowOperations!==!1,D=()=>{t(null),s(null)},I="var(--glass-border)",P="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:d?"WORKFLOW":n.type||"TASK"}),y&&l.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:5,padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:700,background:`${Sr(y)}18`,color:Sr(y),letterSpacing:"0.5px",flexShrink:0},children:["● ",y]}),l.jsx("div",{style:{flex:1}}),l.jsx("button",{onClick:D,style:{background:"none",border:"none",color:P,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:d?"工作流全局数据":n.name}),l.jsxs("div",{style:{fontSize:12,color:P,marginTop:6,fontFamily:"monospace",opacity:.8},children:["REF: ",n.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:P,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,K)=>{const V=h?.taskId===W.taskId;return l.jsx("button",{onClick:()=>s(W),style:{padding:"4px 12px",borderRadius:20,fontSize:12,cursor:"pointer",border:`1px solid ${V?"var(--color-accent)":I}`,background:V?"var(--color-accent)":"var(--bg-tertiary)",color:V?"#fff":"var(--text-primary)",fontFamily:"inherit",transition:"all 0.15s"},children:W.iteration?`迭代 ${W.iteration}`:`尝试 ${K+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 K={summary:"概览",input:"输入 JSON",output:"输出 JSON"},V=i===W;return l.jsx("button",{onClick:()=>u(W),style:{padding:"10px 20px",background:"none",border:"none",borderBottom:`2px solid ${V?"var(--color-accent)":"transparent"}`,color:V?"var(--color-accent)":P,cursor:"pointer",fontSize:13,fontWeight:V?600:400,fontFamily:"inherit",transition:"all 0.15s"},children:K[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:wb(x,b)},{label:"开始时间",value:Qh(x)},{label:"结束时间",value:Qh(b)},{label:d?"Workflow ID":"Task ID",value:l.jsx("span",{style:{fontSize:10,fontFamily:"monospace",opacity:.7,wordBreak:"break-all"},children:w??"-"})}].map(({label:W,value:K})=>l.jsxs("div",{style:{padding:"12px 14px",background:F,borderRadius:10,border:`1px solid ${I}`},children:[l.jsx("div",{style:{fontSize:10,color:P,textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:6,fontWeight:600},children:W}),l.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",fontSize:13},children:K})]},W))}),p.length>1&&l.jsxs("div",{style:{marginBottom:20,padding:"10px 14px",background:`${Sr(v)}10`,border:`1px solid ${Sr(v)}30`,borderRadius:8,fontSize:12,color:Sr(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," 次尝试"]}),!d&&h?.workerId&&l.jsxs("div",{style:{marginBottom:20},children:[l.jsx("div",{style:{fontSize:10,color:P,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:P,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,n.taskReferenceName,h?.taskId),title:S?`从任务 ${n.taskReferenceName} 处重新运行工作流`:"操作权限受限",style:S?Ze:rg,onMouseEnter:W=>!S||Object.assign(W.currentTarget.style,Eb),onMouseLeave:W=>!S||Object.assign(W.currentTarget.style,Ze),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,n.taskReferenceName,h?.taskId),title:S?`跳过任务 ${n.taskReferenceName}`:"操作权限受限",style:S?Ze:rg,onMouseEnter:W=>!S||Object.assign(W.currentTarget.style,Nb),onMouseLeave:W=>!S||Object.assign(W.currentTarget.style,Ze),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(eg,{data:j}),i==="output"&&l.jsx(eg,{data:N})]})]})},eg=({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)}),Ze={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"},Eb={...Ze,borderColor:"var(--color-accent)",color:"var(--color-accent)",background:"var(--bg-primary)"},Nb={...Ze,borderColor:"var(--status-failed)",color:"var(--status-failed)",background:"rgba(239,68,68,0.08)"},rg={...Ze,opacity:.45,cursor:"not-allowed",border:"1px solid var(--border-primary)",background:"var(--bg-secondary)",color:"var(--text-secondary)"},Cb={add:"新增",mod:"修改",del:"删除",replace:"替换"},jb={add:"+",mod:"~",del:"−"};function Ib({diff:e,applied:n,onApply:r,onUndo:t}){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:Cb[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:jb[a.kind]??"·"}),l.jsx("div",{className:"diff-desc",children:a.desc})]},o))}),l.jsx("div",{className:"diff-actions",children:n?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:t,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:r,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 tg(e,n){const r=JSON.parse(JSON.stringify(e));if(n.kind==="replace"&&n.payload)return{next:JSON.parse(JSON.stringify(n.payload)),inverse:{kind:"replace",summary:"撤销替换",rows:[],payload:e}};if(n.kind==="add"&&n.payload)return{next:JSON.parse(JSON.stringify(n.payload)),inverse:{kind:"replace",summary:"撤销生成",rows:[],payload:e}};if(!n.patch)return{next:r,inverse:{kind:n.kind,summary:"(无变更)",rows:[]}};const t=[],s=[];for(const a of n.patch)if(a.op==="patchTask"){const o=r.tasks.find(u=>u.taskReferenceName===a.ref);if(!o)continue;const i={};for(const u of Object.keys(a.set))i[u]=o[u];Object.assign(o,a.set),t.push({op:"patchTask",ref:a.ref,set:i}),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}),t.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(o=>!(o.from===a.from&&o.to===a.to)),t.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(o=>{r.edges=r.edges.filter(i=>!(i.from===o.from&&i.to===o.to))}),a.extraEdges&&a.extraEdges.forEach(o=>r.edges.push(o)),t.push({op:"removeTask",ref:a.task.taskReferenceName}),s.push({kind:"del",desc:`移除 ${a.task.taskReferenceName}`});else if(a.op==="removeTask"){const o=r.tasks.findIndex(c=>c.taskReferenceName===a.ref);if(o<0)continue;const[i]=r.tasks.splice(o,1),u=(r.edges??[]).filter(c=>c.from===a.ref||c.to===a.ref);r.edges=(r.edges??[]).filter(c=>c.from!==a.ref&&c.to!==a.ref),t.push({op:"addTask",task:i,extraEdges:u}),s.push({kind:"add",desc:`恢复 ${a.ref}`})}else if(a.op==="insertAfter"){r.tasks.push(a.task),r.edges=r.edges??[];const o=r.edges.findIndex(i=>i.from===a.after&&i.to===a.edgeTo);o>=0&&r.edges.splice(o,1),r.edges.push({from:a.after,to:a.task.taskReferenceName}),r.edges.push({from:a.task.taskReferenceName,to:a.edgeTo}),t.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 o=r.edges.filter(i=>i.to===a.before);r.edges=r.edges.filter(i=>i.to!==a.before),o.forEach(i=>r.edges.push({from:i.from,to:a.task.taskReferenceName,label:i.label})),r.edges.push({from:a.task.taskReferenceName,to:a.before}),t.push({op:"removeTask",ref:a.task.taskReferenceName}),s.push({kind:"del",desc:`移除 ${a.task.taskReferenceName}(恢复原有入边)`})}return{next:r,inverse:{kind:n.kind,summary:`撤销:${n.summary}`,rows:s,patch:t.reverse()}}}function Rb(e){const n=e.match(/```diff-json\n([\s\S]*?)\n```/);if(!n)return null;try{const r=JSON.parse(n[1]);return!r.kind||!r.summary?null:r}catch{return null}}const ng={id:"1",role:"ai",content:"你好!我是您的流程助手。我可以帮你生成工作流框架、优化逻辑或提供参数配置建议。你想实现什么样的流程?"},ag=e=>e.split(/(```[\s\S]*?```)/).map((r,t)=>{if(r.startsWith("```")&&r.endsWith("```")){const s=r.slice(3,-3),a=s.indexOf(`
|
|
121
|
+
`),o=a>=0?s.slice(a+1):s;return l.jsx("pre",{children:l.jsx("code",{children:o})},t)}return l.jsx("span",{children:Ob(r)},t)}),Ob=e=>{const n=[],r=/(\*\*[^*]+\*\*|`[^`]+`|\n)/g;let t=0,s;for(;(s=r.exec(e))!==null;){s.index>t&&n.push(e.slice(t,s.index));const a=s[0];a.startsWith("**")&&a.endsWith("**")?n.push(l.jsx("strong",{children:a.slice(2,-2)},s.index)):a.startsWith("`")&&a.endsWith("`")?n.push(l.jsx("code",{children:a.slice(1,-1)},s.index)):a===`
|
|
122
|
+
`&&n.push(l.jsx("br",{},s.index)),t=s.index+a.length}return t<e.length&&n.push(e.slice(t)),n},Pb=({aiConfig:e})=>{const{workflowDef:n,setWorkflow:r,mode:t}=oe(),[s,a]=O.useState(!1),[o,i]=O.useState(""),[u,c]=O.useState(!1),[d,f]=O.useState([ng]),[p,h]=O.useState(""),[g,m]=O.useState(null),v=O.useRef(null),y=O.useRef(null),x=O.useRef(null),b=O.useCallback(P=>{if(!P.diff||P.applied||!n)return;const{next:F,inverse:W}=tg(n,P.diff);r(F),f(K=>K.map(V=>V.id===P.id?{...V,applied:!0,inverse:W}:V))},[n,r]),k=O.useCallback(P=>{if(!P.inverse||!P.applied||!n)return;const{next:F}=tg(n,P.inverse);r(F),f(W=>W.map(K=>K.id===P.id?{...K,applied:!1,inverse:void 0}:K))},[n,r]),w=()=>{const P=y.current;P&&(P.style.height="auto",P.style.height=Math.min(P.scrollHeight,120)+"px")},j=()=>{const P=y.current;P&&(P.style.height="auto")};O.useEffect(()=>()=>{x.current?.abort()},[]),O.useEffect(()=>{const P=()=>a(!0);return window.addEventListener("open-ai-chat",P),()=>window.removeEventListener("open-ai-chat",P)},[]);const N=()=>{v.current?.scrollIntoView({behavior:"smooth"})};O.useEffect(()=>{s&&N()},[d,s,p]);const L=O.useCallback(P=>{const F=[{role:"system",content:gb}];for(const K of d)K.role==="user"&&K.content?F.push({role:"user",content:K.content}):K.role==="ai"&&K.content&&!K.thinking&&F.push({role:"assistant",content:K.content});const W=mb(P,n);return F.push({role:"user",content:W}),F},[d,n]),T=async P=>{const F=o.trim();if(!F||u)return;x.current?.abort();const W=new AbortController;x.current=W;const K={id:Date.now().toString(),role:"user",content:F};f(V=>[...V,K]),i(""),j(),c(!0),h("");try{const V=e?.apiKey||localStorage.getItem("AI_API_KEY")||"",te=e?.baseUrl||localStorage.getItem("AI_BASE_URL")||"",re=e?.model||localStorage.getItem("AI_MODEL")||"";if(!V){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:{}}]},$={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(X=>[...X,$]),c(!1)},800);return}const q={apiKey:V};te&&(q.baseUrl=te),re&&(q.model=re);const G=L(F),ie=await fb(G,q,B=>{h($=>$+B)},()=>{},W.signal);let M=Rb(ie);if(!M){const B=ie.match(/```json\n([\s\S]*?)\n```/);if(B)try{const $=JSON.parse(B[1]);M={kind:"replace",summary:"应用 AI 生成的工作流",rows:[{kind:"add",desc:"全量替换为 AI 生成的工作流定义"}],payload:$}}catch{}}const _={id:(Date.now()+1).toString(),role:"ai",content:ie,diff:M??void 0,applied:!1};f(B=>[...B,_]),h("")}catch(V){if(V.name==="AbortError")h(te=>{if(te){const re={id:(Date.now()+1).toString(),role:"ai",content:te};f(q=>[...q,re])}return""});else{const te={id:Date.now().toString(),role:"ai",content:`抱歉,目前无法连接到 AI 服务: ${V.message}`};f(re=>[...re,te]),h("")}}finally{c(!1)}},C=()=>{x.current?.abort()},S=()=>{x.current?.abort(),f([ng]),h(""),c(!1)},D=P=>{navigator.clipboard.writeText(P.content??""),m(P.id),setTimeout(()=>m(null),1500)},I=P=>{P.nativeEvent.isComposing||P.keyCode===229||P.key==="Enter"&&!P.shiftKey&&(P.preventDefault(),T())};return t!=="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:[d.map(P=>l.jsxs("div",{className:`message ${P.role}`,children:[l.jsx("div",{className:"message-content",children:P.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%"}})]}):P.role==="ai"?ag(P.content??""):P.content}),P.diff&&!P.thinking&&l.jsx(Ib,{diff:P.diff,applied:P.applied??!1,onApply:()=>b(P),onUndo:()=>k(P)}),P.role==="ai"&&P.content&&l.jsx("button",{className:"copy-btn",onClick:()=>D(P),title:"复制",children:g===P.id?"✓":"📋"})]},P.id)),u&&p&&l.jsxs("div",{className:"message ai",style:{opacity:.9},children:[l.jsx("div",{className:"message-content",children:ag(p)}),l.jsx("span",{className:"streaming-cursor",children:"▊"})]}),u&&!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:u?"AI 正在响应...":"描述您的需求…(Shift+Enter 换行)",value:o,onChange:P=>i(P.target.value),onInput:w,onKeyDown:I,disabled:u,rows:2}),u?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 助手"]})})})},Ab=new Set(["COMPLETED","FAILED","TIMED_OUT","TERMINATED"]),Lb=({onTriggerExecution:e,onPollExecution:n,executionPollInterval:r=3e3})=>{const{workflowDef:t,showRunPanel:s,setShowRunPanel:a,setRunState:o,importExecutionJSON:i,setMode:u}=oe(),[c,d]=O.useState("form"),[f,p]=O.useState({}),[h,g]=O.useState("{}"),[m,v]=O.useState(""),[y,x]=O.useState(!1),[b,k]=O.useState(""),w=Zr(t?.inputParameters);O.useEffect(()=>{s&&(p({}),g("{}"),v(""),k(""),x(!1))},[s]);const j=O.useCallback(()=>{try{const S={};w.forEach(D=>{const I=f[D.name];if(I!==void 0&&I!=="")if(D.type==="number")S[D.name]=Number(I);else if(D.type==="boolean")S[D.name]=I==="true";else if(D.type==="object"||D.type==="array")try{S[D.name]=JSON.parse(I)}catch{S[D.name]=I}else S[D.name]=I;else D.defaultValue!==void 0&&(S[D.name]=D.defaultValue)}),g(JSON.stringify(S,null,2))}catch{}d("json")},[f,w]),N=O.useCallback(()=>{try{const S=JSON.parse(h),D={};w.forEach(I=>{const P=S[I.name];P!==void 0&&(D[I.name]=typeof P=="object"?JSON.stringify(P,null,2):String(P))}),p(D),v("")}catch{v("JSON 格式有误,无法切换为表单模式")}d("form")},[h,w]),L=O.useCallback(()=>{if(c==="json")try{return JSON.parse(h)}catch{return v("JSON 格式有误,请检查后重试"),null}const S={};return w.forEach(D=>{const I=f[D.name]??(D.defaultValue!==void 0?String(D.defaultValue):"");if(!(I===""&&!D.required))if(D.type==="number")S[D.name]=Number(I);else if(D.type==="boolean")S[D.name]=I==="true";else if(D.type==="object"||D.type==="array")try{S[D.name]=JSON.parse(I)}catch{S[D.name]=I}else S[D.name]=I}),S},[c,h,f,w]),T=O.useCallback(async()=>{if(!e||!t)return;const S=L();if(S===null)return;const D=w.filter(I=>I.required&&(S[I.name]===void 0||S[I.name]===""));if(D.length>0){k(`必填参数未填写:${D.map(I=>I.name).join(", ")}`);return}x(!0),k(""),o("triggering");try{const{workflowId:I}=await e(t.name,t.version??1,S);if(o("polling",I),a(!1),u("run"),!n)return;let P=r;const F=15e3;let W;const K=async()=>{try{const V=await n(I);if(V&&(i(V),Ab.has(V.status))){o("done",I);return}}catch{}P=Math.min(P*1.5,F),W=setTimeout(K,P)};W=setTimeout(K,P),oe.getState().__pollTimer=W}catch(I){const P=I?.message||"执行触发失败,请检查配置后重试";o("error",null,P),k(P),x(!1)}},[e,n,t,L,w,o,a,i,u,r]);if(!s||!t)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:[t.name," ",l.jsxs("span",{className:"wrp-version",children:["v",t.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:D=>p(I=>({...I,[S.name]:D.target.value}))}):S.type==="boolean"?l.jsxs("select",{className:"wrp-input",value:f[S.name]??(S.defaultValue!==void 0?String(S.defaultValue):""),onChange:D=>p(I=>({...I,[S.name]:D.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:D=>p(I=>({...I,[S.name]:D.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 回调"})]})]})})},qb=[{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 Db(e,n){const r=n[e];if(!r)return[];const t=r.reasonForIncompletion||"";if(!t)return[];const s=[];for(const a of qb)a.pattern.test(t)&&s.push({category:a.category,title:a.title,explanation:a.explanation,suggestEditParam:a.suggestEditParam});return s.length===0&&t.length>0&&s.push({category:"logic",title:"执行异常",explanation:`任务执行失败,原因:${t.slice(0,200)}${t.length>200?"...":""}`}),s}function Mb(e,n){const r=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:Db(h.taskReferenceName,e)}}).sort((h,g)=>(h.startTime??0)-(g.startTime??0)),t=["FAILED","FAILED_WITH_TERMINAL_ERROR","TIMED_OUT"],s=r.filter(h=>h.status==="COMPLETED"||h.status==="COMPLETED_WITH_ERRORS").length,a=r.filter(h=>t.includes(h.status)).length,o=r.filter(h=>h.status==="SKIPPED").length,i=r.flatMap(h=>[h.startTime,h.endTime]).filter(h=>!!h),u=i.length?Math.min(...i):0,d=(i.length?Math.max(...i):0)-u,f=n?.status,p=f==="FAILED"||f==="TIMED_OUT"||f==="TERMINATED"||a>0;return{totalTasks:r.length,completedTasks:s,failedTasks:a,skippedTasks:o,totalDurationMs:d,steps:r,hasFailed:p}}function sg(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 Wb(e){return{parameter:"⚙️",timeout:"⏱️",auth:"🔐",network:"🌐",logic:"🔧"}[e]??"⚠️"}function Bb(e){return{parameter:"#f59e0b",timeout:"#8b5cf6",auth:"#ef4444",network:"#3b82f6",logic:"#10b981"}[e]??"#6b7280"}const og={COMPLETED:"完成",COMPLETED_WITH_ERRORS:"完成(含错误)",FAILED:"失败",FAILED_WITH_TERMINAL_ERROR:"终态失败",IN_PROGRESS:"执行中",SCHEDULED:"等待中",TIMED_OUT:"超时",SKIPPED:"跳过",CANCELED:"已取消"},ig={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)"},Fb=()=>{const{executionData:e,workflowInstance:n,showAnalysisPanel:r,setShowAnalysisPanel:t,switchToEditAndFocusParam:s,selectTaskAction:a,taskMap:o}=oe(),i=O.useMemo(()=>e?Mb(e,n??null):null,[e,n]);if(!r||!i)return null;const{totalTasks:u,completedTasks:c,failedTasks:d,skippedTasks:f,totalDurationMs:p,steps:h}=i,g=u>0?Math.round(c/u*100):0,m=n?.status,v=m?ig[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:og[m]??m}),l.jsx("button",{className:"esp-close",onClick:()=>t(!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:u}),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:d>0?"var(--status-failed)":"var(--text-secondary)"},children:d}),l.jsx("span",{className:"esp-card-label",children:"失败"})]}),l.jsxs("div",{className:"esp-card",children:[l.jsx("span",{className:"esp-card-value",children:sg(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:d>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:Bb(x.category)},children:[l.jsxs("div",{className:"esp-diag-title",children:[l.jsx("span",{children:Wb(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=ig[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}}),og[y.status]??y.status]}),l.jsx("span",{className:"esp-step-duration",children:sg(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)})]})]})]})},lg=O.forwardRef(({workflowDef:e,readOnly:n=!1,theme:r="dark",themeColor:t="blue",layoutDirection:s="LR",searchQuery:a="",workflowExecution:o,onRequestImport:i,executionActions:u,aiConfig:c,viewMode:d="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:D,isDetailPanelOpen:I,setIsDetailPanelOpen:P,selectTaskAction:F,workflowDef:W,isSimRunning:K,startSimulation:V,stopSimulation:te,mode:re,setShowRunPanel:q,showAnalysisPanel:G,setShowAnalysisPanel:ie,executionData:R}=oe(),[M,_]=O.useState(!1),B=O.useCallback(()=>{if(!W)return;const U=new Blob([JSON.stringify(W,null,2)],{type:"application/json"}),le=URL.createObjectURL(U),Q=document.createElement("a");Q.href=le,Q.download=`${W.name||"workflow"}.json`,Q.click(),URL.revokeObjectURL(le)},[W]),$=O.useCallback(()=>{W&&navigator.clipboard.writeText(JSON.stringify(W,null,2))},[W]);O.useEffect(()=>{b(r),k(t),w(s),j(n||!!o)},[r,t,s,n,o,b,k,w,j]),O.useEffect(()=>{D(o?"developer":d)},[d,o,D]),O.useEffect(()=>{e&&(x(e,s),oe.temporal.getState().clear())},[e,x,s]),O.useEffect(()=>{o?C(o):S(n?"view":"edit")},[o,C,S,n]),O.useImperativeHandle(y,()=>({getWorkflowDef:()=>oe.getState().workflowDef,getValidationResults:()=>oe.getState().validationResults,save:()=>{const U=oe.getState().workflowDef;U&&f&&f(U)},createBlankWorkflow:U=>{oe.getState().createBlankWorkflow(U),oe.temporal.getState().clear()}}),[f]),O.useEffect(()=>{if(!p)return;let U=!0,le=oe.getState().workflowDef;return oe.subscribe(ee=>{const he=ee.workflowDef;if(he!==le){if(le=he,U){U=!1;return}he&&p(he)}})},[p]);const X=U=>{o?L(U):F(U,!0)};return l.jsxs("div",{className:`workflow-ide ${r==="light"?"light-theme":""}`,"data-mode":r,"data-brand":t,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}}),re==="edit"&&W&&l.jsxs("button",{onClick:()=>q(!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"})}),"执行验证"]}),re==="run"&&R&&l.jsxs("button",{onClick:()=>ie(!G),style:{height:28,padding:"0 10px",background:G?"color-mix(in srgb, var(--color-accent) 20%, transparent)":"transparent",color:G?"var(--color-accent)":"var(--text-secondary)",border:`1px solid ${G?"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"})]}),"分析"]}),re!=="run"&&W&&(K?l.jsxs("button",{onClick:te,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: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:[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-secondary)",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:$,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:[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(ub,{onNodeClick:X,edgeType:T,theme:r,nodesLocked:n||!!o,searchQuery:a,onSave:f,onRequestImport:i,executionActions:u})})}),l.jsx(_b,{task:N,isOpen:I,onClose:()=>P(!1),theme:r,aiConfig:c}),l.jsx(Fh,{isOpen:M,onClose:()=>_(!1),theme:r,onTaskSelect:U=>{F(U,!0)}}),o&&l.jsx(Tb,{executionActions:u}),l.jsx(Pb,{aiConfig:c}),l.jsx(Lb,{onTriggerExecution:g,onPollExecution:m,executionPollInterval:v}),re==="run"&&l.jsx(Fb,{})]})});lg.displayName="WorkflowIDE",De.WorkflowIDE=lg,De.parseWorkflowInputParams=Zr,Object.defineProperty(De,Symbol.toStringTag,{value:"Module"})}));
|