@yiyi_zhang/reactflow-ui 1.0.0 → 1.1.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 +28 -3
- package/dist/WorkflowIDE.d.ts +13 -0
- package/dist/actions/builtin/common.d.ts +8 -0
- package/dist/actions/builtin/ecs.d.ts +12 -0
- package/dist/actions/registry.d.ts +23 -0
- package/dist/actions/types.d.ts +45 -0
- package/dist/components/business/ActionForm.d.ts +12 -0
- package/dist/components/business/DataPillInput.d.ts +14 -0
- package/dist/components/business/DecisionBranchCard.d.ts +13 -0
- package/dist/components/business/ForkJoinCard.d.ts +13 -0
- package/dist/components/business/FriendlyErrorCard.d.ts +8 -0
- package/dist/components/business/LoopDoWhileCard.d.ts +13 -0
- package/dist/components/business/PillPicker.d.ts +11 -0
- package/dist/components/business/RunStoryTimeline.d.ts +9 -0
- package/dist/components/business/StepFlowEditor.d.ts +11 -0
- package/dist/components/template/TemplateExtractor.d.ts +10 -0
- package/dist/components/template/TemplateGallery.d.ts +10 -0
- package/dist/components/template/TemplateSetupWizard.d.ts +9 -0
- package/dist/index.d.ts +29 -0
- package/dist/reactflow-ui-ai.es.js +2117 -2156
- package/dist/reactflow-ui.css +1 -1
- package/dist/reactflow-ui.es.js +15685 -8305
- package/dist/reactflow-ui.umd.js +25 -22
- package/dist/sample-workflows/ecs-lifecycle-automation.json +74 -0
- package/dist/stepmodel/compile.d.ts +5 -0
- package/dist/stepmodel/decompile.d.ts +5 -0
- package/dist/stepmodel/types.d.ts +61 -0
- package/dist/template/applyTemplate.d.ts +10 -0
- package/dist/template/builtin/templates.d.ts +37 -0
- package/dist/template/sanitizer/anonymize.d.ts +5 -0
- package/dist/template/sanitizer/prune.d.ts +10 -0
- package/dist/template/sanitizer/rules.d.ts +10 -0
- package/dist/template/sanitizer/types.d.ts +55 -0
- package/dist/template/templateStore.d.ts +32 -0
- package/dist/template/types.d.ts +99 -0
- package/dist/utils/friendlyErrorTranslator.d.ts +26 -0
- package/package.json +1 -1
- package/dist/components/Controls/ModeSlider.d.ts +0 -2
package/dist/reactflow-ui.umd.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(ce,N){typeof exports=="object"&&typeof module<"u"?N(exports,require("react"),require("reactflow"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","reactflow","react-dom"],N):(ce=typeof globalThis<"u"?globalThis:ce||self,N(ce.ReactflowUI={},ce.React,ce.ReactFlow,ce.ReactDOM))})(this,(function(ce,N,q,Ye){"use strict";var Jt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function vg(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Kt={exports:{}},Ct={};var El;function kg(){if(El)return Ct;El=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function r(n,s,o){var i=null;if(o!==void 0&&(i=""+o),s.key!==void 0&&(i=""+s.key),"key"in s){o={};for(var l in s)l!=="key"&&(o[l]=s[l])}else o=s;return s=o.ref,{$$typeof:e,type:n,key:i,ref:s!==void 0?s:null,props:o}}return Ct.Fragment=t,Ct.jsx=r,Ct.jsxs=r,Ct}var Nt={};var Pl;function Sg(){return Pl||(Pl=1,process.env.NODE_ENV!=="production"&&(function(){function e(O){if(O==null)return null;if(typeof O=="function")return O.$$typeof===w?null:O.displayName||O.name||null;if(typeof O=="string")return O;switch(O){case y:return"Fragment";case x:return"Profiler";case b:return"StrictMode";case S:return"Suspense";case j:return"SuspenseList";case T:return"Activity"}if(typeof O=="object")switch(typeof O.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),O.$$typeof){case g:return"Portal";case k:return O.displayName||"Context";case v:return(O._context.displayName||"Context")+".Consumer";case _:var J=O.render;return O=O.displayName,O||(O=J.displayName||J.name||"",O=O!==""?"ForwardRef("+O+")":"ForwardRef"),O;case R:return J=O.displayName||null,J!==null?J:e(O.type)||"Memo";case L:J=O._payload,O=O._init;try{return e(O(J))}catch{}}return null}function t(O){return""+O}function r(O){try{t(O);var J=!1}catch{J=!0}if(J){J=console;var Z=J.error,A=typeof Symbol=="function"&&Symbol.toStringTag&&O[Symbol.toStringTag]||O.constructor.name||"Object";return Z.call(J,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",A),t(O)}}function n(O){if(O===y)return"<>";if(typeof O=="object"&&O!==null&&O.$$typeof===L)return"<...>";try{var J=e(O);return J?"<"+J+">":"<...>"}catch{return"<...>"}}function s(){var O=D.A;return O===null?null:O.getOwner()}function o(){return Error("react-stack-top-frame")}function i(O){if(E.call(O,"key")){var J=Object.getOwnPropertyDescriptor(O,"key").get;if(J&&J.isReactWarning)return!1}return O.key!==void 0}function l(O,J){function Z(){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)",J))}Z.isReactWarning=!0,Object.defineProperty(O,"key",{get:Z,configurable:!0})}function c(){var O=e(this.type);return K[O]||(K[O]=!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.")),O=this.props.ref,O!==void 0?O:null}function u(O,J,Z,A,B,U){var H=Z.ref;return O={$$typeof:m,type:O,key:J,props:Z,_owner:A},(H!==void 0?H:null)!==null?Object.defineProperty(O,"ref",{enumerable:!1,get:c}):Object.defineProperty(O,"ref",{enumerable:!1,value:null}),O._store={},Object.defineProperty(O._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(O,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(O,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:B}),Object.defineProperty(O,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:U}),Object.freeze&&(Object.freeze(O.props),Object.freeze(O)),O}function d(O,J,Z,A,B,U){var H=J.children;if(H!==void 0)if(A)if(C(H)){for(A=0;A<H.length;A++)p(H[A]);Object.freeze&&Object.freeze(H)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else p(H);if(E.call(J,"key")){H=e(O);var X=Object.keys(J).filter(function(ge){return ge!=="key"});A=0<X.length?"{key: someKey, "+X.join(": ..., ")+": ...}":"{key: someKey}",F[H+A]||(X=0<X.length?"{"+X.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} />`,L,H,Y,H),B[H+L]=!0)}if(H=null,se!==void 0&&(r(se),H=""+se),i(U)&&(r(U.key),H=""+U.key),"key"in U){se={};for(var ie in U)ie!=="key"&&(se[ie]=U[ie])}else se=U;return H&&l(se,typeof P=="function"?P.displayName||P.name||"Unknown":P),d(P,H,se,s(),F,z)}function f(P){h(P)?P._store&&(P._store.validated=1):typeof P=="object"&&P!==null&&P.$$typeof===D&&(P._payload.status==="fulfilled"?h(P._payload.value)&&P._payload.value._store&&(P._payload.value._store.validated=1):P._store&&(P._store.validated=1))}function h(P){return typeof P=="object"&&P!==null&&P.$$typeof===m}var p=I,m=Symbol.for("react.transitional.element"),g=Symbol.for("react.portal"),x=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),y=Symbol.for("react.profiler"),b=Symbol.for("react.consumer"),k=Symbol.for("react.context"),_=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),T=Symbol.for("react.suspense_list"),O=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),N=Symbol.for("react.activity"),S=Symbol.for("react.client.reference"),R=p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,j=Object.prototype.hasOwnProperty,E=Array.isArray,q=console.createTask?console.createTask:function(){return null};p={react_stack_bottom_frame:function(P){return P()}};var $,J={},V=p.react_stack_bottom_frame.bind(p,a)(),A=q(n(a)),B={};Tt.Fragment=x,Tt.jsx=function(P,U,se){var L=1e4>R.recentlyCreatedOwnerStacks++;return u(P,U,se,!1,L?Error("react-stack-top-frame"):V,L?q(n(P)):A)},Tt.jsxs=function(P,U,se){var L=1e4>R.recentlyCreatedOwnerStacks++;return u(P,U,se,!0,L?Error("react-stack-top-frame"):V,L?q(n(P)):A)}})()),Tt}var Sl;function Um(){return Sl||(Sl=1,process.env.NODE_ENV==="production"?Ft.exports=Hm():Ft.exports=Jm()),Ft.exports}var o=Um();const _l=e=>{let t;const r=new Set,n=(d,u)=>{const f=typeof d=="function"?d(t):d;if(!Object.is(f,t)){const h=t;t=u??(typeof f!="object"||f===null)?f:Object.assign({},t,f),r.forEach(p=>p(t,h))}},s=()=>t,l={setState:n,getState:s,getInitialState:()=>c,subscribe:d=>(r.add(d),()=>r.delete(d))},c=t=e(n,s,l);return l},wl=(e=>e?_l(e):_l),Km=e=>e;function xr(e,t=Km){const r=I.useSyncExternalStore(e.subscribe,I.useCallback(()=>t(e.getState()),[e,t]),I.useCallback(()=>t(e.getInitialState()),[e,t]));return I.useDebugValue(r),r}const Gm=e=>{const t=wl(e),r=n=>xr(t,n);return Object.assign(r,t),r},vr=(e=>Gm);function br(e,t){let r;try{r=e()}catch{return}return{getItem:s=>{var a;const i=c=>c===null?null:JSON.parse(c,void 0),l=(a=r.getItem(s))!=null?a:null;return l instanceof Promise?l.then(i):i(l)},setItem:(s,a)=>r.setItem(s,JSON.stringify(a,void 0)),removeItem:s=>r.removeItem(s)}}const kr=e=>t=>{try{const r=e(t);return r instanceof Promise?r:{then(n){return kr(n)(r)},catch(n){return this}}}catch(r){return{then(n){return this},catch(n){return kr(n)(r)}}}},Tl=(e,t)=>(r,n,s)=>{let a={storage:br(()=>localStorage),partialize:g=>g,version:0,merge:(g,x)=>({...x,...g}),...t},i=!1;const l=new Set,c=new Set;let d=a.storage;if(!d)return e((...g)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),r(...g)},n,s);const u=()=>{const g=a.partialize({...n()});return d.setItem(a.name,{state:g,version:a.version})},f=s.setState;s.setState=(g,x)=>(f(g,x),u());const h=e((...g)=>(r(...g),u()),n,s);s.getInitialState=()=>h;let p;const m=()=>{var g,x;if(!d)return;i=!1,l.forEach(y=>{var b;return y((b=n())!=null?b:h)});const v=((x=a.onRehydrateStorage)==null?void 0:x.call(a,(g=n())!=null?g:h))||void 0;return kr(d.getItem.bind(d))(a.name).then(y=>{if(y)if(typeof y.version=="number"&&y.version!==a.version){if(a.migrate){const b=a.migrate(y.state,y.version);return b instanceof Promise?b.then(k=>[!0,k]):[!0,b]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,y.state];return[!1,void 0]}).then(y=>{var b;const[k,_]=y;if(p=a.merge(_,(b=n())!=null?b:h),r(p,!0),k)return u()}).then(()=>{v?.(p,void 0),p=n(),i=!0,c.forEach(y=>y(p))}).catch(y=>{v?.(void 0,y)})};return s.persist={setOptions:g=>{a={...a,...g},g.storage&&(d=g.storage)},clearStorage:()=>{d?.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>m(),hasHydrated:()=>i,onHydrate:g=>(l.add(g),()=>{l.delete(g)}),onFinishHydration:g=>(c.add(g),()=>{c.delete(g)})},a.skipHydration||m(),p||h};var El=(e,t,r)=>(s,a)=>({pastStates:r?.pastStates||[],futureStates:r?.futureStates||[],undo:(i=1)=>{if(a().pastStates.length){const l=r?.partialize?.(t())||t(),c=a().pastStates.splice(-i,i),d=c.shift();e(d),s({pastStates:a().pastStates,futureStates:a().futureStates.concat(r?.diff?.(l,d)||l,c.reverse())})}},redo:(i=1)=>{if(a().futureStates.length){const l=r?.partialize?.(t())||t(),c=a().futureStates.splice(-i,i),d=c.shift();e(d),s({pastStates:a().pastStates.concat(r?.diff?.(l,d)||l,c.reverse()),futureStates:a().futureStates})}},clear:()=>s({pastStates:[],futureStates:[]}),isTracking:!0,pause:()=>s({isTracking:!1}),resume:()=>s({isTracking:!0}),setOnSave:i=>s({_onSave:i}),_onSave:r?.onSave,_handleSet:(i,l,c,d)=>{r?.limit&&a().pastStates.length>=r?.limit&&a().pastStates.shift(),a()._onSave?.(i,c),s({pastStates:a().pastStates.concat(d||i),futureStates:[]})}}),Vm=(e,t)=>(n,s,a)=>{a.temporal=wl(t?.wrapTemporal?.(El(n,s,t))||El(n,s,t));const i=t?.handleSet?.(a.temporal.getState()._handleSet)||a.temporal.getState()._handleSet,l=d=>{if(!a.temporal.getState().isTracking)return;const u=t?.partialize?.(s())||s(),f=t?.diff?.(d,u);f===null||t?.equality?.(d,u)||i(d,void 0,u,f)},c=a.setState;return a.setState=(...d)=>{const u=t?.partialize?.(s())||s();c(...d),l(u)},e((...d)=>{const u=t?.partialize?.(s())||s();n(...d),l(u)},s,a)};function Ym(e,t="TB",r){const n=r?.hideEmptyBranches??!1;if(!e||!e.tasks)return{nodes:[],edges:[],taskMap:{}};const s=[],a=[],i={};let l=0;const c=e.tasks;for(let d=0;d<c.length;d++){const u=c[d],f=Nl(u,l,i,t,c,n);if(s.push(...f.nodes),a.push(...f.edges),l=f.nextId,d>0){const h=c[d-1];Sr(h,u,a,n)}Object.assign(i,f.taskMap)}if(!n&&c.length>0){const d=c[0],u="__workflow_start__";s.push({id:u,type:"plusNode",data:{label:"+",taskReferenceName:u,taskType:"PLUS",parentRef:u,edgeData:{isWorkflowStart:!0},layoutDirection:t},position:{x:0,y:0},sourcePosition:t==="LR"?M.Position.Right:M.Position.Bottom,targetPosition:t==="LR"?M.Position.Left:M.Position.Top}),a.push({id:`e-${u}-${d.taskReferenceName}`,source:u,target:d.taskReferenceName,animated:!0});const f=c[c.length-1],h="__workflow_end__";s.push({id:h,type:"plusNode",data:{label:"+",taskReferenceName:h,taskType:"PLUS",parentRef:f.taskReferenceName,layoutDirection:t},position:{x:0,y:0},sourcePosition:t==="LR"?M.Position.Right:M.Position.Bottom,targetPosition:t==="LR"?M.Position.Left:M.Position.Top}),Sr(f,{taskReferenceName:h},a,n)}return{nodes:s,edges:a,taskMap:i}}function Nl(e,t,r,n="TB",s=[],a=!1){switch(e.type||"SIMPLE"){case"DECISION":case"SWITCH":return Qm(e,t,r,n,a);case"FORK_JOIN":case"FORK_JOIN_DYNAMIC":return Zm(e,t,r,n);case"JOIN":case"EXCLUSIVE_JOIN":return rg(e,t,r,n,s,a);case"DO_WHILE":return eg(e,t,r,n,a);case"SUB_WORKFLOW":return tg(e,t,r,n);default:return Xm(e,t,r,n)}}function Xm(e,t,r,n="TB"){const s={id:e.taskReferenceName,type:"taskNode",data:{label:e.name,taskReferenceName:e.taskReferenceName,taskType:e.type||"SIMPLE",task:e,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?M.Position.Right:M.Position.Bottom,targetPosition:n==="LR"?M.Position.Left:M.Position.Top},a={[e.taskReferenceName]:e};return{nodes:[s],edges:[],taskMap:a,nextId:t+1}}function Qm(e,t,r,n="TB",s=!1){const a=[],i=[];let l=t;const c={},d={id:e.taskReferenceName,type:"decisionNode",data:{label:e.name,taskReferenceName:e.taskReferenceName,taskType:e.type,task:e,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?M.Position.Right:M.Position.Bottom,targetPosition:n==="LR"?M.Position.Left:M.Position.Top};a.push(d),c[e.taskReferenceName]=e;const u=e.decisionCases||{},f=e.defaultCase||[],h=Object.keys(u),p=(m,g)=>{if(n==="TB"){if(m===0&&g>1)return"left";if(m===1&&g>2)return"right"}else{if(m===0&&g>1)return"top";if(m===1&&g>2)return"bottom"}return null};if(h.forEach((m,g)=>{const x=u[m],v=p(g,h.length+1);if(x&&x.length>0){const y=Bt(x,l,{...r,...c},n,s);a.push(...y.nodes),i.push(...y.edges),Object.assign(c,y.taskMap),l=y.nextId;const b=x[0].taskReferenceName;i.push({id:`e-${e.taskReferenceName}-${b}`,source:e.taskReferenceName,sourceHandle:v||void 0,target:b,label:m,animated:!0,data:{branchCase:m},style:{stroke:"#3b82f6"}})}else if(!s){const y=`${e.taskReferenceName}_empty_${m}`;a.push({id:y,type:"plusNode",data:{label:`${m} (空)`,parentRef:e.taskReferenceName,edgeData:{branchCase:m},layoutDirection:n,taskReferenceName:y,taskType:"EMPTY_BRANCH"},position:{x:0,y:0},sourcePosition:n==="LR"?M.Position.Right:M.Position.Bottom,targetPosition:n==="LR"?M.Position.Left:M.Position.Top,style:{background:"transparent",border:"2px dashed var(--border-secondary, #64748b)",borderRadius:"8px",padding:"6px 12px",fontSize:"11px",color:"var(--text-tertiary, #94a3b8)",minWidth:"80px",textAlign:"center"}}),i.push({id:`e-${e.taskReferenceName}-${y}`,source:e.taskReferenceName,sourceHandle:v||void 0,target:y,label:m,animated:!0,data:{branchCase:m},style:{stroke:"#3b82f6",strokeDasharray:"5,5"}})}}),f&&f.length>0){const m=Bt(f,l,{...r,...c},n,s);a.push(...m.nodes),i.push(...m.edges),Object.assign(c,m.taskMap),l=m.nextId;const g=f[0].taskReferenceName;i.push({id:`e-${e.taskReferenceName}-${g}`,source:e.taskReferenceName,target:g,label:"default",animated:!0,data:{branchCase:"default"},style:{stroke:"#f59e0b"}})}else if(!s){const m=`${e.taskReferenceName}_empty_default`;a.push({id:m,type:"plusNode",data:{label:"default (空)",parentRef:e.taskReferenceName,edgeData:{branchCase:"default"},layoutDirection:n,taskReferenceName:m,taskType:"EMPTY_BRANCH"},position:{x:0,y:0},sourcePosition:n==="LR"?M.Position.Right:M.Position.Bottom,targetPosition:n==="LR"?M.Position.Left:M.Position.Top,style:{background:"transparent",border:"2px dashed var(--border-secondary, #64748b)",borderRadius:"8px",padding:"6px 12px",fontSize:"11px",color:"var(--text-tertiary, #94a3b8)",minWidth:"80px",textAlign:"center"}}),i.push({id:`e-${e.taskReferenceName}-${m}`,source:e.taskReferenceName,target:m,label:"default",animated:!0,data:{branchCase:"default"},style:{stroke:"#f59e0b",strokeDasharray:"5,5"}})}return{nodes:a,edges:i,taskMap:c,nextId:l}}function Zm(e,t,r,n="TB"){const s=[],a=[];let i=t;const l={},c=e.type==="FORK_JOIN_DYNAMIC",d={id:e.taskReferenceName,type:"forkNode",data:{label:e.name,taskReferenceName:e.taskReferenceName,taskType:e.type,task:e,isDynamic:c,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?M.Position.Right:M.Position.Bottom,targetPosition:n==="LR"?M.Position.Left:M.Position.Top};if(s.push(d),l[e.taskReferenceName]=e,c){const u=`${e.taskReferenceName}_dynamic_placeholder`;s.push({id:u,type:"dynamicPlaceholderNode",data:{label:"动态分支",taskReferenceName:u,taskType:"DYNAMIC_PLACEHOLDER",layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?M.Position.Right:M.Position.Bottom,targetPosition:n==="LR"?M.Position.Left:M.Position.Top}),a.push({id:`e-${e.taskReferenceName}-${u}`,source:e.taskReferenceName,target:u,animated:!0,style:{stroke:"#10b981",strokeDasharray:"5,5",strokeWidth:2}}),l[u]={taskReferenceName:u,type:"DYNAMIC_PLACEHOLDER"}}return c||(e.forkTasks||[]).forEach((f,h)=>{if(f&&f.length>0){const p=Bt(f,i,{...r,...l},n,!1);s.push(...p.nodes),a.push(...p.edges),Object.assign(l,p.taskMap),i=p.nextId;const m=f[0].taskReferenceName;a.push({id:`e-${e.taskReferenceName}-${m}`,source:e.taskReferenceName,sourceHandle:`branch_${h}`,target:m,label:`分支 ${h+1}`,animated:!0,data:{forkIndex:h},style:{stroke:"#10b981"}})}}),{nodes:s,edges:a,taskMap:l,nextId:i}}function eg(e,t,r,n="TB",s=!1){const a={},i=e.taskReferenceName,l={id:i,type:"loopNode",data:{label:e.name,taskReferenceName:i,taskType:e.type,task:e,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?M.Position.Right:M.Position.Bottom,targetPosition:n==="LR"?M.Position.Left:M.Position.Top,style:{pointerEvents:"none"}};a[i]=e;const c=e.loopOver||[],d=[],u=[];let f=t+1;if(c.length>0){const h=Bt(c,f,{...r,...a},n,s);if(f=h.nextId,Object.assign(a,h.taskMap),h.nodes.forEach(p=>{d.push({...p,parentId:p.parentId??i,extent:p.parentId?p.extent:"parent"})}),u.push(...h.edges),!s){const p=c[0],m=`__loop_start__${i}`;d.push({id:m,type:"plusNode",parentId:i,extent:"parent",data:{label:"+",taskReferenceName:m,taskType:"PLUS",parentRef:i,edgeData:{isLoopBodyStart:!0,loopId:i},layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?M.Position.Right:M.Position.Bottom,targetPosition:n==="LR"?M.Position.Left:M.Position.Top}),u.push({id:`e-${m}-${p.taskReferenceName}`,source:m,target:p.taskReferenceName,animated:!0})}if(!s){const p=c[c.length-1],m=`__loop_end__${i}`;d.push({id:m,type:"plusNode",parentId:i,extent:"parent",data:{label:"+",taskReferenceName:m,taskType:"PLUS",parentRef:p.taskReferenceName,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?M.Position.Right:M.Position.Bottom,targetPosition:n==="LR"?M.Position.Left:M.Position.Top}),u.push({id:`e-${p.taskReferenceName}-${m}`,source:p.taskReferenceName,target:m,animated:!0})}}else if(!s){const h=`${i}_loop_empty_plus`;d.push({id:h,type:"plusNode",parentId:i,extent:"parent",data:{label:"+ 添加",taskReferenceName:h,taskType:"PLUS",parentRef:i,edgeData:{isLoopAdd:!0},layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?M.Position.Right:M.Position.Bottom,targetPosition:n==="LR"?M.Position.Left:M.Position.Top})}return{nodes:[l,...d],edges:u,taskMap:a,nextId:f}}function tg(e,t,r,n="TB"){const s={id:e.taskReferenceName,type:"subWorkflowNode",data:{label:e.name,taskReferenceName:e.taskReferenceName,taskType:e.type,task:e,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?M.Position.Right:M.Position.Bottom,targetPosition:n==="LR"?M.Position.Left:M.Position.Top},a={[e.taskReferenceName]:e};return{nodes:[s],edges:[],taskMap:a,nextId:t+1}}function rg(e,t,r,n="TB",s=[],a=!1){const i={id:e.taskReferenceName,type:"joinNode",data:{label:e.name||"JOIN",taskReferenceName:e.taskReferenceName,taskType:e.type,task:e,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?M.Position.Right:M.Position.Bottom,targetPosition:n==="LR"?M.Position.Left:M.Position.Top},l={[e.taskReferenceName]:e},c=[],d=[];(e.joinOn||[]).forEach(h=>{const p=s.find(m=>m.taskReferenceName===h)||r[h];p&&zt(p,a).forEach(g=>{d.push({id:`e-${g}-${e.taskReferenceName}`,source:g,target:e.taskReferenceName,animated:!0})})});const f=s.findIndex(h=>h.taskReferenceName===e.taskReferenceName);if(f>0){const h=s[f-1];if(h.type==="FORK_JOIN_DYNAMIC"){const p=`${h.taskReferenceName}_dynamic_placeholder`;d.push({id:`e-${p}-${e.taskReferenceName}-dynamic`,source:p,target:e.taskReferenceName,animated:!0,style:{stroke:"#10b981",strokeWidth:2,strokeDasharray:"5,5",opacity:.8}})}else h.type==="FORK_JOIN"&&(h.forkTasks||[]).forEach((m,g)=>{if((!m||m.length===0)&&!a){const x=`${h.taskReferenceName}_empty_branch_${g}`;c.push({id:x,type:"default",data:{label:`分支 ${g+1} (空)`,layoutDirection:n,taskReferenceName:x,taskType:"EMPTY_BRANCH"},position:{x:0,y:0},sourcePosition:n==="LR"?M.Position.Right:M.Position.Bottom,targetPosition:n==="LR"?M.Position.Left:M.Position.Top,style:{background:"transparent",border:"2px dashed var(--border-secondary, #64748b)",borderRadius:"8px",padding:"6px 12px",fontSize:"11px",color:"var(--text-tertiary, #94a3b8)",minWidth:"80px",textAlign:"center"}}),d.push({id:`e-${h.taskReferenceName}-${x}`,source:h.taskReferenceName,sourceHandle:`branch_${g}`,target:x,label:`分支 ${g+1}`,animated:!0,data:{forkIndex:g},style:{stroke:"#10b981",strokeDasharray:"5,5"}}),d.push({id:`e-${x}-${e.taskReferenceName}`,source:x,target:e.taskReferenceName,animated:!0,style:{strokeDasharray:"5,5"}})}})}return{nodes:[i,...c],edges:d,taskMap:l,nextId:t+1}}function Bt(e,t,r,n="TB",s=!1){const a=[],i=[];let l=t;const c={};for(let d=0;d<e.length;d++){const u=e[d],f={...r,...c},h=Nl(u,l,f,n,e,s);if(a.push(...h.nodes),i.push(...h.edges),Object.assign(c,h.taskMap),l=h.nextId,d>0){const p=e[d-1];Sr(p,u,i,s)}}return{nodes:a,edges:i,taskMap:c,nextId:l}}function Sr(e,t,r,n=!1){if(e.type==="FORK_JOIN"||e.type==="FORK_JOIN_DYNAMIC")return;const s=zt(e,n),a=t.taskReferenceName;s.forEach(i=>{const l=`e-${i}-${a}`;r.find(c=>c.id===l)||r.push({id:l,source:i,target:a,animated:!0})})}function zt(e,t=!1){const r=e.type||"SIMPLE";if(r==="DECISION"||r==="SWITCH"){const n=[],s=e.decisionCases||{},a=e.defaultCase||[];if(Object.entries(s).forEach(([i,l])=>{if(l&&l.length>0){const c=l[l.length-1];n.push(...zt(c,t))}else t||n.push(`${e.taskReferenceName}_empty_${i}`)}),a.length>0){const i=a[a.length-1];n.push(...zt(i,t))}else t||n.push(`${e.taskReferenceName}_empty_default`);return n.length>0?n:[e.taskReferenceName]}return[e.taskReferenceName]}const Ae=Ym;function _r(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var wr,jl;function ng(){if(jl)return wr;jl=1;function e(){this.__data__=[],this.size=0}return wr=e,wr}var Tr,Cl;function dt(){if(Cl)return Tr;Cl=1;function e(t,r){return t===r||t!==t&&r!==r}return Tr=e,Tr}var Er,Il;function Ht(){if(Il)return Er;Il=1;var e=dt();function t(r,n){for(var s=r.length;s--;)if(e(r[s][0],n))return s;return-1}return Er=t,Er}var Nr,Rl;function sg(){if(Rl)return Nr;Rl=1;var e=Ht(),t=Array.prototype,r=t.splice;function n(s){var a=this.__data__,i=e(a,s);if(i<0)return!1;var l=a.length-1;return i==l?a.pop():r.call(a,i,1),--this.size,!0}return Nr=n,Nr}var jr,Ol;function ag(){if(Ol)return jr;Ol=1;var e=Ht();function t(r){var n=this.__data__,s=e(n,r);return s<0?void 0:n[s][1]}return jr=t,jr}var Cr,Pl;function og(){if(Pl)return Cr;Pl=1;var e=Ht();function t(r){return e(this.__data__,r)>-1}return Cr=t,Cr}var Ir,Al;function ig(){if(Al)return Ir;Al=1;var e=Ht();function t(r,n){var s=this.__data__,a=e(s,r);return a<0?(++this.size,s.push([r,n])):s[a][1]=n,this}return Ir=t,Ir}var Rr,Ll;function Jt(){if(Ll)return Rr;Ll=1;var e=ng(),t=sg(),r=ag(),n=og(),s=ig();function a(i){var l=-1,c=i==null?0:i.length;for(this.clear();++l<c;){var d=i[l];this.set(d[0],d[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=r,a.prototype.has=n,a.prototype.set=s,Rr=a,Rr}var Or,Dl;function lg(){if(Dl)return Or;Dl=1;var e=Jt();function t(){this.__data__=new e,this.size=0}return Or=t,Or}var Pr,Ml;function cg(){if(Ml)return Pr;Ml=1;function e(t){var r=this.__data__,n=r.delete(t);return this.size=r.size,n}return Pr=e,Pr}var Ar,ql;function dg(){if(ql)return Ar;ql=1;function e(t){return this.__data__.get(t)}return Ar=e,Ar}var Lr,$l;function ug(){if($l)return Lr;$l=1;function e(t){return this.__data__.has(t)}return Lr=e,Lr}var Dr,Wl;function Fl(){if(Wl)return Dr;Wl=1;var e=typeof Wt=="object"&&Wt&&Wt.Object===Object&&Wt;return Dr=e,Dr}var Mr,Bl;function ze(){if(Bl)return Mr;Bl=1;var e=Fl(),t=typeof self=="object"&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return Mr=r,Mr}var qr,zl;function ut(){if(zl)return qr;zl=1;var e=ze(),t=e.Symbol;return qr=t,qr}var $r,Hl;function fg(){if(Hl)return $r;Hl=1;var e=ut(),t=Object.prototype,r=t.hasOwnProperty,n=t.toString,s=e?e.toStringTag:void 0;function a(i){var l=r.call(i,s),c=i[s];try{i[s]=void 0;var d=!0}catch{}var u=n.call(i);return d&&(l?i[s]=c:delete i[s]),u}return $r=a,$r}var Wr,Jl;function pg(){if(Jl)return Wr;Jl=1;var e=Object.prototype,t=e.toString;function r(n){return t.call(n)}return Wr=r,Wr}var Fr,Ul;function nt(){if(Ul)return Fr;Ul=1;var e=ut(),t=fg(),r=pg(),n="[object Null]",s="[object Undefined]",a=e?e.toStringTag:void 0;function i(l){return l==null?l===void 0?s:n:a&&a in Object(l)?t(l):r(l)}return Fr=i,Fr}var Br,Kl;function qe(){if(Kl)return Br;Kl=1;function e(t){var r=typeof t;return t!=null&&(r=="object"||r=="function")}return Br=e,Br}var zr,Gl;function Et(){if(Gl)return zr;Gl=1;var e=nt(),t=qe(),r="[object AsyncFunction]",n="[object Function]",s="[object GeneratorFunction]",a="[object Proxy]";function i(l){if(!t(l))return!1;var c=e(l);return c==n||c==s||c==r||c==a}return zr=i,zr}var Hr,Vl;function hg(){if(Vl)return Hr;Vl=1;var e=ze(),t=e["__core-js_shared__"];return Hr=t,Hr}var Jr,Yl;function mg(){if(Yl)return Jr;Yl=1;var e=hg(),t=(function(){var n=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""})();function r(n){return!!t&&t in n}return Jr=r,Jr}var Ur,Xl;function Ql(){if(Xl)return Ur;Xl=1;var e=Function.prototype,t=e.toString;function r(n){if(n!=null){try{return t.call(n)}catch{}try{return n+""}catch{}}return""}return Ur=r,Ur}var Kr,Zl;function gg(){if(Zl)return Kr;Zl=1;var e=Et(),t=mg(),r=qe(),n=Ql(),s=/[\\^$.*+?()[\]{}|]/g,a=/^\[object .+?Constructor\]$/,i=Function.prototype,l=Object.prototype,c=i.toString,d=l.hasOwnProperty,u=RegExp("^"+c.call(d).replace(s,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function f(h){if(!r(h)||t(h))return!1;var p=e(h)?u:a;return p.test(n(h))}return Kr=f,Kr}var Gr,ec;function yg(){if(ec)return Gr;ec=1;function e(t,r){return t?.[r]}return Gr=e,Gr}var Vr,tc;function st(){if(tc)return Vr;tc=1;var e=gg(),t=yg();function r(n,s){var a=t(n,s);return e(a)?a:void 0}return Vr=r,Vr}var Yr,rc;function Xr(){if(rc)return Yr;rc=1;var e=st(),t=ze(),r=e(t,"Map");return Yr=r,Yr}var Qr,nc;function Ut(){if(nc)return Qr;nc=1;var e=st(),t=e(Object,"create");return Qr=t,Qr}var Zr,sc;function xg(){if(sc)return Zr;sc=1;var e=Ut();function t(){this.__data__=e?e(null):{},this.size=0}return Zr=t,Zr}var en,ac;function vg(){if(ac)return en;ac=1;function e(t){var r=this.has(t)&&delete this.__data__[t];return this.size-=r?1:0,r}return en=e,en}var tn,oc;function bg(){if(oc)return tn;oc=1;var e=Ut(),t="__lodash_hash_undefined__",r=Object.prototype,n=r.hasOwnProperty;function s(a){var i=this.__data__;if(e){var l=i[a];return l===t?void 0:l}return n.call(i,a)?i[a]:void 0}return tn=s,tn}var rn,ic;function kg(){if(ic)return rn;ic=1;var e=Ut(),t=Object.prototype,r=t.hasOwnProperty;function n(s){var a=this.__data__;return e?a[s]!==void 0:r.call(a,s)}return rn=n,rn}var nn,lc;function Sg(){if(lc)return nn;lc=1;var e=Ut(),t="__lodash_hash_undefined__";function r(n,s){var a=this.__data__;return this.size+=this.has(n)?0:1,a[n]=e&&s===void 0?t:s,this}return nn=r,nn}var sn,cc;function _g(){if(cc)return sn;cc=1;var e=xg(),t=vg(),r=bg(),n=kg(),s=Sg();function a(i){var l=-1,c=i==null?0:i.length;for(this.clear();++l<c;){var d=i[l];this.set(d[0],d[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=r,a.prototype.has=n,a.prototype.set=s,sn=a,sn}var an,dc;function wg(){if(dc)return an;dc=1;var e=_g(),t=Jt(),r=Xr();function n(){this.size=0,this.__data__={hash:new e,map:new(r||t),string:new e}}return an=n,an}var on,uc;function Tg(){if(uc)return on;uc=1;function e(t){var r=typeof t;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?t!=="__proto__":t===null}return on=e,on}var ln,fc;function Kt(){if(fc)return ln;fc=1;var e=Tg();function t(r,n){var s=r.__data__;return e(n)?s[typeof n=="string"?"string":"hash"]:s.map}return ln=t,ln}var cn,pc;function Eg(){if(pc)return cn;pc=1;var e=Kt();function t(r){var n=e(this,r).delete(r);return this.size-=n?1:0,n}return cn=t,cn}var dn,hc;function Ng(){if(hc)return dn;hc=1;var e=Kt();function t(r){return e(this,r).get(r)}return dn=t,dn}var un,mc;function jg(){if(mc)return un;mc=1;var e=Kt();function t(r){return e(this,r).has(r)}return un=t,un}var fn,gc;function Cg(){if(gc)return fn;gc=1;var e=Kt();function t(r,n){var s=e(this,r),a=s.size;return s.set(r,n),this.size+=s.size==a?0:1,this}return fn=t,fn}var pn,yc;function hn(){if(yc)return pn;yc=1;var e=wg(),t=Eg(),r=Ng(),n=jg(),s=Cg();function a(i){var l=-1,c=i==null?0:i.length;for(this.clear();++l<c;){var d=i[l];this.set(d[0],d[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=r,a.prototype.has=n,a.prototype.set=s,pn=a,pn}var mn,xc;function Ig(){if(xc)return mn;xc=1;var e=Jt(),t=Xr(),r=hn(),n=200;function s(a,i){var l=this.__data__;if(l instanceof e){var c=l.__data__;if(!t||c.length<n-1)return c.push([a,i]),this.size=++l.size,this;l=this.__data__=new r(c)}return l.set(a,i),this.size=l.size,this}return mn=s,mn}var gn,vc;function Gt(){if(vc)return gn;vc=1;var e=Jt(),t=lg(),r=cg(),n=dg(),s=ug(),a=Ig();function i(l){var c=this.__data__=new e(l);this.size=c.size}return i.prototype.clear=t,i.prototype.delete=r,i.prototype.get=n,i.prototype.has=s,i.prototype.set=a,gn=i,gn}var yn,bc;function xn(){if(bc)return yn;bc=1;function e(t,r){for(var n=-1,s=t==null?0:t.length;++n<s&&r(t[n],n,t)!==!1;);return t}return yn=e,yn}var vn,kc;function Sc(){if(kc)return vn;kc=1;var e=st(),t=(function(){try{var r=e(Object,"defineProperty");return r({},"",{}),r}catch{}})();return vn=t,vn}var bn,_c;function Vt(){if(_c)return bn;_c=1;var e=Sc();function t(r,n,s){n=="__proto__"&&e?e(r,n,{configurable:!0,enumerable:!0,value:s,writable:!0}):r[n]=s}return bn=t,bn}var kn,wc;function Yt(){if(wc)return kn;wc=1;var e=Vt(),t=dt(),r=Object.prototype,n=r.hasOwnProperty;function s(a,i,l){var c=a[i];(!(n.call(a,i)&&t(c,l))||l===void 0&&!(i in a))&&e(a,i,l)}return kn=s,kn}var Sn,Tc;function Nt(){if(Tc)return Sn;Tc=1;var e=Yt(),t=Vt();function r(n,s,a,i){var l=!a;a||(a={});for(var c=-1,d=s.length;++c<d;){var u=s[c],f=i?i(a[u],n[u],u,a,n):void 0;f===void 0&&(f=n[u]),l?t(a,u,f):e(a,u,f)}return a}return Sn=r,Sn}var _n,Ec;function Rg(){if(Ec)return _n;Ec=1;function e(t,r){for(var n=-1,s=Array(t);++n<t;)s[n]=r(n);return s}return _n=e,_n}var wn,Nc;function Ke(){if(Nc)return wn;Nc=1;function e(t){return t!=null&&typeof t=="object"}return wn=e,wn}var Tn,jc;function Og(){if(jc)return Tn;jc=1;var e=nt(),t=Ke(),r="[object Arguments]";function n(s){return t(s)&&e(s)==r}return Tn=n,Tn}var En,Cc;function jt(){if(Cc)return En;Cc=1;var e=Og(),t=Ke(),r=Object.prototype,n=r.hasOwnProperty,s=r.propertyIsEnumerable,a=e((function(){return arguments})())?e:function(i){return t(i)&&n.call(i,"callee")&&!s.call(i,"callee")};return En=a,En}var Nn,Ic;function Ne(){if(Ic)return Nn;Ic=1;var e=Array.isArray;return Nn=e,Nn}var Ct={exports:{}},jn,Rc;function Pg(){if(Rc)return jn;Rc=1;function e(){return!1}return jn=e,jn}Ct.exports;var Oc;function ft(){return Oc||(Oc=1,(function(e,t){var r=ze(),n=Pg(),s=t&&!t.nodeType&&t,a=s&&!0&&e&&!e.nodeType&&e,i=a&&a.exports===s,l=i?r.Buffer:void 0,c=l?l.isBuffer:void 0,d=c||n;e.exports=d})(Ct,Ct.exports)),Ct.exports}var Cn,Pc;function Xt(){if(Pc)return Cn;Pc=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function r(n,s){var a=typeof n;return s=s??e,!!s&&(a=="number"||a!="symbol"&&t.test(n))&&n>-1&&n%1==0&&n<s}return Cn=r,Cn}var In,Ac;function Rn(){if(Ac)return In;Ac=1;var e=9007199254740991;function t(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=e}return In=t,In}var On,Lc;function Ag(){if(Lc)return On;Lc=1;var e=nt(),t=Rn(),r=Ke(),n="[object Arguments]",s="[object Array]",a="[object Boolean]",i="[object Date]",l="[object Error]",c="[object Function]",d="[object Map]",u="[object Number]",f="[object Object]",h="[object RegExp]",p="[object Set]",m="[object String]",g="[object WeakMap]",x="[object ArrayBuffer]",v="[object DataView]",y="[object Float32Array]",b="[object Float64Array]",k="[object Int8Array]",_="[object Int16Array]",w="[object Int32Array]",T="[object Uint8Array]",O="[object Uint8ClampedArray]",D="[object Uint16Array]",N="[object Uint32Array]",S={};S[y]=S[b]=S[k]=S[_]=S[w]=S[T]=S[O]=S[D]=S[N]=!0,S[n]=S[s]=S[x]=S[a]=S[v]=S[i]=S[l]=S[c]=S[d]=S[u]=S[f]=S[h]=S[p]=S[m]=S[g]=!1;function R(j){return r(j)&&t(j.length)&&!!S[e(j)]}return On=R,On}var Pn,Dc;function Qt(){if(Dc)return Pn;Dc=1;function e(t){return function(r){return t(r)}}return Pn=e,Pn}var It={exports:{}};It.exports;var Mc;function An(){return Mc||(Mc=1,(function(e,t){var r=Fl(),n=t&&!t.nodeType&&t,s=n&&!0&&e&&!e.nodeType&&e,a=s&&s.exports===n,i=a&&r.process,l=(function(){try{var c=s&&s.require&&s.require("util").types;return c||i&&i.binding&&i.binding("util")}catch{}})();e.exports=l})(It,It.exports)),It.exports}var Ln,qc;function Rt(){if(qc)return Ln;qc=1;var e=Ag(),t=Qt(),r=An(),n=r&&r.isTypedArray,s=n?t(n):e;return Ln=s,Ln}var Dn,$c;function Wc(){if($c)return Dn;$c=1;var e=Rg(),t=jt(),r=Ne(),n=ft(),s=Xt(),a=Rt(),i=Object.prototype,l=i.hasOwnProperty;function c(d,u){var f=r(d),h=!f&&t(d),p=!f&&!h&&n(d),m=!f&&!h&&!p&&a(d),g=f||h||p||m,x=g?e(d.length,String):[],v=x.length;for(var y in d)(u||l.call(d,y))&&!(g&&(y=="length"||p&&(y=="offset"||y=="parent")||m&&(y=="buffer"||y=="byteLength"||y=="byteOffset")||s(y,v)))&&x.push(y);return x}return Dn=c,Dn}var Mn,Fc;function Zt(){if(Fc)return Mn;Fc=1;var e=Object.prototype;function t(r){var n=r&&r.constructor,s=typeof n=="function"&&n.prototype||e;return r===s}return Mn=t,Mn}var qn,Bc;function zc(){if(Bc)return qn;Bc=1;function e(t,r){return function(n){return t(r(n))}}return qn=e,qn}var $n,Hc;function Lg(){if(Hc)return $n;Hc=1;var e=zc(),t=e(Object.keys,Object);return $n=t,$n}var Wn,Jc;function Fn(){if(Jc)return Wn;Jc=1;var e=Zt(),t=Lg(),r=Object.prototype,n=r.hasOwnProperty;function s(a){if(!e(a))return t(a);var i=[];for(var l in Object(a))n.call(a,l)&&l!="constructor"&&i.push(l);return i}return Wn=s,Wn}var Bn,Uc;function Ve(){if(Uc)return Bn;Uc=1;var e=Et(),t=Rn();function r(n){return n!=null&&t(n.length)&&!e(n)}return Bn=r,Bn}var zn,Kc;function Ze(){if(Kc)return zn;Kc=1;var e=Wc(),t=Fn(),r=Ve();function n(s){return r(s)?e(s):t(s)}return zn=n,zn}var Hn,Gc;function Dg(){if(Gc)return Hn;Gc=1;var e=Nt(),t=Ze();function r(n,s){return n&&e(s,t(s),n)}return Hn=r,Hn}var Jn,Vc;function Mg(){if(Vc)return Jn;Vc=1;function e(t){var r=[];if(t!=null)for(var n in Object(t))r.push(n);return r}return Jn=e,Jn}var Un,Yc;function qg(){if(Yc)return Un;Yc=1;var e=qe(),t=Zt(),r=Mg(),n=Object.prototype,s=n.hasOwnProperty;function a(i){if(!e(i))return r(i);var l=t(i),c=[];for(var d in i)d=="constructor"&&(l||!s.call(i,d))||c.push(d);return c}return Un=a,Un}var Kn,Xc;function at(){if(Xc)return Kn;Xc=1;var e=Wc(),t=qg(),r=Ve();function n(s){return r(s)?e(s,!0):t(s)}return Kn=n,Kn}var Gn,Qc;function $g(){if(Qc)return Gn;Qc=1;var e=Nt(),t=at();function r(n,s){return n&&e(s,t(s),n)}return Gn=r,Gn}var Ot={exports:{}};Ot.exports;var Zc;function ed(){return Zc||(Zc=1,(function(e,t){var r=ze(),n=t&&!t.nodeType&&t,s=n&&!0&&e&&!e.nodeType&&e,a=s&&s.exports===n,i=a?r.Buffer:void 0,l=i?i.allocUnsafe:void 0;function c(d,u){if(u)return d.slice();var f=d.length,h=l?l(f):new d.constructor(f);return d.copy(h),h}e.exports=c})(Ot,Ot.exports)),Ot.exports}var Vn,td;function rd(){if(td)return Vn;td=1;function e(t,r){var n=-1,s=t.length;for(r||(r=Array(s));++n<s;)r[n]=t[n];return r}return Vn=e,Vn}var Yn,nd;function sd(){if(nd)return Yn;nd=1;function e(t,r){for(var n=-1,s=t==null?0:t.length,a=0,i=[];++n<s;){var l=t[n];r(l,n,t)&&(i[a++]=l)}return i}return Yn=e,Yn}var Xn,ad;function od(){if(ad)return Xn;ad=1;function e(){return[]}return Xn=e,Xn}var Qn,id;function Zn(){if(id)return Qn;id=1;var e=sd(),t=od(),r=Object.prototype,n=r.propertyIsEnumerable,s=Object.getOwnPropertySymbols,a=s?function(i){return i==null?[]:(i=Object(i),e(s(i),function(l){return n.call(i,l)}))}:t;return Qn=a,Qn}var es,ld;function Wg(){if(ld)return es;ld=1;var e=Nt(),t=Zn();function r(n,s){return e(n,t(n),s)}return es=r,es}var ts,cd;function rs(){if(cd)return ts;cd=1;function e(t,r){for(var n=-1,s=r.length,a=t.length;++n<s;)t[a+n]=r[n];return t}return ts=e,ts}var ns,dd;function er(){if(dd)return ns;dd=1;var e=zc(),t=e(Object.getPrototypeOf,Object);return ns=t,ns}var ss,ud;function fd(){if(ud)return ss;ud=1;var e=rs(),t=er(),r=Zn(),n=od(),s=Object.getOwnPropertySymbols,a=s?function(i){for(var l=[];i;)e(l,r(i)),i=t(i);return l}:n;return ss=a,ss}var as,pd;function Fg(){if(pd)return as;pd=1;var e=Nt(),t=fd();function r(n,s){return e(n,t(n),s)}return as=r,as}var os,hd;function md(){if(hd)return os;hd=1;var e=rs(),t=Ne();function r(n,s,a){var i=s(n);return t(n)?i:e(i,a(n))}return os=r,os}var is,gd;function yd(){if(gd)return is;gd=1;var e=md(),t=Zn(),r=Ze();function n(s){return e(s,r,t)}return is=n,is}var ls,xd;function Bg(){if(xd)return ls;xd=1;var e=md(),t=fd(),r=at();function n(s){return e(s,r,t)}return ls=n,ls}var cs,vd;function zg(){if(vd)return cs;vd=1;var e=st(),t=ze(),r=e(t,"DataView");return cs=r,cs}var ds,bd;function Hg(){if(bd)return ds;bd=1;var e=st(),t=ze(),r=e(t,"Promise");return ds=r,ds}var us,kd;function Sd(){if(kd)return us;kd=1;var e=st(),t=ze(),r=e(t,"Set");return us=r,us}var fs,_d;function Jg(){if(_d)return fs;_d=1;var e=st(),t=ze(),r=e(t,"WeakMap");return fs=r,fs}var ps,wd;function pt(){if(wd)return ps;wd=1;var e=zg(),t=Xr(),r=Hg(),n=Sd(),s=Jg(),a=nt(),i=Ql(),l="[object Map]",c="[object Object]",d="[object Promise]",u="[object Set]",f="[object WeakMap]",h="[object DataView]",p=i(e),m=i(t),g=i(r),x=i(n),v=i(s),y=a;return(e&&y(new e(new ArrayBuffer(1)))!=h||t&&y(new t)!=l||r&&y(r.resolve())!=d||n&&y(new n)!=u||s&&y(new s)!=f)&&(y=function(b){var k=a(b),_=k==c?b.constructor:void 0,w=_?i(_):"";if(w)switch(w){case p:return h;case m:return l;case g:return d;case x:return u;case v:return f}return k}),ps=y,ps}var hs,Td;function Ug(){if(Td)return hs;Td=1;var e=Object.prototype,t=e.hasOwnProperty;function r(n){var s=n.length,a=new n.constructor(s);return s&&typeof n[0]=="string"&&t.call(n,"index")&&(a.index=n.index,a.input=n.input),a}return hs=r,hs}var ms,Ed;function Nd(){if(Ed)return ms;Ed=1;var e=ze(),t=e.Uint8Array;return ms=t,ms}var gs,jd;function ys(){if(jd)return gs;jd=1;var e=Nd();function t(r){var n=new r.constructor(r.byteLength);return new e(n).set(new e(r)),n}return gs=t,gs}var xs,Cd;function Kg(){if(Cd)return xs;Cd=1;var e=ys();function t(r,n){var s=n?e(r.buffer):r.buffer;return new r.constructor(s,r.byteOffset,r.byteLength)}return xs=t,xs}var vs,Id;function Gg(){if(Id)return vs;Id=1;var e=/\w*$/;function t(r){var n=new r.constructor(r.source,e.exec(r));return n.lastIndex=r.lastIndex,n}return vs=t,vs}var bs,Rd;function Vg(){if(Rd)return bs;Rd=1;var e=ut(),t=e?e.prototype:void 0,r=t?t.valueOf:void 0;function n(s){return r?Object(r.call(s)):{}}return bs=n,bs}var ks,Od;function Pd(){if(Od)return ks;Od=1;var e=ys();function t(r,n){var s=n?e(r.buffer):r.buffer;return new r.constructor(s,r.byteOffset,r.length)}return ks=t,ks}var Ss,Ad;function Yg(){if(Ad)return Ss;Ad=1;var e=ys(),t=Kg(),r=Gg(),n=Vg(),s=Pd(),a="[object Boolean]",i="[object Date]",l="[object Map]",c="[object Number]",d="[object RegExp]",u="[object Set]",f="[object String]",h="[object Symbol]",p="[object ArrayBuffer]",m="[object DataView]",g="[object Float32Array]",x="[object Float64Array]",v="[object Int8Array]",y="[object Int16Array]",b="[object Int32Array]",k="[object Uint8Array]",_="[object Uint8ClampedArray]",w="[object Uint16Array]",T="[object Uint32Array]";function O(D,N,S){var R=D.constructor;switch(N){case p:return e(D);case a:case i:return new R(+D);case m:return t(D,S);case g:case x:case v:case y:case b:case k:case _:case w:case T:return s(D,S);case l:return new R;case c:case f:return new R(D);case d:return r(D);case u:return new R;case h:return n(D)}}return Ss=O,Ss}var _s,Ld;function Dd(){if(Ld)return _s;Ld=1;var e=qe(),t=Object.create,r=(function(){function n(){}return function(s){if(!e(s))return{};if(t)return t(s);n.prototype=s;var a=new n;return n.prototype=void 0,a}})();return _s=r,_s}var ws,Md;function qd(){if(Md)return ws;Md=1;var e=Dd(),t=er(),r=Zt();function n(s){return typeof s.constructor=="function"&&!r(s)?e(t(s)):{}}return ws=n,ws}var Ts,$d;function Xg(){if($d)return Ts;$d=1;var e=pt(),t=Ke(),r="[object Map]";function n(s){return t(s)&&e(s)==r}return Ts=n,Ts}var Es,Wd;function Qg(){if(Wd)return Es;Wd=1;var e=Xg(),t=Qt(),r=An(),n=r&&r.isMap,s=n?t(n):e;return Es=s,Es}var Ns,Fd;function Zg(){if(Fd)return Ns;Fd=1;var e=pt(),t=Ke(),r="[object Set]";function n(s){return t(s)&&e(s)==r}return Ns=n,Ns}var js,Bd;function ey(){if(Bd)return js;Bd=1;var e=Zg(),t=Qt(),r=An(),n=r&&r.isSet,s=n?t(n):e;return js=s,js}var Cs,zd;function Hd(){if(zd)return Cs;zd=1;var e=Gt(),t=xn(),r=Yt(),n=Dg(),s=$g(),a=ed(),i=rd(),l=Wg(),c=Fg(),d=yd(),u=Bg(),f=pt(),h=Ug(),p=Yg(),m=qd(),g=Ne(),x=ft(),v=Qg(),y=qe(),b=ey(),k=Ze(),_=at(),w=1,T=2,O=4,D="[object Arguments]",N="[object Array]",S="[object Boolean]",R="[object Date]",j="[object Error]",E="[object Function]",q="[object GeneratorFunction]",$="[object Map]",J="[object Number]",V="[object Object]",A="[object RegExp]",B="[object Set]",P="[object String]",U="[object Symbol]",se="[object WeakMap]",L="[object ArrayBuffer]",F="[object DataView]",z="[object Float32Array]",H="[object Float64Array]",Y="[object Int8Array]",ie="[object Int16Array]",fe="[object Int32Array]",ve="[object Uint8Array]",be="[object Uint8ClampedArray]",W="[object Uint16Array]",ke="[object Uint32Array]",ee={};ee[D]=ee[N]=ee[L]=ee[F]=ee[S]=ee[R]=ee[z]=ee[H]=ee[Y]=ee[ie]=ee[fe]=ee[$]=ee[J]=ee[V]=ee[A]=ee[B]=ee[P]=ee[U]=ee[ve]=ee[be]=ee[W]=ee[ke]=!0,ee[j]=ee[E]=ee[se]=!1;function me(ne,_e,ce,he,Fe,Se){var ge,Qe=_e&w,Ee=_e&T,rt=_e&O;if(ce&&(ge=Fe?ce(ne,he,Fe,Se):ce(ne)),ge!==void 0)return ge;if(!y(ne))return ne;var Q=g(ne);if(Q){if(ge=h(ne),!Qe)return i(ne,ge)}else{var X=f(ne),te=X==E||X==q;if(x(ne))return a(ne,Qe);if(X==V||X==D||te&&!Fe){if(ge=Ee||te?{}:m(ne),!Qe)return Ee?c(ne,s(ge,ne)):l(ne,n(ge,ne))}else{if(!ee[X])return Fe?ne:{};ge=p(ne,X,Qe)}}Se||(Se=new e);var de=Se.get(ne);if(de)return de;Se.set(ne,ge),b(ne)?ne.forEach(function(C){ge.add(me(C,_e,ce,C,ne,Se))}):v(ne)&&ne.forEach(function(C,K){ge.set(K,me(C,_e,ce,K,ne,Se))});var G=rt?Ee?u:d:Ee?_:k,le=Q?void 0:G(ne);return t(le||ne,function(C,K){le&&(K=C,C=ne[K]),r(ge,K,me(C,_e,ce,K,ne,Se))}),ge}return Cs=me,Cs}var Is,Jd;function ty(){if(Jd)return Is;Jd=1;var e=Hd(),t=4;function r(n){return e(n,t)}return Is=r,Is}var Rs,Ud;function Os(){if(Ud)return Rs;Ud=1;function e(t){return function(){return t}}return Rs=e,Rs}var Ps,Kd;function ry(){if(Kd)return Ps;Kd=1;function e(t){return function(r,n,s){for(var a=-1,i=Object(r),l=s(r),c=l.length;c--;){var d=l[t?c:++a];if(n(i[d],d,i)===!1)break}return r}}return Ps=e,Ps}var As,Gd;function Ls(){if(Gd)return As;Gd=1;var e=ry(),t=e();return As=t,As}var Ds,Vd;function Ms(){if(Vd)return Ds;Vd=1;var e=Ls(),t=Ze();function r(n,s){return n&&e(n,s,t)}return Ds=r,Ds}var qs,Yd;function ny(){if(Yd)return qs;Yd=1;var e=Ve();function t(r,n){return function(s,a){if(s==null)return s;if(!e(s))return r(s,a);for(var i=s.length,l=n?i:-1,c=Object(s);(n?l--:++l<i)&&a(c[l],l,c)!==!1;);return s}}return qs=t,qs}var $s,Xd;function tr(){if(Xd)return $s;Xd=1;var e=Ms(),t=ny(),r=t(e);return $s=r,$s}var Ws,Qd;function ot(){if(Qd)return Ws;Qd=1;function e(t){return t}return Ws=e,Ws}var Fs,Zd;function eu(){if(Zd)return Fs;Zd=1;var e=ot();function t(r){return typeof r=="function"?r:e}return Fs=t,Fs}var Bs,tu;function ru(){if(tu)return Bs;tu=1;var e=xn(),t=tr(),r=eu(),n=Ne();function s(a,i){var l=n(a)?e:t;return l(a,r(i))}return Bs=s,Bs}var zs,nu;function su(){return nu||(nu=1,zs=ru()),zs}var Hs,au;function sy(){if(au)return Hs;au=1;var e=tr();function t(r,n){var s=[];return e(r,function(a,i,l){n(a,i,l)&&s.push(a)}),s}return Hs=t,Hs}var Js,ou;function ay(){if(ou)return Js;ou=1;var e="__lodash_hash_undefined__";function t(r){return this.__data__.set(r,e),this}return Js=t,Js}var Us,iu;function oy(){if(iu)return Us;iu=1;function e(t){return this.__data__.has(t)}return Us=e,Us}var Ks,lu;function cu(){if(lu)return Ks;lu=1;var e=hn(),t=ay(),r=oy();function n(s){var a=-1,i=s==null?0:s.length;for(this.__data__=new e;++a<i;)this.add(s[a])}return n.prototype.add=n.prototype.push=t,n.prototype.has=r,Ks=n,Ks}var Gs,du;function iy(){if(du)return Gs;du=1;function e(t,r){for(var n=-1,s=t==null?0:t.length;++n<s;)if(r(t[n],n,t))return!0;return!1}return Gs=e,Gs}var Vs,uu;function fu(){if(uu)return Vs;uu=1;function e(t,r){return t.has(r)}return Vs=e,Vs}var Ys,pu;function hu(){if(pu)return Ys;pu=1;var e=cu(),t=iy(),r=fu(),n=1,s=2;function a(i,l,c,d,u,f){var h=c&n,p=i.length,m=l.length;if(p!=m&&!(h&&m>p))return!1;var g=f.get(i),x=f.get(l);if(g&&x)return g==l&&x==i;var v=-1,y=!0,b=c&s?new e:void 0;for(f.set(i,l),f.set(l,i);++v<p;){var k=i[v],_=l[v];if(d)var w=h?d(_,k,v,l,i,f):d(k,_,v,i,l,f);if(w!==void 0){if(w)continue;y=!1;break}if(b){if(!t(l,function(T,O){if(!r(b,O)&&(k===T||u(k,T,c,d,f)))return b.push(O)})){y=!1;break}}else if(!(k===_||u(k,_,c,d,f))){y=!1;break}}return f.delete(i),f.delete(l),y}return Ys=a,Ys}var Xs,mu;function ly(){if(mu)return Xs;mu=1;function e(t){var r=-1,n=Array(t.size);return t.forEach(function(s,a){n[++r]=[a,s]}),n}return Xs=e,Xs}var Qs,gu;function Zs(){if(gu)return Qs;gu=1;function e(t){var r=-1,n=Array(t.size);return t.forEach(function(s){n[++r]=s}),n}return Qs=e,Qs}var ea,yu;function cy(){if(yu)return ea;yu=1;var e=ut(),t=Nd(),r=dt(),n=hu(),s=ly(),a=Zs(),i=1,l=2,c="[object Boolean]",d="[object Date]",u="[object Error]",f="[object Map]",h="[object Number]",p="[object RegExp]",m="[object Set]",g="[object String]",x="[object Symbol]",v="[object ArrayBuffer]",y="[object DataView]",b=e?e.prototype:void 0,k=b?b.valueOf:void 0;function _(w,T,O,D,N,S,R){switch(O){case y:if(w.byteLength!=T.byteLength||w.byteOffset!=T.byteOffset)return!1;w=w.buffer,T=T.buffer;case v:return!(w.byteLength!=T.byteLength||!S(new t(w),new t(T)));case c:case d:case h:return r(+w,+T);case u:return w.name==T.name&&w.message==T.message;case p:case g:return w==T+"";case f:var j=s;case m:var E=D&i;if(j||(j=a),w.size!=T.size&&!E)return!1;var q=R.get(w);if(q)return q==T;D|=l,R.set(w,T);var $=n(j(w),j(T),D,N,S,R);return R.delete(w),$;case x:if(k)return k.call(w)==k.call(T)}return!1}return ea=_,ea}var ta,xu;function dy(){if(xu)return ta;xu=1;var e=yd(),t=1,r=Object.prototype,n=r.hasOwnProperty;function s(a,i,l,c,d,u){var f=l&t,h=e(a),p=h.length,m=e(i),g=m.length;if(p!=g&&!f)return!1;for(var x=p;x--;){var v=h[x];if(!(f?v in i:n.call(i,v)))return!1}var y=u.get(a),b=u.get(i);if(y&&b)return y==i&&b==a;var k=!0;u.set(a,i),u.set(i,a);for(var _=f;++x<p;){v=h[x];var w=a[v],T=i[v];if(c)var O=f?c(T,w,v,i,a,u):c(w,T,v,a,i,u);if(!(O===void 0?w===T||d(w,T,l,c,u):O)){k=!1;break}_||(_=v=="constructor")}if(k&&!_){var D=a.constructor,N=i.constructor;D!=N&&"constructor"in a&&"constructor"in i&&!(typeof D=="function"&&D instanceof D&&typeof N=="function"&&N instanceof N)&&(k=!1)}return u.delete(a),u.delete(i),k}return ta=s,ta}var ra,vu;function uy(){if(vu)return ra;vu=1;var e=Gt(),t=hu(),r=cy(),n=dy(),s=pt(),a=Ne(),i=ft(),l=Rt(),c=1,d="[object Arguments]",u="[object Array]",f="[object Object]",h=Object.prototype,p=h.hasOwnProperty;function m(g,x,v,y,b,k){var _=a(g),w=a(x),T=_?u:s(g),O=w?u:s(x);T=T==d?f:T,O=O==d?f:O;var D=T==f,N=O==f,S=T==O;if(S&&i(g)){if(!i(x))return!1;_=!0,D=!1}if(S&&!D)return k||(k=new e),_||l(g)?t(g,x,v,y,b,k):r(g,x,T,v,y,b,k);if(!(v&c)){var R=D&&p.call(g,"__wrapped__"),j=N&&p.call(x,"__wrapped__");if(R||j){var E=R?g.value():g,q=j?x.value():x;return k||(k=new e),b(E,q,v,y,k)}}return S?(k||(k=new e),n(g,x,v,y,b,k)):!1}return ra=m,ra}var na,bu;function ku(){if(bu)return na;bu=1;var e=uy(),t=Ke();function r(n,s,a,i,l){return n===s?!0:n==null||s==null||!t(n)&&!t(s)?n!==n&&s!==s:e(n,s,a,i,r,l)}return na=r,na}var sa,Su;function fy(){if(Su)return sa;Su=1;var e=Gt(),t=ku(),r=1,n=2;function s(a,i,l,c){var d=l.length,u=d,f=!c;if(a==null)return!u;for(a=Object(a);d--;){var h=l[d];if(f&&h[2]?h[1]!==a[h[0]]:!(h[0]in a))return!1}for(;++d<u;){h=l[d];var p=h[0],m=a[p],g=h[1];if(f&&h[2]){if(m===void 0&&!(p in a))return!1}else{var x=new e;if(c)var v=c(m,g,p,a,i,x);if(!(v===void 0?t(g,m,r|n,c,x):v))return!1}}return!0}return sa=s,sa}var aa,_u;function wu(){if(_u)return aa;_u=1;var e=qe();function t(r){return r===r&&!e(r)}return aa=t,aa}var oa,Tu;function py(){if(Tu)return oa;Tu=1;var e=wu(),t=Ze();function r(n){for(var s=t(n),a=s.length;a--;){var i=s[a],l=n[i];s[a]=[i,l,e(l)]}return s}return oa=r,oa}var ia,Eu;function Nu(){if(Eu)return ia;Eu=1;function e(t,r){return function(n){return n==null?!1:n[t]===r&&(r!==void 0||t in Object(n))}}return ia=e,ia}var la,ju;function hy(){if(ju)return la;ju=1;var e=fy(),t=py(),r=Nu();function n(s){var a=t(s);return a.length==1&&a[0][2]?r(a[0][0],a[0][1]):function(i){return i===s||e(i,s,a)}}return la=n,la}var ca,Cu;function ht(){if(Cu)return ca;Cu=1;var e=nt(),t=Ke(),r="[object Symbol]";function n(s){return typeof s=="symbol"||t(s)&&e(s)==r}return ca=n,ca}var da,Iu;function ua(){if(Iu)return da;Iu=1;var e=Ne(),t=ht(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;function s(a,i){if(e(a))return!1;var l=typeof a;return l=="number"||l=="symbol"||l=="boolean"||a==null||t(a)?!0:n.test(a)||!r.test(a)||i!=null&&a in Object(i)}return da=s,da}var fa,Ru;function my(){if(Ru)return fa;Ru=1;var e=hn(),t="Expected a function";function r(n,s){if(typeof n!="function"||s!=null&&typeof s!="function")throw new TypeError(t);var a=function(){var i=arguments,l=s?s.apply(this,i):i[0],c=a.cache;if(c.has(l))return c.get(l);var d=n.apply(this,i);return a.cache=c.set(l,d)||c,d};return a.cache=new(r.Cache||e),a}return r.Cache=e,fa=r,fa}var pa,Ou;function gy(){if(Ou)return pa;Ou=1;var e=my(),t=500;function r(n){var s=e(n,function(i){return a.size===t&&a.clear(),i}),a=s.cache;return s}return pa=r,pa}var ha,Pu;function yy(){if(Pu)return ha;Pu=1;var e=gy(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,n=e(function(s){var a=[];return s.charCodeAt(0)===46&&a.push(""),s.replace(t,function(i,l,c,d){a.push(c?d.replace(r,"$1"):l||i)}),a});return ha=n,ha}var ma,Au;function rr(){if(Au)return ma;Au=1;function e(t,r){for(var n=-1,s=t==null?0:t.length,a=Array(s);++n<s;)a[n]=r(t[n],n,t);return a}return ma=e,ma}var ga,Lu;function xy(){if(Lu)return ga;Lu=1;var e=ut(),t=rr(),r=Ne(),n=ht(),s=e?e.prototype:void 0,a=s?s.toString:void 0;function i(l){if(typeof l=="string")return l;if(r(l))return t(l,i)+"";if(n(l))return a?a.call(l):"";var c=l+"";return c=="0"&&1/l==-1/0?"-0":c}return ga=i,ga}var ya,Du;function Mu(){if(Du)return ya;Du=1;var e=xy();function t(r){return r==null?"":e(r)}return ya=t,ya}var xa,qu;function nr(){if(qu)return xa;qu=1;var e=Ne(),t=ua(),r=yy(),n=Mu();function s(a,i){return e(a)?a:t(a,i)?[a]:r(n(a))}return xa=s,xa}var va,$u;function Pt(){if($u)return va;$u=1;var e=ht();function t(r){if(typeof r=="string"||e(r))return r;var n=r+"";return n=="0"&&1/r==-1/0?"-0":n}return va=t,va}var ba,Wu;function sr(){if(Wu)return ba;Wu=1;var e=nr(),t=Pt();function r(n,s){s=e(s,n);for(var a=0,i=s.length;n!=null&&a<i;)n=n[t(s[a++])];return a&&a==i?n:void 0}return ba=r,ba}var ka,Fu;function vy(){if(Fu)return ka;Fu=1;var e=sr();function t(r,n,s){var a=r==null?void 0:e(r,n);return a===void 0?s:a}return ka=t,ka}var Sa,Bu;function by(){if(Bu)return Sa;Bu=1;function e(t,r){return t!=null&&r in Object(t)}return Sa=e,Sa}var _a,zu;function Hu(){if(zu)return _a;zu=1;var e=nr(),t=jt(),r=Ne(),n=Xt(),s=Rn(),a=Pt();function i(l,c,d){c=e(c,l);for(var u=-1,f=c.length,h=!1;++u<f;){var p=a(c[u]);if(!(h=l!=null&&d(l,p)))break;l=l[p]}return h||++u!=f?h:(f=l==null?0:l.length,!!f&&s(f)&&n(p,f)&&(r(l)||t(l)))}return _a=i,_a}var wa,Ju;function Uu(){if(Ju)return wa;Ju=1;var e=by(),t=Hu();function r(n,s){return n!=null&&t(n,s,e)}return wa=r,wa}var Ta,Ku;function ky(){if(Ku)return Ta;Ku=1;var e=ku(),t=vy(),r=Uu(),n=ua(),s=wu(),a=Nu(),i=Pt(),l=1,c=2;function d(u,f){return n(u)&&s(f)?a(i(u),f):function(h){var p=t(h,u);return p===void 0&&p===f?r(h,u):e(f,p,l|c)}}return Ta=d,Ta}var Ea,Gu;function Vu(){if(Gu)return Ea;Gu=1;function e(t){return function(r){return r?.[t]}}return Ea=e,Ea}var Na,Yu;function Sy(){if(Yu)return Na;Yu=1;var e=sr();function t(r){return function(n){return e(n,r)}}return Na=t,Na}var ja,Xu;function _y(){if(Xu)return ja;Xu=1;var e=Vu(),t=Sy(),r=ua(),n=Pt();function s(a){return r(a)?e(n(a)):t(a)}return ja=s,ja}var Ca,Qu;function Ye(){if(Qu)return Ca;Qu=1;var e=hy(),t=ky(),r=ot(),n=Ne(),s=_y();function a(i){return typeof i=="function"?i:i==null?r:typeof i=="object"?n(i)?t(i[0],i[1]):e(i):s(i)}return Ca=a,Ca}var Ia,Zu;function ef(){if(Zu)return Ia;Zu=1;var e=sd(),t=sy(),r=Ye(),n=Ne();function s(a,i){var l=n(a)?e:t;return l(a,r(i,3))}return Ia=s,Ia}var Ra,tf;function wy(){if(tf)return Ra;tf=1;var e=Object.prototype,t=e.hasOwnProperty;function r(n,s){return n!=null&&t.call(n,s)}return Ra=r,Ra}var Oa,rf;function nf(){if(rf)return Oa;rf=1;var e=wy(),t=Hu();function r(n,s){return n!=null&&t(n,s,e)}return Oa=r,Oa}var Pa,sf;function Ty(){if(sf)return Pa;sf=1;var e=Fn(),t=pt(),r=jt(),n=Ne(),s=Ve(),a=ft(),i=Zt(),l=Rt(),c="[object Map]",d="[object Set]",u=Object.prototype,f=u.hasOwnProperty;function h(p){if(p==null)return!0;if(s(p)&&(n(p)||typeof p=="string"||typeof p.splice=="function"||a(p)||l(p)||r(p)))return!p.length;var m=t(p);if(m==c||m==d)return!p.size;if(i(p))return!e(p).length;for(var g in p)if(f.call(p,g))return!1;return!0}return Pa=h,Pa}var Aa,af;function of(){if(af)return Aa;af=1;function e(t){return t===void 0}return Aa=e,Aa}var La,lf;function cf(){if(lf)return La;lf=1;var e=tr(),t=Ve();function r(n,s){var a=-1,i=t(n)?Array(n.length):[];return e(n,function(l,c,d){i[++a]=s(l,c,d)}),i}return La=r,La}var Da,df;function uf(){if(df)return Da;df=1;var e=rr(),t=Ye(),r=cf(),n=Ne();function s(a,i){var l=n(a)?e:r;return l(a,t(i,3))}return Da=s,Da}var Ma,ff;function Ey(){if(ff)return Ma;ff=1;function e(t,r,n,s){var a=-1,i=t==null?0:t.length;for(s&&i&&(n=t[++a]);++a<i;)n=r(n,t[a],a,t);return n}return Ma=e,Ma}var qa,pf;function Ny(){if(pf)return qa;pf=1;function e(t,r,n,s,a){return a(t,function(i,l,c){n=s?(s=!1,i):r(n,i,l,c)}),n}return qa=e,qa}var $a,hf;function mf(){if(hf)return $a;hf=1;var e=Ey(),t=tr(),r=Ye(),n=Ny(),s=Ne();function a(i,l,c){var d=s(i)?e:n,u=arguments.length<3;return d(i,r(l,4),c,u,t)}return $a=a,$a}var Wa,gf;function jy(){if(gf)return Wa;gf=1;var e=nt(),t=Ne(),r=Ke(),n="[object String]";function s(a){return typeof a=="string"||!t(a)&&r(a)&&e(a)==n}return Wa=s,Wa}var Fa,yf;function Cy(){if(yf)return Fa;yf=1;var e=Vu(),t=e("length");return Fa=t,Fa}var Ba,xf;function Iy(){if(xf)return Ba;xf=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",s=t+r+n,a="\\ufe0e\\ufe0f",i="\\u200d",l=RegExp("["+i+e+s+a+"]");function c(d){return l.test(d)}return Ba=c,Ba}var za,vf;function Ry(){if(vf)return za;vf=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",s=t+r+n,a="\\ufe0e\\ufe0f",i="["+e+"]",l="["+s+"]",c="\\ud83c[\\udffb-\\udfff]",d="(?:"+l+"|"+c+")",u="[^"+e+"]",f="(?:\\ud83c[\\udde6-\\uddff]){2}",h="[\\ud800-\\udbff][\\udc00-\\udfff]",p="\\u200d",m=d+"?",g="["+a+"]?",x="(?:"+p+"(?:"+[u,f,h].join("|")+")"+g+m+")*",v=g+m+x,y="(?:"+[u+l+"?",l,f,h,i].join("|")+")",b=RegExp(c+"(?="+c+")|"+y+v,"g");function k(_){for(var w=b.lastIndex=0;b.test(_);)++w;return w}return za=k,za}var Ha,bf;function Oy(){if(bf)return Ha;bf=1;var e=Cy(),t=Iy(),r=Ry();function n(s){return t(s)?r(s):e(s)}return Ha=n,Ha}var Ja,kf;function Py(){if(kf)return Ja;kf=1;var e=Fn(),t=pt(),r=Ve(),n=jy(),s=Oy(),a="[object Map]",i="[object Set]";function l(c){if(c==null)return 0;if(r(c))return n(c)?s(c):c.length;var d=t(c);return d==a||d==i?c.size:e(c).length}return Ja=l,Ja}var Ua,Sf;function Ay(){if(Sf)return Ua;Sf=1;var e=xn(),t=Dd(),r=Ms(),n=Ye(),s=er(),a=Ne(),i=ft(),l=Et(),c=qe(),d=Rt();function u(f,h,p){var m=a(f),g=m||i(f)||d(f);if(h=n(h,4),p==null){var x=f&&f.constructor;g?p=m?new x:[]:c(f)?p=l(x)?t(s(f)):{}:p={}}return(g?e:r)(f,function(v,y,b){return h(p,v,y,b)}),p}return Ua=u,Ua}var Ka,_f;function Ly(){if(_f)return Ka;_f=1;var e=ut(),t=jt(),r=Ne(),n=e?e.isConcatSpreadable:void 0;function s(a){return r(a)||t(a)||!!(n&&a&&a[n])}return Ka=s,Ka}var Ga,wf;function Va(){if(wf)return Ga;wf=1;var e=rs(),t=Ly();function r(n,s,a,i,l){var c=-1,d=n.length;for(a||(a=t),l||(l=[]);++c<d;){var u=n[c];s>0&&a(u)?s>1?r(u,s-1,a,i,l):e(l,u):i||(l[l.length]=u)}return l}return Ga=r,Ga}var Ya,Tf;function Dy(){if(Tf)return Ya;Tf=1;function e(t,r,n){switch(n.length){case 0:return t.call(r);case 1:return t.call(r,n[0]);case 2:return t.call(r,n[0],n[1]);case 3:return t.call(r,n[0],n[1],n[2])}return t.apply(r,n)}return Ya=e,Ya}var Xa,Ef;function Nf(){if(Ef)return Xa;Ef=1;var e=Dy(),t=Math.max;function r(n,s,a){return s=t(s===void 0?n.length-1:s,0),function(){for(var i=arguments,l=-1,c=t(i.length-s,0),d=Array(c);++l<c;)d[l]=i[s+l];l=-1;for(var u=Array(s+1);++l<s;)u[l]=i[l];return u[s]=a(d),e(n,this,u)}}return Xa=r,Xa}var Qa,jf;function My(){if(jf)return Qa;jf=1;var e=Os(),t=Sc(),r=ot(),n=t?function(s,a){return t(s,"toString",{configurable:!0,enumerable:!1,value:e(a),writable:!0})}:r;return Qa=n,Qa}var Za,Cf;function qy(){if(Cf)return Za;Cf=1;var e=800,t=16,r=Date.now;function n(s){var a=0,i=0;return function(){var l=r(),c=t-(l-i);if(i=l,c>0){if(++a>=e)return arguments[0]}else a=0;return s.apply(void 0,arguments)}}return Za=n,Za}var eo,If;function Rf(){if(If)return eo;If=1;var e=My(),t=qy(),r=t(e);return eo=r,eo}var to,Of;function ar(){if(Of)return to;Of=1;var e=ot(),t=Nf(),r=Rf();function n(s,a){return r(t(s,a,e),s+"")}return to=n,to}var ro,Pf;function Af(){if(Pf)return ro;Pf=1;function e(t,r,n,s){for(var a=t.length,i=n+(s?1:-1);s?i--:++i<a;)if(r(t[i],i,t))return i;return-1}return ro=e,ro}var no,Lf;function $y(){if(Lf)return no;Lf=1;function e(t){return t!==t}return no=e,no}var so,Df;function Wy(){if(Df)return so;Df=1;function e(t,r,n){for(var s=n-1,a=t.length;++s<a;)if(t[s]===r)return s;return-1}return so=e,so}var ao,Mf;function Fy(){if(Mf)return ao;Mf=1;var e=Af(),t=$y(),r=Wy();function n(s,a,i){return a===a?r(s,a,i):e(s,t,i)}return ao=n,ao}var oo,qf;function By(){if(qf)return oo;qf=1;var e=Fy();function t(r,n){var s=r==null?0:r.length;return!!s&&e(r,n,0)>-1}return oo=t,oo}var io,$f;function zy(){if($f)return io;$f=1;function e(t,r,n){for(var s=-1,a=t==null?0:t.length;++s<a;)if(n(r,t[s]))return!0;return!1}return io=e,io}var lo,Wf;function Hy(){if(Wf)return lo;Wf=1;function e(){}return lo=e,lo}var co,Ff;function Jy(){if(Ff)return co;Ff=1;var e=Sd(),t=Hy(),r=Zs(),n=1/0,s=e&&1/r(new e([,-0]))[1]==n?function(a){return new e(a)}:t;return co=s,co}var uo,Bf;function Uy(){if(Bf)return uo;Bf=1;var e=cu(),t=By(),r=zy(),n=fu(),s=Jy(),a=Zs(),i=200;function l(c,d,u){var f=-1,h=t,p=c.length,m=!0,g=[],x=g;if(u)m=!1,h=r;else if(p>=i){var v=d?null:s(c);if(v)return a(v);m=!1,h=n,x=new e}else x=d?[]:g;e:for(;++f<p;){var y=c[f],b=d?d(y):y;if(y=u||y!==0?y:0,m&&b===b){for(var k=x.length;k--;)if(x[k]===b)continue e;d&&x.push(b),g.push(y)}else h(x,b,u)||(x!==g&&x.push(b),g.push(y))}return g}return uo=l,uo}var fo,zf;function Hf(){if(zf)return fo;zf=1;var e=Ve(),t=Ke();function r(n){return t(n)&&e(n)}return fo=r,fo}var po,Jf;function Ky(){if(Jf)return po;Jf=1;var e=Va(),t=ar(),r=Uy(),n=Hf(),s=t(function(a){return r(e(a,1,n,!0))});return po=s,po}var ho,Uf;function Gy(){if(Uf)return ho;Uf=1;var e=rr();function t(r,n){return e(n,function(s){return r[s]})}return ho=t,ho}var mo,Kf;function Gf(){if(Kf)return mo;Kf=1;var e=Gy(),t=Ze();function r(n){return n==null?[]:e(n,t(n))}return mo=r,mo}var go,Vf;function $e(){if(Vf)return go;Vf=1;var e;if(typeof _r=="function")try{e={clone:ty(),constant:Os(),each:su(),filter:ef(),has:nf(),isArray:Ne(),isEmpty:Ty(),isFunction:Et(),isUndefined:of(),keys:Ze(),map:uf(),reduce:mf(),size:Py(),transform:Ay(),union:Ky(),values:Gf()}}catch{}return e||(e=window._),go=e,go}var yo,Yf;function xo(){if(Yf)return yo;Yf=1;var e=$e();yo=s;var t="\0",r="\0",n="";function s(u){this._isDirected=e.has(u,"directed")?u.directed:!0,this._isMultigraph=e.has(u,"multigraph")?u.multigraph:!1,this._isCompound=e.has(u,"compound")?u.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[r]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}s.prototype._nodeCount=0,s.prototype._edgeCount=0,s.prototype.isDirected=function(){return this._isDirected},s.prototype.isMultigraph=function(){return this._isMultigraph},s.prototype.isCompound=function(){return this._isCompound},s.prototype.setGraph=function(u){return this._label=u,this},s.prototype.graph=function(){return this._label},s.prototype.setDefaultNodeLabel=function(u){return e.isFunction(u)||(u=e.constant(u)),this._defaultNodeLabelFn=u,this},s.prototype.nodeCount=function(){return this._nodeCount},s.prototype.nodes=function(){return e.keys(this._nodes)},s.prototype.sources=function(){var u=this;return e.filter(this.nodes(),function(f){return e.isEmpty(u._in[f])})},s.prototype.sinks=function(){var u=this;return e.filter(this.nodes(),function(f){return e.isEmpty(u._out[f])})},s.prototype.setNodes=function(u,f){var h=arguments,p=this;return e.each(u,function(m){h.length>1?p.setNode(m,f):p.setNode(m)}),this},s.prototype.setNode=function(u,f){return e.has(this._nodes,u)?(arguments.length>1&&(this._nodes[u]=f),this):(this._nodes[u]=arguments.length>1?f:this._defaultNodeLabelFn(u),this._isCompound&&(this._parent[u]=r,this._children[u]={},this._children[r][u]=!0),this._in[u]={},this._preds[u]={},this._out[u]={},this._sucs[u]={},++this._nodeCount,this)},s.prototype.node=function(u){return this._nodes[u]},s.prototype.hasNode=function(u){return e.has(this._nodes,u)},s.prototype.removeNode=function(u){var f=this;if(e.has(this._nodes,u)){var h=function(p){f.removeEdge(f._edgeObjs[p])};delete this._nodes[u],this._isCompound&&(this._removeFromParentsChildList(u),delete this._parent[u],e.each(this.children(u),function(p){f.setParent(p)}),delete this._children[u]),e.each(e.keys(this._in[u]),h),delete this._in[u],delete this._preds[u],e.each(e.keys(this._out[u]),h),delete this._out[u],delete this._sucs[u],--this._nodeCount}return this},s.prototype.setParent=function(u,f){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(f))f=r;else{f+="";for(var h=f;!e.isUndefined(h);h=this.parent(h))if(h===u)throw new Error("Setting "+f+" as parent of "+u+" would create a cycle");this.setNode(f)}return this.setNode(u),this._removeFromParentsChildList(u),this._parent[u]=f,this._children[f][u]=!0,this},s.prototype._removeFromParentsChildList=function(u){delete this._children[this._parent[u]][u]},s.prototype.parent=function(u){if(this._isCompound){var f=this._parent[u];if(f!==r)return f}},s.prototype.children=function(u){if(e.isUndefined(u)&&(u=r),this._isCompound){var f=this._children[u];if(f)return e.keys(f)}else{if(u===r)return this.nodes();if(this.hasNode(u))return[]}},s.prototype.predecessors=function(u){var f=this._preds[u];if(f)return e.keys(f)},s.prototype.successors=function(u){var f=this._sucs[u];if(f)return e.keys(f)},s.prototype.neighbors=function(u){var f=this.predecessors(u);if(f)return e.union(f,this.successors(u))},s.prototype.isLeaf=function(u){var f;return this.isDirected()?f=this.successors(u):f=this.neighbors(u),f.length===0},s.prototype.filterNodes=function(u){var f=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});f.setGraph(this.graph());var h=this;e.each(this._nodes,function(g,x){u(x)&&f.setNode(x,g)}),e.each(this._edgeObjs,function(g){f.hasNode(g.v)&&f.hasNode(g.w)&&f.setEdge(g,h.edge(g))});var p={};function m(g){var x=h.parent(g);return x===void 0||f.hasNode(x)?(p[g]=x,x):x in p?p[x]:m(x)}return this._isCompound&&e.each(f.nodes(),function(g){f.setParent(g,m(g))}),f},s.prototype.setDefaultEdgeLabel=function(u){return e.isFunction(u)||(u=e.constant(u)),this._defaultEdgeLabelFn=u,this},s.prototype.edgeCount=function(){return this._edgeCount},s.prototype.edges=function(){return e.values(this._edgeObjs)},s.prototype.setPath=function(u,f){var h=this,p=arguments;return e.reduce(u,function(m,g){return p.length>1?h.setEdge(m,g,f):h.setEdge(m,g),g}),this},s.prototype.setEdge=function(){var u,f,h,p,m=!1,g=arguments[0];typeof g=="object"&&g!==null&&"v"in g?(u=g.v,f=g.w,h=g.name,arguments.length===2&&(p=arguments[1],m=!0)):(u=g,f=arguments[1],h=arguments[3],arguments.length>2&&(p=arguments[2],m=!0)),u=""+u,f=""+f,e.isUndefined(h)||(h=""+h);var x=l(this._isDirected,u,f,h);if(e.has(this._edgeLabels,x))return m&&(this._edgeLabels[x]=p),this;if(!e.isUndefined(h)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(u),this.setNode(f),this._edgeLabels[x]=m?p:this._defaultEdgeLabelFn(u,f,h);var v=c(this._isDirected,u,f,h);return u=v.v,f=v.w,Object.freeze(v),this._edgeObjs[x]=v,a(this._preds[f],u),a(this._sucs[u],f),this._in[f][x]=v,this._out[u][x]=v,this._edgeCount++,this},s.prototype.edge=function(u,f,h){var p=arguments.length===1?d(this._isDirected,arguments[0]):l(this._isDirected,u,f,h);return this._edgeLabels[p]},s.prototype.hasEdge=function(u,f,h){var p=arguments.length===1?d(this._isDirected,arguments[0]):l(this._isDirected,u,f,h);return e.has(this._edgeLabels,p)},s.prototype.removeEdge=function(u,f,h){var p=arguments.length===1?d(this._isDirected,arguments[0]):l(this._isDirected,u,f,h),m=this._edgeObjs[p];return m&&(u=m.v,f=m.w,delete this._edgeLabels[p],delete this._edgeObjs[p],i(this._preds[f],u),i(this._sucs[u],f),delete this._in[f][p],delete this._out[u][p],this._edgeCount--),this},s.prototype.inEdges=function(u,f){var h=this._in[u];if(h){var p=e.values(h);return f?e.filter(p,function(m){return m.v===f}):p}},s.prototype.outEdges=function(u,f){var h=this._out[u];if(h){var p=e.values(h);return f?e.filter(p,function(m){return m.w===f}):p}},s.prototype.nodeEdges=function(u,f){var h=this.inEdges(u,f);if(h)return h.concat(this.outEdges(u,f))};function a(u,f){u[f]?u[f]++:u[f]=1}function i(u,f){--u[f]||delete u[f]}function l(u,f,h,p){var m=""+f,g=""+h;if(!u&&m>g){var x=m;m=g,g=x}return m+n+g+n+(e.isUndefined(p)?t:p)}function c(u,f,h,p){var m=""+f,g=""+h;if(!u&&m>g){var x=m;m=g,g=x}var v={v:m,w:g};return p&&(v.name=p),v}function d(u,f){return l(u,f.v,f.w,f.name)}return yo}var vo,Xf;function Vy(){return Xf||(Xf=1,vo="2.1.8"),vo}var bo,Qf;function Yy(){return Qf||(Qf=1,bo={Graph:xo(),version:Vy()}),bo}var ko,Zf;function Xy(){if(Zf)return ko;Zf=1;var e=$e(),t=xo();ko={write:r,read:a};function r(i){var l={options:{directed:i.isDirected(),multigraph:i.isMultigraph(),compound:i.isCompound()},nodes:n(i),edges:s(i)};return e.isUndefined(i.graph())||(l.value=e.clone(i.graph())),l}function n(i){return e.map(i.nodes(),function(l){var c=i.node(l),d=i.parent(l),u={v:l};return e.isUndefined(c)||(u.value=c),e.isUndefined(d)||(u.parent=d),u})}function s(i){return e.map(i.edges(),function(l){var c=i.edge(l),d={v:l.v,w:l.w};return e.isUndefined(l.name)||(d.name=l.name),e.isUndefined(c)||(d.value=c),d})}function a(i){var l=new t(i.options).setGraph(i.value);return e.each(i.nodes,function(c){l.setNode(c.v,c.value),c.parent&&l.setParent(c.v,c.parent)}),e.each(i.edges,function(c){l.setEdge({v:c.v,w:c.w,name:c.name},c.value)}),l}return ko}var So,ep;function Qy(){if(ep)return So;ep=1;var e=$e();So=t;function t(r){var n={},s=[],a;function i(l){e.has(n,l)||(n[l]=!0,a.push(l),e.each(r.successors(l),i),e.each(r.predecessors(l),i))}return e.each(r.nodes(),function(l){a=[],i(l),a.length&&s.push(a)}),s}return So}var _o,tp;function rp(){if(tp)return _o;tp=1;var e=$e();_o=t;function t(){this._arr=[],this._keyIndices={}}return t.prototype.size=function(){return this._arr.length},t.prototype.keys=function(){return this._arr.map(function(r){return r.key})},t.prototype.has=function(r){return e.has(this._keyIndices,r)},t.prototype.priority=function(r){var n=this._keyIndices[r];if(n!==void 0)return this._arr[n].priority},t.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},t.prototype.add=function(r,n){var s=this._keyIndices;if(r=String(r),!e.has(s,r)){var a=this._arr,i=a.length;return s[r]=i,a.push({key:r,priority:n}),this._decrease(i),!0}return!1},t.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var r=this._arr.pop();return delete this._keyIndices[r.key],this._heapify(0),r.key},t.prototype.decrease=function(r,n){var s=this._keyIndices[r];if(n>this._arr[s].priority)throw new Error("New priority is greater than current priority. Key: "+r+" Old: "+this._arr[s].priority+" New: "+n);this._arr[s].priority=n,this._decrease(s)},t.prototype._heapify=function(r){var n=this._arr,s=2*r,a=s+1,i=r;s<n.length&&(i=n[s].priority<n[i].priority?s:i,a<n.length&&(i=n[a].priority<n[i].priority?a:i),i!==r&&(this._swap(r,i),this._heapify(i)))},t.prototype._decrease=function(r){for(var n=this._arr,s=n[r].priority,a;r!==0&&(a=r>>1,!(n[a].priority<s));)this._swap(r,a),r=a},t.prototype._swap=function(r,n){var s=this._arr,a=this._keyIndices,i=s[r],l=s[n];s[r]=l,s[n]=i,a[l.key]=r,a[i.key]=n},_o}var wo,np;function sp(){if(np)return wo;np=1;var e=$e(),t=rp();wo=n;var r=e.constant(1);function n(a,i,l,c){return s(a,String(i),l||r,c||function(d){return a.outEdges(d)})}function s(a,i,l,c){var d={},u=new t,f,h,p=function(m){var g=m.v!==f?m.v:m.w,x=d[g],v=l(m),y=h.distance+v;if(v<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+m+" Weight: "+v);y<x.distance&&(x.distance=y,x.predecessor=f,u.decrease(g,y))};for(a.nodes().forEach(function(m){var g=m===i?0:Number.POSITIVE_INFINITY;d[m]={distance:g},u.add(m,g)});u.size()>0&&(f=u.removeMin(),h=d[f],h.distance!==Number.POSITIVE_INFINITY);)c(f).forEach(p);return d}return wo}var To,ap;function Zy(){if(ap)return To;ap=1;var e=sp(),t=$e();To=r;function r(n,s,a){return t.transform(n.nodes(),function(i,l){i[l]=e(n,l,s,a)},{})}return To}var Eo,op;function ip(){if(op)return Eo;op=1;var e=$e();Eo=t;function t(r){var n=0,s=[],a={},i=[];function l(c){var d=a[c]={onStack:!0,lowlink:n,index:n++};if(s.push(c),r.successors(c).forEach(function(h){e.has(a,h)?a[h].onStack&&(d.lowlink=Math.min(d.lowlink,a[h].index)):(l(h),d.lowlink=Math.min(d.lowlink,a[h].lowlink))}),d.lowlink===d.index){var u=[],f;do f=s.pop(),a[f].onStack=!1,u.push(f);while(c!==f);i.push(u)}}return r.nodes().forEach(function(c){e.has(a,c)||l(c)}),i}return Eo}var No,lp;function ex(){if(lp)return No;lp=1;var e=$e(),t=ip();No=r;function r(n){return e.filter(t(n),function(s){return s.length>1||s.length===1&&n.hasEdge(s[0],s[0])})}return No}var jo,cp;function tx(){if(cp)return jo;cp=1;var e=$e();jo=r;var t=e.constant(1);function r(s,a,i){return n(s,a||t,i||function(l){return s.outEdges(l)})}function n(s,a,i){var l={},c=s.nodes();return c.forEach(function(d){l[d]={},l[d][d]={distance:0},c.forEach(function(u){d!==u&&(l[d][u]={distance:Number.POSITIVE_INFINITY})}),i(d).forEach(function(u){var f=u.v===d?u.w:u.v,h=a(u);l[d][f]={distance:h,predecessor:d}})}),c.forEach(function(d){var u=l[d];c.forEach(function(f){var h=l[f];c.forEach(function(p){var m=h[d],g=u[p],x=h[p],v=m.distance+g.distance;v<x.distance&&(x.distance=v,x.predecessor=g.predecessor)})})}),l}return jo}var Co,dp;function up(){if(dp)return Co;dp=1;var e=$e();Co=t,t.CycleException=r;function t(n){var s={},a={},i=[];function l(c){if(e.has(a,c))throw new r;e.has(s,c)||(a[c]=!0,s[c]=!0,e.each(n.predecessors(c),l),delete a[c],i.push(c))}if(e.each(n.sinks(),l),e.size(s)!==n.nodeCount())throw new r;return i}function r(){}return r.prototype=new Error,Co}var Io,fp;function rx(){if(fp)return Io;fp=1;var e=up();Io=t;function t(r){try{e(r)}catch(n){if(n instanceof e.CycleException)return!1;throw n}return!0}return Io}var Ro,pp;function hp(){if(pp)return Ro;pp=1;var e=$e();Ro=t;function t(n,s,a){e.isArray(s)||(s=[s]);var i=(n.isDirected()?n.successors:n.neighbors).bind(n),l=[],c={};return e.each(s,function(d){if(!n.hasNode(d))throw new Error("Graph does not have node: "+d);r(n,d,a==="post",c,i,l)}),l}function r(n,s,a,i,l,c){e.has(i,s)||(i[s]=!0,a||c.push(s),e.each(l(s),function(d){r(n,d,a,i,l,c)}),a&&c.push(s))}return Ro}var Oo,mp;function nx(){if(mp)return Oo;mp=1;var e=hp();Oo=t;function t(r,n){return e(r,n,"post")}return Oo}var Po,gp;function sx(){if(gp)return Po;gp=1;var e=hp();Po=t;function t(r,n){return e(r,n,"pre")}return Po}var Ao,yp;function ax(){if(yp)return Ao;yp=1;var e=$e(),t=xo(),r=rp();Ao=n;function n(s,a){var i=new t,l={},c=new r,d;function u(h){var p=h.v===d?h.w:h.v,m=c.priority(p);if(m!==void 0){var g=a(h);g<m&&(l[p]=d,c.decrease(p,g))}}if(s.nodeCount()===0)return i;e.each(s.nodes(),function(h){c.add(h,Number.POSITIVE_INFINITY),i.setNode(h)}),c.decrease(s.nodes()[0],0);for(var f=!1;c.size()>0;){if(d=c.removeMin(),e.has(l,d))i.setEdge(d,l[d]);else{if(f)throw new Error("Input graph is not connected: "+s);f=!0}s.nodeEdges(d).forEach(u)}return i}return Ao}var Lo,xp;function ox(){return xp||(xp=1,Lo={components:Qy(),dijkstra:sp(),dijkstraAll:Zy(),findCycles:ex(),floydWarshall:tx(),isAcyclic:rx(),postorder:nx(),preorder:sx(),prim:ax(),tarjan:ip(),topsort:up()}),Lo}var Do,vp;function ix(){if(vp)return Do;vp=1;var e=Yy();return Do={Graph:e.Graph,json:Xy(),alg:ox(),version:e.version},Do}var Mo,bp;function He(){if(bp)return Mo;bp=1;var e;if(typeof _r=="function")try{e=ix()}catch{}return e||(e=window.graphlib),Mo=e,Mo}var qo,kp;function lx(){if(kp)return qo;kp=1;var e=Hd(),t=1,r=4;function n(s){return e(s,t|r)}return qo=n,qo}var $o,Sp;function or(){if(Sp)return $o;Sp=1;var e=dt(),t=Ve(),r=Xt(),n=qe();function s(a,i,l){if(!n(l))return!1;var c=typeof i;return(c=="number"?t(l)&&r(i,l.length):c=="string"&&i in l)?e(l[i],a):!1}return $o=s,$o}var Wo,_p;function cx(){if(_p)return Wo;_p=1;var e=ar(),t=dt(),r=or(),n=at(),s=Object.prototype,a=s.hasOwnProperty,i=e(function(l,c){l=Object(l);var d=-1,u=c.length,f=u>2?c[2]:void 0;for(f&&r(c[0],c[1],f)&&(u=1);++d<u;)for(var h=c[d],p=n(h),m=-1,g=p.length;++m<g;){var x=p[m],v=l[x];(v===void 0||t(v,s[x])&&!a.call(l,x))&&(l[x]=h[x])}return l});return Wo=i,Wo}var Fo,wp;function dx(){if(wp)return Fo;wp=1;var e=Ye(),t=Ve(),r=Ze();function n(s){return function(a,i,l){var c=Object(a);if(!t(a)){var d=e(i,3);a=r(a),i=function(f){return d(c[f],f,c)}}var u=s(a,i,l);return u>-1?c[d?a[u]:u]:void 0}}return Fo=n,Fo}var Bo,Tp;function ux(){if(Tp)return Bo;Tp=1;var e=/\s/;function t(r){for(var n=r.length;n--&&e.test(r.charAt(n)););return n}return Bo=t,Bo}var zo,Ep;function fx(){if(Ep)return zo;Ep=1;var e=ux(),t=/^\s+/;function r(n){return n&&n.slice(0,e(n)+1).replace(t,"")}return zo=r,zo}var Ho,Np;function px(){if(Np)return Ho;Np=1;var e=fx(),t=qe(),r=ht(),n=NaN,s=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,i=/^0o[0-7]+$/i,l=parseInt;function c(d){if(typeof d=="number")return d;if(r(d))return n;if(t(d)){var u=typeof d.valueOf=="function"?d.valueOf():d;d=t(u)?u+"":u}if(typeof d!="string")return d===0?d:+d;d=e(d);var f=a.test(d);return f||i.test(d)?l(d.slice(2),f?2:8):s.test(d)?n:+d}return Ho=c,Ho}var Jo,jp;function Cp(){if(jp)return Jo;jp=1;var e=px(),t=1/0,r=17976931348623157e292;function n(s){if(!s)return s===0?s:0;if(s=e(s),s===t||s===-t){var a=s<0?-1:1;return a*r}return s===s?s:0}return Jo=n,Jo}var Uo,Ip;function hx(){if(Ip)return Uo;Ip=1;var e=Cp();function t(r){var n=e(r),s=n%1;return n===n?s?n-s:n:0}return Uo=t,Uo}var Ko,Rp;function mx(){if(Rp)return Ko;Rp=1;var e=Af(),t=Ye(),r=hx(),n=Math.max;function s(a,i,l){var c=a==null?0:a.length;if(!c)return-1;var d=l==null?0:r(l);return d<0&&(d=n(c+d,0)),e(a,t(i,3),d)}return Ko=s,Ko}var Go,Op;function gx(){if(Op)return Go;Op=1;var e=dx(),t=mx(),r=e(t);return Go=r,Go}var Vo,Pp;function Ap(){if(Pp)return Vo;Pp=1;var e=Va();function t(r){var n=r==null?0:r.length;return n?e(r,1):[]}return Vo=t,Vo}var Yo,Lp;function yx(){if(Lp)return Yo;Lp=1;var e=Ls(),t=eu(),r=at();function n(s,a){return s==null?s:e(s,t(a),r)}return Yo=n,Yo}var Xo,Dp;function xx(){if(Dp)return Xo;Dp=1;function e(t){var r=t==null?0:t.length;return r?t[r-1]:void 0}return Xo=e,Xo}var Qo,Mp;function vx(){if(Mp)return Qo;Mp=1;var e=Vt(),t=Ms(),r=Ye();function n(s,a){var i={};return a=r(a,3),t(s,function(l,c,d){e(i,c,a(l,c,d))}),i}return Qo=n,Qo}var Zo,qp;function ei(){if(qp)return Zo;qp=1;var e=ht();function t(r,n,s){for(var a=-1,i=r.length;++a<i;){var l=r[a],c=n(l);if(c!=null&&(d===void 0?c===c&&!e(c):s(c,d)))var d=c,u=l}return u}return Zo=t,Zo}var ti,$p;function bx(){if($p)return ti;$p=1;function e(t,r){return t>r}return ti=e,ti}var ri,Wp;function kx(){if(Wp)return ri;Wp=1;var e=ei(),t=bx(),r=ot();function n(s){return s&&s.length?e(s,r,t):void 0}return ri=n,ri}var ni,Fp;function Bp(){if(Fp)return ni;Fp=1;var e=Vt(),t=dt();function r(n,s,a){(a!==void 0&&!t(n[s],a)||a===void 0&&!(s in n))&&e(n,s,a)}return ni=r,ni}var si,zp;function Sx(){if(zp)return si;zp=1;var e=nt(),t=er(),r=Ke(),n="[object Object]",s=Function.prototype,a=Object.prototype,i=s.toString,l=a.hasOwnProperty,c=i.call(Object);function d(u){if(!r(u)||e(u)!=n)return!1;var f=t(u);if(f===null)return!0;var h=l.call(f,"constructor")&&f.constructor;return typeof h=="function"&&h instanceof h&&i.call(h)==c}return si=d,si}var ai,Hp;function Jp(){if(Hp)return ai;Hp=1;function e(t,r){if(!(r==="constructor"&&typeof t[r]=="function")&&r!="__proto__")return t[r]}return ai=e,ai}var oi,Up;function _x(){if(Up)return oi;Up=1;var e=Nt(),t=at();function r(n){return e(n,t(n))}return oi=r,oi}var ii,Kp;function wx(){if(Kp)return ii;Kp=1;var e=Bp(),t=ed(),r=Pd(),n=rd(),s=qd(),a=jt(),i=Ne(),l=Hf(),c=ft(),d=Et(),u=qe(),f=Sx(),h=Rt(),p=Jp(),m=_x();function g(x,v,y,b,k,_,w){var T=p(x,y),O=p(v,y),D=w.get(O);if(D){e(x,y,D);return}var N=_?_(T,O,y+"",x,v,w):void 0,S=N===void 0;if(S){var R=i(O),j=!R&&c(O),E=!R&&!j&&h(O);N=O,R||j||E?i(T)?N=T:l(T)?N=n(T):j?(S=!1,N=t(O,!0)):E?(S=!1,N=r(O,!0)):N=[]:f(O)||a(O)?(N=T,a(T)?N=m(T):(!u(T)||d(T))&&(N=s(O))):S=!1}S&&(w.set(O,N),k(N,O,b,_,w),w.delete(O)),e(x,y,N)}return ii=g,ii}var li,Gp;function Tx(){if(Gp)return li;Gp=1;var e=Gt(),t=Bp(),r=Ls(),n=wx(),s=qe(),a=at(),i=Jp();function l(c,d,u,f,h){c!==d&&r(d,function(p,m){if(h||(h=new e),s(p))n(c,d,m,u,l,f,h);else{var g=f?f(i(c,m),p,m+"",c,d,h):void 0;g===void 0&&(g=p),t(c,m,g)}},a)}return li=l,li}var ci,Vp;function Ex(){if(Vp)return ci;Vp=1;var e=ar(),t=or();function r(n){return e(function(s,a){var i=-1,l=a.length,c=l>1?a[l-1]:void 0,d=l>2?a[2]:void 0;for(c=n.length>3&&typeof c=="function"?(l--,c):void 0,d&&t(a[0],a[1],d)&&(c=l<3?void 0:c,l=1),s=Object(s);++i<l;){var u=a[i];u&&n(s,u,i,c)}return s})}return ci=r,ci}var di,Yp;function Nx(){if(Yp)return di;Yp=1;var e=Tx(),t=Ex(),r=t(function(n,s,a){e(n,s,a)});return di=r,di}var ui,Xp;function Qp(){if(Xp)return ui;Xp=1;function e(t,r){return t<r}return ui=e,ui}var fi,Zp;function jx(){if(Zp)return fi;Zp=1;var e=ei(),t=Qp(),r=ot();function n(s){return s&&s.length?e(s,r,t):void 0}return fi=n,fi}var pi,eh;function Cx(){if(eh)return pi;eh=1;var e=ei(),t=Ye(),r=Qp();function n(s,a){return s&&s.length?e(s,t(a,2),r):void 0}return pi=n,pi}var hi,th;function Ix(){if(th)return hi;th=1;var e=ze(),t=function(){return e.Date.now()};return hi=t,hi}var mi,rh;function Rx(){if(rh)return mi;rh=1;var e=Yt(),t=nr(),r=Xt(),n=qe(),s=Pt();function a(i,l,c,d){if(!n(i))return i;l=t(l,i);for(var u=-1,f=l.length,h=f-1,p=i;p!=null&&++u<f;){var m=s(l[u]),g=c;if(m==="__proto__"||m==="constructor"||m==="prototype")return i;if(u!=h){var x=p[m];g=d?d(x,m,p):void 0,g===void 0&&(g=n(x)?x:r(l[u+1])?[]:{})}e(p,m,g),p=p[m]}return i}return mi=a,mi}var gi,nh;function Ox(){if(nh)return gi;nh=1;var e=sr(),t=Rx(),r=nr();function n(s,a,i){for(var l=-1,c=a.length,d={};++l<c;){var u=a[l],f=e(s,u);i(f,u)&&t(d,r(u,s),f)}return d}return gi=n,gi}var yi,sh;function Px(){if(sh)return yi;sh=1;var e=Ox(),t=Uu();function r(n,s){return e(n,s,function(a,i){return t(n,i)})}return yi=r,yi}var xi,ah;function Ax(){if(ah)return xi;ah=1;var e=Ap(),t=Nf(),r=Rf();function n(s){return r(t(s,void 0,e),s+"")}return xi=n,xi}var vi,oh;function Lx(){if(oh)return vi;oh=1;var e=Px(),t=Ax(),r=t(function(n,s){return n==null?{}:e(n,s)});return vi=r,vi}var bi,ih;function Dx(){if(ih)return bi;ih=1;var e=Math.ceil,t=Math.max;function r(n,s,a,i){for(var l=-1,c=t(e((s-n)/(a||1)),0),d=Array(c);c--;)d[i?c:++l]=n,n+=a;return d}return bi=r,bi}var ki,lh;function Mx(){if(lh)return ki;lh=1;var e=Dx(),t=or(),r=Cp();function n(s){return function(a,i,l){return l&&typeof l!="number"&&t(a,i,l)&&(i=l=void 0),a=r(a),i===void 0?(i=a,a=0):i=r(i),l=l===void 0?a<i?1:-1:r(l),e(a,i,l,s)}}return ki=n,ki}var Si,ch;function qx(){if(ch)return Si;ch=1;var e=Mx(),t=e();return Si=t,Si}var _i,dh;function $x(){if(dh)return _i;dh=1;function e(t,r){var n=t.length;for(t.sort(r);n--;)t[n]=t[n].value;return t}return _i=e,_i}var wi,uh;function Wx(){if(uh)return wi;uh=1;var e=ht();function t(r,n){if(r!==n){var s=r!==void 0,a=r===null,i=r===r,l=e(r),c=n!==void 0,d=n===null,u=n===n,f=e(n);if(!d&&!f&&!l&&r>n||l&&c&&u&&!d&&!f||a&&c&&u||!s&&u||!i)return 1;if(!a&&!l&&!f&&r<n||f&&s&&i&&!a&&!l||d&&s&&i||!c&&i||!u)return-1}return 0}return wi=t,wi}var Ti,fh;function Fx(){if(fh)return Ti;fh=1;var e=Wx();function t(r,n,s){for(var a=-1,i=r.criteria,l=n.criteria,c=i.length,d=s.length;++a<c;){var u=e(i[a],l[a]);if(u){if(a>=d)return u;var f=s[a];return u*(f=="desc"?-1:1)}}return r.index-n.index}return Ti=t,Ti}var Ei,ph;function Bx(){if(ph)return Ei;ph=1;var e=rr(),t=sr(),r=Ye(),n=cf(),s=$x(),a=Qt(),i=Fx(),l=ot(),c=Ne();function d(u,f,h){f.length?f=e(f,function(g){return c(g)?function(x){return t(x,g.length===1?g[0]:g)}:g}):f=[l];var p=-1;f=e(f,a(r));var m=n(u,function(g,x,v){var y=e(f,function(b){return b(g)});return{criteria:y,index:++p,value:g}});return s(m,function(g,x){return i(g,x,h)})}return Ei=d,Ei}var Ni,hh;function zx(){if(hh)return Ni;hh=1;var e=Va(),t=Bx(),r=ar(),n=or(),s=r(function(a,i){if(a==null)return[];var l=i.length;return l>1&&n(a,i[0],i[1])?i=[]:l>2&&n(i[0],i[1],i[2])&&(i=[i[0]]),t(a,e(i,1),[])});return Ni=s,Ni}var ji,mh;function Hx(){if(mh)return ji;mh=1;var e=Mu(),t=0;function r(n){var s=++t;return e(n)+s}return ji=r,ji}var Ci,gh;function Jx(){if(gh)return Ci;gh=1;function e(t,r,n){for(var s=-1,a=t.length,i=r.length,l={};++s<a;){var c=s<i?r[s]:void 0;n(l,t[s],c)}return l}return Ci=e,Ci}var Ii,yh;function Ux(){if(yh)return Ii;yh=1;var e=Yt(),t=Jx();function r(n,s){return t(n||[],s||[],e)}return Ii=r,Ii}var Ri,xh;function we(){if(xh)return Ri;xh=1;var e;if(typeof _r=="function")try{e={cloneDeep:lx(),constant:Os(),defaults:cx(),each:su(),filter:ef(),find:gx(),flatten:Ap(),forEach:ru(),forIn:yx(),has:nf(),isUndefined:of(),last:xx(),map:uf(),mapValues:vx(),max:kx(),merge:Nx(),min:jx(),minBy:Cx(),now:Ix(),pick:Lx(),range:qx(),reduce:mf(),sortBy:zx(),uniqueId:Hx(),values:Gf(),zipObject:Ux()}}catch{}return e||(e=window._),Ri=e,Ri}var Oi,vh;function Kx(){if(vh)return Oi;vh=1,Oi=e;function e(){var n={};n._next=n._prev=n,this._sentinel=n}e.prototype.dequeue=function(){var n=this._sentinel,s=n._prev;if(s!==n)return t(s),s},e.prototype.enqueue=function(n){var s=this._sentinel;n._prev&&n._next&&t(n),n._next=s._next,s._next._prev=n,s._next=n,n._prev=s},e.prototype.toString=function(){for(var n=[],s=this._sentinel,a=s._prev;a!==s;)n.push(JSON.stringify(a,r)),a=a._prev;return"["+n.join(", ")+"]"};function t(n){n._prev._next=n._next,n._next._prev=n._prev,delete n._next,delete n._prev}function r(n,s){if(n!=="_next"&&n!=="_prev")return s}return Oi}var Pi,bh;function Gx(){if(bh)return Pi;bh=1;var e=we(),t=He().Graph,r=Kx();Pi=s;var n=e.constant(1);function s(d,u){if(d.nodeCount()<=1)return[];var f=l(d,u||n),h=a(f.graph,f.buckets,f.zeroIdx);return e.flatten(e.map(h,function(p){return d.outEdges(p.v,p.w)}),!0)}function a(d,u,f){for(var h=[],p=u[u.length-1],m=u[0],g;d.nodeCount();){for(;g=m.dequeue();)i(d,u,f,g);for(;g=p.dequeue();)i(d,u,f,g);if(d.nodeCount()){for(var x=u.length-2;x>0;--x)if(g=u[x].dequeue(),g){h=h.concat(i(d,u,f,g,!0));break}}}return h}function i(d,u,f,h,p){var m=p?[]:void 0;return e.forEach(d.inEdges(h.v),function(g){var x=d.edge(g),v=d.node(g.v);p&&m.push({v:g.v,w:g.w}),v.out-=x,c(u,f,v)}),e.forEach(d.outEdges(h.v),function(g){var x=d.edge(g),v=g.w,y=d.node(v);y.in-=x,c(u,f,y)}),d.removeNode(h.v),m}function l(d,u){var f=new t,h=0,p=0;e.forEach(d.nodes(),function(x){f.setNode(x,{v:x,in:0,out:0})}),e.forEach(d.edges(),function(x){var v=f.edge(x.v,x.w)||0,y=u(x),b=v+y;f.setEdge(x.v,x.w,b),p=Math.max(p,f.node(x.v).out+=y),h=Math.max(h,f.node(x.w).in+=y)});var m=e.range(p+h+3).map(function(){return new r}),g=h+1;return e.forEach(f.nodes(),function(x){c(m,g,f.node(x))}),{graph:f,buckets:m,zeroIdx:g}}function c(d,u,f){f.out?f.in?d[f.out-f.in+u].enqueue(f):d[d.length-1].enqueue(f):d[0].enqueue(f)}return Pi}var Ai,kh;function Vx(){if(kh)return Ai;kh=1;var e=we(),t=Gx();Ai={run:r,undo:s};function r(a){var i=a.graph().acyclicer==="greedy"?t(a,l(a)):n(a);e.forEach(i,function(c){var d=a.edge(c);a.removeEdge(c),d.forwardName=c.name,d.reversed=!0,a.setEdge(c.w,c.v,d,e.uniqueId("rev"))});function l(c){return function(d){return c.edge(d).weight}}}function n(a){var i=[],l={},c={};function d(u){e.has(c,u)||(c[u]=!0,l[u]=!0,e.forEach(a.outEdges(u),function(f){e.has(l,f.w)?i.push(f):d(f.w)}),delete l[u])}return e.forEach(a.nodes(),d),i}function s(a){e.forEach(a.edges(),function(i){var l=a.edge(i);if(l.reversed){a.removeEdge(i);var c=l.forwardName;delete l.reversed,delete l.forwardName,a.setEdge(i.w,i.v,l,c)}})}return Ai}var Li,Sh;function De(){if(Sh)return Li;Sh=1;var e=we(),t=He().Graph;Li={addDummyNode:r,simplify:n,asNonCompoundGraph:s,successorWeights:a,predecessorWeights:i,intersectRect:l,buildLayerMatrix:c,normalizeRanks:d,removeEmptyRanks:u,addBorderNode:f,maxRank:h,partition:p,time:m,notime:g};function r(x,v,y,b){var k;do k=e.uniqueId(b);while(x.hasNode(k));return y.dummy=v,x.setNode(k,y),k}function n(x){var v=new t().setGraph(x.graph());return e.forEach(x.nodes(),function(y){v.setNode(y,x.node(y))}),e.forEach(x.edges(),function(y){var b=v.edge(y.v,y.w)||{weight:0,minlen:1},k=x.edge(y);v.setEdge(y.v,y.w,{weight:b.weight+k.weight,minlen:Math.max(b.minlen,k.minlen)})}),v}function s(x){var v=new t({multigraph:x.isMultigraph()}).setGraph(x.graph());return e.forEach(x.nodes(),function(y){x.children(y).length||v.setNode(y,x.node(y))}),e.forEach(x.edges(),function(y){v.setEdge(y,x.edge(y))}),v}function a(x){var v=e.map(x.nodes(),function(y){var b={};return e.forEach(x.outEdges(y),function(k){b[k.w]=(b[k.w]||0)+x.edge(k).weight}),b});return e.zipObject(x.nodes(),v)}function i(x){var v=e.map(x.nodes(),function(y){var b={};return e.forEach(x.inEdges(y),function(k){b[k.v]=(b[k.v]||0)+x.edge(k).weight}),b});return e.zipObject(x.nodes(),v)}function l(x,v){var y=x.x,b=x.y,k=v.x-y,_=v.y-b,w=x.width/2,T=x.height/2;if(!k&&!_)throw new Error("Not possible to find intersection inside of the rectangle");var O,D;return Math.abs(_)*w>Math.abs(k)*T?(_<0&&(T=-T),O=T*k/_,D=T):(k<0&&(w=-w),O=w,D=w*_/k),{x:y+O,y:b+D}}function c(x){var v=e.map(e.range(h(x)+1),function(){return[]});return e.forEach(x.nodes(),function(y){var b=x.node(y),k=b.rank;e.isUndefined(k)||(v[k][b.order]=y)}),v}function d(x){var v=e.min(e.map(x.nodes(),function(y){return x.node(y).rank}));e.forEach(x.nodes(),function(y){var b=x.node(y);e.has(b,"rank")&&(b.rank-=v)})}function u(x){var v=e.min(e.map(x.nodes(),function(_){return x.node(_).rank})),y=[];e.forEach(x.nodes(),function(_){var w=x.node(_).rank-v;y[w]||(y[w]=[]),y[w].push(_)});var b=0,k=x.graph().nodeRankFactor;e.forEach(y,function(_,w){e.isUndefined(_)&&w%k!==0?--b:b&&e.forEach(_,function(T){x.node(T).rank+=b})})}function f(x,v,y,b){var k={width:0,height:0};return arguments.length>=4&&(k.rank=y,k.order=b),r(x,"border",k,v)}function h(x){return e.max(e.map(x.nodes(),function(v){var y=x.node(v).rank;if(!e.isUndefined(y))return y}))}function p(x,v){var y={lhs:[],rhs:[]};return e.forEach(x,function(b){v(b)?y.lhs.push(b):y.rhs.push(b)}),y}function m(x,v){var y=e.now();try{return v()}finally{console.log(x+" time: "+(e.now()-y)+"ms")}}function g(x,v){return v()}return Li}var Di,_h;function Yx(){if(_h)return Di;_h=1;var e=we(),t=De();Di={run:r,undo:s};function r(a){a.graph().dummyChains=[],e.forEach(a.edges(),function(i){n(a,i)})}function n(a,i){var l=i.v,c=a.node(l).rank,d=i.w,u=a.node(d).rank,f=i.name,h=a.edge(i),p=h.labelRank;if(u!==c+1){a.removeEdge(i);var m,g,x;for(x=0,++c;c<u;++x,++c)h.points=[],g={width:0,height:0,edgeLabel:h,edgeObj:i,rank:c},m=t.addDummyNode(a,"edge",g,"_d"),c===p&&(g.width=h.width,g.height=h.height,g.dummy="edge-label",g.labelpos=h.labelpos),a.setEdge(l,m,{weight:h.weight},f),x===0&&a.graph().dummyChains.push(m),l=m;a.setEdge(l,d,{weight:h.weight},f)}}function s(a){e.forEach(a.graph().dummyChains,function(i){var l=a.node(i),c=l.edgeLabel,d;for(a.setEdge(l.edgeObj,c);l.dummy;)d=a.successors(i)[0],a.removeNode(i),c.points.push({x:l.x,y:l.y}),l.dummy==="edge-label"&&(c.x=l.x,c.y=l.y,c.width=l.width,c.height=l.height),i=d,l=a.node(i)})}return Di}var Mi,wh;function ir(){if(wh)return Mi;wh=1;var e=we();Mi={longestPath:t,slack:r};function t(n){var s={};function a(i){var l=n.node(i);if(e.has(s,i))return l.rank;s[i]=!0;var c=e.min(e.map(n.outEdges(i),function(d){return a(d.w)-n.edge(d).minlen}));return(c===Number.POSITIVE_INFINITY||c===void 0||c===null)&&(c=0),l.rank=c}e.forEach(n.sources(),a)}function r(n,s){return n.node(s.w).rank-n.node(s.v).rank-n.edge(s).minlen}return Mi}var qi,Th;function Eh(){if(Th)return qi;Th=1;var e=we(),t=He().Graph,r=ir().slack;qi=n;function n(l){var c=new t({directed:!1}),d=l.nodes()[0],u=l.nodeCount();c.setNode(d,{});for(var f,h;s(c,l)<u;)f=a(c,l),h=c.hasNode(f.v)?r(l,f):-r(l,f),i(c,l,h);return c}function s(l,c){function d(u){e.forEach(c.nodeEdges(u),function(f){var h=f.v,p=u===h?f.w:h;!l.hasNode(p)&&!r(c,f)&&(l.setNode(p,{}),l.setEdge(u,p,{}),d(p))})}return e.forEach(l.nodes(),d),l.nodeCount()}function a(l,c){return e.minBy(c.edges(),function(d){if(l.hasNode(d.v)!==l.hasNode(d.w))return r(c,d)})}function i(l,c,d){e.forEach(l.nodes(),function(u){c.node(u).rank+=d})}return qi}var $i,Nh;function Xx(){if(Nh)return $i;Nh=1;var e=we(),t=Eh(),r=ir().slack,n=ir().longestPath,s=He().alg.preorder,a=He().alg.postorder,i=De().simplify;$i=l,l.initLowLimValues=f,l.initCutValues=c,l.calcCutValue=u,l.leaveEdge=p,l.enterEdge=m,l.exchangeEdges=g;function l(b){b=i(b),n(b);var k=t(b);f(k),c(k,b);for(var _,w;_=p(k);)w=m(k,b,_),g(k,b,_,w)}function c(b,k){var _=a(b,b.nodes());_=_.slice(0,_.length-1),e.forEach(_,function(w){d(b,k,w)})}function d(b,k,_){var w=b.node(_),T=w.parent;b.edge(_,T).cutvalue=u(b,k,_)}function u(b,k,_){var w=b.node(_),T=w.parent,O=!0,D=k.edge(_,T),N=0;return D||(O=!1,D=k.edge(T,_)),N=D.weight,e.forEach(k.nodeEdges(_),function(S){var R=S.v===_,j=R?S.w:S.v;if(j!==T){var E=R===O,q=k.edge(S).weight;if(N+=E?q:-q,v(b,_,j)){var $=b.edge(_,j).cutvalue;N+=E?-$:$}}}),N}function f(b,k){arguments.length<2&&(k=b.nodes()[0]),h(b,{},1,k)}function h(b,k,_,w,T){var O=_,D=b.node(w);return k[w]=!0,e.forEach(b.neighbors(w),function(N){e.has(k,N)||(_=h(b,k,_,N,w))}),D.low=O,D.lim=_++,T?D.parent=T:delete D.parent,_}function p(b){return e.find(b.edges(),function(k){return b.edge(k).cutvalue<0})}function m(b,k,_){var w=_.v,T=_.w;k.hasEdge(w,T)||(w=_.w,T=_.v);var O=b.node(w),D=b.node(T),N=O,S=!1;O.lim>D.lim&&(N=D,S=!0);var R=e.filter(k.edges(),function(j){return S===y(b,b.node(j.v),N)&&S!==y(b,b.node(j.w),N)});return e.minBy(R,function(j){return r(k,j)})}function g(b,k,_,w){var T=_.v,O=_.w;b.removeEdge(T,O),b.setEdge(w.v,w.w,{}),f(b),c(b,k),x(b,k)}function x(b,k){var _=e.find(b.nodes(),function(T){return!k.node(T).parent}),w=s(b,_);w=w.slice(1),e.forEach(w,function(T){var O=b.node(T).parent,D=k.edge(T,O),N=!1;D||(D=k.edge(O,T),N=!0),k.node(T).rank=k.node(O).rank+(N?D.minlen:-D.minlen)})}function v(b,k,_){return b.hasEdge(k,_)}function y(b,k,_){return _.low<=k.lim&&k.lim<=_.lim}return $i}var Wi,jh;function Qx(){if(jh)return Wi;jh=1;var e=ir(),t=e.longestPath,r=Eh(),n=Xx();Wi=s;function s(c){switch(c.graph().ranker){case"network-simplex":l(c);break;case"tight-tree":i(c);break;case"longest-path":a(c);break;default:l(c)}}var a=t;function i(c){t(c),r(c)}function l(c){n(c)}return Wi}var Fi,Ch;function Zx(){if(Ch)return Fi;Ch=1;var e=we();Fi=t;function t(s){var a=n(s);e.forEach(s.graph().dummyChains,function(i){for(var l=s.node(i),c=l.edgeObj,d=r(s,a,c.v,c.w),u=d.path,f=d.lca,h=0,p=u[h],m=!0;i!==c.w;){if(l=s.node(i),m){for(;(p=u[h])!==f&&s.node(p).maxRank<l.rank;)h++;p===f&&(m=!1)}if(!m){for(;h<u.length-1&&s.node(p=u[h+1]).minRank<=l.rank;)h++;p=u[h]}s.setParent(i,p),i=s.successors(i)[0]}})}function r(s,a,i,l){var c=[],d=[],u=Math.min(a[i].low,a[l].low),f=Math.max(a[i].lim,a[l].lim),h,p;h=i;do h=s.parent(h),c.push(h);while(h&&(a[h].low>u||f>a[h].lim));for(p=h,h=l;(h=s.parent(h))!==p;)d.push(h);return{path:c.concat(d.reverse()),lca:p}}function n(s){var a={},i=0;function l(c){var d=i;e.forEach(s.children(c),l),a[c]={low:d,lim:i++}}return e.forEach(s.children(),l),a}return Fi}var Bi,Ih;function ev(){if(Ih)return Bi;Ih=1;var e=we(),t=De();Bi={run:r,cleanup:i};function r(l){var c=t.addDummyNode(l,"root",{},"_root"),d=s(l),u=e.max(e.values(d))-1,f=2*u+1;l.graph().nestingRoot=c,e.forEach(l.edges(),function(p){l.edge(p).minlen*=f});var h=a(l)+1;e.forEach(l.children(),function(p){n(l,c,f,h,u,d,p)}),l.graph().nodeRankFactor=f}function n(l,c,d,u,f,h,p){var m=l.children(p);if(!m.length){p!==c&&l.setEdge(c,p,{weight:0,minlen:d});return}var g=t.addBorderNode(l,"_bt"),x=t.addBorderNode(l,"_bb"),v=l.node(p);l.setParent(g,p),v.borderTop=g,l.setParent(x,p),v.borderBottom=x,e.forEach(m,function(y){n(l,c,d,u,f,h,y);var b=l.node(y),k=b.borderTop?b.borderTop:y,_=b.borderBottom?b.borderBottom:y,w=b.borderTop?u:2*u,T=k!==_?1:f-h[p]+1;l.setEdge(g,k,{weight:w,minlen:T,nestingEdge:!0}),l.setEdge(_,x,{weight:w,minlen:T,nestingEdge:!0})}),l.parent(p)||l.setEdge(c,g,{weight:0,minlen:f+h[p]})}function s(l){var c={};function d(u,f){var h=l.children(u);h&&h.length&&e.forEach(h,function(p){d(p,f+1)}),c[u]=f}return e.forEach(l.children(),function(u){d(u,1)}),c}function a(l){return e.reduce(l.edges(),function(c,d){return c+l.edge(d).weight},0)}function i(l){var c=l.graph();l.removeNode(c.nestingRoot),delete c.nestingRoot,e.forEach(l.edges(),function(d){var u=l.edge(d);u.nestingEdge&&l.removeEdge(d)})}return Bi}var zi,Rh;function tv(){if(Rh)return zi;Rh=1;var e=we(),t=De();zi=r;function r(s){function a(i){var l=s.children(i),c=s.node(i);if(l.length&&e.forEach(l,a),e.has(c,"minRank")){c.borderLeft=[],c.borderRight=[];for(var d=c.minRank,u=c.maxRank+1;d<u;++d)n(s,"borderLeft","_bl",i,c,d),n(s,"borderRight","_br",i,c,d)}}e.forEach(s.children(),a)}function n(s,a,i,l,c,d){var u={width:0,height:0,rank:d,borderType:a},f=c[a][d-1],h=t.addDummyNode(s,"border",u,i);c[a][d]=h,s.setParent(h,l),f&&s.setEdge(f,h,{weight:1})}return zi}var Hi,Oh;function rv(){if(Oh)return Hi;Oh=1;var e=we();Hi={adjust:t,undo:r};function t(d){var u=d.graph().rankdir.toLowerCase();(u==="lr"||u==="rl")&&n(d)}function r(d){var u=d.graph().rankdir.toLowerCase();(u==="bt"||u==="rl")&&a(d),(u==="lr"||u==="rl")&&(l(d),n(d))}function n(d){e.forEach(d.nodes(),function(u){s(d.node(u))}),e.forEach(d.edges(),function(u){s(d.edge(u))})}function s(d){var u=d.width;d.width=d.height,d.height=u}function a(d){e.forEach(d.nodes(),function(u){i(d.node(u))}),e.forEach(d.edges(),function(u){var f=d.edge(u);e.forEach(f.points,i),e.has(f,"y")&&i(f)})}function i(d){d.y=-d.y}function l(d){e.forEach(d.nodes(),function(u){c(d.node(u))}),e.forEach(d.edges(),function(u){var f=d.edge(u);e.forEach(f.points,c),e.has(f,"x")&&c(f)})}function c(d){var u=d.x;d.x=d.y,d.y=u}return Hi}var Ji,Ph;function nv(){if(Ph)return Ji;Ph=1;var e=we();Ji=t;function t(r){var n={},s=e.filter(r.nodes(),function(d){return!r.children(d).length}),a=e.max(e.map(s,function(d){return r.node(d).rank})),i=e.map(e.range(a+1),function(){return[]});function l(d){if(!e.has(n,d)){n[d]=!0;var u=r.node(d);i[u.rank].push(d),e.forEach(r.successors(d),l)}}var c=e.sortBy(s,function(d){return r.node(d).rank});return e.forEach(c,l),i}return Ji}var Ui,Ah;function sv(){if(Ah)return Ui;Ah=1;var e=we();Ui=t;function t(n,s){for(var a=0,i=1;i<s.length;++i)a+=r(n,s[i-1],s[i]);return a}function r(n,s,a){for(var i=e.zipObject(a,e.map(a,function(h,p){return p})),l=e.flatten(e.map(s,function(h){return e.sortBy(e.map(n.outEdges(h),function(p){return{pos:i[p.w],weight:n.edge(p).weight}}),"pos")}),!0),c=1;c<a.length;)c<<=1;var d=2*c-1;c-=1;var u=e.map(new Array(d),function(){return 0}),f=0;return e.forEach(l.forEach(function(h){var p=h.pos+c;u[p]+=h.weight;for(var m=0;p>0;)p%2&&(m+=u[p+1]),p=p-1>>1,u[p]+=h.weight;f+=h.weight*m})),f}return Ui}var Ki,Lh;function av(){if(Lh)return Ki;Lh=1;var e=we();Ki=t;function t(r,n){return e.map(n,function(s){var a=r.inEdges(s);if(a.length){var i=e.reduce(a,function(l,c){var d=r.edge(c),u=r.node(c.v);return{sum:l.sum+d.weight*u.order,weight:l.weight+d.weight}},{sum:0,weight:0});return{v:s,barycenter:i.sum/i.weight,weight:i.weight}}else return{v:s}})}return Ki}var Gi,Dh;function ov(){if(Dh)return Gi;Dh=1;var e=we();Gi=t;function t(s,a){var i={};e.forEach(s,function(c,d){var u=i[c.v]={indegree:0,in:[],out:[],vs:[c.v],i:d};e.isUndefined(c.barycenter)||(u.barycenter=c.barycenter,u.weight=c.weight)}),e.forEach(a.edges(),function(c){var d=i[c.v],u=i[c.w];!e.isUndefined(d)&&!e.isUndefined(u)&&(u.indegree++,d.out.push(i[c.w]))});var l=e.filter(i,function(c){return!c.indegree});return r(l)}function r(s){var a=[];function i(d){return function(u){u.merged||(e.isUndefined(u.barycenter)||e.isUndefined(d.barycenter)||u.barycenter>=d.barycenter)&&n(d,u)}}function l(d){return function(u){u.in.push(d),--u.indegree===0&&s.push(u)}}for(;s.length;){var c=s.pop();a.push(c),e.forEach(c.in.reverse(),i(c)),e.forEach(c.out,l(c))}return e.map(e.filter(a,function(d){return!d.merged}),function(d){return e.pick(d,["vs","i","barycenter","weight"])})}function n(s,a){var i=0,l=0;s.weight&&(i+=s.barycenter*s.weight,l+=s.weight),a.weight&&(i+=a.barycenter*a.weight,l+=a.weight),s.vs=a.vs.concat(s.vs),s.barycenter=i/l,s.weight=l,s.i=Math.min(a.i,s.i),a.merged=!0}return Gi}var Vi,Mh;function iv(){if(Mh)return Vi;Mh=1;var e=we(),t=De();Vi=r;function r(a,i){var l=t.partition(a,function(g){return e.has(g,"barycenter")}),c=l.lhs,d=e.sortBy(l.rhs,function(g){return-g.i}),u=[],f=0,h=0,p=0;c.sort(s(!!i)),p=n(u,d,p),e.forEach(c,function(g){p+=g.vs.length,u.push(g.vs),f+=g.barycenter*g.weight,h+=g.weight,p=n(u,d,p)});var m={vs:e.flatten(u,!0)};return h&&(m.barycenter=f/h,m.weight=h),m}function n(a,i,l){for(var c;i.length&&(c=e.last(i)).i<=l;)i.pop(),a.push(c.vs),l++;return l}function s(a){return function(i,l){return i.barycenter<l.barycenter?-1:i.barycenter>l.barycenter?1:a?l.i-i.i:i.i-l.i}}return Vi}var Yi,qh;function lv(){if(qh)return Yi;qh=1;var e=we(),t=av(),r=ov(),n=iv();Yi=s;function s(l,c,d,u){var f=l.children(c),h=l.node(c),p=h?h.borderLeft:void 0,m=h?h.borderRight:void 0,g={};p&&(f=e.filter(f,function(_){return _!==p&&_!==m}));var x=t(l,f);e.forEach(x,function(_){if(l.children(_.v).length){var w=s(l,_.v,d,u);g[_.v]=w,e.has(w,"barycenter")&&i(_,w)}});var v=r(x,d);a(v,g);var y=n(v,u);if(p&&(y.vs=e.flatten([p,y.vs,m],!0),l.predecessors(p).length)){var b=l.node(l.predecessors(p)[0]),k=l.node(l.predecessors(m)[0]);e.has(y,"barycenter")||(y.barycenter=0,y.weight=0),y.barycenter=(y.barycenter*y.weight+b.order+k.order)/(y.weight+2),y.weight+=2}return y}function a(l,c){e.forEach(l,function(d){d.vs=e.flatten(d.vs.map(function(u){return c[u]?c[u].vs:u}),!0)})}function i(l,c){e.isUndefined(l.barycenter)?(l.barycenter=c.barycenter,l.weight=c.weight):(l.barycenter=(l.barycenter*l.weight+c.barycenter*c.weight)/(l.weight+c.weight),l.weight+=c.weight)}return Yi}var Xi,$h;function cv(){if($h)return Xi;$h=1;var e=we(),t=He().Graph;Xi=r;function r(s,a,i){var l=n(s),c=new t({compound:!0}).setGraph({root:l}).setDefaultNodeLabel(function(d){return s.node(d)});return e.forEach(s.nodes(),function(d){var u=s.node(d),f=s.parent(d);(u.rank===a||u.minRank<=a&&a<=u.maxRank)&&(c.setNode(d),c.setParent(d,f||l),e.forEach(s[i](d),function(h){var p=h.v===d?h.w:h.v,m=c.edge(p,d),g=e.isUndefined(m)?0:m.weight;c.setEdge(p,d,{weight:s.edge(h).weight+g})}),e.has(u,"minRank")&&c.setNode(d,{borderLeft:u.borderLeft[a],borderRight:u.borderRight[a]}))}),c}function n(s){for(var a;s.hasNode(a=e.uniqueId("_root")););return a}return Xi}var Qi,Wh;function dv(){if(Wh)return Qi;Wh=1;var e=we();Qi=t;function t(r,n,s){var a={},i;e.forEach(s,function(l){for(var c=r.parent(l),d,u;c;){if(d=r.parent(c),d?(u=a[d],a[d]=c):(u=i,i=c),u&&u!==c){n.setEdge(u,c);return}c=d}})}return Qi}var Zi,Fh;function uv(){if(Fh)return Zi;Fh=1;var e=we(),t=nv(),r=sv(),n=lv(),s=cv(),a=dv(),i=He().Graph,l=De();Zi=c;function c(h){var p=l.maxRank(h),m=d(h,e.range(1,p+1),"inEdges"),g=d(h,e.range(p-1,-1,-1),"outEdges"),x=t(h);f(h,x);for(var v=Number.POSITIVE_INFINITY,y,b=0,k=0;k<4;++b,++k){u(b%2?m:g,b%4>=2),x=l.buildLayerMatrix(h);var _=r(h,x);_<v&&(k=0,y=e.cloneDeep(x),v=_)}f(h,y)}function d(h,p,m){return e.map(p,function(g){return s(h,g,m)})}function u(h,p){var m=new i;e.forEach(h,function(g){var x=g.graph().root,v=n(g,x,m,p);e.forEach(v.vs,function(y,b){g.node(y).order=b}),a(g,m,v.vs)})}function f(h,p){e.forEach(p,function(m){e.forEach(m,function(g,x){h.node(g).order=x})})}return Zi}var el,Bh;function fv(){if(Bh)return el;Bh=1;var e=we(),t=He().Graph,r=De();el={positionX:m,findType1Conflicts:n,findType2Conflicts:s,addConflict:i,hasConflict:l,verticalAlignment:c,horizontalCompaction:d,alignCoordinates:h,findSmallestWidthAlignment:f,balance:p};function n(v,y){var b={};function k(_,w){var T=0,O=0,D=_.length,N=e.last(w);return e.forEach(w,function(S,R){var j=a(v,S),E=j?v.node(j).order:D;(j||S===N)&&(e.forEach(w.slice(O,R+1),function(q){e.forEach(v.predecessors(q),function($){var J=v.node($),V=J.order;(V<T||E<V)&&!(J.dummy&&v.node(q).dummy)&&i(b,$,q)})}),O=R+1,T=E)}),w}return e.reduce(y,k),b}function s(v,y){var b={};function k(w,T,O,D,N){var S;e.forEach(e.range(T,O),function(R){S=w[R],v.node(S).dummy&&e.forEach(v.predecessors(S),function(j){var E=v.node(j);E.dummy&&(E.order<D||E.order>N)&&i(b,j,S)})})}function _(w,T){var O=-1,D,N=0;return e.forEach(T,function(S,R){if(v.node(S).dummy==="border"){var j=v.predecessors(S);j.length&&(D=v.node(j[0]).order,k(T,N,R,O,D),N=R,O=D)}k(T,N,T.length,D,w.length)}),T}return e.reduce(y,_),b}function a(v,y){if(v.node(y).dummy)return e.find(v.predecessors(y),function(b){return v.node(b).dummy})}function i(v,y,b){if(y>b){var k=y;y=b,b=k}var _=v[y];_||(v[y]=_={}),_[b]=!0}function l(v,y,b){if(y>b){var k=y;y=b,b=k}return e.has(v[y],b)}function c(v,y,b,k){var _={},w={},T={};return e.forEach(y,function(O){e.forEach(O,function(D,N){_[D]=D,w[D]=D,T[D]=N})}),e.forEach(y,function(O){var D=-1;e.forEach(O,function(N){var S=k(N);if(S.length){S=e.sortBy(S,function($){return T[$]});for(var R=(S.length-1)/2,j=Math.floor(R),E=Math.ceil(R);j<=E;++j){var q=S[j];w[N]===N&&D<T[q]&&!l(b,N,q)&&(w[q]=N,w[N]=_[N]=_[q],D=T[q])}}})}),{root:_,align:w}}function d(v,y,b,k,_){var w={},T=u(v,y,b,_),O=_?"borderLeft":"borderRight";function D(R,j){for(var E=T.nodes(),q=E.pop(),$={};q;)$[q]?R(q):($[q]=!0,E.push(q),E=E.concat(j(q))),q=E.pop()}function N(R){w[R]=T.inEdges(R).reduce(function(j,E){return Math.max(j,w[E.v]+T.edge(E))},0)}function S(R){var j=T.outEdges(R).reduce(function(q,$){return Math.min(q,w[$.w]-T.edge($))},Number.POSITIVE_INFINITY),E=v.node(R);j!==Number.POSITIVE_INFINITY&&E.borderType!==O&&(w[R]=Math.max(w[R],j))}return D(N,T.predecessors.bind(T)),D(S,T.successors.bind(T)),e.forEach(k,function(R){w[R]=w[b[R]]}),w}function u(v,y,b,k){var _=new t,w=v.graph(),T=g(w.nodesep,w.edgesep,k);return e.forEach(y,function(O){var D;e.forEach(O,function(N){var S=b[N];if(_.setNode(S),D){var R=b[D],j=_.edge(R,S);_.setEdge(R,S,Math.max(T(v,N,D),j||0))}D=N})}),_}function f(v,y){return e.minBy(e.values(y),function(b){var k=Number.NEGATIVE_INFINITY,_=Number.POSITIVE_INFINITY;return e.forIn(b,function(w,T){var O=x(v,T)/2;k=Math.max(w+O,k),_=Math.min(w-O,_)}),k-_})}function h(v,y){var b=e.values(y),k=e.min(b),_=e.max(b);e.forEach(["u","d"],function(w){e.forEach(["l","r"],function(T){var O=w+T,D=v[O],N;if(D!==y){var S=e.values(D);N=T==="l"?k-e.min(S):_-e.max(S),N&&(v[O]=e.mapValues(D,function(R){return R+N}))}})})}function p(v,y){return e.mapValues(v.ul,function(b,k){if(y)return v[y.toLowerCase()][k];var _=e.sortBy(e.map(v,k));return(_[1]+_[2])/2})}function m(v){var y=r.buildLayerMatrix(v),b=e.merge(n(v,y),s(v,y)),k={},_;e.forEach(["u","d"],function(T){_=T==="u"?y:e.values(y).reverse(),e.forEach(["l","r"],function(O){O==="r"&&(_=e.map(_,function(R){return e.values(R).reverse()}));var D=(T==="u"?v.predecessors:v.successors).bind(v),N=c(v,_,b,D),S=d(v,_,N.root,N.align,O==="r");O==="r"&&(S=e.mapValues(S,function(R){return-R})),k[T+O]=S})});var w=f(v,k);return h(k,w),p(k,v.graph().align)}function g(v,y,b){return function(k,_,w){var T=k.node(_),O=k.node(w),D=0,N;if(D+=T.width/2,e.has(T,"labelpos"))switch(T.labelpos.toLowerCase()){case"l":N=-T.width/2;break;case"r":N=T.width/2;break}if(N&&(D+=b?N:-N),N=0,D+=(T.dummy?y:v)/2,D+=(O.dummy?y:v)/2,D+=O.width/2,e.has(O,"labelpos"))switch(O.labelpos.toLowerCase()){case"l":N=O.width/2;break;case"r":N=-O.width/2;break}return N&&(D+=b?N:-N),N=0,D}}function x(v,y){return v.node(y).width}return el}var tl,zh;function pv(){if(zh)return tl;zh=1;var e=we(),t=De(),r=fv().positionX;tl=n;function n(a){a=t.asNonCompoundGraph(a),s(a),e.forEach(r(a),function(i,l){a.node(l).x=i})}function s(a){var i=t.buildLayerMatrix(a),l=a.graph().ranksep,c=0;e.forEach(i,function(d){var u=e.max(e.map(d,function(f){return a.node(f).height}));e.forEach(d,function(f){a.node(f).y=c+u/2}),c+=u+l})}return tl}var rl,Hh;function hv(){if(Hh)return rl;Hh=1;var e=we(),t=Vx(),r=Yx(),n=Qx(),s=De().normalizeRanks,a=Zx(),i=De().removeEmptyRanks,l=ev(),c=tv(),d=rv(),u=uv(),f=pv(),h=De(),p=He().Graph;rl=m;function m(L,F){var z=F&&F.debugTiming?h.time:h.notime;z("layout",function(){var H=z(" buildLayoutGraph",function(){return D(L)});z(" runLayout",function(){g(H,z)}),z(" updateInputGraph",function(){x(L,H)})})}function g(L,F){F(" makeSpaceForEdgeLabels",function(){N(L)}),F(" removeSelfEdges",function(){A(L)}),F(" acyclic",function(){t.run(L)}),F(" nestingGraph.run",function(){l.run(L)}),F(" rank",function(){n(h.asNonCompoundGraph(L))}),F(" injectEdgeLabelProxies",function(){S(L)}),F(" removeEmptyRanks",function(){i(L)}),F(" nestingGraph.cleanup",function(){l.cleanup(L)}),F(" normalizeRanks",function(){s(L)}),F(" assignRankMinMax",function(){R(L)}),F(" removeEdgeLabelProxies",function(){j(L)}),F(" normalize.run",function(){r.run(L)}),F(" parentDummyChains",function(){a(L)}),F(" addBorderSegments",function(){c(L)}),F(" order",function(){u(L)}),F(" insertSelfEdges",function(){B(L)}),F(" adjustCoordinateSystem",function(){d.adjust(L)}),F(" position",function(){f(L)}),F(" positionSelfEdges",function(){P(L)}),F(" removeBorderNodes",function(){V(L)}),F(" normalize.undo",function(){r.undo(L)}),F(" fixupEdgeLabelCoords",function(){$(L)}),F(" undoCoordinateSystem",function(){d.undo(L)}),F(" translateGraph",function(){E(L)}),F(" assignNodeIntersects",function(){q(L)}),F(" reversePoints",function(){J(L)}),F(" acyclic.undo",function(){t.undo(L)})}function x(L,F){e.forEach(L.nodes(),function(z){var H=L.node(z),Y=F.node(z);H&&(H.x=Y.x,H.y=Y.y,F.children(z).length&&(H.width=Y.width,H.height=Y.height))}),e.forEach(L.edges(),function(z){var H=L.edge(z),Y=F.edge(z);H.points=Y.points,e.has(Y,"x")&&(H.x=Y.x,H.y=Y.y)}),L.graph().width=F.graph().width,L.graph().height=F.graph().height}var v=["nodesep","edgesep","ranksep","marginx","marginy"],y={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},b=["acyclicer","ranker","rankdir","align"],k=["width","height"],_={width:0,height:0},w=["minlen","weight","width","height","labeloffset"],T={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},O=["labelpos"];function D(L){var F=new p({multigraph:!0,compound:!0}),z=se(L.graph());return F.setGraph(e.merge({},y,U(z,v),e.pick(z,b))),e.forEach(L.nodes(),function(H){var Y=se(L.node(H));F.setNode(H,e.defaults(U(Y,k),_)),F.setParent(H,L.parent(H))}),e.forEach(L.edges(),function(H){var Y=se(L.edge(H));F.setEdge(H,e.merge({},T,U(Y,w),e.pick(Y,O)))}),F}function N(L){var F=L.graph();F.ranksep/=2,e.forEach(L.edges(),function(z){var H=L.edge(z);H.minlen*=2,H.labelpos.toLowerCase()!=="c"&&(F.rankdir==="TB"||F.rankdir==="BT"?H.width+=H.labeloffset:H.height+=H.labeloffset)})}function S(L){e.forEach(L.edges(),function(F){var z=L.edge(F);if(z.width&&z.height){var H=L.node(F.v),Y=L.node(F.w),ie={rank:(Y.rank-H.rank)/2+H.rank,e:F};h.addDummyNode(L,"edge-proxy",ie,"_ep")}})}function R(L){var F=0;e.forEach(L.nodes(),function(z){var H=L.node(z);H.borderTop&&(H.minRank=L.node(H.borderTop).rank,H.maxRank=L.node(H.borderBottom).rank,F=e.max(F,H.maxRank))}),L.graph().maxRank=F}function j(L){e.forEach(L.nodes(),function(F){var z=L.node(F);z.dummy==="edge-proxy"&&(L.edge(z.e).labelRank=z.rank,L.removeNode(F))})}function E(L){var F=Number.POSITIVE_INFINITY,z=0,H=Number.POSITIVE_INFINITY,Y=0,ie=L.graph(),fe=ie.marginx||0,ve=ie.marginy||0;function be(W){var ke=W.x,ee=W.y,me=W.width,ne=W.height;F=Math.min(F,ke-me/2),z=Math.max(z,ke+me/2),H=Math.min(H,ee-ne/2),Y=Math.max(Y,ee+ne/2)}e.forEach(L.nodes(),function(W){be(L.node(W))}),e.forEach(L.edges(),function(W){var ke=L.edge(W);e.has(ke,"x")&&be(ke)}),F-=fe,H-=ve,e.forEach(L.nodes(),function(W){var ke=L.node(W);ke.x-=F,ke.y-=H}),e.forEach(L.edges(),function(W){var ke=L.edge(W);e.forEach(ke.points,function(ee){ee.x-=F,ee.y-=H}),e.has(ke,"x")&&(ke.x-=F),e.has(ke,"y")&&(ke.y-=H)}),ie.width=z-F+fe,ie.height=Y-H+ve}function q(L){e.forEach(L.edges(),function(F){var z=L.edge(F),H=L.node(F.v),Y=L.node(F.w),ie,fe;z.points?(ie=z.points[0],fe=z.points[z.points.length-1]):(z.points=[],ie=Y,fe=H),z.points.unshift(h.intersectRect(H,ie)),z.points.push(h.intersectRect(Y,fe))})}function $(L){e.forEach(L.edges(),function(F){var z=L.edge(F);if(e.has(z,"x"))switch((z.labelpos==="l"||z.labelpos==="r")&&(z.width-=z.labeloffset),z.labelpos){case"l":z.x-=z.width/2+z.labeloffset;break;case"r":z.x+=z.width/2+z.labeloffset;break}})}function J(L){e.forEach(L.edges(),function(F){var z=L.edge(F);z.reversed&&z.points.reverse()})}function V(L){e.forEach(L.nodes(),function(F){if(L.children(F).length){var z=L.node(F),H=L.node(z.borderTop),Y=L.node(z.borderBottom),ie=L.node(e.last(z.borderLeft)),fe=L.node(e.last(z.borderRight));z.width=Math.abs(fe.x-ie.x),z.height=Math.abs(Y.y-H.y),z.x=ie.x+z.width/2,z.y=H.y+z.height/2}}),e.forEach(L.nodes(),function(F){L.node(F).dummy==="border"&&L.removeNode(F)})}function A(L){e.forEach(L.edges(),function(F){if(F.v===F.w){var z=L.node(F.v);z.selfEdges||(z.selfEdges=[]),z.selfEdges.push({e:F,label:L.edge(F)}),L.removeEdge(F)}})}function B(L){var F=h.buildLayerMatrix(L);e.forEach(F,function(z){var H=0;e.forEach(z,function(Y,ie){var fe=L.node(Y);fe.order=ie+H,e.forEach(fe.selfEdges,function(ve){h.addDummyNode(L,"selfedge",{width:ve.label.width,height:ve.label.height,rank:fe.rank,order:ie+ ++H,e:ve.e,label:ve.label},"_se")}),delete fe.selfEdges})})}function P(L){e.forEach(L.nodes(),function(F){var z=L.node(F);if(z.dummy==="selfedge"){var H=L.node(z.e.v),Y=H.x+H.width/2,ie=H.y,fe=z.x-Y,ve=H.height/2;L.setEdge(z.e,z.label),L.removeNode(F),z.label.points=[{x:Y+2*fe/3,y:ie-ve},{x:Y+5*fe/6,y:ie-ve},{x:Y+fe,y:ie},{x:Y+5*fe/6,y:ie+ve},{x:Y+2*fe/3,y:ie+ve}],z.label.x=z.x,z.label.y=z.y}})}function U(L,F){return e.mapValues(e.pick(L,F),Number)}function se(L){var F={};return e.forEach(L,function(z,H){F[H.toLowerCase()]=z}),F}return rl}var nl,Jh;function mv(){if(Jh)return nl;Jh=1;var e=we(),t=De(),r=He().Graph;nl={debugOrdering:n};function n(s){var a=t.buildLayerMatrix(s),i=new r({compound:!0,multigraph:!0}).setGraph({});return e.forEach(s.nodes(),function(l){i.setNode(l,{label:l}),i.setParent(l,"layer"+s.node(l).rank)}),e.forEach(s.edges(),function(l){i.setEdge(l.v,l.w,{},l.name)}),e.forEach(a,function(l,c){var d="layer"+c;i.setNode(d,{rank:"same"}),e.reduce(l,function(u,f){return i.setEdge(u,f,{style:"invis"}),f})}),i}return nl}var sl,Uh;function gv(){return Uh||(Uh=1,sl="0.8.5"),sl}var al,Kh;function yv(){return Kh||(Kh=1,al={graphlib:He(),layout:hv(),debug:mv(),util:{time:De().time,notime:De().notime},version:gv()}),al}var xv=yv();const Gh=zm(xv);function mt(e,t="TB"){if(e.data?._layoutWidth&&e.data?._layoutHeight)return{width:e.data._layoutWidth,height:e.data._layoutHeight};let r=240,n=84;switch(e.type){case"decisionNode":r=164,n=164;break;case"forkNode":r=240,n=84;break;case"joinNode":r=240,n=84;break;case"dynamicPlaceholderNode":r=220,n=70;break;case"loopNode":r=320,n=200;break;case"subWorkflowNode":r=240,n=84;break;case"eventNode":r=240,n=84;break;case"default":r=240,n=40;break;case"plusNode":r=e.data.label&&e.data.label!=="+"?120:32,n=32;break;default:r=240,n=84;break}return{width:r,height:n}}function vv(e,t,r=8){const n=[];if(e.length<r)return n;const s=new Map,a={},i={};e.forEach(f=>{s.set(f.id,f),a[f.id]=[],i[f.id]=[]}),t.forEach(f=>{a[f.source]&&a[f.source].push(f.target),i[f.target]&&i[f.target].push(f.source)});const l=new Set,c=new Set(["input","output","decisionNode","forkNode","joinNode","loopNode","default","plusNode"]),d=f=>!c.has(f.type||""),u=[...e].sort((f,h)=>f.position.y-h.position.y);for(const f of u){if(l.has(f.id)||!d(f)||a[f.id].length>1)continue;const h=[f.id];let p=f,m=a[p.id];for(;m&&m.length===1;){const g=m[0],x=s.get(g);if(!x||l.has(g)||!d(x)||i[g].length!==1)break;h.push(g),p=x,m=a[p.id]}h.length>=r&&(n.push(h),h.forEach(g=>l.add(g)))}return n}function bv(e,t,r,n,s,a=5,i="view"){const l=t.find(y=>y.id===e[0]),{width:c,height:d}=mt(l||t[0],r),u=Math.max(.7,1-(e.length-10)/80),f=i==="edit"||i==="run"?1.15:1,h=Math.min(n,Math.round(60*u*f)),p=Math.min(s,Math.round(80*u*f)),m=c+h,g=d+p;let x=0,v=0;if(r==="TB"){const y=Math.ceil(e.length/a);x=a*m-h,v=y*g-p}else x=Math.ceil(e.length/a)*m-h,v=a*g-p;return x+=40,v+=40,{width:x,height:v,gridKW:m,gridKH:g,cols:a}}const ol=58,Vh=20,kv=16;function Sv(e,t,r,n){if(e.length===0)return{positionedChildren:[],containerWidth:280,containerHeight:ol+50};const s=e.map(f=>({...f,parentId:void 0,extent:void 0})),{nodes:a}=il(s,t,{direction:r,mode:n,enableSnakeLayout:!1});let i=0,l=0;a.forEach(f=>{const{width:h,height:p}=mt(f,r);i=Math.max(i,f.position.x+h),l=Math.max(l,f.position.y+p)});const c=Math.max(300,i+Vh*2),d=ol+l+kv;return{positionedChildren:a.map(f=>{const h=e.find(p=>p.id===f.id);return{...f,parentId:h.parentId,extent:h.extent,position:{x:f.position.x+Vh,y:f.position.y+ol}}}),containerWidth:c,containerHeight:d}}function il(e,t,r={}){const{direction:n="TB",mode:s="view",enableSnakeLayout:a=!0,snakeColumns:i=5,snakeMinChainLength:l=8,snakeMinNodeCount:c=10}=r,d=e.length,u=e.filter(N=>N.type!=="plusNode").length;let f=n==="LR"?150:120,h=n==="LR"?120:100,p=f,m=h;if(d>15){let N=Math.max(.5,1-(d-15)/50),S=Math.max(.4,1-(d-15)/40);(s==="edit"||s==="run")&&(N=1-(1-N)*.5,S=1-(1-S)*.5),p=Math.round(f*N),m=Math.round(h*S)}const g=a&&u>c?vv(e,t,l):[],x={};g.forEach((N,S)=>{N.forEach(R=>{x[R]=S})});const v=new Gh.graphlib.Graph;v.setDefaultEdgeLabel(()=>({})),v.setGraph({rankdir:n,ranker:"network-simplex",ranksep:p,nodesep:m,edgesep:50,marginx:50,marginy:50});const y=new Set,b={};e.forEach(N=>{const S=x[N.id];if(S!==void 0){if(!y.has(S)){y.add(S);const R=bv(g[S],e,n,m,p,i,s);b[S]=R,v.setNode(`__CHAIN_${S}`,{width:R.width,height:R.height})}}else{const{width:R,height:j}=mt(N,n);v.setNode(N.id,{width:R,height:j})}});const k={};t.forEach(N=>{const S=x[N.source],R=x[N.target],j=S!==void 0?`__CHAIN_${S}`:N.source,E=R!==void 0?`__CHAIN_${R}`:N.target;j!==E&&(k[E]=(k[E]||0)+1)}),t.forEach(N=>{const S=x[N.source],R=x[N.target];let j=N.source,E=N.target;if(S!==void 0&&(j=`__CHAIN_${S}`),R!==void 0&&(E=`__CHAIN_${R}`),j!==E){const q=(k[E]||0)>1;v.setEdge(j,E,{weight:q?1:2})}}),Gh.layout(v);const _={};for(const N of e)_[N.id]={...N};const w=[],T=new Set;e.forEach(N=>{if(x[N.id]===void 0){const S=v.node(N.id),R=_[N.id],{width:j,height:E}=mt(R,n);R.position={x:S.x-j/2,y:S.y-E/2},R.data={...R.data,sourcePosition:void 0,targetPosition:void 0},R.sourcePosition=n==="LR"?M.Position.Right:M.Position.Bottom,R.targetPosition=n==="LR"?M.Position.Left:M.Position.Top,w.push(R)}else T.add(N.id)}),g.forEach((N,S)=>{const R=`__CHAIN_${S}`,j=v.node(R),E=b[S],q=j.x-E.width/2+20,$=j.y-E.height/2+20,J=E.cols,V=E.gridKW,A=E.gridKH;N.forEach((B,P)=>{const U=_[B];let se=0,L=0,F,z;if(n==="TB"){const H=Math.floor(P/J),Y=P%J,ie=H%2===0,fe=Math.ceil(N.length/J),ve=H===fe-1,be=N.length%J||J,W=ve?(J-be)*V/2:0;let ke;ie?ke=Y*V+W:ke=(J-1-Y)*V-W;const ee=H*A;se=q+ke,L=$+ee;const me=ve?be:J;ie?(z=M.Position.Left,F=M.Position.Right,Y===me-1&&P!==N.length-1&&(F=M.Position.Bottom),Y===0&&P!==0&&(z=M.Position.Top)):(z=M.Position.Right,F=M.Position.Left,Y===me-1&&P!==N.length-1&&(F=M.Position.Bottom),Y===0&&P!==0&&(z=M.Position.Top)),P===0&&(z=M.Position.Top),P===N.length-1&&(F=M.Position.Bottom)}else{const H=Math.floor(P/J),Y=P%J,ie=H%2===0,fe=Math.ceil(N.length/J),ve=H===fe-1,be=N.length%J||J,W=ve?Math.max(0,(J-be)*A)/2:0,ke=H*V;let ee;ie?ee=Y*A+W:ee=(J-1-Y)*A-W,se=q+ke,L=$+ee;const me=ve?be:J;ie?(z=M.Position.Top,F=M.Position.Bottom,Y===me-1&&P!==N.length-1&&(F=M.Position.Right),Y===0&&P!==0&&(z=M.Position.Left)):(z=M.Position.Bottom,F=M.Position.Top,Y===me-1&&P!==N.length-1&&(F=M.Position.Right),Y===0&&P!==0&&(z=M.Position.Left)),P===0&&(z=M.Position.Left),P===N.length-1&&(F=M.Position.Right)}U.position={x:se,y:L},U.data={...U.data,sourcePosition:F,targetPosition:z},U.sourcePosition=F,U.targetPosition=z,w.push(U)})});const O=w.reduce((N,S)=>({...N,[S.id]:S}),{}),D=t.map(N=>{const S=O[N.source],R=O[N.target];if(!S||!R||T.has(S.id)||S.type!=="decisionNode")return N;const{width:j,height:E}=mt(S,n),{width:q,height:$}=mt(R,n),J={x:S.position.x+j/2,y:S.position.y+E/2},V={x:R.position.x+q/2,y:R.position.y+$/2};let A=null;if(n==="TB"){const B=j*.25;V.x<J.x-B?A="left":V.x>J.x+B&&(A="right")}else{const B=E*.25;V.y<J.y-B?A="top":V.y>J.y+B&&(A="bottom")}return{...N,sourceHandle:A}});return{nodes:w,edges:D}}function je(e,t,r={}){const n=r.direction||"TB",s=r.mode||"view",a=e.filter(v=>v.parentId),i=e.filter(v=>!v.parentId);if(a.length===0)return il(e,t,r);const l=new Map(a.map(v=>[v.id,v])),c={},d=[];t.forEach(v=>{const y=l.get(v.source),b=l.get(v.target);if(y?.parentId&&y.parentId===b?.parentId){const k=y.parentId;c[k]||(c[k]=[]),c[k].push(v)}else d.push(v)});const u={};a.forEach(v=>{const y=v.parentId;u[y]||(u[y]=[]),u[y].push(v)});const f={},h=[];for(const[v,y]of Object.entries(u)){const b=c[v]||[],{positionedChildren:k,containerWidth:_,containerHeight:w}=Sv(y,b,n,s);f[v]={width:_,height:w},h.push(...k)}const p=i.map(v=>{if(v.type==="loopNode"&&f[v.id]){const{width:y,height:b}=f[v.id];return{...v,data:{...v.data,_layoutWidth:y,_layoutHeight:b},style:{...v.style,width:y,height:b}}}return v}),{nodes:m,edges:g}=il(p,d,r);return{nodes:[...m.map(v=>{if(v.type==="loopNode"&&f[v.id]){const{width:y,height:b}=f[v.id];return{...v,width:y,height:b,style:{...v.style,width:y,height:b}}}return v}),...h],edges:[...g,...Object.values(c).flat()]}}function Me(e,t){if(!e)return null;for(const r of e){if(r.taskReferenceName===t)return r;if(r.decisionCases){for(const s of Object.keys(r.decisionCases)){const a=Me(r.decisionCases[s],t);if(a)return a}const n=Me(r.defaultCase,t);if(n)return n}if(r.forkTasks)for(const n of r.forkTasks){const s=Me(n,t);if(s)return s}if(r.loopOver){const n=Me(r.loopOver,t);if(n)return n}}return null}function Ge(e,t){if(!e)return!1;const r=e.findIndex(n=>n.taskReferenceName===t);if(r!==-1)return e.splice(r,1),!0;for(const n of e){if(n.decisionCases){for(const s of Object.keys(n.decisionCases))if(Ge(n.decisionCases[s],t))return!0;if(Ge(n.defaultCase,t))return!0}if(n.forkTasks){for(const s of n.forkTasks)if(Ge(s,t))return!0}if(n.loopOver&&Ge(n.loopOver,t))return!0}return!1}function gt(e,t){if(!e)return null;if(e.some(r=>r.taskReferenceName===t))return e;for(const r of e){if(r.decisionCases){for(const s of Object.values(r.decisionCases)){const a=gt(s,t);if(a)return a}const n=gt(r.defaultCase,t);if(n)return n}if(r.forkTasks)for(const n of r.forkTasks){const s=gt(n,t);if(s)return s}if(r.loopOver){const n=gt(r.loopOver,t);if(n)return n}}return null}function Yh(e,t){const r=e.findIndex(n=>n.taskReferenceName===t);if(r<0)return null;for(let n=r+1;n<e.length;n++)if(e[n].type==="JOIN"||e[n].type==="EXCLUSIVE_JOIN")return e[n].taskReferenceName;return null}function Xh(e,t){const r=e.findIndex(n=>n.taskReferenceName===t);if(r<0)return null;for(let n=r-1;n>=0;n--)if(e[n].type==="FORK_JOIN"||e[n].type==="FORK_JOIN_DYNAMIC")return e[n].taskReferenceName;return null}function Je(e,t,r){if(!e)return!1;if(t==="start")return e.unshift(r),!0;const n=e.findIndex(s=>s.taskReferenceName===t);if(n!==-1)return e.splice(n+1,0,r),!0;for(const s of e){if(s.decisionCases){for(const a of Object.keys(s.decisionCases))if(Je(s.decisionCases[a],t,r))return!0;if(Je(s.defaultCase,t,r))return!0}if(s.forkTasks){for(const a of s.forkTasks)if(Je(a,t,r))return!0}if(s.loopOver&&Je(s.loopOver,t,r))return!0}return!1}function yt(e,t,r,n){for(const s of e||[]){if(s.taskReferenceName===t){if(r.branchCase==="default")return s.defaultCase||(s.defaultCase=[]),s.defaultCase.unshift(n),!0;if(r.branchCase!==void 0)return s.decisionCases||(s.decisionCases={}),s.decisionCases[r.branchCase]||(s.decisionCases[r.branchCase]=[]),s.decisionCases[r.branchCase].unshift(n),!0;if(r.forkIndex!==void 0)return s.forkTasks||(s.forkTasks=[]),s.forkTasks[r.forkIndex].unshift(n),!0;if(r.isLoopAdd)return s.loopOver||(s.loopOver=[]),s.loopOver.unshift(n),!0}if(s.decisionCases){for(const a of Object.keys(s.decisionCases))if(yt(s.decisionCases[a],t,r,n))return!0;if(yt(s.defaultCase,t,r,n))return!0}if(s.forkTasks){for(const a of s.forkTasks)if(yt(a,t,r,n))return!0}if(s.loopOver&&yt(s.loopOver,t,r,n))return!0}return!1}function Le(e){if(e)for(let t=0;t<e.length;t++){const r=e[t];if(r.type==="FORK_JOIN"&&t+1<e.length){const n=e[t+1];if(n.type==="JOIN"){const s=[];(r.forkTasks||[]).forEach(a=>{a&&a.length>0&&s.push(a[a.length-1].taskReferenceName)}),n.joinOn=s}}r.decisionCases&&(Object.values(r.decisionCases).forEach(n=>Le(n)),r.defaultCase&&Le(r.defaultCase)),r.forkTasks&&r.forkTasks.forEach(n=>Le(n)),r.loopOver&&Le(r.loopOver)}}const _v=[{field:"name",type:"required",message:"工作流名称 (name) 必填"},{field:"version",type:"required",message:"工作流版本 (version) 必填"},{field:"tasks",type:"min_length",value:1,message:"工作流必须包含至少一个任务"}],Qh={common:[{field:"name",type:"required",message:"任务类型名称 (name) 必填"},{field:"taskReferenceName",type:"required",message:"引用名 (taskReferenceName) 必填"},{field:"taskReferenceName",type:"pattern",value:/^[a-zA-Z0-9_]+$/,message:"引用名仅允许字母、数字和下划线"},{field:"taskReferenceName",type:"unique",message:"引用名在工作流中必须唯一"}],types:{HTTP:[{field:"inputParameters.http_request.uri",type:"required",message:"HTTP 任务缺少请求地址 (uri) 配置"},{field:"inputParameters.http_request.method",type:"required",level:"warning",message:"HTTP 任务未指定 Method,建议配置"}],INLINE:[{field:"inputParameters.expression",type:"custom",validate:(e,t)=>!!(t?.inputParameters?.expression||t?.inputParameters?.scriptExpression),message:"INLINE 任务缺少脚本表达式 (expression)"}],LAMBDA:[{field:"inputParameters.scriptExpression",type:"required",message:"LAMBDA 任务缺少脚本表达式 (scriptExpression)"}],JSON_JQ_TRANSFORM:[{field:"inputParameters.queryExpression",type:"required",message:"JQ 任务缺少查询表达式 (queryExpression)"}],SUB_WORKFLOW:[{field:"subWorkflowParam.name",type:"required",message:"子工作流任务缺少子流程名称 (name)"}],START_WORKFLOW:[{field:"inputParameters.startWorkflow.name",type:"custom",validate:(e,t)=>!!t?.inputParameters?.startWorkflow?.name,message:"START_WORKFLOW 任务缺少目标工作流名称"}],DYNAMIC:[{field:"dynamicTaskNameParam",type:"required",message:"DYNAMIC 任务缺少 dynamicTaskNameParam 配置"}],TERMINATE:[{field:"inputParameters.terminationStatus",type:"required",level:"warning",message:"终止任务未指定状态 (terminationStatus)"},{field:"inputParameters.terminationStatus",type:"enum",value:["COMPLETED","FAILED"],message:"终止状态必须为 COMPLETED 或 FAILED"}],DO_WHILE:[{field:"loopCondition",type:"custom",validate:(e,t)=>!!(t?.loopCondition||t?.inputParameters?.items),message:"循环任务需要配置退出条件 (loopCondition) 或列表 (items)"}],DECISION:[{field:"decisionCases",type:"custom",validate:e=>Object.keys(e||{}).length>0,message:"决策任务必须至少包含一个分支 (decisionCases)"},{field:"decisionCases",type:"custom",validate:e=>{const t=Object.keys(e||{});return new Set(t).size===t.length},message:"决策分支条件不能重复"}],SWITCH:[{field:"decisionCases",type:"custom",validate:e=>Object.keys(e||{}).length>0,message:"Switch 任务必须至少包含一个分支"}],FORK_JOIN_DYNAMIC:[{field:"dynamicForkTasksParam",type:"custom",validate:(e,t)=>!!(t?.dynamicForkTasksParam||t?.forkTaskType||t?.forkTaskWorkflow),message:"FORK_JOIN_DYNAMIC 任务需要配置 dynamicForkTasksParam 或 forkTaskType 或 forkTaskWorkflow",level:"warning"}]}};class wv{rules=[];setRules(t){this.rules=[...t]}getRules(){return this.rules}hasRules(){return this.rules.length>0}runAll(t){const r=[],n=[];for(const s of this.rules)try{const a=s.validate(t);for(const i of a)s.level==="warning"?n.push(i):r.push(i)}catch{r.push({type:"GLOBAL",ref:"",message:`自定义规则 "${s.id}" 执行异常`})}return{errors:r,warnings:n}}buildPromptSection(){return this.rules.length===0?null:`## 业务校验规则(必须遵守)
|
|
6
|
+
<%s key={someKey} {...props} />`,A,H,X,H),F[H+A]=!0)}if(H=null,Z!==void 0&&(r(Z),H=""+Z),i(J)&&(r(J.key),H=""+J.key),"key"in J){Z={};for(var ie in J)ie!=="key"&&(Z[ie]=J[ie])}else Z=J;return H&&l(Z,typeof O=="function"?O.displayName||O.name||"Unknown":O),u(O,H,Z,s(),B,U)}function p(O){h(O)?O._store&&(O._store.validated=1):typeof O=="object"&&O!==null&&O.$$typeof===L&&(O._payload.status==="fulfilled"?h(O._payload.value)&&O._payload.value._store&&(O._payload.value._store.validated=1):O._store&&(O._store.validated=1))}function h(O){return typeof O=="object"&&O!==null&&O.$$typeof===m}var f=N,m=Symbol.for("react.transitional.element"),g=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),b=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),v=Symbol.for("react.consumer"),k=Symbol.for("react.context"),_=Symbol.for("react.forward_ref"),S=Symbol.for("react.suspense"),j=Symbol.for("react.suspense_list"),R=Symbol.for("react.memo"),L=Symbol.for("react.lazy"),T=Symbol.for("react.activity"),w=Symbol.for("react.client.reference"),D=f.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,E=Object.prototype.hasOwnProperty,C=Array.isArray,z=console.createTask?console.createTask:function(){return null};f={react_stack_bottom_frame:function(O){return O()}};var W,K={},M=f.react_stack_bottom_frame.bind(f,o)(),I=z(n(o)),F={};Nt.Fragment=y,Nt.jsx=function(O,J,Z){var A=1e4>D.recentlyCreatedOwnerStacks++;return d(O,J,Z,!1,A?Error("react-stack-top-frame"):M,A?z(n(O)):I)},Nt.jsxs=function(O,J,Z){var A=1e4>D.recentlyCreatedOwnerStacks++;return d(O,J,Z,!0,A?Error("react-stack-top-frame"):M,A?z(n(O)):I)}})()),Nt}var Ol;function _g(){return Ol||(Ol=1,process.env.NODE_ENV==="production"?Kt.exports=kg():Kt.exports=Sg()),Kt.exports}var a=_g();const Dl=e=>{let t;const r=new Set,n=(u,d)=>{const p=typeof u=="function"?u(t):u;if(!Object.is(p,t)){const h=t;t=d??(typeof p!="object"||p===null)?p:Object.assign({},t,p),r.forEach(f=>f(t,h))}},s=()=>t,l={setState:n,getState:s,getInitialState:()=>c,subscribe:u=>(r.add(u),()=>r.delete(u))},c=t=e(n,s,l);return l},Al=(e=>e?Dl(e):Dl),jg=e=>e;function wr(e,t=jg){const r=N.useSyncExternalStore(e.subscribe,N.useCallback(()=>t(e.getState()),[e,t]),N.useCallback(()=>t(e.getInitialState()),[e,t]));return N.useDebugValue(r),r}const wg=e=>{const t=Al(e),r=n=>wr(t,n);return Object.assign(r,t),r},Ir=(e=>wg);function Tr(e,t){let r;try{r=e()}catch{return}return{getItem:s=>{var o;const i=c=>c===null?null:JSON.parse(c,void 0),l=(o=r.getItem(s))!=null?o:null;return l instanceof Promise?l.then(i):i(l)},setItem:(s,o)=>r.setItem(s,JSON.stringify(o,void 0)),removeItem:s=>r.removeItem(s)}}const Cr=e=>t=>{try{const r=e(t);return r instanceof Promise?r:{then(n){return Cr(n)(r)},catch(n){return this}}}catch(r){return{then(n){return this},catch(n){return Cr(n)(r)}}}},Ll=(e,t)=>(r,n,s)=>{let o={storage:Tr(()=>localStorage),partialize:g=>g,version:0,merge:(g,y)=>({...y,...g}),...t},i=!1;const l=new Set,c=new Set;let u=o.storage;if(!u)return e((...g)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),r(...g)},n,s);const d=()=>{const g=o.partialize({...n()});return u.setItem(o.name,{state:g,version:o.version})},p=s.setState;s.setState=(g,y)=>(p(g,y),d());const h=e((...g)=>(r(...g),d()),n,s);s.getInitialState=()=>h;let f;const m=()=>{var g,y;if(!u)return;i=!1,l.forEach(x=>{var v;return x((v=n())!=null?v:h)});const b=((y=o.onRehydrateStorage)==null?void 0:y.call(o,(g=n())!=null?g:h))||void 0;return Cr(u.getItem.bind(u))(o.name).then(x=>{if(x)if(typeof x.version=="number"&&x.version!==o.version){if(o.migrate){const v=o.migrate(x.state,x.version);return v instanceof Promise?v.then(k=>[!0,k]):[!0,v]}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 v;const[k,_]=x;if(f=o.merge(_,(v=n())!=null?v:h),r(f,!0),k)return d()}).then(()=>{b?.(f,void 0),f=n(),i=!0,c.forEach(x=>x(f))}).catch(x=>{b?.(void 0,x)})};return s.persist={setOptions:g=>{o={...o,...g},g.storage&&(u=g.storage)},clearStorage:()=>{u?.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>m(),hasHydrated:()=>i,onHydrate:g=>(l.add(g),()=>{l.delete(g)}),onFinishHydration:g=>(c.add(g),()=>{c.delete(g)})},o.skipHydration||m(),f||h};var Ml=(e,t,r)=>(s,o)=>({pastStates:r?.pastStates||[],futureStates:r?.futureStates||[],undo:(i=1)=>{if(o().pastStates.length){const l=r?.partialize?.(t())||t(),c=o().pastStates.splice(-i,i),u=c.shift();e(u),s({pastStates:o().pastStates,futureStates:o().futureStates.concat(r?.diff?.(l,u)||l,c.reverse())})}},redo:(i=1)=>{if(o().futureStates.length){const l=r?.partialize?.(t())||t(),c=o().futureStates.splice(-i,i),u=c.shift();e(u),s({pastStates:o().pastStates.concat(r?.diff?.(l,u)||l,c.reverse()),futureStates:o().futureStates})}},clear:()=>s({pastStates:[],futureStates:[]}),isTracking:!0,pause:()=>s({isTracking:!1}),resume:()=>s({isTracking:!0}),setOnSave:i=>s({_onSave:i}),_onSave:r?.onSave,_handleSet:(i,l,c,u)=>{r?.limit&&o().pastStates.length>=r?.limit&&o().pastStates.shift(),o()._onSave?.(i,c),s({pastStates:o().pastStates.concat(u||i),futureStates:[]})}}),Ig=(e,t)=>(n,s,o)=>{o.temporal=Al(t?.wrapTemporal?.(Ml(n,s,t))||Ml(n,s,t));const i=t?.handleSet?.(o.temporal.getState()._handleSet)||o.temporal.getState()._handleSet,l=u=>{if(!o.temporal.getState().isTracking)return;const d=t?.partialize?.(s())||s(),p=t?.diff?.(u,d);p===null||t?.equality?.(u,d)||i(u,void 0,d,p)},c=o.setState;return o.setState=(...u)=>{const d=t?.partialize?.(s())||s();c(...u),l(d)},e((...u)=>{const d=t?.partialize?.(s())||s();n(...u),l(d)},s,o)};function Tg(e,t="TB",r){const n=r?.hideEmptyBranches??!1;if(!e||!e.tasks)return{nodes:[],edges:[],taskMap:{}};const s=[],o=[],i={};let l=0;const c=e.tasks;for(let u=0;u<c.length;u++){const d=c[u],p=ql(d,l,i,t,c,n);if(s.push(...p.nodes),o.push(...p.edges),l=p.nextId,u>0){const h=c[u-1];Nr(h,d,o,n)}Object.assign(i,p.taskMap)}if(!n&&c.length>0){const u=c[0],d="__workflow_start__";s.push({id:d,type:"plusNode",data:{label:"+",taskReferenceName:d,taskType:"PLUS",parentRef:d,edgeData:{isWorkflowStart:!0},layoutDirection:t},position:{x:0,y:0},sourcePosition:t==="LR"?q.Position.Right:q.Position.Bottom,targetPosition:t==="LR"?q.Position.Left:q.Position.Top}),o.push({id:`e-${d}-${u.taskReferenceName}`,source:d,target:u.taskReferenceName,animated:!0});const p=c[c.length-1],h="__workflow_end__";s.push({id:h,type:"plusNode",data:{label:"+",taskReferenceName:h,taskType:"PLUS",parentRef:p.taskReferenceName,layoutDirection:t},position:{x:0,y:0},sourcePosition:t==="LR"?q.Position.Right:q.Position.Bottom,targetPosition:t==="LR"?q.Position.Left:q.Position.Top}),Nr(p,{taskReferenceName:h},o,n)}return{nodes:s,edges:o,taskMap:i}}function ql(e,t,r,n="TB",s=[],o=!1){switch(e.type||"SIMPLE"){case"DECISION":case"SWITCH":return Ng(e,t,r,n,o);case"FORK_JOIN":case"FORK_JOIN_DYNAMIC":return Rg(e,t,r,n);case"JOIN":case"EXCLUSIVE_JOIN":return Og(e,t,r,n,s,o);case"DO_WHILE":return Eg(e,t,r,n,o);case"SUB_WORKFLOW":return Pg(e,t,r,n);default:return Cg(e,t,r,n)}}function Cg(e,t,r,n="TB"){const s={id:e.taskReferenceName,type:"taskNode",data:{label:e.name,taskReferenceName:e.taskReferenceName,taskType:e.type||"SIMPLE",task:e,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?q.Position.Right:q.Position.Bottom,targetPosition:n==="LR"?q.Position.Left:q.Position.Top},o={[e.taskReferenceName]:e};return{nodes:[s],edges:[],taskMap:o,nextId:t+1}}function Ng(e,t,r,n="TB",s=!1){const o=[],i=[];let l=t;const c={},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"?q.Position.Right:q.Position.Bottom,targetPosition:n==="LR"?q.Position.Left:q.Position.Top};o.push(u),c[e.taskReferenceName]=e;const d=e.decisionCases||{},p=e.defaultCase||[],h=Object.keys(d),f=(m,g)=>{if(n==="TB"){if(m===0&&g>1)return"left";if(m===1&&g>2)return"right"}else{if(m===0&&g>1)return"top";if(m===1&&g>2)return"bottom"}return null};if(h.forEach((m,g)=>{const y=d[m],b=f(g,h.length+1);if(y&&y.length>0){const x=Vt(y,l,{...r,...c},n,s);o.push(...x.nodes),i.push(...x.edges),Object.assign(c,x.taskMap),l=x.nextId;const v=y[0].taskReferenceName;i.push({id:`e-${e.taskReferenceName}-${v}`,source:e.taskReferenceName,sourceHandle:b||void 0,target:v,label:m,animated:!0,data:{branchCase:m},style:{stroke:"#3b82f6"}})}else if(!s){const x=`${e.taskReferenceName}_empty_${m}`;o.push({id:x,type:"plusNode",data:{label:`${m} (空)`,parentRef:e.taskReferenceName,edgeData:{branchCase:m},layoutDirection:n,taskReferenceName:x,taskType:"EMPTY_BRANCH"},position:{x:0,y:0},sourcePosition:n==="LR"?q.Position.Right:q.Position.Bottom,targetPosition:n==="LR"?q.Position.Left:q.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}-${x}`,source:e.taskReferenceName,sourceHandle:b||void 0,target:x,label:m,animated:!0,data:{branchCase:m},style:{stroke:"#3b82f6",strokeDasharray:"5,5"}})}}),p&&p.length>0){const m=Vt(p,l,{...r,...c},n,s);o.push(...m.nodes),i.push(...m.edges),Object.assign(c,m.taskMap),l=m.nextId;const g=p[0].taskReferenceName;i.push({id:`e-${e.taskReferenceName}-${g}`,source:e.taskReferenceName,target:g,label:"default",animated:!0,data:{branchCase:"default"},style:{stroke:"#f59e0b"}})}else if(!s){const m=`${e.taskReferenceName}_empty_default`;o.push({id:m,type:"plusNode",data:{label:"default (空)",parentRef:e.taskReferenceName,edgeData:{branchCase:"default"},layoutDirection:n,taskReferenceName:m,taskType:"EMPTY_BRANCH"},position:{x:0,y:0},sourcePosition:n==="LR"?q.Position.Right:q.Position.Bottom,targetPosition:n==="LR"?q.Position.Left:q.Position.Top,style:{background:"transparent",border:"2px dashed var(--border-secondary, #64748b)",borderRadius:"8px",padding:"6px 12px",fontSize:"11px",color:"var(--text-tertiary, #94a3b8)",minWidth:"80px",textAlign:"center"}}),i.push({id:`e-${e.taskReferenceName}-${m}`,source:e.taskReferenceName,target:m,label:"default",animated:!0,data:{branchCase:"default"},style:{stroke:"#f59e0b",strokeDasharray:"5,5"}})}return{nodes:o,edges:i,taskMap:c,nextId:l}}function Rg(e,t,r,n="TB"){const s=[],o=[];let i=t;const l={},c=e.type==="FORK_JOIN_DYNAMIC",u={id:e.taskReferenceName,type:"forkNode",data:{label:e.name,taskReferenceName:e.taskReferenceName,taskType:e.type,task:e,isDynamic:c,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?q.Position.Right:q.Position.Bottom,targetPosition:n==="LR"?q.Position.Left:q.Position.Top};if(s.push(u),l[e.taskReferenceName]=e,c){const d=`${e.taskReferenceName}_dynamic_placeholder`;s.push({id:d,type:"dynamicPlaceholderNode",data:{label:"动态分支",taskReferenceName:d,taskType:"DYNAMIC_PLACEHOLDER",layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?q.Position.Right:q.Position.Bottom,targetPosition:n==="LR"?q.Position.Left:q.Position.Top}),o.push({id:`e-${e.taskReferenceName}-${d}`,source:e.taskReferenceName,target:d,animated:!0,style:{stroke:"#10b981",strokeDasharray:"5,5",strokeWidth:2}}),l[d]={taskReferenceName:d,type:"DYNAMIC_PLACEHOLDER"}}return c||(e.forkTasks||[]).forEach((p,h)=>{if(p&&p.length>0){const f=Vt(p,i,{...r,...l},n,!1);s.push(...f.nodes),o.push(...f.edges),Object.assign(l,f.taskMap),i=f.nextId;const m=p[0].taskReferenceName;o.push({id:`e-${e.taskReferenceName}-${m}`,source:e.taskReferenceName,sourceHandle:`branch_${h}`,target:m,label:`分支 ${h+1}`,animated:!0,data:{forkIndex:h},style:{stroke:"#10b981"}})}}),{nodes:s,edges:o,taskMap:l,nextId:i}}function Eg(e,t,r,n="TB",s=!1){const o={},i=e.taskReferenceName,l={id:i,type:"loopNode",data:{label:e.name,taskReferenceName:i,taskType:e.type,task:e,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?q.Position.Right:q.Position.Bottom,targetPosition:n==="LR"?q.Position.Left:q.Position.Top,style:{pointerEvents:"none"}};o[i]=e;const c=e.loopOver||[],u=[],d=[];let p=t+1;if(c.length>0){const h=Vt(c,p,{...r,...o},n,s);if(p=h.nextId,Object.assign(o,h.taskMap),h.nodes.forEach(f=>{u.push({...f,parentId:f.parentId??i,extent:f.parentId?f.extent:"parent"})}),d.push(...h.edges),!s){const f=c[0],m=`__loop_start__${i}`;u.push({id:m,type:"plusNode",parentId:i,extent:"parent",data:{label:"+",taskReferenceName:m,taskType:"PLUS",parentRef:i,edgeData:{isLoopBodyStart:!0,loopId:i},layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?q.Position.Right:q.Position.Bottom,targetPosition:n==="LR"?q.Position.Left:q.Position.Top}),d.push({id:`e-${m}-${f.taskReferenceName}`,source:m,target:f.taskReferenceName,animated:!0})}if(!s){const f=c[c.length-1],m=`__loop_end__${i}`;u.push({id:m,type:"plusNode",parentId:i,extent:"parent",data:{label:"+",taskReferenceName:m,taskType:"PLUS",parentRef:f.taskReferenceName,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?q.Position.Right:q.Position.Bottom,targetPosition:n==="LR"?q.Position.Left:q.Position.Top}),d.push({id:`e-${f.taskReferenceName}-${m}`,source:f.taskReferenceName,target:m,animated:!0})}}else if(!s){const h=`${i}_loop_empty_plus`;u.push({id:h,type:"plusNode",parentId:i,extent:"parent",data:{label:"+ 添加",taskReferenceName:h,taskType:"PLUS",parentRef:i,edgeData:{isLoopAdd:!0},layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?q.Position.Right:q.Position.Bottom,targetPosition:n==="LR"?q.Position.Left:q.Position.Top})}return{nodes:[l,...u],edges:d,taskMap:o,nextId:p}}function Pg(e,t,r,n="TB"){const s={id:e.taskReferenceName,type:"subWorkflowNode",data:{label:e.name,taskReferenceName:e.taskReferenceName,taskType:e.type,task:e,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?q.Position.Right:q.Position.Bottom,targetPosition:n==="LR"?q.Position.Left:q.Position.Top},o={[e.taskReferenceName]:e};return{nodes:[s],edges:[],taskMap:o,nextId:t+1}}function Og(e,t,r,n="TB",s=[],o=!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"?q.Position.Right:q.Position.Bottom,targetPosition:n==="LR"?q.Position.Left:q.Position.Top},l={[e.taskReferenceName]:e},c=[],u=[];(e.joinOn||[]).forEach(h=>{const f=s.find(m=>m.taskReferenceName===h)||r[h];f&&Gt(f,o).forEach(g=>{u.push({id:`e-${g}-${e.taskReferenceName}`,source:g,target:e.taskReferenceName,animated:!0})})});const p=s.findIndex(h=>h.taskReferenceName===e.taskReferenceName);if(p>0){const h=s[p-1];if(h.type==="FORK_JOIN_DYNAMIC"){const f=`${h.taskReferenceName}_dynamic_placeholder`;u.push({id:`e-${f}-${e.taskReferenceName}-dynamic`,source:f,target:e.taskReferenceName,animated:!0,style:{stroke:"#10b981",strokeWidth:2,strokeDasharray:"5,5",opacity:.8}})}else h.type==="FORK_JOIN"&&(h.forkTasks||[]).forEach((m,g)=>{if((!m||m.length===0)&&!o){const y=`${h.taskReferenceName}_empty_branch_${g}`;c.push({id:y,type:"default",data:{label:`分支 ${g+1} (空)`,layoutDirection:n,taskReferenceName:y,taskType:"EMPTY_BRANCH"},position:{x:0,y:0},sourcePosition:n==="LR"?q.Position.Right:q.Position.Bottom,targetPosition:n==="LR"?q.Position.Left:q.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-${h.taskReferenceName}-${y}`,source:h.taskReferenceName,sourceHandle:`branch_${g}`,target:y,label:`分支 ${g+1}`,animated:!0,data:{forkIndex:g},style:{stroke:"#10b981",strokeDasharray:"5,5"}}),u.push({id:`e-${y}-${e.taskReferenceName}`,source:y,target:e.taskReferenceName,animated:!0,style:{strokeDasharray:"5,5"}})}})}return{nodes:[i,...c],edges:u,taskMap:l,nextId:t+1}}function Vt(e,t,r,n="TB",s=!1){const o=[],i=[];let l=t;const c={};for(let u=0;u<e.length;u++){const d=e[u],p={...r,...c},h=ql(d,l,p,n,e,s);if(o.push(...h.nodes),i.push(...h.edges),Object.assign(c,h.taskMap),l=h.nextId,u>0){const f=e[u-1];Nr(f,d,i,s)}}return{nodes:o,edges:i,taskMap:c,nextId:l}}function Nr(e,t,r,n=!1){if(e.type==="FORK_JOIN"||e.type==="FORK_JOIN_DYNAMIC")return;const s=Gt(e,n),o=t.taskReferenceName;s.forEach(i=>{const l=`e-${i}-${o}`;r.find(c=>c.id===l)||r.push({id:l,source:i,target:o,animated:!0})})}function Gt(e,t=!1){const r=e.type||"SIMPLE";if(r==="DECISION"||r==="SWITCH"){const n=[],s=e.decisionCases||{},o=e.defaultCase||[];if(Object.entries(s).forEach(([i,l])=>{if(l&&l.length>0){const c=l[l.length-1];n.push(...Gt(c,t))}else t||n.push(`${e.taskReferenceName}_empty_${i}`)}),o.length>0){const i=o[o.length-1];n.push(...Gt(i,t))}else t||n.push(`${e.taskReferenceName}_empty_default`);return n.length>0?n:[e.taskReferenceName]}return[e.taskReferenceName]}const De=Tg;function Rr(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 Er,zl;function Dg(){if(zl)return Er;zl=1;function e(){this.__data__=[],this.size=0}return Er=e,Er}var Pr,$l;function ft(){if($l)return Pr;$l=1;function e(t,r){return t===r||t!==t&&r!==r}return Pr=e,Pr}var Or,Wl;function Yt(){if(Wl)return Or;Wl=1;var e=ft();function t(r,n){for(var s=r.length;s--;)if(e(r[s][0],n))return s;return-1}return Or=t,Or}var Dr,Fl;function Ag(){if(Fl)return Dr;Fl=1;var e=Yt(),t=Array.prototype,r=t.splice;function n(s){var o=this.__data__,i=e(o,s);if(i<0)return!1;var l=o.length-1;return i==l?o.pop():r.call(o,i,1),--this.size,!0}return Dr=n,Dr}var Ar,Bl;function Lg(){if(Bl)return Ar;Bl=1;var e=Yt();function t(r){var n=this.__data__,s=e(n,r);return s<0?void 0:n[s][1]}return Ar=t,Ar}var Lr,Hl;function Mg(){if(Hl)return Lr;Hl=1;var e=Yt();function t(r){return e(this.__data__,r)>-1}return Lr=t,Lr}var Mr,Ul;function qg(){if(Ul)return Mr;Ul=1;var e=Yt();function t(r,n){var s=this.__data__,o=e(s,r);return o<0?(++this.size,s.push([r,n])):s[o][1]=n,this}return Mr=t,Mr}var qr,Jl;function Xt(){if(Jl)return qr;Jl=1;var e=Dg(),t=Ag(),r=Lg(),n=Mg(),s=qg();function o(i){var l=-1,c=i==null?0:i.length;for(this.clear();++l<c;){var u=i[l];this.set(u[0],u[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=r,o.prototype.has=n,o.prototype.set=s,qr=o,qr}var zr,Kl;function zg(){if(Kl)return zr;Kl=1;var e=Xt();function t(){this.__data__=new e,this.size=0}return zr=t,zr}var $r,Vl;function $g(){if(Vl)return $r;Vl=1;function e(t){var r=this.__data__,n=r.delete(t);return this.size=r.size,n}return $r=e,$r}var Wr,Gl;function Wg(){if(Gl)return Wr;Gl=1;function e(t){return this.__data__.get(t)}return Wr=e,Wr}var Fr,Yl;function Fg(){if(Yl)return Fr;Yl=1;function e(t){return this.__data__.has(t)}return Fr=e,Fr}var Br,Xl;function Zl(){if(Xl)return Br;Xl=1;var e=typeof Jt=="object"&&Jt&&Jt.Object===Object&&Jt;return Br=e,Br}var Hr,Ql;function He(){if(Ql)return Hr;Ql=1;var e=Zl(),t=typeof self=="object"&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return Hr=r,Hr}var Ur,ec;function ht(){if(ec)return Ur;ec=1;var e=He(),t=e.Symbol;return Ur=t,Ur}var Jr,tc;function Bg(){if(tc)return Jr;tc=1;var e=ht(),t=Object.prototype,r=t.hasOwnProperty,n=t.toString,s=e?e.toStringTag:void 0;function o(i){var l=r.call(i,s),c=i[s];try{i[s]=void 0;var u=!0}catch{}var d=n.call(i);return u&&(l?i[s]=c:delete i[s]),d}return Jr=o,Jr}var Kr,rc;function Hg(){if(rc)return Kr;rc=1;var e=Object.prototype,t=e.toString;function r(n){return t.call(n)}return Kr=r,Kr}var Vr,nc;function ot(){if(nc)return Vr;nc=1;var e=ht(),t=Bg(),r=Hg(),n="[object Null]",s="[object Undefined]",o=e?e.toStringTag:void 0;function i(l){return l==null?l===void 0?s:n:o&&o in Object(l)?t(l):r(l)}return Vr=i,Vr}var Gr,ac;function ze(){if(ac)return Gr;ac=1;function e(t){var r=typeof t;return t!=null&&(r=="object"||r=="function")}return Gr=e,Gr}var Yr,sc;function Rt(){if(sc)return Yr;sc=1;var e=ot(),t=ze(),r="[object AsyncFunction]",n="[object Function]",s="[object GeneratorFunction]",o="[object Proxy]";function i(l){if(!t(l))return!1;var c=e(l);return c==n||c==s||c==r||c==o}return Yr=i,Yr}var Xr,oc;function Ug(){if(oc)return Xr;oc=1;var e=He(),t=e["__core-js_shared__"];return Xr=t,Xr}var Zr,ic;function Jg(){if(ic)return Zr;ic=1;var e=Ug(),t=(function(){var n=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""})();function r(n){return!!t&&t in n}return Zr=r,Zr}var Qr,lc;function cc(){if(lc)return Qr;lc=1;var e=Function.prototype,t=e.toString;function r(n){if(n!=null){try{return t.call(n)}catch{}try{return n+""}catch{}}return""}return Qr=r,Qr}var en,dc;function Kg(){if(dc)return en;dc=1;var e=Rt(),t=Jg(),r=ze(),n=cc(),s=/[\\^$.*+?()[\]{}|]/g,o=/^\[object .+?Constructor\]$/,i=Function.prototype,l=Object.prototype,c=i.toString,u=l.hasOwnProperty,d=RegExp("^"+c.call(u).replace(s,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function p(h){if(!r(h)||t(h))return!1;var f=e(h)?d:o;return f.test(n(h))}return en=p,en}var tn,uc;function Vg(){if(uc)return tn;uc=1;function e(t,r){return t?.[r]}return tn=e,tn}var rn,pc;function it(){if(pc)return rn;pc=1;var e=Kg(),t=Vg();function r(n,s){var o=t(n,s);return e(o)?o:void 0}return rn=r,rn}var nn,fc;function an(){if(fc)return nn;fc=1;var e=it(),t=He(),r=e(t,"Map");return nn=r,nn}var sn,hc;function Zt(){if(hc)return sn;hc=1;var e=it(),t=e(Object,"create");return sn=t,sn}var on,mc;function Gg(){if(mc)return on;mc=1;var e=Zt();function t(){this.__data__=e?e(null):{},this.size=0}return on=t,on}var ln,gc;function Yg(){if(gc)return ln;gc=1;function e(t){var r=this.has(t)&&delete this.__data__[t];return this.size-=r?1:0,r}return ln=e,ln}var cn,yc;function Xg(){if(yc)return cn;yc=1;var e=Zt(),t="__lodash_hash_undefined__",r=Object.prototype,n=r.hasOwnProperty;function s(o){var i=this.__data__;if(e){var l=i[o];return l===t?void 0:l}return n.call(i,o)?i[o]:void 0}return cn=s,cn}var dn,xc;function Zg(){if(xc)return dn;xc=1;var e=Zt(),t=Object.prototype,r=t.hasOwnProperty;function n(s){var o=this.__data__;return e?o[s]!==void 0:r.call(o,s)}return dn=n,dn}var un,bc;function Qg(){if(bc)return un;bc=1;var e=Zt(),t="__lodash_hash_undefined__";function r(n,s){var o=this.__data__;return this.size+=this.has(n)?0:1,o[n]=e&&s===void 0?t:s,this}return un=r,un}var pn,vc;function ey(){if(vc)return pn;vc=1;var e=Gg(),t=Yg(),r=Xg(),n=Zg(),s=Qg();function o(i){var l=-1,c=i==null?0:i.length;for(this.clear();++l<c;){var u=i[l];this.set(u[0],u[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=r,o.prototype.has=n,o.prototype.set=s,pn=o,pn}var fn,kc;function ty(){if(kc)return fn;kc=1;var e=ey(),t=Xt(),r=an();function n(){this.size=0,this.__data__={hash:new e,map:new(r||t),string:new e}}return fn=n,fn}var hn,Sc;function ry(){if(Sc)return hn;Sc=1;function e(t){var r=typeof t;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?t!=="__proto__":t===null}return hn=e,hn}var mn,_c;function Qt(){if(_c)return mn;_c=1;var e=ry();function t(r,n){var s=r.__data__;return e(n)?s[typeof n=="string"?"string":"hash"]:s.map}return mn=t,mn}var gn,jc;function ny(){if(jc)return gn;jc=1;var e=Qt();function t(r){var n=e(this,r).delete(r);return this.size-=n?1:0,n}return gn=t,gn}var yn,wc;function ay(){if(wc)return yn;wc=1;var e=Qt();function t(r){return e(this,r).get(r)}return yn=t,yn}var xn,Ic;function sy(){if(Ic)return xn;Ic=1;var e=Qt();function t(r){return e(this,r).has(r)}return xn=t,xn}var bn,Tc;function oy(){if(Tc)return bn;Tc=1;var e=Qt();function t(r,n){var s=e(this,r),o=s.size;return s.set(r,n),this.size+=s.size==o?0:1,this}return bn=t,bn}var vn,Cc;function kn(){if(Cc)return vn;Cc=1;var e=ty(),t=ny(),r=ay(),n=sy(),s=oy();function o(i){var l=-1,c=i==null?0:i.length;for(this.clear();++l<c;){var u=i[l];this.set(u[0],u[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=r,o.prototype.has=n,o.prototype.set=s,vn=o,vn}var Sn,Nc;function iy(){if(Nc)return Sn;Nc=1;var e=Xt(),t=an(),r=kn(),n=200;function s(o,i){var l=this.__data__;if(l instanceof e){var c=l.__data__;if(!t||c.length<n-1)return c.push([o,i]),this.size=++l.size,this;l=this.__data__=new r(c)}return l.set(o,i),this.size=l.size,this}return Sn=s,Sn}var _n,Rc;function er(){if(Rc)return _n;Rc=1;var e=Xt(),t=zg(),r=$g(),n=Wg(),s=Fg(),o=iy();function i(l){var c=this.__data__=new e(l);this.size=c.size}return i.prototype.clear=t,i.prototype.delete=r,i.prototype.get=n,i.prototype.has=s,i.prototype.set=o,_n=i,_n}var jn,Ec;function wn(){if(Ec)return jn;Ec=1;function e(t,r){for(var n=-1,s=t==null?0:t.length;++n<s&&r(t[n],n,t)!==!1;);return t}return jn=e,jn}var In,Pc;function Oc(){if(Pc)return In;Pc=1;var e=it(),t=(function(){try{var r=e(Object,"defineProperty");return r({},"",{}),r}catch{}})();return In=t,In}var Tn,Dc;function tr(){if(Dc)return Tn;Dc=1;var e=Oc();function t(r,n,s){n=="__proto__"&&e?e(r,n,{configurable:!0,enumerable:!0,value:s,writable:!0}):r[n]=s}return Tn=t,Tn}var Cn,Ac;function rr(){if(Ac)return Cn;Ac=1;var e=tr(),t=ft(),r=Object.prototype,n=r.hasOwnProperty;function s(o,i,l){var c=o[i];(!(n.call(o,i)&&t(c,l))||l===void 0&&!(i in o))&&e(o,i,l)}return Cn=s,Cn}var Nn,Lc;function Et(){if(Lc)return Nn;Lc=1;var e=rr(),t=tr();function r(n,s,o,i){var l=!o;o||(o={});for(var c=-1,u=s.length;++c<u;){var d=s[c],p=i?i(o[d],n[d],d,o,n):void 0;p===void 0&&(p=n[d]),l?t(o,d,p):e(o,d,p)}return o}return Nn=r,Nn}var Rn,Mc;function ly(){if(Mc)return Rn;Mc=1;function e(t,r){for(var n=-1,s=Array(t);++n<t;)s[n]=r(n);return s}return Rn=e,Rn}var En,qc;function Ve(){if(qc)return En;qc=1;function e(t){return t!=null&&typeof t=="object"}return En=e,En}var Pn,zc;function cy(){if(zc)return Pn;zc=1;var e=ot(),t=Ve(),r="[object Arguments]";function n(s){return t(s)&&e(s)==r}return Pn=n,Pn}var On,$c;function Pt(){if($c)return On;$c=1;var e=cy(),t=Ve(),r=Object.prototype,n=r.hasOwnProperty,s=r.propertyIsEnumerable,o=e((function(){return arguments})())?e:function(i){return t(i)&&n.call(i,"callee")&&!s.call(i,"callee")};return On=o,On}var Dn,Wc;function Ce(){if(Wc)return Dn;Wc=1;var e=Array.isArray;return Dn=e,Dn}var Ot={exports:{}},An,Fc;function dy(){if(Fc)return An;Fc=1;function e(){return!1}return An=e,An}Ot.exports;var Bc;function mt(){return Bc||(Bc=1,(function(e,t){var r=He(),n=dy(),s=t&&!t.nodeType&&t,o=s&&!0&&e&&!e.nodeType&&e,i=o&&o.exports===s,l=i?r.Buffer:void 0,c=l?l.isBuffer:void 0,u=c||n;e.exports=u})(Ot,Ot.exports)),Ot.exports}var Ln,Hc;function nr(){if(Hc)return Ln;Hc=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function r(n,s){var o=typeof n;return s=s??e,!!s&&(o=="number"||o!="symbol"&&t.test(n))&&n>-1&&n%1==0&&n<s}return Ln=r,Ln}var Mn,Uc;function qn(){if(Uc)return Mn;Uc=1;var e=9007199254740991;function t(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=e}return Mn=t,Mn}var zn,Jc;function uy(){if(Jc)return zn;Jc=1;var e=ot(),t=qn(),r=Ve(),n="[object Arguments]",s="[object Array]",o="[object Boolean]",i="[object Date]",l="[object Error]",c="[object Function]",u="[object Map]",d="[object Number]",p="[object Object]",h="[object RegExp]",f="[object Set]",m="[object String]",g="[object WeakMap]",y="[object ArrayBuffer]",b="[object DataView]",x="[object Float32Array]",v="[object Float64Array]",k="[object Int8Array]",_="[object Int16Array]",S="[object Int32Array]",j="[object Uint8Array]",R="[object Uint8ClampedArray]",L="[object Uint16Array]",T="[object Uint32Array]",w={};w[x]=w[v]=w[k]=w[_]=w[S]=w[j]=w[R]=w[L]=w[T]=!0,w[n]=w[s]=w[y]=w[o]=w[b]=w[i]=w[l]=w[c]=w[u]=w[d]=w[p]=w[h]=w[f]=w[m]=w[g]=!1;function D(E){return r(E)&&t(E.length)&&!!w[e(E)]}return zn=D,zn}var $n,Kc;function ar(){if(Kc)return $n;Kc=1;function e(t){return function(r){return t(r)}}return $n=e,$n}var Dt={exports:{}};Dt.exports;var Vc;function Wn(){return Vc||(Vc=1,(function(e,t){var r=Zl(),n=t&&!t.nodeType&&t,s=n&&!0&&e&&!e.nodeType&&e,o=s&&s.exports===n,i=o&&r.process,l=(function(){try{var c=s&&s.require&&s.require("util").types;return c||i&&i.binding&&i.binding("util")}catch{}})();e.exports=l})(Dt,Dt.exports)),Dt.exports}var Fn,Gc;function At(){if(Gc)return Fn;Gc=1;var e=uy(),t=ar(),r=Wn(),n=r&&r.isTypedArray,s=n?t(n):e;return Fn=s,Fn}var Bn,Yc;function Xc(){if(Yc)return Bn;Yc=1;var e=ly(),t=Pt(),r=Ce(),n=mt(),s=nr(),o=At(),i=Object.prototype,l=i.hasOwnProperty;function c(u,d){var p=r(u),h=!p&&t(u),f=!p&&!h&&n(u),m=!p&&!h&&!f&&o(u),g=p||h||f||m,y=g?e(u.length,String):[],b=y.length;for(var x in u)(d||l.call(u,x))&&!(g&&(x=="length"||f&&(x=="offset"||x=="parent")||m&&(x=="buffer"||x=="byteLength"||x=="byteOffset")||s(x,b)))&&y.push(x);return y}return Bn=c,Bn}var Hn,Zc;function sr(){if(Zc)return Hn;Zc=1;var e=Object.prototype;function t(r){var n=r&&r.constructor,s=typeof n=="function"&&n.prototype||e;return r===s}return Hn=t,Hn}var Un,Qc;function ed(){if(Qc)return Un;Qc=1;function e(t,r){return function(n){return t(r(n))}}return Un=e,Un}var Jn,td;function py(){if(td)return Jn;td=1;var e=ed(),t=e(Object.keys,Object);return Jn=t,Jn}var Kn,rd;function Vn(){if(rd)return Kn;rd=1;var e=sr(),t=py(),r=Object.prototype,n=r.hasOwnProperty;function s(o){if(!e(o))return t(o);var i=[];for(var l in Object(o))n.call(o,l)&&l!="constructor"&&i.push(l);return i}return Kn=s,Kn}var Gn,nd;function Xe(){if(nd)return Gn;nd=1;var e=Rt(),t=qn();function r(n){return n!=null&&t(n.length)&&!e(n)}return Gn=r,Gn}var Yn,ad;function tt(){if(ad)return Yn;ad=1;var e=Xc(),t=Vn(),r=Xe();function n(s){return r(s)?e(s):t(s)}return Yn=n,Yn}var Xn,sd;function fy(){if(sd)return Xn;sd=1;var e=Et(),t=tt();function r(n,s){return n&&e(s,t(s),n)}return Xn=r,Xn}var Zn,od;function hy(){if(od)return Zn;od=1;function e(t){var r=[];if(t!=null)for(var n in Object(t))r.push(n);return r}return Zn=e,Zn}var Qn,id;function my(){if(id)return Qn;id=1;var e=ze(),t=sr(),r=hy(),n=Object.prototype,s=n.hasOwnProperty;function o(i){if(!e(i))return r(i);var l=t(i),c=[];for(var u in i)u=="constructor"&&(l||!s.call(i,u))||c.push(u);return c}return Qn=o,Qn}var ea,ld;function lt(){if(ld)return ea;ld=1;var e=Xc(),t=my(),r=Xe();function n(s){return r(s)?e(s,!0):t(s)}return ea=n,ea}var ta,cd;function gy(){if(cd)return ta;cd=1;var e=Et(),t=lt();function r(n,s){return n&&e(s,t(s),n)}return ta=r,ta}var Lt={exports:{}};Lt.exports;var dd;function ud(){return dd||(dd=1,(function(e,t){var r=He(),n=t&&!t.nodeType&&t,s=n&&!0&&e&&!e.nodeType&&e,o=s&&s.exports===n,i=o?r.Buffer:void 0,l=i?i.allocUnsafe:void 0;function c(u,d){if(d)return u.slice();var p=u.length,h=l?l(p):new u.constructor(p);return u.copy(h),h}e.exports=c})(Lt,Lt.exports)),Lt.exports}var ra,pd;function fd(){if(pd)return ra;pd=1;function e(t,r){var n=-1,s=t.length;for(r||(r=Array(s));++n<s;)r[n]=t[n];return r}return ra=e,ra}var na,hd;function md(){if(hd)return na;hd=1;function e(t,r){for(var n=-1,s=t==null?0:t.length,o=0,i=[];++n<s;){var l=t[n];r(l,n,t)&&(i[o++]=l)}return i}return na=e,na}var aa,gd;function yd(){if(gd)return aa;gd=1;function e(){return[]}return aa=e,aa}var sa,xd;function oa(){if(xd)return sa;xd=1;var e=md(),t=yd(),r=Object.prototype,n=r.propertyIsEnumerable,s=Object.getOwnPropertySymbols,o=s?function(i){return i==null?[]:(i=Object(i),e(s(i),function(l){return n.call(i,l)}))}:t;return sa=o,sa}var ia,bd;function yy(){if(bd)return ia;bd=1;var e=Et(),t=oa();function r(n,s){return e(n,t(n),s)}return ia=r,ia}var la,vd;function ca(){if(vd)return la;vd=1;function e(t,r){for(var n=-1,s=r.length,o=t.length;++n<s;)t[o+n]=r[n];return t}return la=e,la}var da,kd;function or(){if(kd)return da;kd=1;var e=ed(),t=e(Object.getPrototypeOf,Object);return da=t,da}var ua,Sd;function _d(){if(Sd)return ua;Sd=1;var e=ca(),t=or(),r=oa(),n=yd(),s=Object.getOwnPropertySymbols,o=s?function(i){for(var l=[];i;)e(l,r(i)),i=t(i);return l}:n;return ua=o,ua}var pa,jd;function xy(){if(jd)return pa;jd=1;var e=Et(),t=_d();function r(n,s){return e(n,t(n),s)}return pa=r,pa}var fa,wd;function Id(){if(wd)return fa;wd=1;var e=ca(),t=Ce();function r(n,s,o){var i=s(n);return t(n)?i:e(i,o(n))}return fa=r,fa}var ha,Td;function Cd(){if(Td)return ha;Td=1;var e=Id(),t=oa(),r=tt();function n(s){return e(s,r,t)}return ha=n,ha}var ma,Nd;function by(){if(Nd)return ma;Nd=1;var e=Id(),t=_d(),r=lt();function n(s){return e(s,r,t)}return ma=n,ma}var ga,Rd;function vy(){if(Rd)return ga;Rd=1;var e=it(),t=He(),r=e(t,"DataView");return ga=r,ga}var ya,Ed;function ky(){if(Ed)return ya;Ed=1;var e=it(),t=He(),r=e(t,"Promise");return ya=r,ya}var xa,Pd;function Od(){if(Pd)return xa;Pd=1;var e=it(),t=He(),r=e(t,"Set");return xa=r,xa}var ba,Dd;function Sy(){if(Dd)return ba;Dd=1;var e=it(),t=He(),r=e(t,"WeakMap");return ba=r,ba}var va,Ad;function gt(){if(Ad)return va;Ad=1;var e=vy(),t=an(),r=ky(),n=Od(),s=Sy(),o=ot(),i=cc(),l="[object Map]",c="[object Object]",u="[object Promise]",d="[object Set]",p="[object WeakMap]",h="[object DataView]",f=i(e),m=i(t),g=i(r),y=i(n),b=i(s),x=o;return(e&&x(new e(new ArrayBuffer(1)))!=h||t&&x(new t)!=l||r&&x(r.resolve())!=u||n&&x(new n)!=d||s&&x(new s)!=p)&&(x=function(v){var k=o(v),_=k==c?v.constructor:void 0,S=_?i(_):"";if(S)switch(S){case f:return h;case m:return l;case g:return u;case y:return d;case b:return p}return k}),va=x,va}var ka,Ld;function _y(){if(Ld)return ka;Ld=1;var e=Object.prototype,t=e.hasOwnProperty;function r(n){var s=n.length,o=new n.constructor(s);return s&&typeof n[0]=="string"&&t.call(n,"index")&&(o.index=n.index,o.input=n.input),o}return ka=r,ka}var Sa,Md;function qd(){if(Md)return Sa;Md=1;var e=He(),t=e.Uint8Array;return Sa=t,Sa}var _a,zd;function ja(){if(zd)return _a;zd=1;var e=qd();function t(r){var n=new r.constructor(r.byteLength);return new e(n).set(new e(r)),n}return _a=t,_a}var wa,$d;function jy(){if($d)return wa;$d=1;var e=ja();function t(r,n){var s=n?e(r.buffer):r.buffer;return new r.constructor(s,r.byteOffset,r.byteLength)}return wa=t,wa}var Ia,Wd;function wy(){if(Wd)return Ia;Wd=1;var e=/\w*$/;function t(r){var n=new r.constructor(r.source,e.exec(r));return n.lastIndex=r.lastIndex,n}return Ia=t,Ia}var Ta,Fd;function Iy(){if(Fd)return Ta;Fd=1;var e=ht(),t=e?e.prototype:void 0,r=t?t.valueOf:void 0;function n(s){return r?Object(r.call(s)):{}}return Ta=n,Ta}var Ca,Bd;function Hd(){if(Bd)return Ca;Bd=1;var e=ja();function t(r,n){var s=n?e(r.buffer):r.buffer;return new r.constructor(s,r.byteOffset,r.length)}return Ca=t,Ca}var Na,Ud;function Ty(){if(Ud)return Na;Ud=1;var e=ja(),t=jy(),r=wy(),n=Iy(),s=Hd(),o="[object Boolean]",i="[object Date]",l="[object Map]",c="[object Number]",u="[object RegExp]",d="[object Set]",p="[object String]",h="[object Symbol]",f="[object ArrayBuffer]",m="[object DataView]",g="[object Float32Array]",y="[object Float64Array]",b="[object Int8Array]",x="[object Int16Array]",v="[object Int32Array]",k="[object Uint8Array]",_="[object Uint8ClampedArray]",S="[object Uint16Array]",j="[object Uint32Array]";function R(L,T,w){var D=L.constructor;switch(T){case f:return e(L);case o:case i:return new D(+L);case m:return t(L,w);case g:case y:case b:case x:case v:case k:case _:case S:case j:return s(L,w);case l:return new D;case c:case p:return new D(L);case u:return r(L);case d:return new D;case h:return n(L)}}return Na=R,Na}var Ra,Jd;function Kd(){if(Jd)return Ra;Jd=1;var e=ze(),t=Object.create,r=(function(){function n(){}return function(s){if(!e(s))return{};if(t)return t(s);n.prototype=s;var o=new n;return n.prototype=void 0,o}})();return Ra=r,Ra}var Ea,Vd;function Gd(){if(Vd)return Ea;Vd=1;var e=Kd(),t=or(),r=sr();function n(s){return typeof s.constructor=="function"&&!r(s)?e(t(s)):{}}return Ea=n,Ea}var Pa,Yd;function Cy(){if(Yd)return Pa;Yd=1;var e=gt(),t=Ve(),r="[object Map]";function n(s){return t(s)&&e(s)==r}return Pa=n,Pa}var Oa,Xd;function Ny(){if(Xd)return Oa;Xd=1;var e=Cy(),t=ar(),r=Wn(),n=r&&r.isMap,s=n?t(n):e;return Oa=s,Oa}var Da,Zd;function Ry(){if(Zd)return Da;Zd=1;var e=gt(),t=Ve(),r="[object Set]";function n(s){return t(s)&&e(s)==r}return Da=n,Da}var Aa,Qd;function Ey(){if(Qd)return Aa;Qd=1;var e=Ry(),t=ar(),r=Wn(),n=r&&r.isSet,s=n?t(n):e;return Aa=s,Aa}var La,eu;function tu(){if(eu)return La;eu=1;var e=er(),t=wn(),r=rr(),n=fy(),s=gy(),o=ud(),i=fd(),l=yy(),c=xy(),u=Cd(),d=by(),p=gt(),h=_y(),f=Ty(),m=Gd(),g=Ce(),y=mt(),b=Ny(),x=ze(),v=Ey(),k=tt(),_=lt(),S=1,j=2,R=4,L="[object Arguments]",T="[object Array]",w="[object Boolean]",D="[object Date]",E="[object Error]",C="[object Function]",z="[object GeneratorFunction]",W="[object Map]",K="[object Number]",M="[object Object]",I="[object RegExp]",F="[object Set]",O="[object String]",J="[object Symbol]",Z="[object WeakMap]",A="[object ArrayBuffer]",B="[object DataView]",U="[object Float32Array]",H="[object Float64Array]",X="[object Int8Array]",ie="[object Int16Array]",ge="[object Int32Array]",Se="[object Uint8Array]",we="[object Uint8ClampedArray]",$="[object Uint16Array]",ke="[object Uint32Array]",te={};te[L]=te[T]=te[A]=te[B]=te[w]=te[D]=te[U]=te[H]=te[X]=te[ie]=te[ge]=te[W]=te[K]=te[M]=te[I]=te[F]=te[O]=te[J]=te[Se]=te[we]=te[$]=te[ke]=!0,te[E]=te[C]=te[Z]=!1;function se(re,ve,ue,pe,Fe,_e){var ye,et=ve&S,Te=ve&j,st=ve&R;if(ue&&(ye=Fe?ue(re,pe,Fe,_e):ue(re)),ye!==void 0)return ye;if(!x(re))return re;var Q=g(re);if(Q){if(ye=h(re),!et)return i(re,ye)}else{var Y=p(re),ne=Y==C||Y==z;if(y(re))return o(re,et);if(Y==M||Y==L||ne&&!Fe){if(ye=Te||ne?{}:m(re),!et)return Te?c(re,s(ye,re)):l(re,n(ye,re))}else{if(!te[Y])return Fe?re:{};ye=f(re,Y,et)}}_e||(_e=new e);var fe=_e.get(re);if(fe)return fe;_e.set(re,ye),v(re)?re.forEach(function(P){ye.add(se(P,ve,ue,P,re,_e))}):b(re)&&re.forEach(function(P,V){ye.set(V,se(P,ve,ue,V,re,_e))});var G=st?Te?d:u:Te?_:k,de=Q?void 0:G(re);return t(de||re,function(P,V){de&&(V=P,P=re[V]),r(ye,V,se(P,ve,ue,V,re,_e))}),ye}return La=se,La}var Ma,ru;function Py(){if(ru)return Ma;ru=1;var e=tu(),t=4;function r(n){return e(n,t)}return Ma=r,Ma}var qa,nu;function za(){if(nu)return qa;nu=1;function e(t){return function(){return t}}return qa=e,qa}var $a,au;function Oy(){if(au)return $a;au=1;function e(t){return function(r,n,s){for(var o=-1,i=Object(r),l=s(r),c=l.length;c--;){var u=l[t?c:++o];if(n(i[u],u,i)===!1)break}return r}}return $a=e,$a}var Wa,su;function Fa(){if(su)return Wa;su=1;var e=Oy(),t=e();return Wa=t,Wa}var Ba,ou;function Ha(){if(ou)return Ba;ou=1;var e=Fa(),t=tt();function r(n,s){return n&&e(n,s,t)}return Ba=r,Ba}var Ua,iu;function Dy(){if(iu)return Ua;iu=1;var e=Xe();function t(r,n){return function(s,o){if(s==null)return s;if(!e(s))return r(s,o);for(var i=s.length,l=n?i:-1,c=Object(s);(n?l--:++l<i)&&o(c[l],l,c)!==!1;);return s}}return Ua=t,Ua}var Ja,lu;function ir(){if(lu)return Ja;lu=1;var e=Ha(),t=Dy(),r=t(e);return Ja=r,Ja}var Ka,cu;function ct(){if(cu)return Ka;cu=1;function e(t){return t}return Ka=e,Ka}var Va,du;function uu(){if(du)return Va;du=1;var e=ct();function t(r){return typeof r=="function"?r:e}return Va=t,Va}var Ga,pu;function fu(){if(pu)return Ga;pu=1;var e=wn(),t=ir(),r=uu(),n=Ce();function s(o,i){var l=n(o)?e:t;return l(o,r(i))}return Ga=s,Ga}var Ya,hu;function mu(){return hu||(hu=1,Ya=fu()),Ya}var Xa,gu;function Ay(){if(gu)return Xa;gu=1;var e=ir();function t(r,n){var s=[];return e(r,function(o,i,l){n(o,i,l)&&s.push(o)}),s}return Xa=t,Xa}var Za,yu;function Ly(){if(yu)return Za;yu=1;var e="__lodash_hash_undefined__";function t(r){return this.__data__.set(r,e),this}return Za=t,Za}var Qa,xu;function My(){if(xu)return Qa;xu=1;function e(t){return this.__data__.has(t)}return Qa=e,Qa}var es,bu;function vu(){if(bu)return es;bu=1;var e=kn(),t=Ly(),r=My();function n(s){var o=-1,i=s==null?0:s.length;for(this.__data__=new e;++o<i;)this.add(s[o])}return n.prototype.add=n.prototype.push=t,n.prototype.has=r,es=n,es}var ts,ku;function qy(){if(ku)return ts;ku=1;function e(t,r){for(var n=-1,s=t==null?0:t.length;++n<s;)if(r(t[n],n,t))return!0;return!1}return ts=e,ts}var rs,Su;function _u(){if(Su)return rs;Su=1;function e(t,r){return t.has(r)}return rs=e,rs}var ns,ju;function wu(){if(ju)return ns;ju=1;var e=vu(),t=qy(),r=_u(),n=1,s=2;function o(i,l,c,u,d,p){var h=c&n,f=i.length,m=l.length;if(f!=m&&!(h&&m>f))return!1;var g=p.get(i),y=p.get(l);if(g&&y)return g==l&&y==i;var b=-1,x=!0,v=c&s?new e:void 0;for(p.set(i,l),p.set(l,i);++b<f;){var k=i[b],_=l[b];if(u)var S=h?u(_,k,b,l,i,p):u(k,_,b,i,l,p);if(S!==void 0){if(S)continue;x=!1;break}if(v){if(!t(l,function(j,R){if(!r(v,R)&&(k===j||d(k,j,c,u,p)))return v.push(R)})){x=!1;break}}else if(!(k===_||d(k,_,c,u,p))){x=!1;break}}return p.delete(i),p.delete(l),x}return ns=o,ns}var as,Iu;function zy(){if(Iu)return as;Iu=1;function e(t){var r=-1,n=Array(t.size);return t.forEach(function(s,o){n[++r]=[o,s]}),n}return as=e,as}var ss,Tu;function os(){if(Tu)return ss;Tu=1;function e(t){var r=-1,n=Array(t.size);return t.forEach(function(s){n[++r]=s}),n}return ss=e,ss}var is,Cu;function $y(){if(Cu)return is;Cu=1;var e=ht(),t=qd(),r=ft(),n=wu(),s=zy(),o=os(),i=1,l=2,c="[object Boolean]",u="[object Date]",d="[object Error]",p="[object Map]",h="[object Number]",f="[object RegExp]",m="[object Set]",g="[object String]",y="[object Symbol]",b="[object ArrayBuffer]",x="[object DataView]",v=e?e.prototype:void 0,k=v?v.valueOf:void 0;function _(S,j,R,L,T,w,D){switch(R){case x:if(S.byteLength!=j.byteLength||S.byteOffset!=j.byteOffset)return!1;S=S.buffer,j=j.buffer;case b:return!(S.byteLength!=j.byteLength||!w(new t(S),new t(j)));case c:case u:case h:return r(+S,+j);case d:return S.name==j.name&&S.message==j.message;case f:case g:return S==j+"";case p:var E=s;case m:var C=L&i;if(E||(E=o),S.size!=j.size&&!C)return!1;var z=D.get(S);if(z)return z==j;L|=l,D.set(S,j);var W=n(E(S),E(j),L,T,w,D);return D.delete(S),W;case y:if(k)return k.call(S)==k.call(j)}return!1}return is=_,is}var ls,Nu;function Wy(){if(Nu)return ls;Nu=1;var e=Cd(),t=1,r=Object.prototype,n=r.hasOwnProperty;function s(o,i,l,c,u,d){var p=l&t,h=e(o),f=h.length,m=e(i),g=m.length;if(f!=g&&!p)return!1;for(var y=f;y--;){var b=h[y];if(!(p?b in i:n.call(i,b)))return!1}var x=d.get(o),v=d.get(i);if(x&&v)return x==i&&v==o;var k=!0;d.set(o,i),d.set(i,o);for(var _=p;++y<f;){b=h[y];var S=o[b],j=i[b];if(c)var R=p?c(j,S,b,i,o,d):c(S,j,b,o,i,d);if(!(R===void 0?S===j||u(S,j,l,c,d):R)){k=!1;break}_||(_=b=="constructor")}if(k&&!_){var L=o.constructor,T=i.constructor;L!=T&&"constructor"in o&&"constructor"in i&&!(typeof L=="function"&&L instanceof L&&typeof T=="function"&&T instanceof T)&&(k=!1)}return d.delete(o),d.delete(i),k}return ls=s,ls}var cs,Ru;function Fy(){if(Ru)return cs;Ru=1;var e=er(),t=wu(),r=$y(),n=Wy(),s=gt(),o=Ce(),i=mt(),l=At(),c=1,u="[object Arguments]",d="[object Array]",p="[object Object]",h=Object.prototype,f=h.hasOwnProperty;function m(g,y,b,x,v,k){var _=o(g),S=o(y),j=_?d:s(g),R=S?d:s(y);j=j==u?p:j,R=R==u?p:R;var L=j==p,T=R==p,w=j==R;if(w&&i(g)){if(!i(y))return!1;_=!0,L=!1}if(w&&!L)return k||(k=new e),_||l(g)?t(g,y,b,x,v,k):r(g,y,j,b,x,v,k);if(!(b&c)){var D=L&&f.call(g,"__wrapped__"),E=T&&f.call(y,"__wrapped__");if(D||E){var C=D?g.value():g,z=E?y.value():y;return k||(k=new e),v(C,z,b,x,k)}}return w?(k||(k=new e),n(g,y,b,x,v,k)):!1}return cs=m,cs}var ds,Eu;function Pu(){if(Eu)return ds;Eu=1;var e=Fy(),t=Ve();function r(n,s,o,i,l){return n===s?!0:n==null||s==null||!t(n)&&!t(s)?n!==n&&s!==s:e(n,s,o,i,r,l)}return ds=r,ds}var us,Ou;function By(){if(Ou)return us;Ou=1;var e=er(),t=Pu(),r=1,n=2;function s(o,i,l,c){var u=l.length,d=u,p=!c;if(o==null)return!d;for(o=Object(o);u--;){var h=l[u];if(p&&h[2]?h[1]!==o[h[0]]:!(h[0]in o))return!1}for(;++u<d;){h=l[u];var f=h[0],m=o[f],g=h[1];if(p&&h[2]){if(m===void 0&&!(f in o))return!1}else{var y=new e;if(c)var b=c(m,g,f,o,i,y);if(!(b===void 0?t(g,m,r|n,c,y):b))return!1}}return!0}return us=s,us}var ps,Du;function Au(){if(Du)return ps;Du=1;var e=ze();function t(r){return r===r&&!e(r)}return ps=t,ps}var fs,Lu;function Hy(){if(Lu)return fs;Lu=1;var e=Au(),t=tt();function r(n){for(var s=t(n),o=s.length;o--;){var i=s[o],l=n[i];s[o]=[i,l,e(l)]}return s}return fs=r,fs}var hs,Mu;function qu(){if(Mu)return hs;Mu=1;function e(t,r){return function(n){return n==null?!1:n[t]===r&&(r!==void 0||t in Object(n))}}return hs=e,hs}var ms,zu;function Uy(){if(zu)return ms;zu=1;var e=By(),t=Hy(),r=qu();function n(s){var o=t(s);return o.length==1&&o[0][2]?r(o[0][0],o[0][1]):function(i){return i===s||e(i,s,o)}}return ms=n,ms}var gs,$u;function yt(){if($u)return gs;$u=1;var e=ot(),t=Ve(),r="[object Symbol]";function n(s){return typeof s=="symbol"||t(s)&&e(s)==r}return gs=n,gs}var ys,Wu;function xs(){if(Wu)return ys;Wu=1;var e=Ce(),t=yt(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;function s(o,i){if(e(o))return!1;var l=typeof o;return l=="number"||l=="symbol"||l=="boolean"||o==null||t(o)?!0:n.test(o)||!r.test(o)||i!=null&&o in Object(i)}return ys=s,ys}var bs,Fu;function Jy(){if(Fu)return bs;Fu=1;var e=kn(),t="Expected a function";function r(n,s){if(typeof n!="function"||s!=null&&typeof s!="function")throw new TypeError(t);var o=function(){var i=arguments,l=s?s.apply(this,i):i[0],c=o.cache;if(c.has(l))return c.get(l);var u=n.apply(this,i);return o.cache=c.set(l,u)||c,u};return o.cache=new(r.Cache||e),o}return r.Cache=e,bs=r,bs}var vs,Bu;function Ky(){if(Bu)return vs;Bu=1;var e=Jy(),t=500;function r(n){var s=e(n,function(i){return o.size===t&&o.clear(),i}),o=s.cache;return s}return vs=r,vs}var ks,Hu;function Vy(){if(Hu)return ks;Hu=1;var e=Ky(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,n=e(function(s){var o=[];return s.charCodeAt(0)===46&&o.push(""),s.replace(t,function(i,l,c,u){o.push(c?u.replace(r,"$1"):l||i)}),o});return ks=n,ks}var Ss,Uu;function lr(){if(Uu)return Ss;Uu=1;function e(t,r){for(var n=-1,s=t==null?0:t.length,o=Array(s);++n<s;)o[n]=r(t[n],n,t);return o}return Ss=e,Ss}var _s,Ju;function Gy(){if(Ju)return _s;Ju=1;var e=ht(),t=lr(),r=Ce(),n=yt(),s=e?e.prototype:void 0,o=s?s.toString:void 0;function i(l){if(typeof l=="string")return l;if(r(l))return t(l,i)+"";if(n(l))return o?o.call(l):"";var c=l+"";return c=="0"&&1/l==-1/0?"-0":c}return _s=i,_s}var js,Ku;function Vu(){if(Ku)return js;Ku=1;var e=Gy();function t(r){return r==null?"":e(r)}return js=t,js}var ws,Gu;function cr(){if(Gu)return ws;Gu=1;var e=Ce(),t=xs(),r=Vy(),n=Vu();function s(o,i){return e(o)?o:t(o,i)?[o]:r(n(o))}return ws=s,ws}var Is,Yu;function Mt(){if(Yu)return Is;Yu=1;var e=yt();function t(r){if(typeof r=="string"||e(r))return r;var n=r+"";return n=="0"&&1/r==-1/0?"-0":n}return Is=t,Is}var Ts,Xu;function dr(){if(Xu)return Ts;Xu=1;var e=cr(),t=Mt();function r(n,s){s=e(s,n);for(var o=0,i=s.length;n!=null&&o<i;)n=n[t(s[o++])];return o&&o==i?n:void 0}return Ts=r,Ts}var Cs,Zu;function Yy(){if(Zu)return Cs;Zu=1;var e=dr();function t(r,n,s){var o=r==null?void 0:e(r,n);return o===void 0?s:o}return Cs=t,Cs}var Ns,Qu;function Xy(){if(Qu)return Ns;Qu=1;function e(t,r){return t!=null&&r in Object(t)}return Ns=e,Ns}var Rs,ep;function tp(){if(ep)return Rs;ep=1;var e=cr(),t=Pt(),r=Ce(),n=nr(),s=qn(),o=Mt();function i(l,c,u){c=e(c,l);for(var d=-1,p=c.length,h=!1;++d<p;){var f=o(c[d]);if(!(h=l!=null&&u(l,f)))break;l=l[f]}return h||++d!=p?h:(p=l==null?0:l.length,!!p&&s(p)&&n(f,p)&&(r(l)||t(l)))}return Rs=i,Rs}var Es,rp;function np(){if(rp)return Es;rp=1;var e=Xy(),t=tp();function r(n,s){return n!=null&&t(n,s,e)}return Es=r,Es}var Ps,ap;function Zy(){if(ap)return Ps;ap=1;var e=Pu(),t=Yy(),r=np(),n=xs(),s=Au(),o=qu(),i=Mt(),l=1,c=2;function u(d,p){return n(d)&&s(p)?o(i(d),p):function(h){var f=t(h,d);return f===void 0&&f===p?r(h,d):e(p,f,l|c)}}return Ps=u,Ps}var Os,sp;function op(){if(sp)return Os;sp=1;function e(t){return function(r){return r?.[t]}}return Os=e,Os}var Ds,ip;function Qy(){if(ip)return Ds;ip=1;var e=dr();function t(r){return function(n){return e(n,r)}}return Ds=t,Ds}var As,lp;function ex(){if(lp)return As;lp=1;var e=op(),t=Qy(),r=xs(),n=Mt();function s(o){return r(o)?e(n(o)):t(o)}return As=s,As}var Ls,cp;function Ze(){if(cp)return Ls;cp=1;var e=Uy(),t=Zy(),r=ct(),n=Ce(),s=ex();function o(i){return typeof i=="function"?i:i==null?r:typeof i=="object"?n(i)?t(i[0],i[1]):e(i):s(i)}return Ls=o,Ls}var Ms,dp;function up(){if(dp)return Ms;dp=1;var e=md(),t=Ay(),r=Ze(),n=Ce();function s(o,i){var l=n(o)?e:t;return l(o,r(i,3))}return Ms=s,Ms}var qs,pp;function tx(){if(pp)return qs;pp=1;var e=Object.prototype,t=e.hasOwnProperty;function r(n,s){return n!=null&&t.call(n,s)}return qs=r,qs}var zs,fp;function hp(){if(fp)return zs;fp=1;var e=tx(),t=tp();function r(n,s){return n!=null&&t(n,s,e)}return zs=r,zs}var $s,mp;function rx(){if(mp)return $s;mp=1;var e=Vn(),t=gt(),r=Pt(),n=Ce(),s=Xe(),o=mt(),i=sr(),l=At(),c="[object Map]",u="[object Set]",d=Object.prototype,p=d.hasOwnProperty;function h(f){if(f==null)return!0;if(s(f)&&(n(f)||typeof f=="string"||typeof f.splice=="function"||o(f)||l(f)||r(f)))return!f.length;var m=t(f);if(m==c||m==u)return!f.size;if(i(f))return!e(f).length;for(var g in f)if(p.call(f,g))return!1;return!0}return $s=h,$s}var Ws,gp;function yp(){if(gp)return Ws;gp=1;function e(t){return t===void 0}return Ws=e,Ws}var Fs,xp;function bp(){if(xp)return Fs;xp=1;var e=ir(),t=Xe();function r(n,s){var o=-1,i=t(n)?Array(n.length):[];return e(n,function(l,c,u){i[++o]=s(l,c,u)}),i}return Fs=r,Fs}var Bs,vp;function kp(){if(vp)return Bs;vp=1;var e=lr(),t=Ze(),r=bp(),n=Ce();function s(o,i){var l=n(o)?e:r;return l(o,t(i,3))}return Bs=s,Bs}var Hs,Sp;function nx(){if(Sp)return Hs;Sp=1;function e(t,r,n,s){var o=-1,i=t==null?0:t.length;for(s&&i&&(n=t[++o]);++o<i;)n=r(n,t[o],o,t);return n}return Hs=e,Hs}var Us,_p;function ax(){if(_p)return Us;_p=1;function e(t,r,n,s,o){return o(t,function(i,l,c){n=s?(s=!1,i):r(n,i,l,c)}),n}return Us=e,Us}var Js,jp;function wp(){if(jp)return Js;jp=1;var e=nx(),t=ir(),r=Ze(),n=ax(),s=Ce();function o(i,l,c){var u=s(i)?e:n,d=arguments.length<3;return u(i,r(l,4),c,d,t)}return Js=o,Js}var Ks,Ip;function sx(){if(Ip)return Ks;Ip=1;var e=ot(),t=Ce(),r=Ve(),n="[object String]";function s(o){return typeof o=="string"||!t(o)&&r(o)&&e(o)==n}return Ks=s,Ks}var Vs,Tp;function ox(){if(Tp)return Vs;Tp=1;var e=op(),t=e("length");return Vs=t,Vs}var Gs,Cp;function ix(){if(Cp)return Gs;Cp=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",s=t+r+n,o="\\ufe0e\\ufe0f",i="\\u200d",l=RegExp("["+i+e+s+o+"]");function c(u){return l.test(u)}return Gs=c,Gs}var Ys,Np;function lx(){if(Np)return Ys;Np=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",s=t+r+n,o="\\ufe0e\\ufe0f",i="["+e+"]",l="["+s+"]",c="\\ud83c[\\udffb-\\udfff]",u="(?:"+l+"|"+c+")",d="[^"+e+"]",p="(?:\\ud83c[\\udde6-\\uddff]){2}",h="[\\ud800-\\udbff][\\udc00-\\udfff]",f="\\u200d",m=u+"?",g="["+o+"]?",y="(?:"+f+"(?:"+[d,p,h].join("|")+")"+g+m+")*",b=g+m+y,x="(?:"+[d+l+"?",l,p,h,i].join("|")+")",v=RegExp(c+"(?="+c+")|"+x+b,"g");function k(_){for(var S=v.lastIndex=0;v.test(_);)++S;return S}return Ys=k,Ys}var Xs,Rp;function cx(){if(Rp)return Xs;Rp=1;var e=ox(),t=ix(),r=lx();function n(s){return t(s)?r(s):e(s)}return Xs=n,Xs}var Zs,Ep;function dx(){if(Ep)return Zs;Ep=1;var e=Vn(),t=gt(),r=Xe(),n=sx(),s=cx(),o="[object Map]",i="[object Set]";function l(c){if(c==null)return 0;if(r(c))return n(c)?s(c):c.length;var u=t(c);return u==o||u==i?c.size:e(c).length}return Zs=l,Zs}var Qs,Pp;function ux(){if(Pp)return Qs;Pp=1;var e=wn(),t=Kd(),r=Ha(),n=Ze(),s=or(),o=Ce(),i=mt(),l=Rt(),c=ze(),u=At();function d(p,h,f){var m=o(p),g=m||i(p)||u(p);if(h=n(h,4),f==null){var y=p&&p.constructor;g?f=m?new y:[]:c(p)?f=l(y)?t(s(p)):{}:f={}}return(g?e:r)(p,function(b,x,v){return h(f,b,x,v)}),f}return Qs=d,Qs}var eo,Op;function px(){if(Op)return eo;Op=1;var e=ht(),t=Pt(),r=Ce(),n=e?e.isConcatSpreadable:void 0;function s(o){return r(o)||t(o)||!!(n&&o&&o[n])}return eo=s,eo}var to,Dp;function ro(){if(Dp)return to;Dp=1;var e=ca(),t=px();function r(n,s,o,i,l){var c=-1,u=n.length;for(o||(o=t),l||(l=[]);++c<u;){var d=n[c];s>0&&o(d)?s>1?r(d,s-1,o,i,l):e(l,d):i||(l[l.length]=d)}return l}return to=r,to}var no,Ap;function fx(){if(Ap)return no;Ap=1;function e(t,r,n){switch(n.length){case 0:return t.call(r);case 1:return t.call(r,n[0]);case 2:return t.call(r,n[0],n[1]);case 3:return t.call(r,n[0],n[1],n[2])}return t.apply(r,n)}return no=e,no}var ao,Lp;function Mp(){if(Lp)return ao;Lp=1;var e=fx(),t=Math.max;function r(n,s,o){return s=t(s===void 0?n.length-1:s,0),function(){for(var i=arguments,l=-1,c=t(i.length-s,0),u=Array(c);++l<c;)u[l]=i[s+l];l=-1;for(var d=Array(s+1);++l<s;)d[l]=i[l];return d[s]=o(u),e(n,this,d)}}return ao=r,ao}var so,qp;function hx(){if(qp)return so;qp=1;var e=za(),t=Oc(),r=ct(),n=t?function(s,o){return t(s,"toString",{configurable:!0,enumerable:!1,value:e(o),writable:!0})}:r;return so=n,so}var oo,zp;function mx(){if(zp)return oo;zp=1;var e=800,t=16,r=Date.now;function n(s){var o=0,i=0;return function(){var l=r(),c=t-(l-i);if(i=l,c>0){if(++o>=e)return arguments[0]}else o=0;return s.apply(void 0,arguments)}}return oo=n,oo}var io,$p;function Wp(){if($p)return io;$p=1;var e=hx(),t=mx(),r=t(e);return io=r,io}var lo,Fp;function ur(){if(Fp)return lo;Fp=1;var e=ct(),t=Mp(),r=Wp();function n(s,o){return r(t(s,o,e),s+"")}return lo=n,lo}var co,Bp;function Hp(){if(Bp)return co;Bp=1;function e(t,r,n,s){for(var o=t.length,i=n+(s?1:-1);s?i--:++i<o;)if(r(t[i],i,t))return i;return-1}return co=e,co}var uo,Up;function gx(){if(Up)return uo;Up=1;function e(t){return t!==t}return uo=e,uo}var po,Jp;function yx(){if(Jp)return po;Jp=1;function e(t,r,n){for(var s=n-1,o=t.length;++s<o;)if(t[s]===r)return s;return-1}return po=e,po}var fo,Kp;function xx(){if(Kp)return fo;Kp=1;var e=Hp(),t=gx(),r=yx();function n(s,o,i){return o===o?r(s,o,i):e(s,t,i)}return fo=n,fo}var ho,Vp;function bx(){if(Vp)return ho;Vp=1;var e=xx();function t(r,n){var s=r==null?0:r.length;return!!s&&e(r,n,0)>-1}return ho=t,ho}var mo,Gp;function vx(){if(Gp)return mo;Gp=1;function e(t,r,n){for(var s=-1,o=t==null?0:t.length;++s<o;)if(n(r,t[s]))return!0;return!1}return mo=e,mo}var go,Yp;function kx(){if(Yp)return go;Yp=1;function e(){}return go=e,go}var yo,Xp;function Sx(){if(Xp)return yo;Xp=1;var e=Od(),t=kx(),r=os(),n=1/0,s=e&&1/r(new e([,-0]))[1]==n?function(o){return new e(o)}:t;return yo=s,yo}var xo,Zp;function _x(){if(Zp)return xo;Zp=1;var e=vu(),t=bx(),r=vx(),n=_u(),s=Sx(),o=os(),i=200;function l(c,u,d){var p=-1,h=t,f=c.length,m=!0,g=[],y=g;if(d)m=!1,h=r;else if(f>=i){var b=u?null:s(c);if(b)return o(b);m=!1,h=n,y=new e}else y=u?[]:g;e:for(;++p<f;){var x=c[p],v=u?u(x):x;if(x=d||x!==0?x:0,m&&v===v){for(var k=y.length;k--;)if(y[k]===v)continue e;u&&y.push(v),g.push(x)}else h(y,v,d)||(y!==g&&y.push(v),g.push(x))}return g}return xo=l,xo}var bo,Qp;function ef(){if(Qp)return bo;Qp=1;var e=Xe(),t=Ve();function r(n){return t(n)&&e(n)}return bo=r,bo}var vo,tf;function jx(){if(tf)return vo;tf=1;var e=ro(),t=ur(),r=_x(),n=ef(),s=t(function(o){return r(e(o,1,n,!0))});return vo=s,vo}var ko,rf;function wx(){if(rf)return ko;rf=1;var e=lr();function t(r,n){return e(n,function(s){return r[s]})}return ko=t,ko}var So,nf;function af(){if(nf)return So;nf=1;var e=wx(),t=tt();function r(n){return n==null?[]:e(n,t(n))}return So=r,So}var _o,sf;function $e(){if(sf)return _o;sf=1;var e;if(typeof Rr=="function")try{e={clone:Py(),constant:za(),each:mu(),filter:up(),has:hp(),isArray:Ce(),isEmpty:rx(),isFunction:Rt(),isUndefined:yp(),keys:tt(),map:kp(),reduce:wp(),size:dx(),transform:ux(),union:jx(),values:af()}}catch{}return e||(e=window._),_o=e,_o}var jo,of;function wo(){if(of)return jo;of=1;var e=$e();jo=s;var t="\0",r="\0",n="";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(p){return e.isEmpty(d._in[p])})},s.prototype.sinks=function(){var d=this;return e.filter(this.nodes(),function(p){return e.isEmpty(d._out[p])})},s.prototype.setNodes=function(d,p){var h=arguments,f=this;return e.each(d,function(m){h.length>1?f.setNode(m,p):f.setNode(m)}),this},s.prototype.setNode=function(d,p){return e.has(this._nodes,d)?(arguments.length>1&&(this._nodes[d]=p),this):(this._nodes[d]=arguments.length>1?p: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 p=this;if(e.has(this._nodes,d)){var h=function(f){p.removeEdge(p._edgeObjs[f])};delete this._nodes[d],this._isCompound&&(this._removeFromParentsChildList(d),delete this._parent[d],e.each(this.children(d),function(f){p.setParent(f)}),delete this._children[d]),e.each(e.keys(this._in[d]),h),delete this._in[d],delete this._preds[d],e.each(e.keys(this._out[d]),h),delete this._out[d],delete this._sucs[d],--this._nodeCount}return this},s.prototype.setParent=function(d,p){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(p))p=r;else{p+="";for(var h=p;!e.isUndefined(h);h=this.parent(h))if(h===d)throw new Error("Setting "+p+" as parent of "+d+" would create a cycle");this.setNode(p)}return this.setNode(d),this._removeFromParentsChildList(d),this._parent[d]=p,this._children[p][d]=!0,this},s.prototype._removeFromParentsChildList=function(d){delete this._children[this._parent[d]][d]},s.prototype.parent=function(d){if(this._isCompound){var p=this._parent[d];if(p!==r)return p}},s.prototype.children=function(d){if(e.isUndefined(d)&&(d=r),this._isCompound){var p=this._children[d];if(p)return e.keys(p)}else{if(d===r)return this.nodes();if(this.hasNode(d))return[]}},s.prototype.predecessors=function(d){var p=this._preds[d];if(p)return e.keys(p)},s.prototype.successors=function(d){var p=this._sucs[d];if(p)return e.keys(p)},s.prototype.neighbors=function(d){var p=this.predecessors(d);if(p)return e.union(p,this.successors(d))},s.prototype.isLeaf=function(d){var p;return this.isDirected()?p=this.successors(d):p=this.neighbors(d),p.length===0},s.prototype.filterNodes=function(d){var p=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});p.setGraph(this.graph());var h=this;e.each(this._nodes,function(g,y){d(y)&&p.setNode(y,g)}),e.each(this._edgeObjs,function(g){p.hasNode(g.v)&&p.hasNode(g.w)&&p.setEdge(g,h.edge(g))});var f={};function m(g){var y=h.parent(g);return y===void 0||p.hasNode(y)?(f[g]=y,y):y in f?f[y]:m(y)}return this._isCompound&&e.each(p.nodes(),function(g){p.setParent(g,m(g))}),p},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,p){var h=this,f=arguments;return e.reduce(d,function(m,g){return f.length>1?h.setEdge(m,g,p):h.setEdge(m,g),g}),this},s.prototype.setEdge=function(){var d,p,h,f,m=!1,g=arguments[0];typeof g=="object"&&g!==null&&"v"in g?(d=g.v,p=g.w,h=g.name,arguments.length===2&&(f=arguments[1],m=!0)):(d=g,p=arguments[1],h=arguments[3],arguments.length>2&&(f=arguments[2],m=!0)),d=""+d,p=""+p,e.isUndefined(h)||(h=""+h);var y=l(this._isDirected,d,p,h);if(e.has(this._edgeLabels,y))return m&&(this._edgeLabels[y]=f),this;if(!e.isUndefined(h)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(d),this.setNode(p),this._edgeLabels[y]=m?f:this._defaultEdgeLabelFn(d,p,h);var b=c(this._isDirected,d,p,h);return d=b.v,p=b.w,Object.freeze(b),this._edgeObjs[y]=b,o(this._preds[p],d),o(this._sucs[d],p),this._in[p][y]=b,this._out[d][y]=b,this._edgeCount++,this},s.prototype.edge=function(d,p,h){var f=arguments.length===1?u(this._isDirected,arguments[0]):l(this._isDirected,d,p,h);return this._edgeLabels[f]},s.prototype.hasEdge=function(d,p,h){var f=arguments.length===1?u(this._isDirected,arguments[0]):l(this._isDirected,d,p,h);return e.has(this._edgeLabels,f)},s.prototype.removeEdge=function(d,p,h){var f=arguments.length===1?u(this._isDirected,arguments[0]):l(this._isDirected,d,p,h),m=this._edgeObjs[f];return m&&(d=m.v,p=m.w,delete this._edgeLabels[f],delete this._edgeObjs[f],i(this._preds[p],d),i(this._sucs[d],p),delete this._in[p][f],delete this._out[d][f],this._edgeCount--),this},s.prototype.inEdges=function(d,p){var h=this._in[d];if(h){var f=e.values(h);return p?e.filter(f,function(m){return m.v===p}):f}},s.prototype.outEdges=function(d,p){var h=this._out[d];if(h){var f=e.values(h);return p?e.filter(f,function(m){return m.w===p}):f}},s.prototype.nodeEdges=function(d,p){var h=this.inEdges(d,p);if(h)return h.concat(this.outEdges(d,p))};function o(d,p){d[p]?d[p]++:d[p]=1}function i(d,p){--d[p]||delete d[p]}function l(d,p,h,f){var m=""+p,g=""+h;if(!d&&m>g){var y=m;m=g,g=y}return m+n+g+n+(e.isUndefined(f)?t:f)}function c(d,p,h,f){var m=""+p,g=""+h;if(!d&&m>g){var y=m;m=g,g=y}var b={v:m,w:g};return f&&(b.name=f),b}function u(d,p){return l(d,p.v,p.w,p.name)}return jo}var Io,lf;function Ix(){return lf||(lf=1,Io="2.1.8"),Io}var To,cf;function Tx(){return cf||(cf=1,To={Graph:wo(),version:Ix()}),To}var Co,df;function Cx(){if(df)return Co;df=1;var e=$e(),t=wo();Co={write:r,read:o};function r(i){var l={options:{directed:i.isDirected(),multigraph:i.isMultigraph(),compound:i.isCompound()},nodes:n(i),edges:s(i)};return e.isUndefined(i.graph())||(l.value=e.clone(i.graph())),l}function n(i){return e.map(i.nodes(),function(l){var c=i.node(l),u=i.parent(l),d={v:l};return e.isUndefined(c)||(d.value=c),e.isUndefined(u)||(d.parent=u),d})}function s(i){return e.map(i.edges(),function(l){var c=i.edge(l),u={v:l.v,w:l.w};return e.isUndefined(l.name)||(u.name=l.name),e.isUndefined(c)||(u.value=c),u})}function o(i){var l=new t(i.options).setGraph(i.value);return e.each(i.nodes,function(c){l.setNode(c.v,c.value),c.parent&&l.setParent(c.v,c.parent)}),e.each(i.edges,function(c){l.setEdge({v:c.v,w:c.w,name:c.name},c.value)}),l}return Co}var No,uf;function Nx(){if(uf)return No;uf=1;var e=$e();No=t;function t(r){var n={},s=[],o;function i(l){e.has(n,l)||(n[l]=!0,o.push(l),e.each(r.successors(l),i),e.each(r.predecessors(l),i))}return e.each(r.nodes(),function(l){o=[],i(l),o.length&&s.push(o)}),s}return No}var Ro,pf;function ff(){if(pf)return Ro;pf=1;var e=$e();Ro=t;function t(){this._arr=[],this._keyIndices={}}return t.prototype.size=function(){return this._arr.length},t.prototype.keys=function(){return this._arr.map(function(r){return r.key})},t.prototype.has=function(r){return e.has(this._keyIndices,r)},t.prototype.priority=function(r){var n=this._keyIndices[r];if(n!==void 0)return this._arr[n].priority},t.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},t.prototype.add=function(r,n){var s=this._keyIndices;if(r=String(r),!e.has(s,r)){var o=this._arr,i=o.length;return s[r]=i,o.push({key:r,priority:n}),this._decrease(i),!0}return!1},t.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var r=this._arr.pop();return delete this._keyIndices[r.key],this._heapify(0),r.key},t.prototype.decrease=function(r,n){var s=this._keyIndices[r];if(n>this._arr[s].priority)throw new Error("New priority is greater than current priority. Key: "+r+" Old: "+this._arr[s].priority+" New: "+n);this._arr[s].priority=n,this._decrease(s)},t.prototype._heapify=function(r){var n=this._arr,s=2*r,o=s+1,i=r;s<n.length&&(i=n[s].priority<n[i].priority?s:i,o<n.length&&(i=n[o].priority<n[i].priority?o:i),i!==r&&(this._swap(r,i),this._heapify(i)))},t.prototype._decrease=function(r){for(var n=this._arr,s=n[r].priority,o;r!==0&&(o=r>>1,!(n[o].priority<s));)this._swap(r,o),r=o},t.prototype._swap=function(r,n){var s=this._arr,o=this._keyIndices,i=s[r],l=s[n];s[r]=l,s[n]=i,o[l.key]=r,o[i.key]=n},Ro}var Eo,hf;function mf(){if(hf)return Eo;hf=1;var e=$e(),t=ff();Eo=n;var r=e.constant(1);function n(o,i,l,c){return s(o,String(i),l||r,c||function(u){return o.outEdges(u)})}function s(o,i,l,c){var u={},d=new t,p,h,f=function(m){var g=m.v!==p?m.v:m.w,y=u[g],b=l(m),x=h.distance+b;if(b<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+m+" Weight: "+b);x<y.distance&&(y.distance=x,y.predecessor=p,d.decrease(g,x))};for(o.nodes().forEach(function(m){var g=m===i?0:Number.POSITIVE_INFINITY;u[m]={distance:g},d.add(m,g)});d.size()>0&&(p=d.removeMin(),h=u[p],h.distance!==Number.POSITIVE_INFINITY);)c(p).forEach(f);return u}return Eo}var Po,gf;function Rx(){if(gf)return Po;gf=1;var e=mf(),t=$e();Po=r;function r(n,s,o){return t.transform(n.nodes(),function(i,l){i[l]=e(n,l,s,o)},{})}return Po}var Oo,yf;function xf(){if(yf)return Oo;yf=1;var e=$e();Oo=t;function t(r){var n=0,s=[],o={},i=[];function l(c){var u=o[c]={onStack:!0,lowlink:n,index:n++};if(s.push(c),r.successors(c).forEach(function(h){e.has(o,h)?o[h].onStack&&(u.lowlink=Math.min(u.lowlink,o[h].index)):(l(h),u.lowlink=Math.min(u.lowlink,o[h].lowlink))}),u.lowlink===u.index){var d=[],p;do p=s.pop(),o[p].onStack=!1,d.push(p);while(c!==p);i.push(d)}}return r.nodes().forEach(function(c){e.has(o,c)||l(c)}),i}return Oo}var Do,bf;function Ex(){if(bf)return Do;bf=1;var e=$e(),t=xf();Do=r;function r(n){return e.filter(t(n),function(s){return s.length>1||s.length===1&&n.hasEdge(s[0],s[0])})}return Do}var Ao,vf;function Px(){if(vf)return Ao;vf=1;var e=$e();Ao=r;var t=e.constant(1);function r(s,o,i){return n(s,o||t,i||function(l){return s.outEdges(l)})}function n(s,o,i){var l={},c=s.nodes();return c.forEach(function(u){l[u]={},l[u][u]={distance:0},c.forEach(function(d){u!==d&&(l[u][d]={distance:Number.POSITIVE_INFINITY})}),i(u).forEach(function(d){var p=d.v===u?d.w:d.v,h=o(d);l[u][p]={distance:h,predecessor:u}})}),c.forEach(function(u){var d=l[u];c.forEach(function(p){var h=l[p];c.forEach(function(f){var m=h[u],g=d[f],y=h[f],b=m.distance+g.distance;b<y.distance&&(y.distance=b,y.predecessor=g.predecessor)})})}),l}return Ao}var Lo,kf;function Sf(){if(kf)return Lo;kf=1;var e=$e();Lo=t,t.CycleException=r;function t(n){var s={},o={},i=[];function l(c){if(e.has(o,c))throw new r;e.has(s,c)||(o[c]=!0,s[c]=!0,e.each(n.predecessors(c),l),delete o[c],i.push(c))}if(e.each(n.sinks(),l),e.size(s)!==n.nodeCount())throw new r;return i}function r(){}return r.prototype=new Error,Lo}var Mo,_f;function Ox(){if(_f)return Mo;_f=1;var e=Sf();Mo=t;function t(r){try{e(r)}catch(n){if(n instanceof e.CycleException)return!1;throw n}return!0}return Mo}var qo,jf;function wf(){if(jf)return qo;jf=1;var e=$e();qo=t;function t(n,s,o){e.isArray(s)||(s=[s]);var i=(n.isDirected()?n.successors:n.neighbors).bind(n),l=[],c={};return e.each(s,function(u){if(!n.hasNode(u))throw new Error("Graph does not have node: "+u);r(n,u,o==="post",c,i,l)}),l}function r(n,s,o,i,l,c){e.has(i,s)||(i[s]=!0,o||c.push(s),e.each(l(s),function(u){r(n,u,o,i,l,c)}),o&&c.push(s))}return qo}var zo,If;function Dx(){if(If)return zo;If=1;var e=wf();zo=t;function t(r,n){return e(r,n,"post")}return zo}var $o,Tf;function Ax(){if(Tf)return $o;Tf=1;var e=wf();$o=t;function t(r,n){return e(r,n,"pre")}return $o}var Wo,Cf;function Lx(){if(Cf)return Wo;Cf=1;var e=$e(),t=wo(),r=ff();Wo=n;function n(s,o){var i=new t,l={},c=new r,u;function d(h){var f=h.v===u?h.w:h.v,m=c.priority(f);if(m!==void 0){var g=o(h);g<m&&(l[f]=u,c.decrease(f,g))}}if(s.nodeCount()===0)return i;e.each(s.nodes(),function(h){c.add(h,Number.POSITIVE_INFINITY),i.setNode(h)}),c.decrease(s.nodes()[0],0);for(var p=!1;c.size()>0;){if(u=c.removeMin(),e.has(l,u))i.setEdge(u,l[u]);else{if(p)throw new Error("Input graph is not connected: "+s);p=!0}s.nodeEdges(u).forEach(d)}return i}return Wo}var Fo,Nf;function Mx(){return Nf||(Nf=1,Fo={components:Nx(),dijkstra:mf(),dijkstraAll:Rx(),findCycles:Ex(),floydWarshall:Px(),isAcyclic:Ox(),postorder:Dx(),preorder:Ax(),prim:Lx(),tarjan:xf(),topsort:Sf()}),Fo}var Bo,Rf;function qx(){if(Rf)return Bo;Rf=1;var e=Tx();return Bo={Graph:e.Graph,json:Cx(),alg:Mx(),version:e.version},Bo}var Ho,Ef;function Ue(){if(Ef)return Ho;Ef=1;var e;if(typeof Rr=="function")try{e=qx()}catch{}return e||(e=window.graphlib),Ho=e,Ho}var Uo,Pf;function zx(){if(Pf)return Uo;Pf=1;var e=tu(),t=1,r=4;function n(s){return e(s,t|r)}return Uo=n,Uo}var Jo,Of;function pr(){if(Of)return Jo;Of=1;var e=ft(),t=Xe(),r=nr(),n=ze();function s(o,i,l){if(!n(l))return!1;var c=typeof i;return(c=="number"?t(l)&&r(i,l.length):c=="string"&&i in l)?e(l[i],o):!1}return Jo=s,Jo}var Ko,Df;function $x(){if(Df)return Ko;Df=1;var e=ur(),t=ft(),r=pr(),n=lt(),s=Object.prototype,o=s.hasOwnProperty,i=e(function(l,c){l=Object(l);var u=-1,d=c.length,p=d>2?c[2]:void 0;for(p&&r(c[0],c[1],p)&&(d=1);++u<d;)for(var h=c[u],f=n(h),m=-1,g=f.length;++m<g;){var y=f[m],b=l[y];(b===void 0||t(b,s[y])&&!o.call(l,y))&&(l[y]=h[y])}return l});return Ko=i,Ko}var Vo,Af;function Wx(){if(Af)return Vo;Af=1;var e=Ze(),t=Xe(),r=tt();function n(s){return function(o,i,l){var c=Object(o);if(!t(o)){var u=e(i,3);o=r(o),i=function(p){return u(c[p],p,c)}}var d=s(o,i,l);return d>-1?c[u?o[d]:d]:void 0}}return Vo=n,Vo}var Go,Lf;function Fx(){if(Lf)return Go;Lf=1;var e=/\s/;function t(r){for(var n=r.length;n--&&e.test(r.charAt(n)););return n}return Go=t,Go}var Yo,Mf;function Bx(){if(Mf)return Yo;Mf=1;var e=Fx(),t=/^\s+/;function r(n){return n&&n.slice(0,e(n)+1).replace(t,"")}return Yo=r,Yo}var Xo,qf;function Hx(){if(qf)return Xo;qf=1;var e=Bx(),t=ze(),r=yt(),n=NaN,s=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,i=/^0o[0-7]+$/i,l=parseInt;function c(u){if(typeof u=="number")return u;if(r(u))return n;if(t(u)){var d=typeof u.valueOf=="function"?u.valueOf():u;u=t(d)?d+"":d}if(typeof u!="string")return u===0?u:+u;u=e(u);var p=o.test(u);return p||i.test(u)?l(u.slice(2),p?2:8):s.test(u)?n:+u}return Xo=c,Xo}var Zo,zf;function $f(){if(zf)return Zo;zf=1;var e=Hx(),t=1/0,r=17976931348623157e292;function n(s){if(!s)return s===0?s:0;if(s=e(s),s===t||s===-t){var o=s<0?-1:1;return o*r}return s===s?s:0}return Zo=n,Zo}var Qo,Wf;function Ux(){if(Wf)return Qo;Wf=1;var e=$f();function t(r){var n=e(r),s=n%1;return n===n?s?n-s:n:0}return Qo=t,Qo}var ei,Ff;function Jx(){if(Ff)return ei;Ff=1;var e=Hp(),t=Ze(),r=Ux(),n=Math.max;function s(o,i,l){var c=o==null?0:o.length;if(!c)return-1;var u=l==null?0:r(l);return u<0&&(u=n(c+u,0)),e(o,t(i,3),u)}return ei=s,ei}var ti,Bf;function Kx(){if(Bf)return ti;Bf=1;var e=Wx(),t=Jx(),r=e(t);return ti=r,ti}var ri,Hf;function Uf(){if(Hf)return ri;Hf=1;var e=ro();function t(r){var n=r==null?0:r.length;return n?e(r,1):[]}return ri=t,ri}var ni,Jf;function Vx(){if(Jf)return ni;Jf=1;var e=Fa(),t=uu(),r=lt();function n(s,o){return s==null?s:e(s,t(o),r)}return ni=n,ni}var ai,Kf;function Gx(){if(Kf)return ai;Kf=1;function e(t){var r=t==null?0:t.length;return r?t[r-1]:void 0}return ai=e,ai}var si,Vf;function Yx(){if(Vf)return si;Vf=1;var e=tr(),t=Ha(),r=Ze();function n(s,o){var i={};return o=r(o,3),t(s,function(l,c,u){e(i,c,o(l,c,u))}),i}return si=n,si}var oi,Gf;function ii(){if(Gf)return oi;Gf=1;var e=yt();function t(r,n,s){for(var o=-1,i=r.length;++o<i;){var l=r[o],c=n(l);if(c!=null&&(u===void 0?c===c&&!e(c):s(c,u)))var u=c,d=l}return d}return oi=t,oi}var li,Yf;function Xx(){if(Yf)return li;Yf=1;function e(t,r){return t>r}return li=e,li}var ci,Xf;function Zx(){if(Xf)return ci;Xf=1;var e=ii(),t=Xx(),r=ct();function n(s){return s&&s.length?e(s,r,t):void 0}return ci=n,ci}var di,Zf;function Qf(){if(Zf)return di;Zf=1;var e=tr(),t=ft();function r(n,s,o){(o!==void 0&&!t(n[s],o)||o===void 0&&!(s in n))&&e(n,s,o)}return di=r,di}var ui,eh;function Qx(){if(eh)return ui;eh=1;var e=ot(),t=or(),r=Ve(),n="[object Object]",s=Function.prototype,o=Object.prototype,i=s.toString,l=o.hasOwnProperty,c=i.call(Object);function u(d){if(!r(d)||e(d)!=n)return!1;var p=t(d);if(p===null)return!0;var h=l.call(p,"constructor")&&p.constructor;return typeof h=="function"&&h instanceof h&&i.call(h)==c}return ui=u,ui}var pi,th;function rh(){if(th)return pi;th=1;function e(t,r){if(!(r==="constructor"&&typeof t[r]=="function")&&r!="__proto__")return t[r]}return pi=e,pi}var fi,nh;function eb(){if(nh)return fi;nh=1;var e=Et(),t=lt();function r(n){return e(n,t(n))}return fi=r,fi}var hi,ah;function tb(){if(ah)return hi;ah=1;var e=Qf(),t=ud(),r=Hd(),n=fd(),s=Gd(),o=Pt(),i=Ce(),l=ef(),c=mt(),u=Rt(),d=ze(),p=Qx(),h=At(),f=rh(),m=eb();function g(y,b,x,v,k,_,S){var j=f(y,x),R=f(b,x),L=S.get(R);if(L){e(y,x,L);return}var T=_?_(j,R,x+"",y,b,S):void 0,w=T===void 0;if(w){var D=i(R),E=!D&&c(R),C=!D&&!E&&h(R);T=R,D||E||C?i(j)?T=j:l(j)?T=n(j):E?(w=!1,T=t(R,!0)):C?(w=!1,T=r(R,!0)):T=[]:p(R)||o(R)?(T=j,o(j)?T=m(j):(!d(j)||u(j))&&(T=s(R))):w=!1}w&&(S.set(R,T),k(T,R,v,_,S),S.delete(R)),e(y,x,T)}return hi=g,hi}var mi,sh;function rb(){if(sh)return mi;sh=1;var e=er(),t=Qf(),r=Fa(),n=tb(),s=ze(),o=lt(),i=rh();function l(c,u,d,p,h){c!==u&&r(u,function(f,m){if(h||(h=new e),s(f))n(c,u,m,d,l,p,h);else{var g=p?p(i(c,m),f,m+"",c,u,h):void 0;g===void 0&&(g=f),t(c,m,g)}},o)}return mi=l,mi}var gi,oh;function nb(){if(oh)return gi;oh=1;var e=ur(),t=pr();function r(n){return e(function(s,o){var i=-1,l=o.length,c=l>1?o[l-1]:void 0,u=l>2?o[2]:void 0;for(c=n.length>3&&typeof c=="function"?(l--,c):void 0,u&&t(o[0],o[1],u)&&(c=l<3?void 0:c,l=1),s=Object(s);++i<l;){var d=o[i];d&&n(s,d,i,c)}return s})}return gi=r,gi}var yi,ih;function ab(){if(ih)return yi;ih=1;var e=rb(),t=nb(),r=t(function(n,s,o){e(n,s,o)});return yi=r,yi}var xi,lh;function ch(){if(lh)return xi;lh=1;function e(t,r){return t<r}return xi=e,xi}var bi,dh;function sb(){if(dh)return bi;dh=1;var e=ii(),t=ch(),r=ct();function n(s){return s&&s.length?e(s,r,t):void 0}return bi=n,bi}var vi,uh;function ob(){if(uh)return vi;uh=1;var e=ii(),t=Ze(),r=ch();function n(s,o){return s&&s.length?e(s,t(o,2),r):void 0}return vi=n,vi}var ki,ph;function ib(){if(ph)return ki;ph=1;var e=He(),t=function(){return e.Date.now()};return ki=t,ki}var Si,fh;function lb(){if(fh)return Si;fh=1;var e=rr(),t=cr(),r=nr(),n=ze(),s=Mt();function o(i,l,c,u){if(!n(i))return i;l=t(l,i);for(var d=-1,p=l.length,h=p-1,f=i;f!=null&&++d<p;){var m=s(l[d]),g=c;if(m==="__proto__"||m==="constructor"||m==="prototype")return i;if(d!=h){var y=f[m];g=u?u(y,m,f):void 0,g===void 0&&(g=n(y)?y:r(l[d+1])?[]:{})}e(f,m,g),f=f[m]}return i}return Si=o,Si}var _i,hh;function cb(){if(hh)return _i;hh=1;var e=dr(),t=lb(),r=cr();function n(s,o,i){for(var l=-1,c=o.length,u={};++l<c;){var d=o[l],p=e(s,d);i(p,d)&&t(u,r(d,s),p)}return u}return _i=n,_i}var ji,mh;function db(){if(mh)return ji;mh=1;var e=cb(),t=np();function r(n,s){return e(n,s,function(o,i){return t(n,i)})}return ji=r,ji}var wi,gh;function ub(){if(gh)return wi;gh=1;var e=Uf(),t=Mp(),r=Wp();function n(s){return r(t(s,void 0,e),s+"")}return wi=n,wi}var Ii,yh;function pb(){if(yh)return Ii;yh=1;var e=db(),t=ub(),r=t(function(n,s){return n==null?{}:e(n,s)});return Ii=r,Ii}var Ti,xh;function fb(){if(xh)return Ti;xh=1;var e=Math.ceil,t=Math.max;function r(n,s,o,i){for(var l=-1,c=t(e((s-n)/(o||1)),0),u=Array(c);c--;)u[i?c:++l]=n,n+=o;return u}return Ti=r,Ti}var Ci,bh;function hb(){if(bh)return Ci;bh=1;var e=fb(),t=pr(),r=$f();function n(s){return function(o,i,l){return l&&typeof l!="number"&&t(o,i,l)&&(i=l=void 0),o=r(o),i===void 0?(i=o,o=0):i=r(i),l=l===void 0?o<i?1:-1:r(l),e(o,i,l,s)}}return Ci=n,Ci}var Ni,vh;function mb(){if(vh)return Ni;vh=1;var e=hb(),t=e();return Ni=t,Ni}var Ri,kh;function gb(){if(kh)return Ri;kh=1;function e(t,r){var n=t.length;for(t.sort(r);n--;)t[n]=t[n].value;return t}return Ri=e,Ri}var Ei,Sh;function yb(){if(Sh)return Ei;Sh=1;var e=yt();function t(r,n){if(r!==n){var s=r!==void 0,o=r===null,i=r===r,l=e(r),c=n!==void 0,u=n===null,d=n===n,p=e(n);if(!u&&!p&&!l&&r>n||l&&c&&d&&!u&&!p||o&&c&&d||!s&&d||!i)return 1;if(!o&&!l&&!p&&r<n||p&&s&&i&&!o&&!l||u&&s&&i||!c&&i||!d)return-1}return 0}return Ei=t,Ei}var Pi,_h;function xb(){if(_h)return Pi;_h=1;var e=yb();function t(r,n,s){for(var o=-1,i=r.criteria,l=n.criteria,c=i.length,u=s.length;++o<c;){var d=e(i[o],l[o]);if(d){if(o>=u)return d;var p=s[o];return d*(p=="desc"?-1:1)}}return r.index-n.index}return Pi=t,Pi}var Oi,jh;function bb(){if(jh)return Oi;jh=1;var e=lr(),t=dr(),r=Ze(),n=bp(),s=gb(),o=ar(),i=xb(),l=ct(),c=Ce();function u(d,p,h){p.length?p=e(p,function(g){return c(g)?function(y){return t(y,g.length===1?g[0]:g)}:g}):p=[l];var f=-1;p=e(p,o(r));var m=n(d,function(g,y,b){var x=e(p,function(v){return v(g)});return{criteria:x,index:++f,value:g}});return s(m,function(g,y){return i(g,y,h)})}return Oi=u,Oi}var Di,wh;function vb(){if(wh)return Di;wh=1;var e=ro(),t=bb(),r=ur(),n=pr(),s=r(function(o,i){if(o==null)return[];var l=i.length;return l>1&&n(o,i[0],i[1])?i=[]:l>2&&n(i[0],i[1],i[2])&&(i=[i[0]]),t(o,e(i,1),[])});return Di=s,Di}var Ai,Ih;function kb(){if(Ih)return Ai;Ih=1;var e=Vu(),t=0;function r(n){var s=++t;return e(n)+s}return Ai=r,Ai}var Li,Th;function Sb(){if(Th)return Li;Th=1;function e(t,r,n){for(var s=-1,o=t.length,i=r.length,l={};++s<o;){var c=s<i?r[s]:void 0;n(l,t[s],c)}return l}return Li=e,Li}var Mi,Ch;function _b(){if(Ch)return Mi;Ch=1;var e=rr(),t=Sb();function r(n,s){return t(n||[],s||[],e)}return Mi=r,Mi}var qi,Nh;function je(){if(Nh)return qi;Nh=1;var e;if(typeof Rr=="function")try{e={cloneDeep:zx(),constant:za(),defaults:$x(),each:mu(),filter:up(),find:Kx(),flatten:Uf(),forEach:fu(),forIn:Vx(),has:hp(),isUndefined:yp(),last:Gx(),map:kp(),mapValues:Yx(),max:Zx(),merge:ab(),min:sb(),minBy:ob(),now:ib(),pick:pb(),range:mb(),reduce:wp(),sortBy:vb(),uniqueId:kb(),values:af(),zipObject:_b()}}catch{}return e||(e=window._),qi=e,qi}var zi,Rh;function jb(){if(Rh)return zi;Rh=1,zi=e;function e(){var n={};n._next=n._prev=n,this._sentinel=n}e.prototype.dequeue=function(){var n=this._sentinel,s=n._prev;if(s!==n)return t(s),s},e.prototype.enqueue=function(n){var s=this._sentinel;n._prev&&n._next&&t(n),n._next=s._next,s._next._prev=n,s._next=n,n._prev=s},e.prototype.toString=function(){for(var n=[],s=this._sentinel,o=s._prev;o!==s;)n.push(JSON.stringify(o,r)),o=o._prev;return"["+n.join(", ")+"]"};function t(n){n._prev._next=n._next,n._next._prev=n._prev,delete n._next,delete n._prev}function r(n,s){if(n!=="_next"&&n!=="_prev")return s}return zi}var $i,Eh;function wb(){if(Eh)return $i;Eh=1;var e=je(),t=Ue().Graph,r=jb();$i=s;var n=e.constant(1);function s(u,d){if(u.nodeCount()<=1)return[];var p=l(u,d||n),h=o(p.graph,p.buckets,p.zeroIdx);return e.flatten(e.map(h,function(f){return u.outEdges(f.v,f.w)}),!0)}function o(u,d,p){for(var h=[],f=d[d.length-1],m=d[0],g;u.nodeCount();){for(;g=m.dequeue();)i(u,d,p,g);for(;g=f.dequeue();)i(u,d,p,g);if(u.nodeCount()){for(var y=d.length-2;y>0;--y)if(g=d[y].dequeue(),g){h=h.concat(i(u,d,p,g,!0));break}}}return h}function i(u,d,p,h,f){var m=f?[]:void 0;return e.forEach(u.inEdges(h.v),function(g){var y=u.edge(g),b=u.node(g.v);f&&m.push({v:g.v,w:g.w}),b.out-=y,c(d,p,b)}),e.forEach(u.outEdges(h.v),function(g){var y=u.edge(g),b=g.w,x=u.node(b);x.in-=y,c(d,p,x)}),u.removeNode(h.v),m}function l(u,d){var p=new t,h=0,f=0;e.forEach(u.nodes(),function(y){p.setNode(y,{v:y,in:0,out:0})}),e.forEach(u.edges(),function(y){var b=p.edge(y.v,y.w)||0,x=d(y),v=b+x;p.setEdge(y.v,y.w,v),f=Math.max(f,p.node(y.v).out+=x),h=Math.max(h,p.node(y.w).in+=x)});var m=e.range(f+h+3).map(function(){return new r}),g=h+1;return e.forEach(p.nodes(),function(y){c(m,g,p.node(y))}),{graph:p,buckets:m,zeroIdx:g}}function c(u,d,p){p.out?p.in?u[p.out-p.in+d].enqueue(p):u[u.length-1].enqueue(p):u[0].enqueue(p)}return $i}var Wi,Ph;function Ib(){if(Ph)return Wi;Ph=1;var e=je(),t=wb();Wi={run:r,undo:s};function r(o){var i=o.graph().acyclicer==="greedy"?t(o,l(o)):n(o);e.forEach(i,function(c){var u=o.edge(c);o.removeEdge(c),u.forwardName=c.name,u.reversed=!0,o.setEdge(c.w,c.v,u,e.uniqueId("rev"))});function l(c){return function(u){return c.edge(u).weight}}}function n(o){var i=[],l={},c={};function u(d){e.has(c,d)||(c[d]=!0,l[d]=!0,e.forEach(o.outEdges(d),function(p){e.has(l,p.w)?i.push(p):u(p.w)}),delete l[d])}return e.forEach(o.nodes(),u),i}function s(o){e.forEach(o.edges(),function(i){var l=o.edge(i);if(l.reversed){o.removeEdge(i);var c=l.forwardName;delete l.reversed,delete l.forwardName,o.setEdge(i.w,i.v,l,c)}})}return Wi}var Fi,Oh;function Me(){if(Oh)return Fi;Oh=1;var e=je(),t=Ue().Graph;Fi={addDummyNode:r,simplify:n,asNonCompoundGraph:s,successorWeights:o,predecessorWeights:i,intersectRect:l,buildLayerMatrix:c,normalizeRanks:u,removeEmptyRanks:d,addBorderNode:p,maxRank:h,partition:f,time:m,notime:g};function r(y,b,x,v){var k;do k=e.uniqueId(v);while(y.hasNode(k));return x.dummy=b,y.setNode(k,x),k}function n(y){var b=new t().setGraph(y.graph());return e.forEach(y.nodes(),function(x){b.setNode(x,y.node(x))}),e.forEach(y.edges(),function(x){var v=b.edge(x.v,x.w)||{weight:0,minlen:1},k=y.edge(x);b.setEdge(x.v,x.w,{weight:v.weight+k.weight,minlen:Math.max(v.minlen,k.minlen)})}),b}function s(y){var b=new t({multigraph:y.isMultigraph()}).setGraph(y.graph());return e.forEach(y.nodes(),function(x){y.children(x).length||b.setNode(x,y.node(x))}),e.forEach(y.edges(),function(x){b.setEdge(x,y.edge(x))}),b}function o(y){var b=e.map(y.nodes(),function(x){var v={};return e.forEach(y.outEdges(x),function(k){v[k.w]=(v[k.w]||0)+y.edge(k).weight}),v});return e.zipObject(y.nodes(),b)}function i(y){var b=e.map(y.nodes(),function(x){var v={};return e.forEach(y.inEdges(x),function(k){v[k.v]=(v[k.v]||0)+y.edge(k).weight}),v});return e.zipObject(y.nodes(),b)}function l(y,b){var x=y.x,v=y.y,k=b.x-x,_=b.y-v,S=y.width/2,j=y.height/2;if(!k&&!_)throw new Error("Not possible to find intersection inside of the rectangle");var R,L;return Math.abs(_)*S>Math.abs(k)*j?(_<0&&(j=-j),R=j*k/_,L=j):(k<0&&(S=-S),R=S,L=S*_/k),{x:x+R,y:v+L}}function c(y){var b=e.map(e.range(h(y)+1),function(){return[]});return e.forEach(y.nodes(),function(x){var v=y.node(x),k=v.rank;e.isUndefined(k)||(b[k][v.order]=x)}),b}function u(y){var b=e.min(e.map(y.nodes(),function(x){return y.node(x).rank}));e.forEach(y.nodes(),function(x){var v=y.node(x);e.has(v,"rank")&&(v.rank-=b)})}function d(y){var b=e.min(e.map(y.nodes(),function(_){return y.node(_).rank})),x=[];e.forEach(y.nodes(),function(_){var S=y.node(_).rank-b;x[S]||(x[S]=[]),x[S].push(_)});var v=0,k=y.graph().nodeRankFactor;e.forEach(x,function(_,S){e.isUndefined(_)&&S%k!==0?--v:v&&e.forEach(_,function(j){y.node(j).rank+=v})})}function p(y,b,x,v){var k={width:0,height:0};return arguments.length>=4&&(k.rank=x,k.order=v),r(y,"border",k,b)}function h(y){return e.max(e.map(y.nodes(),function(b){var x=y.node(b).rank;if(!e.isUndefined(x))return x}))}function f(y,b){var x={lhs:[],rhs:[]};return e.forEach(y,function(v){b(v)?x.lhs.push(v):x.rhs.push(v)}),x}function m(y,b){var x=e.now();try{return b()}finally{console.log(y+" time: "+(e.now()-x)+"ms")}}function g(y,b){return b()}return Fi}var Bi,Dh;function Tb(){if(Dh)return Bi;Dh=1;var e=je(),t=Me();Bi={run:r,undo:s};function r(o){o.graph().dummyChains=[],e.forEach(o.edges(),function(i){n(o,i)})}function n(o,i){var l=i.v,c=o.node(l).rank,u=i.w,d=o.node(u).rank,p=i.name,h=o.edge(i),f=h.labelRank;if(d!==c+1){o.removeEdge(i);var m,g,y;for(y=0,++c;c<d;++y,++c)h.points=[],g={width:0,height:0,edgeLabel:h,edgeObj:i,rank:c},m=t.addDummyNode(o,"edge",g,"_d"),c===f&&(g.width=h.width,g.height=h.height,g.dummy="edge-label",g.labelpos=h.labelpos),o.setEdge(l,m,{weight:h.weight},p),y===0&&o.graph().dummyChains.push(m),l=m;o.setEdge(l,u,{weight:h.weight},p)}}function s(o){e.forEach(o.graph().dummyChains,function(i){var l=o.node(i),c=l.edgeLabel,u;for(o.setEdge(l.edgeObj,c);l.dummy;)u=o.successors(i)[0],o.removeNode(i),c.points.push({x:l.x,y:l.y}),l.dummy==="edge-label"&&(c.x=l.x,c.y=l.y,c.width=l.width,c.height=l.height),i=u,l=o.node(i)})}return Bi}var Hi,Ah;function fr(){if(Ah)return Hi;Ah=1;var e=je();Hi={longestPath:t,slack:r};function t(n){var s={};function o(i){var l=n.node(i);if(e.has(s,i))return l.rank;s[i]=!0;var c=e.min(e.map(n.outEdges(i),function(u){return o(u.w)-n.edge(u).minlen}));return(c===Number.POSITIVE_INFINITY||c===void 0||c===null)&&(c=0),l.rank=c}e.forEach(n.sources(),o)}function r(n,s){return n.node(s.w).rank-n.node(s.v).rank-n.edge(s).minlen}return Hi}var Ui,Lh;function Mh(){if(Lh)return Ui;Lh=1;var e=je(),t=Ue().Graph,r=fr().slack;Ui=n;function n(l){var c=new t({directed:!1}),u=l.nodes()[0],d=l.nodeCount();c.setNode(u,{});for(var p,h;s(c,l)<d;)p=o(c,l),h=c.hasNode(p.v)?r(l,p):-r(l,p),i(c,l,h);return c}function s(l,c){function u(d){e.forEach(c.nodeEdges(d),function(p){var h=p.v,f=d===h?p.w:h;!l.hasNode(f)&&!r(c,p)&&(l.setNode(f,{}),l.setEdge(d,f,{}),u(f))})}return e.forEach(l.nodes(),u),l.nodeCount()}function o(l,c){return e.minBy(c.edges(),function(u){if(l.hasNode(u.v)!==l.hasNode(u.w))return r(c,u)})}function i(l,c,u){e.forEach(l.nodes(),function(d){c.node(d).rank+=u})}return Ui}var Ji,qh;function Cb(){if(qh)return Ji;qh=1;var e=je(),t=Mh(),r=fr().slack,n=fr().longestPath,s=Ue().alg.preorder,o=Ue().alg.postorder,i=Me().simplify;Ji=l,l.initLowLimValues=p,l.initCutValues=c,l.calcCutValue=d,l.leaveEdge=f,l.enterEdge=m,l.exchangeEdges=g;function l(v){v=i(v),n(v);var k=t(v);p(k),c(k,v);for(var _,S;_=f(k);)S=m(k,v,_),g(k,v,_,S)}function c(v,k){var _=o(v,v.nodes());_=_.slice(0,_.length-1),e.forEach(_,function(S){u(v,k,S)})}function u(v,k,_){var S=v.node(_),j=S.parent;v.edge(_,j).cutvalue=d(v,k,_)}function d(v,k,_){var S=v.node(_),j=S.parent,R=!0,L=k.edge(_,j),T=0;return L||(R=!1,L=k.edge(j,_)),T=L.weight,e.forEach(k.nodeEdges(_),function(w){var D=w.v===_,E=D?w.w:w.v;if(E!==j){var C=D===R,z=k.edge(w).weight;if(T+=C?z:-z,b(v,_,E)){var W=v.edge(_,E).cutvalue;T+=C?-W:W}}}),T}function p(v,k){arguments.length<2&&(k=v.nodes()[0]),h(v,{},1,k)}function h(v,k,_,S,j){var R=_,L=v.node(S);return k[S]=!0,e.forEach(v.neighbors(S),function(T){e.has(k,T)||(_=h(v,k,_,T,S))}),L.low=R,L.lim=_++,j?L.parent=j:delete L.parent,_}function f(v){return e.find(v.edges(),function(k){return v.edge(k).cutvalue<0})}function m(v,k,_){var S=_.v,j=_.w;k.hasEdge(S,j)||(S=_.w,j=_.v);var R=v.node(S),L=v.node(j),T=R,w=!1;R.lim>L.lim&&(T=L,w=!0);var D=e.filter(k.edges(),function(E){return w===x(v,v.node(E.v),T)&&w!==x(v,v.node(E.w),T)});return e.minBy(D,function(E){return r(k,E)})}function g(v,k,_,S){var j=_.v,R=_.w;v.removeEdge(j,R),v.setEdge(S.v,S.w,{}),p(v),c(v,k),y(v,k)}function y(v,k){var _=e.find(v.nodes(),function(j){return!k.node(j).parent}),S=s(v,_);S=S.slice(1),e.forEach(S,function(j){var R=v.node(j).parent,L=k.edge(j,R),T=!1;L||(L=k.edge(R,j),T=!0),k.node(j).rank=k.node(R).rank+(T?L.minlen:-L.minlen)})}function b(v,k,_){return v.hasEdge(k,_)}function x(v,k,_){return _.low<=k.lim&&k.lim<=_.lim}return Ji}var Ki,zh;function Nb(){if(zh)return Ki;zh=1;var e=fr(),t=e.longestPath,r=Mh(),n=Cb();Ki=s;function s(c){switch(c.graph().ranker){case"network-simplex":l(c);break;case"tight-tree":i(c);break;case"longest-path":o(c);break;default:l(c)}}var o=t;function i(c){t(c),r(c)}function l(c){n(c)}return Ki}var Vi,$h;function Rb(){if($h)return Vi;$h=1;var e=je();Vi=t;function t(s){var o=n(s);e.forEach(s.graph().dummyChains,function(i){for(var l=s.node(i),c=l.edgeObj,u=r(s,o,c.v,c.w),d=u.path,p=u.lca,h=0,f=d[h],m=!0;i!==c.w;){if(l=s.node(i),m){for(;(f=d[h])!==p&&s.node(f).maxRank<l.rank;)h++;f===p&&(m=!1)}if(!m){for(;h<d.length-1&&s.node(f=d[h+1]).minRank<=l.rank;)h++;f=d[h]}s.setParent(i,f),i=s.successors(i)[0]}})}function r(s,o,i,l){var c=[],u=[],d=Math.min(o[i].low,o[l].low),p=Math.max(o[i].lim,o[l].lim),h,f;h=i;do h=s.parent(h),c.push(h);while(h&&(o[h].low>d||p>o[h].lim));for(f=h,h=l;(h=s.parent(h))!==f;)u.push(h);return{path:c.concat(u.reverse()),lca:f}}function n(s){var o={},i=0;function l(c){var u=i;e.forEach(s.children(c),l),o[c]={low:u,lim:i++}}return e.forEach(s.children(),l),o}return Vi}var Gi,Wh;function Eb(){if(Wh)return Gi;Wh=1;var e=je(),t=Me();Gi={run:r,cleanup:i};function r(l){var c=t.addDummyNode(l,"root",{},"_root"),u=s(l),d=e.max(e.values(u))-1,p=2*d+1;l.graph().nestingRoot=c,e.forEach(l.edges(),function(f){l.edge(f).minlen*=p});var h=o(l)+1;e.forEach(l.children(),function(f){n(l,c,p,h,d,u,f)}),l.graph().nodeRankFactor=p}function n(l,c,u,d,p,h,f){var m=l.children(f);if(!m.length){f!==c&&l.setEdge(c,f,{weight:0,minlen:u});return}var g=t.addBorderNode(l,"_bt"),y=t.addBorderNode(l,"_bb"),b=l.node(f);l.setParent(g,f),b.borderTop=g,l.setParent(y,f),b.borderBottom=y,e.forEach(m,function(x){n(l,c,u,d,p,h,x);var v=l.node(x),k=v.borderTop?v.borderTop:x,_=v.borderBottom?v.borderBottom:x,S=v.borderTop?d:2*d,j=k!==_?1:p-h[f]+1;l.setEdge(g,k,{weight:S,minlen:j,nestingEdge:!0}),l.setEdge(_,y,{weight:S,minlen:j,nestingEdge:!0})}),l.parent(f)||l.setEdge(c,g,{weight:0,minlen:p+h[f]})}function s(l){var c={};function u(d,p){var h=l.children(d);h&&h.length&&e.forEach(h,function(f){u(f,p+1)}),c[d]=p}return e.forEach(l.children(),function(d){u(d,1)}),c}function o(l){return e.reduce(l.edges(),function(c,u){return c+l.edge(u).weight},0)}function i(l){var c=l.graph();l.removeNode(c.nestingRoot),delete c.nestingRoot,e.forEach(l.edges(),function(u){var d=l.edge(u);d.nestingEdge&&l.removeEdge(u)})}return Gi}var Yi,Fh;function Pb(){if(Fh)return Yi;Fh=1;var e=je(),t=Me();Yi=r;function r(s){function o(i){var l=s.children(i),c=s.node(i);if(l.length&&e.forEach(l,o),e.has(c,"minRank")){c.borderLeft=[],c.borderRight=[];for(var u=c.minRank,d=c.maxRank+1;u<d;++u)n(s,"borderLeft","_bl",i,c,u),n(s,"borderRight","_br",i,c,u)}}e.forEach(s.children(),o)}function n(s,o,i,l,c,u){var d={width:0,height:0,rank:u,borderType:o},p=c[o][u-1],h=t.addDummyNode(s,"border",d,i);c[o][u]=h,s.setParent(h,l),p&&s.setEdge(p,h,{weight:1})}return Yi}var Xi,Bh;function Ob(){if(Bh)return Xi;Bh=1;var e=je();Xi={adjust:t,undo:r};function t(u){var d=u.graph().rankdir.toLowerCase();(d==="lr"||d==="rl")&&n(u)}function r(u){var d=u.graph().rankdir.toLowerCase();(d==="bt"||d==="rl")&&o(u),(d==="lr"||d==="rl")&&(l(u),n(u))}function n(u){e.forEach(u.nodes(),function(d){s(u.node(d))}),e.forEach(u.edges(),function(d){s(u.edge(d))})}function s(u){var d=u.width;u.width=u.height,u.height=d}function o(u){e.forEach(u.nodes(),function(d){i(u.node(d))}),e.forEach(u.edges(),function(d){var p=u.edge(d);e.forEach(p.points,i),e.has(p,"y")&&i(p)})}function i(u){u.y=-u.y}function l(u){e.forEach(u.nodes(),function(d){c(u.node(d))}),e.forEach(u.edges(),function(d){var p=u.edge(d);e.forEach(p.points,c),e.has(p,"x")&&c(p)})}function c(u){var d=u.x;u.x=u.y,u.y=d}return Xi}var Zi,Hh;function Db(){if(Hh)return Zi;Hh=1;var e=je();Zi=t;function t(r){var n={},s=e.filter(r.nodes(),function(u){return!r.children(u).length}),o=e.max(e.map(s,function(u){return r.node(u).rank})),i=e.map(e.range(o+1),function(){return[]});function l(u){if(!e.has(n,u)){n[u]=!0;var d=r.node(u);i[d.rank].push(u),e.forEach(r.successors(u),l)}}var c=e.sortBy(s,function(u){return r.node(u).rank});return e.forEach(c,l),i}return Zi}var Qi,Uh;function Ab(){if(Uh)return Qi;Uh=1;var e=je();Qi=t;function t(n,s){for(var o=0,i=1;i<s.length;++i)o+=r(n,s[i-1],s[i]);return o}function r(n,s,o){for(var i=e.zipObject(o,e.map(o,function(h,f){return f})),l=e.flatten(e.map(s,function(h){return e.sortBy(e.map(n.outEdges(h),function(f){return{pos:i[f.w],weight:n.edge(f).weight}}),"pos")}),!0),c=1;c<o.length;)c<<=1;var u=2*c-1;c-=1;var d=e.map(new Array(u),function(){return 0}),p=0;return e.forEach(l.forEach(function(h){var f=h.pos+c;d[f]+=h.weight;for(var m=0;f>0;)f%2&&(m+=d[f+1]),f=f-1>>1,d[f]+=h.weight;p+=h.weight*m})),p}return Qi}var el,Jh;function Lb(){if(Jh)return el;Jh=1;var e=je();el=t;function t(r,n){return e.map(n,function(s){var o=r.inEdges(s);if(o.length){var i=e.reduce(o,function(l,c){var u=r.edge(c),d=r.node(c.v);return{sum:l.sum+u.weight*d.order,weight:l.weight+u.weight}},{sum:0,weight:0});return{v:s,barycenter:i.sum/i.weight,weight:i.weight}}else return{v:s}})}return el}var tl,Kh;function Mb(){if(Kh)return tl;Kh=1;var e=je();tl=t;function t(s,o){var i={};e.forEach(s,function(c,u){var d=i[c.v]={indegree:0,in:[],out:[],vs:[c.v],i:u};e.isUndefined(c.barycenter)||(d.barycenter=c.barycenter,d.weight=c.weight)}),e.forEach(o.edges(),function(c){var u=i[c.v],d=i[c.w];!e.isUndefined(u)&&!e.isUndefined(d)&&(d.indegree++,u.out.push(i[c.w]))});var l=e.filter(i,function(c){return!c.indegree});return r(l)}function r(s){var o=[];function i(u){return function(d){d.merged||(e.isUndefined(d.barycenter)||e.isUndefined(u.barycenter)||d.barycenter>=u.barycenter)&&n(u,d)}}function l(u){return function(d){d.in.push(u),--d.indegree===0&&s.push(d)}}for(;s.length;){var c=s.pop();o.push(c),e.forEach(c.in.reverse(),i(c)),e.forEach(c.out,l(c))}return e.map(e.filter(o,function(u){return!u.merged}),function(u){return e.pick(u,["vs","i","barycenter","weight"])})}function n(s,o){var i=0,l=0;s.weight&&(i+=s.barycenter*s.weight,l+=s.weight),o.weight&&(i+=o.barycenter*o.weight,l+=o.weight),s.vs=o.vs.concat(s.vs),s.barycenter=i/l,s.weight=l,s.i=Math.min(o.i,s.i),o.merged=!0}return tl}var rl,Vh;function qb(){if(Vh)return rl;Vh=1;var e=je(),t=Me();rl=r;function r(o,i){var l=t.partition(o,function(g){return e.has(g,"barycenter")}),c=l.lhs,u=e.sortBy(l.rhs,function(g){return-g.i}),d=[],p=0,h=0,f=0;c.sort(s(!!i)),f=n(d,u,f),e.forEach(c,function(g){f+=g.vs.length,d.push(g.vs),p+=g.barycenter*g.weight,h+=g.weight,f=n(d,u,f)});var m={vs:e.flatten(d,!0)};return h&&(m.barycenter=p/h,m.weight=h),m}function n(o,i,l){for(var c;i.length&&(c=e.last(i)).i<=l;)i.pop(),o.push(c.vs),l++;return l}function s(o){return function(i,l){return i.barycenter<l.barycenter?-1:i.barycenter>l.barycenter?1:o?l.i-i.i:i.i-l.i}}return rl}var nl,Gh;function zb(){if(Gh)return nl;Gh=1;var e=je(),t=Lb(),r=Mb(),n=qb();nl=s;function s(l,c,u,d){var p=l.children(c),h=l.node(c),f=h?h.borderLeft:void 0,m=h?h.borderRight:void 0,g={};f&&(p=e.filter(p,function(_){return _!==f&&_!==m}));var y=t(l,p);e.forEach(y,function(_){if(l.children(_.v).length){var S=s(l,_.v,u,d);g[_.v]=S,e.has(S,"barycenter")&&i(_,S)}});var b=r(y,u);o(b,g);var x=n(b,d);if(f&&(x.vs=e.flatten([f,x.vs,m],!0),l.predecessors(f).length)){var v=l.node(l.predecessors(f)[0]),k=l.node(l.predecessors(m)[0]);e.has(x,"barycenter")||(x.barycenter=0,x.weight=0),x.barycenter=(x.barycenter*x.weight+v.order+k.order)/(x.weight+2),x.weight+=2}return x}function o(l,c){e.forEach(l,function(u){u.vs=e.flatten(u.vs.map(function(d){return c[d]?c[d].vs:d}),!0)})}function i(l,c){e.isUndefined(l.barycenter)?(l.barycenter=c.barycenter,l.weight=c.weight):(l.barycenter=(l.barycenter*l.weight+c.barycenter*c.weight)/(l.weight+c.weight),l.weight+=c.weight)}return nl}var al,Yh;function $b(){if(Yh)return al;Yh=1;var e=je(),t=Ue().Graph;al=r;function r(s,o,i){var l=n(s),c=new t({compound:!0}).setGraph({root:l}).setDefaultNodeLabel(function(u){return s.node(u)});return e.forEach(s.nodes(),function(u){var d=s.node(u),p=s.parent(u);(d.rank===o||d.minRank<=o&&o<=d.maxRank)&&(c.setNode(u),c.setParent(u,p||l),e.forEach(s[i](u),function(h){var f=h.v===u?h.w:h.v,m=c.edge(f,u),g=e.isUndefined(m)?0:m.weight;c.setEdge(f,u,{weight:s.edge(h).weight+g})}),e.has(d,"minRank")&&c.setNode(u,{borderLeft:d.borderLeft[o],borderRight:d.borderRight[o]}))}),c}function n(s){for(var o;s.hasNode(o=e.uniqueId("_root")););return o}return al}var sl,Xh;function Wb(){if(Xh)return sl;Xh=1;var e=je();sl=t;function t(r,n,s){var o={},i;e.forEach(s,function(l){for(var c=r.parent(l),u,d;c;){if(u=r.parent(c),u?(d=o[u],o[u]=c):(d=i,i=c),d&&d!==c){n.setEdge(d,c);return}c=u}})}return sl}var ol,Zh;function Fb(){if(Zh)return ol;Zh=1;var e=je(),t=Db(),r=Ab(),n=zb(),s=$b(),o=Wb(),i=Ue().Graph,l=Me();ol=c;function c(h){var f=l.maxRank(h),m=u(h,e.range(1,f+1),"inEdges"),g=u(h,e.range(f-1,-1,-1),"outEdges"),y=t(h);p(h,y);for(var b=Number.POSITIVE_INFINITY,x,v=0,k=0;k<4;++v,++k){d(v%2?m:g,v%4>=2),y=l.buildLayerMatrix(h);var _=r(h,y);_<b&&(k=0,x=e.cloneDeep(y),b=_)}p(h,x)}function u(h,f,m){return e.map(f,function(g){return s(h,g,m)})}function d(h,f){var m=new i;e.forEach(h,function(g){var y=g.graph().root,b=n(g,y,m,f);e.forEach(b.vs,function(x,v){g.node(x).order=v}),o(g,m,b.vs)})}function p(h,f){e.forEach(f,function(m){e.forEach(m,function(g,y){h.node(g).order=y})})}return ol}var il,Qh;function Bb(){if(Qh)return il;Qh=1;var e=je(),t=Ue().Graph,r=Me();il={positionX:m,findType1Conflicts:n,findType2Conflicts:s,addConflict:i,hasConflict:l,verticalAlignment:c,horizontalCompaction:u,alignCoordinates:h,findSmallestWidthAlignment:p,balance:f};function n(b,x){var v={};function k(_,S){var j=0,R=0,L=_.length,T=e.last(S);return e.forEach(S,function(w,D){var E=o(b,w),C=E?b.node(E).order:L;(E||w===T)&&(e.forEach(S.slice(R,D+1),function(z){e.forEach(b.predecessors(z),function(W){var K=b.node(W),M=K.order;(M<j||C<M)&&!(K.dummy&&b.node(z).dummy)&&i(v,W,z)})}),R=D+1,j=C)}),S}return e.reduce(x,k),v}function s(b,x){var v={};function k(S,j,R,L,T){var w;e.forEach(e.range(j,R),function(D){w=S[D],b.node(w).dummy&&e.forEach(b.predecessors(w),function(E){var C=b.node(E);C.dummy&&(C.order<L||C.order>T)&&i(v,E,w)})})}function _(S,j){var R=-1,L,T=0;return e.forEach(j,function(w,D){if(b.node(w).dummy==="border"){var E=b.predecessors(w);E.length&&(L=b.node(E[0]).order,k(j,T,D,R,L),T=D,R=L)}k(j,T,j.length,L,S.length)}),j}return e.reduce(x,_),v}function o(b,x){if(b.node(x).dummy)return e.find(b.predecessors(x),function(v){return b.node(v).dummy})}function i(b,x,v){if(x>v){var k=x;x=v,v=k}var _=b[x];_||(b[x]=_={}),_[v]=!0}function l(b,x,v){if(x>v){var k=x;x=v,v=k}return e.has(b[x],v)}function c(b,x,v,k){var _={},S={},j={};return e.forEach(x,function(R){e.forEach(R,function(L,T){_[L]=L,S[L]=L,j[L]=T})}),e.forEach(x,function(R){var L=-1;e.forEach(R,function(T){var w=k(T);if(w.length){w=e.sortBy(w,function(W){return j[W]});for(var D=(w.length-1)/2,E=Math.floor(D),C=Math.ceil(D);E<=C;++E){var z=w[E];S[T]===T&&L<j[z]&&!l(v,T,z)&&(S[z]=T,S[T]=_[T]=_[z],L=j[z])}}})}),{root:_,align:S}}function u(b,x,v,k,_){var S={},j=d(b,x,v,_),R=_?"borderLeft":"borderRight";function L(D,E){for(var C=j.nodes(),z=C.pop(),W={};z;)W[z]?D(z):(W[z]=!0,C.push(z),C=C.concat(E(z))),z=C.pop()}function T(D){S[D]=j.inEdges(D).reduce(function(E,C){return Math.max(E,S[C.v]+j.edge(C))},0)}function w(D){var E=j.outEdges(D).reduce(function(z,W){return Math.min(z,S[W.w]-j.edge(W))},Number.POSITIVE_INFINITY),C=b.node(D);E!==Number.POSITIVE_INFINITY&&C.borderType!==R&&(S[D]=Math.max(S[D],E))}return L(T,j.predecessors.bind(j)),L(w,j.successors.bind(j)),e.forEach(k,function(D){S[D]=S[v[D]]}),S}function d(b,x,v,k){var _=new t,S=b.graph(),j=g(S.nodesep,S.edgesep,k);return e.forEach(x,function(R){var L;e.forEach(R,function(T){var w=v[T];if(_.setNode(w),L){var D=v[L],E=_.edge(D,w);_.setEdge(D,w,Math.max(j(b,T,L),E||0))}L=T})}),_}function p(b,x){return e.minBy(e.values(x),function(v){var k=Number.NEGATIVE_INFINITY,_=Number.POSITIVE_INFINITY;return e.forIn(v,function(S,j){var R=y(b,j)/2;k=Math.max(S+R,k),_=Math.min(S-R,_)}),k-_})}function h(b,x){var v=e.values(x),k=e.min(v),_=e.max(v);e.forEach(["u","d"],function(S){e.forEach(["l","r"],function(j){var R=S+j,L=b[R],T;if(L!==x){var w=e.values(L);T=j==="l"?k-e.min(w):_-e.max(w),T&&(b[R]=e.mapValues(L,function(D){return D+T}))}})})}function f(b,x){return e.mapValues(b.ul,function(v,k){if(x)return b[x.toLowerCase()][k];var _=e.sortBy(e.map(b,k));return(_[1]+_[2])/2})}function m(b){var x=r.buildLayerMatrix(b),v=e.merge(n(b,x),s(b,x)),k={},_;e.forEach(["u","d"],function(j){_=j==="u"?x:e.values(x).reverse(),e.forEach(["l","r"],function(R){R==="r"&&(_=e.map(_,function(D){return e.values(D).reverse()}));var L=(j==="u"?b.predecessors:b.successors).bind(b),T=c(b,_,v,L),w=u(b,_,T.root,T.align,R==="r");R==="r"&&(w=e.mapValues(w,function(D){return-D})),k[j+R]=w})});var S=p(b,k);return h(k,S),f(k,b.graph().align)}function g(b,x,v){return function(k,_,S){var j=k.node(_),R=k.node(S),L=0,T;if(L+=j.width/2,e.has(j,"labelpos"))switch(j.labelpos.toLowerCase()){case"l":T=-j.width/2;break;case"r":T=j.width/2;break}if(T&&(L+=v?T:-T),T=0,L+=(j.dummy?x:b)/2,L+=(R.dummy?x:b)/2,L+=R.width/2,e.has(R,"labelpos"))switch(R.labelpos.toLowerCase()){case"l":T=R.width/2;break;case"r":T=-R.width/2;break}return T&&(L+=v?T:-T),T=0,L}}function y(b,x){return b.node(x).width}return il}var ll,em;function Hb(){if(em)return ll;em=1;var e=je(),t=Me(),r=Bb().positionX;ll=n;function n(o){o=t.asNonCompoundGraph(o),s(o),e.forEach(r(o),function(i,l){o.node(l).x=i})}function s(o){var i=t.buildLayerMatrix(o),l=o.graph().ranksep,c=0;e.forEach(i,function(u){var d=e.max(e.map(u,function(p){return o.node(p).height}));e.forEach(u,function(p){o.node(p).y=c+d/2}),c+=d+l})}return ll}var cl,tm;function Ub(){if(tm)return cl;tm=1;var e=je(),t=Ib(),r=Tb(),n=Nb(),s=Me().normalizeRanks,o=Rb(),i=Me().removeEmptyRanks,l=Eb(),c=Pb(),u=Ob(),d=Fb(),p=Hb(),h=Me(),f=Ue().Graph;cl=m;function m(A,B){var U=B&&B.debugTiming?h.time:h.notime;U("layout",function(){var H=U(" buildLayoutGraph",function(){return L(A)});U(" runLayout",function(){g(H,U)}),U(" updateInputGraph",function(){y(A,H)})})}function g(A,B){B(" makeSpaceForEdgeLabels",function(){T(A)}),B(" removeSelfEdges",function(){I(A)}),B(" acyclic",function(){t.run(A)}),B(" nestingGraph.run",function(){l.run(A)}),B(" rank",function(){n(h.asNonCompoundGraph(A))}),B(" injectEdgeLabelProxies",function(){w(A)}),B(" removeEmptyRanks",function(){i(A)}),B(" nestingGraph.cleanup",function(){l.cleanup(A)}),B(" normalizeRanks",function(){s(A)}),B(" assignRankMinMax",function(){D(A)}),B(" removeEdgeLabelProxies",function(){E(A)}),B(" normalize.run",function(){r.run(A)}),B(" parentDummyChains",function(){o(A)}),B(" addBorderSegments",function(){c(A)}),B(" order",function(){d(A)}),B(" insertSelfEdges",function(){F(A)}),B(" adjustCoordinateSystem",function(){u.adjust(A)}),B(" position",function(){p(A)}),B(" positionSelfEdges",function(){O(A)}),B(" removeBorderNodes",function(){M(A)}),B(" normalize.undo",function(){r.undo(A)}),B(" fixupEdgeLabelCoords",function(){W(A)}),B(" undoCoordinateSystem",function(){u.undo(A)}),B(" translateGraph",function(){C(A)}),B(" assignNodeIntersects",function(){z(A)}),B(" reversePoints",function(){K(A)}),B(" acyclic.undo",function(){t.undo(A)})}function y(A,B){e.forEach(A.nodes(),function(U){var H=A.node(U),X=B.node(U);H&&(H.x=X.x,H.y=X.y,B.children(U).length&&(H.width=X.width,H.height=X.height))}),e.forEach(A.edges(),function(U){var H=A.edge(U),X=B.edge(U);H.points=X.points,e.has(X,"x")&&(H.x=X.x,H.y=X.y)}),A.graph().width=B.graph().width,A.graph().height=B.graph().height}var b=["nodesep","edgesep","ranksep","marginx","marginy"],x={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},v=["acyclicer","ranker","rankdir","align"],k=["width","height"],_={width:0,height:0},S=["minlen","weight","width","height","labeloffset"],j={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},R=["labelpos"];function L(A){var B=new f({multigraph:!0,compound:!0}),U=Z(A.graph());return B.setGraph(e.merge({},x,J(U,b),e.pick(U,v))),e.forEach(A.nodes(),function(H){var X=Z(A.node(H));B.setNode(H,e.defaults(J(X,k),_)),B.setParent(H,A.parent(H))}),e.forEach(A.edges(),function(H){var X=Z(A.edge(H));B.setEdge(H,e.merge({},j,J(X,S),e.pick(X,R)))}),B}function T(A){var B=A.graph();B.ranksep/=2,e.forEach(A.edges(),function(U){var H=A.edge(U);H.minlen*=2,H.labelpos.toLowerCase()!=="c"&&(B.rankdir==="TB"||B.rankdir==="BT"?H.width+=H.labeloffset:H.height+=H.labeloffset)})}function w(A){e.forEach(A.edges(),function(B){var U=A.edge(B);if(U.width&&U.height){var H=A.node(B.v),X=A.node(B.w),ie={rank:(X.rank-H.rank)/2+H.rank,e:B};h.addDummyNode(A,"edge-proxy",ie,"_ep")}})}function D(A){var B=0;e.forEach(A.nodes(),function(U){var H=A.node(U);H.borderTop&&(H.minRank=A.node(H.borderTop).rank,H.maxRank=A.node(H.borderBottom).rank,B=e.max(B,H.maxRank))}),A.graph().maxRank=B}function E(A){e.forEach(A.nodes(),function(B){var U=A.node(B);U.dummy==="edge-proxy"&&(A.edge(U.e).labelRank=U.rank,A.removeNode(B))})}function C(A){var B=Number.POSITIVE_INFINITY,U=0,H=Number.POSITIVE_INFINITY,X=0,ie=A.graph(),ge=ie.marginx||0,Se=ie.marginy||0;function we($){var ke=$.x,te=$.y,se=$.width,re=$.height;B=Math.min(B,ke-se/2),U=Math.max(U,ke+se/2),H=Math.min(H,te-re/2),X=Math.max(X,te+re/2)}e.forEach(A.nodes(),function($){we(A.node($))}),e.forEach(A.edges(),function($){var ke=A.edge($);e.has(ke,"x")&&we(ke)}),B-=ge,H-=Se,e.forEach(A.nodes(),function($){var ke=A.node($);ke.x-=B,ke.y-=H}),e.forEach(A.edges(),function($){var ke=A.edge($);e.forEach(ke.points,function(te){te.x-=B,te.y-=H}),e.has(ke,"x")&&(ke.x-=B),e.has(ke,"y")&&(ke.y-=H)}),ie.width=U-B+ge,ie.height=X-H+Se}function z(A){e.forEach(A.edges(),function(B){var U=A.edge(B),H=A.node(B.v),X=A.node(B.w),ie,ge;U.points?(ie=U.points[0],ge=U.points[U.points.length-1]):(U.points=[],ie=X,ge=H),U.points.unshift(h.intersectRect(H,ie)),U.points.push(h.intersectRect(X,ge))})}function W(A){e.forEach(A.edges(),function(B){var U=A.edge(B);if(e.has(U,"x"))switch((U.labelpos==="l"||U.labelpos==="r")&&(U.width-=U.labeloffset),U.labelpos){case"l":U.x-=U.width/2+U.labeloffset;break;case"r":U.x+=U.width/2+U.labeloffset;break}})}function K(A){e.forEach(A.edges(),function(B){var U=A.edge(B);U.reversed&&U.points.reverse()})}function M(A){e.forEach(A.nodes(),function(B){if(A.children(B).length){var U=A.node(B),H=A.node(U.borderTop),X=A.node(U.borderBottom),ie=A.node(e.last(U.borderLeft)),ge=A.node(e.last(U.borderRight));U.width=Math.abs(ge.x-ie.x),U.height=Math.abs(X.y-H.y),U.x=ie.x+U.width/2,U.y=H.y+U.height/2}}),e.forEach(A.nodes(),function(B){A.node(B).dummy==="border"&&A.removeNode(B)})}function I(A){e.forEach(A.edges(),function(B){if(B.v===B.w){var U=A.node(B.v);U.selfEdges||(U.selfEdges=[]),U.selfEdges.push({e:B,label:A.edge(B)}),A.removeEdge(B)}})}function F(A){var B=h.buildLayerMatrix(A);e.forEach(B,function(U){var H=0;e.forEach(U,function(X,ie){var ge=A.node(X);ge.order=ie+H,e.forEach(ge.selfEdges,function(Se){h.addDummyNode(A,"selfedge",{width:Se.label.width,height:Se.label.height,rank:ge.rank,order:ie+ ++H,e:Se.e,label:Se.label},"_se")}),delete ge.selfEdges})})}function O(A){e.forEach(A.nodes(),function(B){var U=A.node(B);if(U.dummy==="selfedge"){var H=A.node(U.e.v),X=H.x+H.width/2,ie=H.y,ge=U.x-X,Se=H.height/2;A.setEdge(U.e,U.label),A.removeNode(B),U.label.points=[{x:X+2*ge/3,y:ie-Se},{x:X+5*ge/6,y:ie-Se},{x:X+ge,y:ie},{x:X+5*ge/6,y:ie+Se},{x:X+2*ge/3,y:ie+Se}],U.label.x=U.x,U.label.y=U.y}})}function J(A,B){return e.mapValues(e.pick(A,B),Number)}function Z(A){var B={};return e.forEach(A,function(U,H){B[H.toLowerCase()]=U}),B}return cl}var dl,rm;function Jb(){if(rm)return dl;rm=1;var e=je(),t=Me(),r=Ue().Graph;dl={debugOrdering:n};function n(s){var o=t.buildLayerMatrix(s),i=new r({compound:!0,multigraph:!0}).setGraph({});return e.forEach(s.nodes(),function(l){i.setNode(l,{label:l}),i.setParent(l,"layer"+s.node(l).rank)}),e.forEach(s.edges(),function(l){i.setEdge(l.v,l.w,{},l.name)}),e.forEach(o,function(l,c){var u="layer"+c;i.setNode(u,{rank:"same"}),e.reduce(l,function(d,p){return i.setEdge(d,p,{style:"invis"}),p})}),i}return dl}var ul,nm;function Kb(){return nm||(nm=1,ul="0.8.5"),ul}var pl,am;function Vb(){return am||(am=1,pl={graphlib:Ue(),layout:Ub(),debug:Jb(),util:{time:Me().time,notime:Me().notime},version:Kb()}),pl}var Gb=Vb();const sm=vg(Gb);function xt(e,t="TB"){if(e.data?._layoutWidth&&e.data?._layoutHeight)return{width:e.data._layoutWidth,height:e.data._layoutHeight};let r=240,n=84;switch(e.type){case"decisionNode":r=164,n=164;break;case"forkNode":r=240,n=84;break;case"joinNode":r=240,n=84;break;case"dynamicPlaceholderNode":r=220,n=70;break;case"loopNode":r=320,n=200;break;case"subWorkflowNode":r=240,n=84;break;case"eventNode":r=240,n=84;break;case"default":r=240,n=40;break;case"plusNode":r=e.data.label&&e.data.label!=="+"?120:32,n=32;break;default:r=240,n=84;break}return{width:r,height:n}}function Yb(e,t,r=8){const n=[];if(e.length<r)return n;const s=new Map,o={},i={};e.forEach(p=>{s.set(p.id,p),o[p.id]=[],i[p.id]=[]}),t.forEach(p=>{o[p.source]&&o[p.source].push(p.target),i[p.target]&&i[p.target].push(p.source)});const l=new Set,c=new Set(["input","output","decisionNode","forkNode","joinNode","loopNode","default","plusNode"]),u=p=>!c.has(p.type||""),d=[...e].sort((p,h)=>p.position.y-h.position.y);for(const p of d){if(l.has(p.id)||!u(p)||o[p.id].length>1)continue;const h=[p.id];let f=p,m=o[f.id];for(;m&&m.length===1;){const g=m[0],y=s.get(g);if(!y||l.has(g)||!u(y)||i[g].length!==1)break;h.push(g),f=y,m=o[f.id]}h.length>=r&&(n.push(h),h.forEach(g=>l.add(g)))}return n}function Xb(e,t,r,n,s,o=5,i="view"){const l=t.find(x=>x.id===e[0]),{width:c,height:u}=xt(l||t[0],r),d=Math.max(.7,1-(e.length-10)/80),p=i==="edit"||i==="run"?1.15:1,h=Math.min(n,Math.round(60*d*p)),f=Math.min(s,Math.round(80*d*p)),m=c+h,g=u+f;let y=0,b=0;if(r==="TB"){const x=Math.ceil(e.length/o);y=o*m-h,b=x*g-f}else y=Math.ceil(e.length/o)*m-h,b=o*g-f;return y+=40,b+=40,{width:y,height:b,gridKW:m,gridKH:g,cols:o}}const fl=58,om=20,Zb=16;function Qb(e,t,r,n){if(e.length===0)return{positionedChildren:[],containerWidth:280,containerHeight:fl+50};const s=e.map(p=>({...p,parentId:void 0,extent:void 0})),{nodes:o}=hl(s,t,{direction:r,mode:n,enableSnakeLayout:!1});let i=0,l=0;o.forEach(p=>{const{width:h,height:f}=xt(p,r);i=Math.max(i,p.position.x+h),l=Math.max(l,p.position.y+f)});const c=Math.max(300,i+om*2),u=fl+l+Zb;return{positionedChildren:o.map(p=>{const h=e.find(f=>f.id===p.id);return{...p,parentId:h.parentId,extent:h.extent,position:{x:p.position.x+om,y:p.position.y+fl}}}),containerWidth:c,containerHeight:u}}function hl(e,t,r={}){const{direction:n="TB",mode:s="view",enableSnakeLayout:o=!0,snakeColumns:i=5,snakeMinChainLength:l=8,snakeMinNodeCount:c=10}=r,u=e.length,d=e.filter(T=>T.type!=="plusNode").length;let p=n==="LR"?150:120,h=n==="LR"?120:100,f=p,m=h;if(u>15){let T=Math.max(.5,1-(u-15)/50),w=Math.max(.4,1-(u-15)/40);(s==="edit"||s==="run")&&(T=1-(1-T)*.5,w=1-(1-w)*.5),f=Math.round(p*T),m=Math.round(h*w)}const g=o&&d>c?Yb(e,t,l):[],y={};g.forEach((T,w)=>{T.forEach(D=>{y[D]=w})});const b=new sm.graphlib.Graph;b.setDefaultEdgeLabel(()=>({})),b.setGraph({rankdir:n,ranker:"network-simplex",ranksep:f,nodesep:m,edgesep:50,marginx:50,marginy:50});const x=new Set,v={};e.forEach(T=>{const w=y[T.id];if(w!==void 0){if(!x.has(w)){x.add(w);const D=Xb(g[w],e,n,m,f,i,s);v[w]=D,b.setNode(`__CHAIN_${w}`,{width:D.width,height:D.height})}}else{const{width:D,height:E}=xt(T,n);b.setNode(T.id,{width:D,height:E})}});const k={};t.forEach(T=>{const w=y[T.source],D=y[T.target],E=w!==void 0?`__CHAIN_${w}`:T.source,C=D!==void 0?`__CHAIN_${D}`:T.target;E!==C&&(k[C]=(k[C]||0)+1)}),t.forEach(T=>{const w=y[T.source],D=y[T.target];let E=T.source,C=T.target;if(w!==void 0&&(E=`__CHAIN_${w}`),D!==void 0&&(C=`__CHAIN_${D}`),E!==C){const z=(k[C]||0)>1;b.setEdge(E,C,{weight:z?1:2})}}),sm.layout(b);const _={};for(const T of e)_[T.id]={...T};const S=[],j=new Set;e.forEach(T=>{if(y[T.id]===void 0){const w=b.node(T.id),D=_[T.id],{width:E,height:C}=xt(D,n);D.position={x:w.x-E/2,y:w.y-C/2},D.data={...D.data,sourcePosition:void 0,targetPosition:void 0},D.sourcePosition=n==="LR"?q.Position.Right:q.Position.Bottom,D.targetPosition=n==="LR"?q.Position.Left:q.Position.Top,S.push(D)}else j.add(T.id)}),g.forEach((T,w)=>{const D=`__CHAIN_${w}`,E=b.node(D),C=v[w],z=E.x-C.width/2+20,W=E.y-C.height/2+20,K=C.cols,M=C.gridKW,I=C.gridKH;T.forEach((F,O)=>{const J=_[F];let Z=0,A=0,B,U;if(n==="TB"){const H=Math.floor(O/K),X=O%K,ie=H%2===0,ge=Math.ceil(T.length/K),Se=H===ge-1,we=T.length%K||K,$=Se?(K-we)*M/2:0;let ke;ie?ke=X*M+$:ke=(K-1-X)*M-$;const te=H*I;Z=z+ke,A=W+te;const se=Se?we:K;ie?(U=q.Position.Left,B=q.Position.Right,X===se-1&&O!==T.length-1&&(B=q.Position.Bottom),X===0&&O!==0&&(U=q.Position.Top)):(U=q.Position.Right,B=q.Position.Left,X===se-1&&O!==T.length-1&&(B=q.Position.Bottom),X===0&&O!==0&&(U=q.Position.Top)),O===0&&(U=q.Position.Top),O===T.length-1&&(B=q.Position.Bottom)}else{const H=Math.floor(O/K),X=O%K,ie=H%2===0,ge=Math.ceil(T.length/K),Se=H===ge-1,we=T.length%K||K,$=Se?Math.max(0,(K-we)*I)/2:0,ke=H*M;let te;ie?te=X*I+$:te=(K-1-X)*I-$,Z=z+ke,A=W+te;const se=Se?we:K;ie?(U=q.Position.Top,B=q.Position.Bottom,X===se-1&&O!==T.length-1&&(B=q.Position.Right),X===0&&O!==0&&(U=q.Position.Left)):(U=q.Position.Bottom,B=q.Position.Top,X===se-1&&O!==T.length-1&&(B=q.Position.Right),X===0&&O!==0&&(U=q.Position.Left)),O===0&&(U=q.Position.Left),O===T.length-1&&(B=q.Position.Right)}J.position={x:Z,y:A},J.data={...J.data,sourcePosition:B,targetPosition:U},J.sourcePosition=B,J.targetPosition=U,S.push(J)})});const R=S.reduce((T,w)=>({...T,[w.id]:w}),{}),L=t.map(T=>{const w=R[T.source],D=R[T.target];if(!w||!D||j.has(w.id)||w.type!=="decisionNode")return T;const{width:E,height:C}=xt(w,n),{width:z,height:W}=xt(D,n),K={x:w.position.x+E/2,y:w.position.y+C/2},M={x:D.position.x+z/2,y:D.position.y+W/2};let I=null;if(n==="TB"){const F=E*.25;M.x<K.x-F?I="left":M.x>K.x+F&&(I="right")}else{const F=C*.25;M.y<K.y-F?I="top":M.y>K.y+F&&(I="bottom")}return{...T,sourceHandle:I}});return{nodes:S,edges:L}}function Ne(e,t,r={}){const n=r.direction||"TB",s=r.mode||"view",o=e.filter(b=>b.parentId),i=e.filter(b=>!b.parentId);if(o.length===0)return hl(e,t,r);const l=new Map(o.map(b=>[b.id,b])),c={},u=[];t.forEach(b=>{const x=l.get(b.source),v=l.get(b.target);if(x?.parentId&&x.parentId===v?.parentId){const k=x.parentId;c[k]||(c[k]=[]),c[k].push(b)}else u.push(b)});const d={};o.forEach(b=>{const x=b.parentId;d[x]||(d[x]=[]),d[x].push(b)});const p={},h=[];for(const[b,x]of Object.entries(d)){const v=c[b]||[],{positionedChildren:k,containerWidth:_,containerHeight:S}=Qb(x,v,n,s);p[b]={width:_,height:S},h.push(...k)}const f=i.map(b=>{if(b.type==="loopNode"&&p[b.id]){const{width:x,height:v}=p[b.id];return{...b,data:{...b.data,_layoutWidth:x,_layoutHeight:v},style:{...b.style,width:x,height:v}}}return b}),{nodes:m,edges:g}=hl(f,u,r);return{nodes:[...m.map(b=>{if(b.type==="loopNode"&&p[b.id]){const{width:x,height:v}=p[b.id];return{...b,width:x,height:v,style:{...b.style,width:x,height:v}}}return b}),...h],edges:[...g,...Object.values(c).flat()]}}function qe(e,t){if(!e)return null;for(const r of e){if(r.taskReferenceName===t)return r;if(r.decisionCases){for(const s of Object.keys(r.decisionCases)){const o=qe(r.decisionCases[s],t);if(o)return o}const n=qe(r.defaultCase,t);if(n)return n}if(r.forkTasks)for(const n of r.forkTasks){const s=qe(n,t);if(s)return s}if(r.loopOver){const n=qe(r.loopOver,t);if(n)return n}}return null}function Ge(e,t){if(!e)return!1;const r=e.findIndex(n=>n.taskReferenceName===t);if(r!==-1)return e.splice(r,1),!0;for(const n of e){if(n.decisionCases){for(const s of Object.keys(n.decisionCases))if(Ge(n.decisionCases[s],t))return!0;if(Ge(n.defaultCase,t))return!0}if(n.forkTasks){for(const s of n.forkTasks)if(Ge(s,t))return!0}if(n.loopOver&&Ge(n.loopOver,t))return!0}return!1}function bt(e,t){if(!e)return null;if(e.some(r=>r.taskReferenceName===t))return e;for(const r of e){if(r.decisionCases){for(const s of Object.values(r.decisionCases)){const o=bt(s,t);if(o)return o}const n=bt(r.defaultCase,t);if(n)return n}if(r.forkTasks)for(const n of r.forkTasks){const s=bt(n,t);if(s)return s}if(r.loopOver){const n=bt(r.loopOver,t);if(n)return n}}return null}function im(e,t){const r=e.findIndex(n=>n.taskReferenceName===t);if(r<0)return null;for(let n=r+1;n<e.length;n++)if(e[n].type==="JOIN"||e[n].type==="EXCLUSIVE_JOIN")return e[n].taskReferenceName;return null}function lm(e,t){const r=e.findIndex(n=>n.taskReferenceName===t);if(r<0)return null;for(let n=r-1;n>=0;n--)if(e[n].type==="FORK_JOIN"||e[n].type==="FORK_JOIN_DYNAMIC")return e[n].taskReferenceName;return null}function Je(e,t,r){if(!e)return!1;if(t==="start")return e.unshift(r),!0;const n=e.findIndex(s=>s.taskReferenceName===t);if(n!==-1)return e.splice(n+1,0,r),!0;for(const s of e){if(s.decisionCases){for(const o of Object.keys(s.decisionCases))if(Je(s.decisionCases[o],t,r))return!0;if(Je(s.defaultCase,t,r))return!0}if(s.forkTasks){for(const o of s.forkTasks)if(Je(o,t,r))return!0}if(s.loopOver&&Je(s.loopOver,t,r))return!0}return!1}function vt(e,t,r,n){for(const s of e||[]){if(s.taskReferenceName===t){if(r.branchCase==="default")return s.defaultCase||(s.defaultCase=[]),s.defaultCase.unshift(n),!0;if(r.branchCase!==void 0)return s.decisionCases||(s.decisionCases={}),s.decisionCases[r.branchCase]||(s.decisionCases[r.branchCase]=[]),s.decisionCases[r.branchCase].unshift(n),!0;if(r.forkIndex!==void 0)return s.forkTasks||(s.forkTasks=[]),s.forkTasks[r.forkIndex].unshift(n),!0;if(r.isLoopAdd)return s.loopOver||(s.loopOver=[]),s.loopOver.unshift(n),!0}if(s.decisionCases){for(const o of Object.keys(s.decisionCases))if(vt(s.decisionCases[o],t,r,n))return!0;if(vt(s.defaultCase,t,r,n))return!0}if(s.forkTasks){for(const o of s.forkTasks)if(vt(o,t,r,n))return!0}if(s.loopOver&&vt(s.loopOver,t,r,n))return!0}return!1}function Ae(e){if(e)for(let t=0;t<e.length;t++){const r=e[t];if(r.type==="FORK_JOIN"&&t+1<e.length){const n=e[t+1];if(n.type==="JOIN"){const s=[];(r.forkTasks||[]).forEach(o=>{o&&o.length>0&&s.push(o[o.length-1].taskReferenceName)}),n.joinOn=s}}r.decisionCases&&(Object.values(r.decisionCases).forEach(n=>Ae(n)),r.defaultCase&&Ae(r.defaultCase)),r.forkTasks&&r.forkTasks.forEach(n=>Ae(n)),r.loopOver&&Ae(r.loopOver)}}const ev=[{field:"name",type:"required",message:"工作流名称 (name) 必填"},{field:"version",type:"required",message:"工作流版本 (version) 必填"},{field:"tasks",type:"min_length",value:1,message:"工作流必须包含至少一个任务"}],cm={common:[{field:"name",type:"required",message:"任务类型名称 (name) 必填"},{field:"taskReferenceName",type:"required",message:"引用名 (taskReferenceName) 必填"},{field:"taskReferenceName",type:"pattern",value:/^[a-zA-Z0-9_]+$/,message:"引用名仅允许字母、数字和下划线"},{field:"taskReferenceName",type:"unique",message:"引用名在工作流中必须唯一"}],types:{HTTP:[{field:"inputParameters.http_request.uri",type:"required",message:"HTTP 任务缺少请求地址 (uri) 配置"},{field:"inputParameters.http_request.method",type:"required",level:"warning",message:"HTTP 任务未指定 Method,建议配置"}],INLINE:[{field:"inputParameters.expression",type:"custom",validate:(e,t)=>!!(t?.inputParameters?.expression||t?.inputParameters?.scriptExpression),message:"INLINE 任务缺少脚本表达式 (expression)"}],LAMBDA:[{field:"inputParameters.scriptExpression",type:"required",message:"LAMBDA 任务缺少脚本表达式 (scriptExpression)"}],JSON_JQ_TRANSFORM:[{field:"inputParameters.queryExpression",type:"required",message:"JQ 任务缺少查询表达式 (queryExpression)"}],SUB_WORKFLOW:[{field:"subWorkflowParam.name",type:"required",message:"子工作流任务缺少子流程名称 (name)"}],START_WORKFLOW:[{field:"inputParameters.startWorkflow.name",type:"custom",validate:(e,t)=>!!t?.inputParameters?.startWorkflow?.name,message:"START_WORKFLOW 任务缺少目标工作流名称"}],DYNAMIC:[{field:"dynamicTaskNameParam",type:"required",message:"DYNAMIC 任务缺少 dynamicTaskNameParam 配置"}],TERMINATE:[{field:"inputParameters.terminationStatus",type:"required",level:"warning",message:"终止任务未指定状态 (terminationStatus)"},{field:"inputParameters.terminationStatus",type:"enum",value:["COMPLETED","FAILED"],message:"终止状态必须为 COMPLETED 或 FAILED"}],DO_WHILE:[{field:"loopCondition",type:"custom",validate:(e,t)=>!!(t?.loopCondition||t?.inputParameters?.items),message:"循环任务需要配置退出条件 (loopCondition) 或列表 (items)"}],DECISION:[{field:"decisionCases",type:"custom",validate:e=>Object.keys(e||{}).length>0,message:"决策任务必须至少包含一个分支 (decisionCases)"},{field:"decisionCases",type:"custom",validate:e=>{const t=Object.keys(e||{});return new Set(t).size===t.length},message:"决策分支条件不能重复"}],SWITCH:[{field:"decisionCases",type:"custom",validate:e=>Object.keys(e||{}).length>0,message:"Switch 任务必须至少包含一个分支"}],FORK_JOIN_DYNAMIC:[{field:"dynamicForkTasksParam",type:"custom",validate:(e,t)=>!!(t?.dynamicForkTasksParam||t?.forkTaskType||t?.forkTaskWorkflow),message:"FORK_JOIN_DYNAMIC 任务需要配置 dynamicForkTasksParam 或 forkTaskType 或 forkTaskWorkflow",level:"warning"}]}};class tv{rules=[];setRules(t){this.rules=[...t]}getRules(){return this.rules}hasRules(){return this.rules.length>0}runAll(t){const r=[],n=[];for(const s of this.rules)try{const o=s.validate(t);for(const i of o)s.level==="warning"?n.push(i):r.push(i)}catch{r.push({type:"GLOBAL",ref:"",message:`自定义规则 "${s.id}" 执行异常`})}return{errors:r,warnings:n}}buildPromptSection(){return this.rules.length===0?null:`## 业务校验规则(必须遵守)
|
|
7
7
|
以下规则由集成方定义,生成工作流时必须满足:
|
|
8
8
|
${this.rules.map(r=>`- ${r.description}`).join(`
|
|
9
|
-
`)}`}}const
|
|
10
|
-
**${r.taskName}** ${n}${s}`),r.inputSchema&&Object.keys(r.inputSchema).length>0){const
|
|
11
|
-
`)}}const Cv=new jv;function xt(e,t,r){if(t.push({task:e,isConditional:r}),e.decisionCases)for(const n of Object.values(e.decisionCases))for(const s of n||[])xt(s,t,!0);if(e.defaultCase)for(const n of e.defaultCase)xt(n,t,!0);if(e.forkTasks)for(const n of e.forkTasks)for(const s of n||[])xt(s,t,r);if(e.loopOver)for(const n of e.loopOver)xt(n,t,r)}function em(e,t){if(!e||!Array.isArray(e.tasks))return[];const r=[];function n(a,i){for(let l=0;l<a.length;l++){const c=a[l];if(c.taskReferenceName===t)return!0;if(c.decisionCases||c.defaultCase){for(const d of Object.values(c.decisionCases||{})){const u=[];if(s(d||[],!0,u))return r.push({task:c,isConditional:i}),r.push(...u),!0}if(c.defaultCase){const d=[];if(s(c.defaultCase,!0,d))return r.push({task:c,isConditional:i}),r.push(...d),!0}}if(c.forkTasks)for(const d of c.forkTasks){const u=[];if(s(d||[],i,u))return r.push({task:c,isConditional:i}),r.push(...u),!0}if(c.loopOver){const d=[];if(s(c.loopOver,i,d))return r.push({task:c,isConditional:i}),r.push(...d),!0}xt(c,r,i)}return!1}function s(a,i,l){for(let c=0;c<a.length;c++){const d=a[c];if(d.taskReferenceName===t)return!0;if(d.decisionCases||d.defaultCase){for(const u of Object.values(d.decisionCases||{})){const f=[];if(s(u||[],!0,f))return l.push({task:d,isConditional:i}),l.push(...f),!0}if(d.defaultCase){const u=[];if(s(d.defaultCase,!0,u))return l.push({task:d,isConditional:i}),l.push(...u),!0}}if(d.forkTasks)for(const u of d.forkTasks){const f=[];if(s(u||[],i,f))return l.push({task:d,isConditional:i}),l.push(...f),!0}if(d.loopOver){const u=[];if(s(d.loopOver,i,u))return l.push({task:d,isConditional:i}),l.push(...u),!0}xt(d,l,i)}return!1}return n(e.tasks,!1),r}function cl(e,t){return em(e,t).map(r=>r.task)}function lr(e){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string")return e.length>32?`"${e.slice(0,32)}..."`:`"${e}"`;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return`Array(${e.length})`;if(typeof e=="object"){const t=Object.keys(e);return`{ ${t.slice(0,3).join(", ")}${t.length>3?", ...":""} }`}return String(e)}function dl(e){if(e==null)return"any";if(Array.isArray(e))return"array";const t=typeof e;return t==="string"||t==="number"||t==="boolean"||t==="object"?t:"any"}function ul(e,t,r="",n=0,s=3,a=[]){if(!e||typeof e!="object"||n>s)return a;for(const[i,l]of Object.entries(e)){const c=r?`${r}.${i}`:i,d=dl(l);a.push({path:c,expression:`\${${t}.output.${c}}`,valueType:d,sampleValue:lr(l),source:"runtime_sample"}),d==="object"&&l!==null&&Object.keys(l).length>0&&n<s?ul(l,t,c,n+1,s,a):d==="array"&&Array.isArray(l)&&l.length>0&&typeof l[0]=="object"&&l[0]!==null&&n<s&&ul(l[0],t,`${c}[0]`,n+1,s,a)}return a}function tm(e,t){const r=e.taskReferenceName,n=new Map,s=t?.[r]?.output;if(s&&typeof s=="object"){const l=ul(s,r);for(const c of l)n.set(c.path,c)}const a=Cv.get(e.name);if(a?.outputSchema){for(const[l,c]of Object.entries(a.outputSchema))if(!n.has(l)){const d=c.toLowerCase(),u=d.includes("number")||d.includes("int")?"number":d.includes("bool")?"boolean":d.includes("array")||d.includes("[]")?"array":d.includes("object")?"object":"string";n.set(l,{path:l,expression:`\${${r}.output.${l}}`,valueType:u,description:c,source:"schema_registry"})}}const i=(l,c,d)=>{n.has(l)||n.set(l,{path:l,expression:`\${${r}.output.${l}}`,valueType:c,description:d,source:"task_type_contract"})};switch(e.type){case"HTTP":i("response.body","object","HTTP 响应体 JSON 数据"),i("response.statusCode","number","HTTP 状态码 (如 200)"),i("response.headers","object","HTTP 响应头");break;case"JSON_JQ_TRANSFORM":i("result","any","JQ 表达式单值计算结果"),i("resultList","array","JQ 表达式列表计算结果");break;case"DO_WHILE":i("iteration","number","当前循环迭代轮次 (从 1 开始)");break;case"SUB_WORKFLOW":i("workflowId","string","子工作流实例 ID"),i("result","object","子工作流返回输出");break;case"HUMAN":i("approved","boolean","人工审批结果"),i("comment","string","审批意见备注"),i("assignee","string","实际审批人");break;default:n.size===0&&(i("result","any",`${e.name||r} 默认执行结果`),i("data","object",`${e.name||r} 业务输出对象`));break}return Array.from(n.values())}function rm(e,t,r,n){if(!e)return[];const s=[],a=At(e.inputParameters);if(a.length>0)for(const d of a){const u=n?.[d.name]??d.defaultValue;s.push({label:`workflow.input.${d.name}`,value:`\${workflow.input.${d.name}}`,category:"workflow_input",valueType:d.type==="number"?"number":d.type==="boolean"?"boolean":d.type==="object"?"object":d.type==="array"?"array":"string",sourceRef:"workflow.input",sourceLabel:"工作流输入",description:d.description||`工作流启动参数 ${d.name}`,sampleValue:u!==void 0&&u!==""?lr(u):void 0})}else if(n&&typeof n=="object")for(const[d,u]of Object.entries(n))s.push({label:`workflow.input.${d}`,value:`\${workflow.input.${d}}`,category:"workflow_input",valueType:dl(u),sourceRef:"workflow.input",sourceLabel:"工作流输入",description:`工作流运行态输入字段 ${d}`,sampleValue:lr(u)});else s.push({label:"workflow.input.data",value:"${workflow.input.data}",category:"workflow_input",valueType:"any",sourceRef:"workflow.input",sourceLabel:"工作流输入",description:"引用工作流启动时传入的参数(可在全局设置中定义 inputParameters)"});const i=em(e,t),l=new Set;for(let d=i.length-1;d>=0;d--){const{task:u,isConditional:f}=i[d];if(u.type==="SET_VARIABLE"&&u.inputParameters){for(const[p,m]of Object.entries(u.inputParameters))l.has(p)||(l.add(p),s.push({label:`workflow.variables.${p}`,value:`\${workflow.variables.${p}}`,category:"variable",valueType:dl(m),sourceRef:u.taskReferenceName,sourceLabel:`变量 (${u.name||u.taskReferenceName})`,description:`由上游 SET_VARIABLE 节点 [${u.taskReferenceName}] 设置的全局变量`,sampleValue:lr(m),isConditional:f}));continue}if(u.type==="JOIN"||u.type==="TERMINATE")continue;const h=tm(u,r);for(const p of h)s.push({label:`${u.taskReferenceName}.output.${p.path}`,value:p.expression,category:"upstream",valueType:p.valueType,sourceRef:u.taskReferenceName,sourceLabel:`${u.name||u.taskReferenceName} (${u.type})`,description:p.description||`来自上游任务 [${u.name||u.taskReferenceName}] 的输出字段`,sampleValue:p.sampleValue,isConditional:f})}const c=[{key:"workflow.workflowId",desc:"当前工作流执行实例唯一 ID"},{key:"workflow.correlationId",desc:"外部业务关联 ID (Correlation ID)"},{key:"workflow.status",desc:"当前工作流状态"},{key:"workflow.version",desc:"当前工作流定义版本号"}];for(const d of c)s.push({label:d.key,value:`\${${d.key}}`,category:"system",valueType:"string",sourceRef:"workflow",sourceLabel:"系统元数据",description:d.desc});return s}function it(e,t=[]){if(!e)return t;for(const r of e){if(t.push(r),r.decisionCases)for(const n of Object.values(r.decisionCases))it(n,t);if(r.defaultCase&&it(r.defaultCase,t),r.forkTasks)for(const n of r.forkTasks)it(n,t);r.loopOver&&it(r.loopOver,t)}return t}function vt(e,t=[]){if(typeof e=="string"){const r=/\$\{([^}]+)\}/g;let n;for(;(n=r.exec(e))!==null;)t.push(n[1].trim())}else if(Array.isArray(e))for(const r of e)vt(r,t);else if(e&&typeof e=="object")for(const r of Object.values(e))vt(r,t);return t}function nm(e){if(!e||!Array.isArray(e.tasks))return{edges:[],diagnostics:[]};const t=it(e.tasks),r=new Map,n=new Map;for(const l of t)if(r.set(l.taskReferenceName,l),l.type==="SET_VARIABLE"&&l.inputParameters)for(const c of Object.keys(l.inputParameters))n.set(c,l.taskReferenceName);const s=[],a=[],i=new Set;for(const l of t){const c=l.taskReferenceName,d=new Set(cl(e,c).map(f=>f.taskReferenceName)),u=[];vt(l.inputParameters,u),vt(l.httpRequest,u),l.loopCondition&&vt(l.loopCondition,u),l.expression&&vt(l.expression,u);for(const f of u){if(f.startsWith("workflow.input.")||f==="workflow.input")continue;if(f.startsWith("workflow.variables.")){const p=f.slice(19).split(".")[0],m=n.get(p);if(m&&m!==c){const g=d.has(m),x=`dfg-${m}->${c}-var:${p}`;i.has(x)||(i.add(x),s.push({id:x,sourceRef:m,targetRef:c,fieldPath:`variables.${p}`,expression:`\${${f}}`,sourceType:"workflow_variable",isValidUpstream:g,issue:g?void 0:"forward_ref"}))}continue}if(f.startsWith("workflow."))continue;const h=f.split(".");if(h.length>=2&&(h[1]==="output"||h[1]==="input")){const p=h[0],m=h.slice(2).join(".")||h[1];if(p===c)continue;const g=r.has(p),x=d.has(p);let v;g?x||(v="forward_ref",a.push({taskRef:c,expression:`\${${f}}`,issue:"forward_ref",message:`任务 [${c}] 引用了非上游或互斥分支任务 "${p}" 的输出`})):(v="undefined_ref",a.push({taskRef:c,expression:`\${${f}}`,issue:"undefined_ref",message:`任务 [${c}] 引用了不存在的任务 "${p}"`}));const y=`dfg-${p}->${c}-${m}`;i.has(y)||(i.add(y),s.push({id:y,sourceRef:p,targetRef:c,fieldPath:m,expression:`\${${f}}`,sourceType:"task_output",isValidUpstream:g&&x,issue:v}))}}}return{edges:s,diagnostics:a}}function sm(e,t,r){const n=t.trim(),s=r.trim();if(!n||!s||n===s)return{updatedDef:e,replacedCount:0,affectedTaskRefs:[]};const a=JSON.parse(JSON.stringify(e));let i=0;const l=new Set,c=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),d=new RegExp(`\\$\\{\\s*${c}(\\.|\\s*\\})`,"g"),u=new RegExp(`\\$\\.\\b${c}\\b`,"g");function f(p,m){if(typeof p=="string"){let g=p;return d.lastIndex=0,d.test(g)&&(g=g.replace(d,(x,v)=>(i++,l.add(m),`\${${s}${v}`))),u.lastIndex=0,u.test(g)&&(g=g.replace(u,()=>(i++,l.add(m),`$.${s}`))),g}if(Array.isArray(p))return p.map(g=>f(g,m));if(p&&typeof p=="object"){const g={};for(const[x,v]of Object.entries(p))g[x]=f(v,m);return g}return p}const h=it(a.tasks);for(const p of h){const m=p.taskReferenceName===n?s:p.taskReferenceName;p.taskReferenceName===n&&(p.taskReferenceName=s),p.inputParameters&&(p.inputParameters=f(p.inputParameters,m)),p.httpRequest&&(p.httpRequest=f(p.httpRequest,m)),p.loopCondition&&(p.loopCondition=f(p.loopCondition,m)),p.expression&&(p.expression=f(p.expression,m)),Array.isArray(p.joinOn)&&(p.joinOn=p.joinOn.map(g=>g===n?(i++,l.add(m),s):g)),Array.isArray(p.defaultExclusiveJoinTask)&&(p.defaultExclusiveJoinTask=p.defaultExclusiveJoinTask.map(g=>g===n?(i++,l.add(m),s):g))}return a.outputParameters&&(a.outputParameters=f(a.outputParameters,"__workflow_output__")),l.delete(s),{updatedDef:a,replacedCount:i,affectedTaskRefs:Array.from(l)}}function am(e){return!e||typeof e!="object"?null:e.__isMockOverride||"outputData"in e||"forceCase"in e||"durationMs"in e||"status"in e&&(e.status==="COMPLETED"||e.status==="FAILED"||e.status==="TIMED_OUT"||e.status==="COMPLETED_WITH_ERRORS")&&Object.keys(e).every(t=>["__isMockOverride","status","durationMs","forceCase","outputData","reasonForIncompletion"].includes(t))?e:{__isMockOverride:!0,outputData:e}}function cr(e,t){if(!e||!t)return;const r=t.split(".");let n=e;for(const s of r){if(n==null)return;n=n[s]}return n}function dr(e,t){if(typeof e=="string"){const r=e.match(/^\$\{([^}]+)\}$/);if(r){const n=om(r[1].trim(),t);return n!==void 0?n:e}return e.replace(/\$\{([^}]+)\}/g,(n,s)=>{const a=om(s.trim(),t);return a===void 0?n:typeof a=="object"?JSON.stringify(a):String(a)})}if(Array.isArray(e))return e.map(r=>dr(r,t));if(e&&typeof e=="object"){const r={};for(const[n,s]of Object.entries(e))r[n]=dr(s,t);return r}return e}function om(e,t){if(e==="workflow.input")return t.workflowInput;if(e.startsWith("workflow.input."))return cr(t.workflowInput,e.slice(15));if(e==="workflow.variables")return t.variables;if(e.startsWith("workflow.variables."))return cr(t.variables,e.slice(19));if(e==="workflow.workflowId")return"sandbox-dryrun-wf-001";if(e==="workflow.correlationId")return"corr-sandbox-9921";const r=e.indexOf(".output");if(r>0){const n=e.slice(0,r),s=e.slice(r+7),a=t.taskOutputs[n];if(!a)return;if(!s||s==="")return a;if(s.startsWith("."))return cr(a,s.slice(1))}}function ur(e,t={},r){switch(e.type){case"HTTP":{const n=t.http_request||e.httpRequest||t;return{response:{statusCode:200,headers:{"content-type":"application/json","x-sandbox":"true"},body:{code:0,status:"SUCCESS",message:`Simulated HTTP ${n?.method||"GET"} response for ${e.name}`,requestEcho:n?.uri||"/api/v1/resource",data:{id:`res_${e.taskReferenceName}_${r||1}`,verified:!0,score:95,items:[{id:1,name:"item-alpha"},{id:2,name:"item-beta"}]}}}}}case"JSON_JQ_TRANSFORM":{const n=t.queryExpression||e.inputParameters?.queryExpression||".";if(n==="."||!n){const s={...t};return delete s.queryExpression,{result:s,resultList:[s]}}if(typeof n=="string"&&n.startsWith(".")){const s=n.slice(1).replace(/\[\]/g,""),a=s?cr(t,s):t;return{result:a!==void 0?a:{transformed:!0,expression:n},resultList:Array.isArray(a)?a:[a??{transformed:!0}]}}return{result:{transformed:!0,queryExpression:n,sourceKeys:Object.keys(t)},resultList:[{transformed:!0}]}}case"SET_VARIABLE":return{variables:{...Object.keys(t).length?t:e.inputParameters||{}}};case"INLINE":return{result:{evaluated:!0,evaluatorType:t.evaluatorType||e.evaluatorType||"graaljs",summary:`Executed inline script for ${e.taskReferenceName}`,...t}};case"EVENT":return{event_produced:`conductor:event:${e.sink||e.name}`,payload:t};case"WAIT":return{waited:!0,duration:t.duration||"1s"};case"TERMINATE":return{terminationStatus:t.terminationStatus||"COMPLETED",terminationReason:t.terminationReason||"Terminated in sandbox dry-run",output:t.workflowOutput||{}};default:return{code:0,status:"OK",result:`Simulated output from ${e.name}`,processedAt:new Date().toISOString(),iteration:r??1,inputEcho:t,data:{id:`${e.taskReferenceName}_out_${r||1}`,approved:!0,amount:t.amount??100}}}}function Iv(e,t,r,n){const s=am(r.taskMocks[e.taskReferenceName]);if(s?.outputData)return e.type==="SET_VARIABLE"&&Object.assign(r.variables,s.outputData),structuredClone(s.outputData);e.type==="SET_VARIABLE"&&Object.assign(r.variables,t);const a=ur(e,t,n);return a.processedAt&&(a.processedAt=new Date(r.currentTimeMs).toISOString()),a}function Rv(e,t,r,n){if(n)return n;const s=Object.keys(r);if(s.length===0)return"default";const a=e.caseValueParam||"case_value",i=t[a]??e.expression;if(i!=null){const l=String(i).trim();if(r[l])return l;for(const c of s)if(l.includes(c))return c}return s[0]}function fr(e,t,r){for(const n of e){const s=Ov(n,t,r);if(s==="FAILED"||s==="TERMINATED")return s}return"COMPLETED"}function Ov(e,t,r){t.seqCounter+=1;const n=t.seqCounter,s=t.currentTimeMs,a=8+n%5*4,i=s+a;t.currentTimeMs=i;const l=am(t.taskMocks[e.taskReferenceName]),c=dr(e.inputParameters||{},t),d=r&&r>1?`${e.taskReferenceName}__${r}`:e.taskReferenceName;if(e.type==="SWITCH"||e.type==="DECISION"){const y=e.decisionCases||{},b=Rv(e,c,y,l?.forceCase),k=b==="__default__"?e.defaultCase||[]:y[b]||e.defaultCase||[],_={taskId:`sandbox-task-${n}`,taskType:e.type,taskDefName:e.name,referenceTaskName:d,status:"COMPLETED",scheduledTime:s,startTime:i,endTime:i+(l?.durationMs??12),seq:n,pollCount:1,retryCount:0,iteration:r,inputData:{...c,case_value_param:b},outputData:l?.outputData||{selectedCase:b==="__default__"?"defaultCase":b,evaluatedExpression:e.expression||e.caseValueParam||"default"},workflowTask:e};return t.currentTimeMs=_.endTime,t.taskOutputs[e.taskReferenceName]=_.outputData,t.tasks.push(_),fr(k,t,r)}if(e.type==="FORK_JOIN"){const y=e.forkTasks||[],b=i,k={taskId:`sandbox-task-${n}`,taskType:"FORK_JOIN",taskDefName:e.name,referenceTaskName:d,status:"COMPLETED",scheduledTime:s,startTime:b,endTime:b+10,seq:n,pollCount:1,retryCount:0,iteration:r,inputData:c,outputData:{forkedBranches:y.length},workflowTask:e};t.tasks.push(k);const _=b+10;let w=_;for(const T of y){t.currentTimeMs=_;const O=fr(T,t,r);if(t.currentTimeMs>w&&(w=t.currentTimeMs),O!=="COMPLETED")return O}return t.currentTimeMs=w,t.taskOutputs[e.taskReferenceName]=k.outputData,"COMPLETED"}if(e.type==="JOIN"){const y=e.joinOn||[],b={};for(const w of y)t.taskOutputs[w]&&(b[w]=t.taskOutputs[w]);const k=i+15,_={taskId:`sandbox-task-${n}`,taskType:"JOIN",taskDefName:e.name,referenceTaskName:d,status:"COMPLETED",scheduledTime:s,startTime:i,endTime:k,seq:n,pollCount:1,retryCount:0,iteration:r,inputData:{joinOn:y},outputData:b,workflowTask:e};return t.currentTimeMs=k,t.taskOutputs[e.taskReferenceName]=b,t.tasks.push(_),"COMPLETED"}if(e.type==="DO_WHILE"){const y=e.loopOver||[],b=Math.max(1,Math.min(t.maxLoopIterations,10)),k={taskId:`sandbox-task-${n}`,taskType:"DO_WHILE",taskDefName:e.name,referenceTaskName:d,status:"COMPLETED",scheduledTime:s,startTime:i,endTime:i,seq:n,pollCount:1,retryCount:0,iteration:b,inputData:{loopCondition:e.loopCondition,resolvedInput:c},outputData:{iteration:b},workflowTask:e};t.tasks.push(k);const _={};for(let w=1;w<=b;w++){const T=fr(y,t,w);_[String(w)]={};for(const O of y)t.taskOutputs[O.taskReferenceName]&&(_[String(w)][O.taskReferenceName]=t.taskOutputs[O.taskReferenceName]);if(T!=="COMPLETED")return k.endTime=t.currentTimeMs,T}return k.endTime=t.currentTimeMs+10,k.outputData={iteration:b,..._},t.currentTimeMs=k.endTime,t.taskOutputs[e.taskReferenceName]=k.outputData,"COMPLETED"}const u=e.type==="HTTP"?145+n%4*35:e.type==="SIMPLE"?85+n%5*30:28+n%3*12,f=typeof l?.durationMs=="number"&&l.durationMs>=0?l.durationMs:u,h=i+f,p=Iv(e,c,t,r),m=e.type==="TERMINATE"&&c.terminationStatus==="FAILED",g=l?.status||(m?"FAILED_WITH_TERMINAL_ERROR":"COMPLETED"),x=g==="FAILED"||g==="FAILED_WITH_TERMINAL_ERROR"||g==="TIMED_OUT",v={taskId:`sandbox-task-${n}`,taskType:e.type,taskDefName:e.name,referenceTaskName:d,status:g,scheduledTime:s,startTime:i,endTime:h,seq:n,pollCount:1,retryCount:0,iteration:r,workerId:"browser-local-sandbox-worker",inputData:c,outputData:p,reasonForIncompletion:x?l?.reasonForIncompletion||(m?c.terminationReason||"Terminated with FAILED status":`沙箱人工模拟任务异常 (${g})`):void 0,workflowTask:e};return t.currentTimeMs=h,t.taskOutputs[e.taskReferenceName]=p,t.tasks.push(v),x?"FAILED":e.type==="TERMINATE"?m?"FAILED":"TERMINATED":"COMPLETED"}function Lt(e){const t={orderId:"ORD-2026-88412",userId:"usr_99201",amount:299,currency:"CNY",env:"sandbox"};if(Array.isArray(e.inputParameters))for(const r of e.inputParameters){const n=typeof r=="string"?r:r?.name,s=typeof r=="object"&&r!==null?r.example??r.defaultValue??`sample_${n}`:`sample_${n}`;n&&!(n in t)&&(t[n]=s)}try{const r=JSON.stringify(e.tasks||[]),n=/\$\{\s*workflow\.input\.([a-zA-Z0-9_]+)/g;let s;for(;(s=n.exec(r))!==null;){const a=s[1];a&&!(a in t)&&(t[a]=`mock_${a}`)}}catch{}return t}function im(e,t={}){const r=Date.now()-2e3,n=t.workflowInput||Lt(e),s={workflowInput:n,variables:{},taskOutputs:{},taskMocks:t.taskMocks||{},tasks:[],currentTimeMs:r,maxLoopIterations:t.maxLoopIterations??2,seqCounter:0},a=fr(e.tasks||[],s),i={};if(e.outputParameters&&Object.keys(e.outputParameters).length>0)Object.assign(i,dr(e.outputParameters,s));else{const c=s.tasks[s.tasks.length-1];c?.outputData&&Object.assign(i,c.outputData)}const l=a==="FAILED"?"FAILED":a==="TERMINATED"?"TERMINATED":"COMPLETED";return{workflowId:`sandbox-dryrun-${Date.now().toString(36)}`,workflowName:e.name||"sandbox_workflow",workflowVersion:e.version||1,status:l,startTime:r,endTime:s.currentTimeMs,createTime:r,updateTime:s.currentTimeMs,input:n,output:i,variables:s.variables,tasks:s.tasks,workflowDefinition:structuredClone(e)}}function Dt(e,t=[]){return Array.isArray(e)&&e.forEach((r,n)=>{if(r){if(r.type==="FORK_JOIN_DYNAMIC"){for(let s=n+1;s<e.length;s++)if(e[s]?.type==="JOIN"||e[s]?.type==="EXCLUSIVE_JOIN"){t.push({forkRef:r.taskReferenceName,joinRef:e[s].taskReferenceName});break}}r.decisionCases&&Object.values(r.decisionCases).forEach(s=>Dt(s,t)),r.defaultCase&&Dt(r.defaultCase,t),Array.isArray(r.forkTasks)&&r.forkTasks.forEach(s=>Dt(s,t)),Array.isArray(r.loopOver)&&Dt(r.loopOver,t)}}),t}const oe=vr()(Tl(Vm((e,t)=>({mode:"view",workflowDef:null,workflowInstance:null,nodes:[],edges:[],taskMap:{},layoutDirection:"TB",selectedTask:null,selectedTaskInstance:null,isDetailPanelOpen:!1,executionData:null,dynamicRuntimeTasksByFork:{},validationResults:{isValid:!0,errors:[],warnings:[]},theme:"dark",themeColor:"blue",edgeType:"smoothstep",nodesLocked:!0,copiedTask:null,viewMode:"business",simState:{},isSimRunning:!1,workflowLoadKey:0,runState:"idle",pendingExecutionId:null,executionError:null,showRunPanel:!1,showAnalysisPanel:!1,focusedParamKey:null,showDataLineage:!1,lastRefactorNotice:null,showWaterfallPanel:!1,timeTravelTimestamp:null,activeLoopIterations:{},inlineCopilotTaskRef:null,setWorkflow:(r,n)=>{const s=n||t().layoutDirection,a=JSON.parse(JSON.stringify(r));Le(a.tasks);const{nodes:i,edges:l,taskMap:c}=Ae(a,s,{hideEmptyBranches:t().mode!=="edit"}),{nodes:d,edges:u}=je(i,l,{direction:s,mode:t().mode}),f=We(a);e({workflowDef:a,nodes:d,edges:u,taskMap:c,validationResults:f,layoutDirection:s,workflowLoadKey:t().workflowLoadKey+1})},setMode:r=>{t().mode==="run"&&r!=="run"&&e({executionData:null,workflowInstance:null,dynamicRuntimeTasksByFork:{},timeTravelTimestamp:null,showWaterfallPanel:!1,activeLoopIterations:{}}),e({mode:r});const{workflowDef:s,layoutDirection:a}=t();if(s){const{nodes:i,edges:l,taskMap:c}=Ae(s,a,{hideEmptyBranches:r!=="edit"}),{nodes:d,edges:u}=je(i,l,{direction:a,mode:r});e({nodes:d,edges:u,taskMap:c})}},setExecutionData:r=>e({executionData:r,dynamicRuntimeTasksByFork:r===null?{}:t().dynamicRuntimeTasksByFork}),updateTaskStatus:(r,n)=>{const{executionData:s}=t();if(!s)return;const a={...s};a[r]&&(a[r]={...a[r],status:n},e({executionData:a}))},loadSampleExecution:async()=>{try{const n=await(await fetch("/sample-workflows/sample-execution.json")).json();t().importExecutionJSON(n)}catch(r){console.error("Failed to load sample execution:",r),alert("加载示例运行数据失败")}},importExecutionJSON:r=>{if(!r)return;let n=[],s=null,a=t().workflowDef;if(Array.isArray(r.tasks)?(n=r.tasks,r.workflowId&&r.status&&(s=r,r.workflowDefinition&&(a=r.workflowDefinition))):Array.isArray(r)&&(n=r),n.length===0)return;a&&JSON.stringify(a)!==JSON.stringify(t().workflowDef)&&t().setWorkflow(a);const i=t().taskMap,l={},c=(p,m,g)=>{const x=g!==void 0&&m.iteration===void 0?{...m,iteration:g}:m;l[p]||(l[p]={taskReferenceName:p,status:x.status,attempts:[],startTime:x.startTime,endTime:x.endTime,output:x.outputData,input:x.inputData,reasonForIncompletion:x.reasonForIncompletion,iteration:x.iteration}),l[p].attempts.push(x)};n.forEach(p=>{const m=p.referenceTaskName;if(!m)return;const g=m.match(/^(.+)__(\d+)$/);if(g&&i[g[1]]){const x=g[1],v=parseInt(g[2],10);c(x,p,v)}c(m,p)}),Object.values(l).forEach(p=>{p.attempts.some(x=>x.iteration!==void 0&&x.iteration>0)?(p.attempts.sort((x,v)=>(x.iteration??0)-(v.iteration??0)),p.totalIterations=p.attempts.reduce((x,v)=>Math.max(x,v.iteration??0),0),p.startTime=p.attempts[0]?.startTime):p.attempts.sort((x,v)=>(x.retryCount??0)-(v.retryCount??0));const g=p.attempts[p.attempts.length-1];g&&(p.status=g.status,p.endTime=g.endTime,p.output=g.outputData,p.input=g.inputData,p.reasonForIncompletion=g.reasonForIncompletion,p.iteration=g.iteration)});const u=t().workflowDef?.tasks||[],f=Dt(u),h={};f.forEach(({forkRef:p,joinRef:m})=>{const g=n.findIndex(y=>y.referenceTaskName===p),x=n.findIndex(y=>y.referenceTaskName===m);if(g<0||x<0)return;const v=new Set;h[p]=n.slice(g+1,x).filter(y=>!y.referenceTaskName||!y.taskId||i[y.referenceTaskName]||v.has(y.referenceTaskName)?!1:(v.add(y.referenceTaskName),!0)).map(y=>y)}),e({executionData:l,dynamicRuntimeTasksByFork:h,workflowInstance:s,timeTravelTimestamp:null,activeLoopIterations:{},mode:"run"})},setSelectedTask:r=>e({selectedTask:r?{...r}:null}),setIsDetailPanelOpen:r=>e({isDetailPanelOpen:r}),selectTaskAction:(r,n=!0)=>{e({selectedTask:r?{...r}:null,isDetailPanelOpen:r?n:!1,selectedTaskInstance:null})},setSelectedTaskInstance:r=>e({selectedTaskInstance:r}),setLayoutDirection:r=>{const{workflowDef:n}=t();if(n){const{nodes:s,edges:a,taskMap:i}=Ae(n,r,{hideEmptyBranches:t().mode!=="edit"}),{nodes:l,edges:c}=je(s,a,{direction:r,mode:t().mode});e({nodes:l,edges:c,taskMap:i,layoutDirection:r})}else e({layoutDirection:r})},onNodesChange:r=>{const n=t().nodes,s=new Set(n.map(i=>i.id)),a=r.filter(i=>"id"in i&&s.has(i.id));a.length!==0&&e({nodes:M.applyNodeChanges(a,n)})},onEdgesChange:r=>{const n=t().edges,s=M.applyEdgeChanges(r,n);s!==n&&e({edges:s})},onConnect:r=>{const{edges:n,layoutDirection:s}=t(),a=M.addEdge(r,n),{nodes:i,edges:l}=je(t().nodes,a,{direction:s,mode:t().mode});e({edges:l,nodes:i})},checkTaskRefUniqueness:(r,n)=>{if(r===n)return!0;const{taskMap:s}=t();return!s[r]},updateTask:(r,n,s)=>{const{workflowDef:a,layoutDirection:i}=t();if(!a)return;let l=JSON.parse(JSON.stringify(a)),c=t().lastRefactorNotice;const d=typeof n=="object"?Object.keys(n):[n],u=typeof n=="object"?n.taskReferenceName:n==="taskReferenceName"?s:void 0;let f=r;if(typeof u=="string"&&u.trim()&&u.trim()!==r){const p=u.trim(),m=sm(l,r,p);l=m.updatedDef,f=p,m.replacedCount>0&&(c={oldRef:r,newRef:p,replacedCount:m.replacedCount,affectedTasks:m.affectedTaskRefs,timestamp:Date.now()})}const h=Me(l.tasks,f);if(h){typeof n=="object"?Object.assign(h,n,{taskReferenceName:f}):n!=="taskReferenceName"&&(h[n]=s),Le(l.tasks);const p=We(l),m=new Set(["taskReferenceName","type","decisionCases","defaultCase","forkTasks","loopOver","joinOn"]);if(d.some(x=>m.has(x))){const{nodes:x,edges:v,taskMap:y}=Ae(l,i,{hideEmptyBranches:t().mode!=="edit"}),{nodes:b,edges:k}=je(x,v,{direction:i,mode:t().mode}),_=t().selectedTask?.taskReferenceName===r?h:t().selectedTask;e({workflowDef:l,nodes:b,edges:k,taskMap:y,selectedTask:_,validationResults:p,lastRefactorNotice:c})}else{const x=t().nodes.map(b=>b.data?.taskReferenceName===r?{...b,data:{...b.data,label:h.name||b.data.label,task:h,loopCondition:h.loopCondition??b.data.loopCondition,subWorkflowName:h.subWorkflowParam?.name??b.data.subWorkflowName}}:b),v={...t().taskMap,[r]:h},y=t().selectedTask?.taskReferenceName===r?h:t().selectedTask;e({workflowDef:l,nodes:x,taskMap:v,selectedTask:y,validationResults:p})}}},updateWorkflowProperties:r=>{const{workflowDef:n,layoutDirection:s}=t();if(!n)return;const a=JSON.parse(JSON.stringify(n));Object.assign(a,r),Le(a.tasks);const i=We(a);if("tasks"in r){const{nodes:l,edges:c,taskMap:d}=Ae(a,s,{hideEmptyBranches:t().mode!=="edit"}),{nodes:u,edges:f}=je(l,c,{direction:s,mode:t().mode});e({workflowDef:a,nodes:u,edges:f,taskMap:d,validationResults:i})}else e({workflowDef:a,validationResults:i})},addNode:(r,n,s,a,i={})=>{const{workflowDef:l,layoutDirection:c}=t();if(!l)return;const d=JSON.parse(JSON.stringify(l)),u={name:r.data.label,taskReferenceName:r.data.taskReferenceName,type:r.data.taskType||"SIMPLE",inputParameters:{}};switch(u.type){case"HTTP":u.httpRequest={method:"GET",uri:"https://example.com/api",headers:{"Content-Type":"application/json"},body:{}};break;case"KAFKA_PUBLISH":u.inputParameters={topic:"my_topic",value:"${workflow.input.value}",bootStrapServers:"localhost:9092",headers:{},key:"msg_key"};break;case"JSON_JQ_TRANSFORM":u.inputParameters={queryExpression:".name",input:{}};break;case"SET_VARIABLE":u.inputParameters={variableName:"variableValue"};break;case"SUB_WORKFLOW":u.subWorkflowParam={name:"execution_workflow",version:1};break;case"EVENT":u.sink="conductor";break;case"WAIT":u.inputParameters={duration:"30s"};break;case"TERMINATE":u.inputParameters={terminationStatus:"COMPLETED",workflowOutput:{}};break}if(u.type==="FORK_JOIN"||u.type==="FORK_JOIN_DYNAMIC"){u.type==="FORK_JOIN"?u.forkTasks=[[],[]]:(u.dynamicForkTasksParam="dynamic_tasks",u.dynamicForkTasksInputParamName="input");const v={name:`${u.name}_join`,taskReferenceName:`${u.taskReferenceName}_join`,type:"JOIN",joinOn:[]};if(i.isWorkflowStart)d.tasks.unshift(v),d.tasks.unshift(u);else if(i.isLoopBodyStart){const y=Me(d.tasks,n);y&&(y.loopOver||(y.loopOver=[]),y.loopOver.unshift(v),y.loopOver.unshift(u))}else i.branchCase!==void 0||i.forkIndex!==void 0||i.isLoopAdd?(yt(d.tasks,n,i,u),Je(d.tasks,u.taskReferenceName,v)):d.tasks.length===0?d.tasks.push(u,v):(Je(d.tasks,n,u),Je(d.tasks,u.taskReferenceName,v))}else if(u.type==="DECISION"||u.type==="SWITCH"?(u.evaluatorType="value-param",u.caseValueParam="case_param",u.decisionCases={case1:[]},u.defaultCase=[]):u.type==="DO_WHILE"?(u.loopCondition="$.taskReferenceName.output.value < 10",u.loopOver=[]):u.type==="INLINE"?(u.evaluatorType="graaljs",u.inputParameters={expression:`function execute(input) {
|
|
9
|
+
`)}`}}const dm=new tv,rv=(e,t)=>t.split(".").reduce((r,n)=>r&&r[n]!==void 0?r[n]:void 0,e),ml=(e,t,r,n)=>{const{errors:s,warnings:o}=n,i=e.taskReferenceName||"GLOBAL";t.forEach(l=>{const c=rv(e,l.field);let u=!0;switch(l.type){case"required":u=c!=null&&c!=="";break;case"min_length":u=Array.isArray(c)&&c.length>=l.value;break;case"pattern":u=l.value.test(c);break;case"enum":u=l.value.includes(c);break;case"unique":l.field==="taskReferenceName"&&c&&(r.taskRefs.has(c)?u=!1:r.taskRefs.add(c));break;case"custom":typeof l.validate=="function"&&(u=l.validate(c,e,r));break}if(!u){const d={type:e.taskReferenceName?"TASK":"GLOBAL",ref:i,message:l.message};l.level==="warning"?o.push(d):s.push(d)}})},We=e=>{const t=[],r=[],n={taskRefs:new Set,taskMap:{}};if(!e)return{isValid:!1,errors:[{type:"GLOBAL",ref:"",message:"工作流定义为空"}],warnings:[]};if(ml(e,ev,n,{errors:t,warnings:r}),!e.tasks||e.tasks.length===0)return{isValid:!1,errors:t,warnings:r};const s=i=>{i.forEach(l=>{ml(l,cm.common,n,{errors:t,warnings:r});const c=cm.types[l.type];c&&ml(l,c,n,{errors:t,warnings:r}),l.decisionCases&&Object.keys(l.decisionCases).forEach(u=>{s(l.decisionCases[u])}),l.defaultCase&&s(l.defaultCase),l.forkTasks&&l.forkTasks.forEach(u=>s(u)),l.loopOver&&s(l.loopOver)})};s(e.tasks);const o=nv(e.tasks);if(t.push(...o),dm.hasRules()){const i=dm.runAll(e);t.push(...i.errors),r.push(...i.warnings)}return{isValid:t.length===0,errors:t,warnings:r}},nv=e=>{const t=[],r=new Map,n=new Set,s=d=>{for(let p=0;p<d.length;p++){const h=d[p],f=h.taskReferenceName;if(n.add(f),r.has(f)||r.set(f,[]),p<d.length-1){const m=d[p+1].taskReferenceName;h.type!=="FORK_JOIN"&&h.type!=="FORK_JOIN_DYNAMIC"&&r.get(f).push(m)}if(h.decisionCases)for(const m of Object.values(h.decisionCases))m.length>0&&(r.get(f).push(m[0].taskReferenceName),s(m));if(h.defaultCase&&h.defaultCase.length>0&&(r.get(f).push(h.defaultCase[0].taskReferenceName),s(h.defaultCase)),h.forkTasks)for(const m of h.forkTasks)m.length>0&&(r.get(f).push(m[0].taskReferenceName),s(m));if(h.loopOver)for(const m of h.loopOver)n.add(m.taskReferenceName);if(h.joinOn)for(const m of h.joinOn)r.has(m)||r.set(m,[]),r.get(m).push(f)}};s(e);const o=0,i=1,l=2,c=new Map;for(const d of n)c.set(d,o);const u=d=>{c.set(d,i);const p=r.get(d)||[];for(const h of p)if(c.has(h)){if(c.get(h)===i)return t.push({type:"GLOBAL",ref:h,message:`检测到环路:任务 "${d}" → "${h}" 形成了循环依赖`}),!0;if(c.get(h)===o&&u(h))return!0}return c.set(d,l),!1};for(const d of n)c.get(d)===o&&u(d);return t};function av(e,t){const r=new Set(e),n={};e.forEach(l=>n[l]=0),t.forEach(l=>{r.has(l.source)&&r.has(l.target)&&(n[l.target]=(n[l.target]??0)+1)});const s=[];let o=e.filter(l=>n[l]===0);const i={...n};for(;o.length>0;){s.push([...o]);const l=[];o.forEach(c=>{t.forEach(u=>{u.source===c&&r.has(u.target)&&(i[u.target]--,i[u.target]===0&&l.push(u.target))})}),o=l}return s}function qt(e){return!e||e.length===0?[]:typeof e[0]=="string"?e.map(t=>({name:t})):e}class sv{schemas=new Map;setSchemas(t){this.schemas.clear();for(const r of t)this.schemas.set(r.taskName,r)}get(t){return this.schemas.get(t)}getAll(){return Array.from(this.schemas.values())}hasSchemas(){return this.schemas.size>0}buildPromptSection(){if(!this.hasSchemas())return null;const t=["## 任务 Schema 注册表(数据流参考)","以下任务的输入/输出字段已注册。生成 inputParameters 时请引用正确的上游输出字段(格式:`${taskRef.output.fieldName}`)。"];for(const r of this.getAll()){const n=r.taskType?`(${r.taskType})`:"",s=r.description?` — ${r.description}`:"";if(t.push(`
|
|
10
|
+
**${r.taskName}** ${n}${s}`),r.inputSchema&&Object.keys(r.inputSchema).length>0){const o=Object.entries(r.inputSchema).map(([i,l])=>`${i}: ${l}`).join(", ");t.push(`- 输入: ${o}`)}if(r.outputSchema&&Object.keys(r.outputSchema).length>0){const o=Object.entries(r.outputSchema).map(([i,l])=>`${i}: ${l}`).join(", ");t.push(`- 输出: ${o}`)}}return t.join(`
|
|
11
|
+
`)}}const ov=new sv;function kt(e,t,r){if(t.push({task:e,isConditional:r}),e.decisionCases)for(const n of Object.values(e.decisionCases))for(const s of n||[])kt(s,t,!0);if(e.defaultCase)for(const n of e.defaultCase)kt(n,t,!0);if(e.forkTasks)for(const n of e.forkTasks)for(const s of n||[])kt(s,t,r);if(e.loopOver)for(const n of e.loopOver)kt(n,t,r)}function um(e,t){if(!e||!Array.isArray(e.tasks))return[];const r=[];function n(o,i){for(let l=0;l<o.length;l++){const c=o[l];if(c.taskReferenceName===t)return!0;if(c.decisionCases||c.defaultCase){for(const u of Object.values(c.decisionCases||{})){const d=[];if(s(u||[],!0,d))return r.push({task:c,isConditional:i}),r.push(...d),!0}if(c.defaultCase){const u=[];if(s(c.defaultCase,!0,u))return r.push({task:c,isConditional:i}),r.push(...u),!0}}if(c.forkTasks)for(const u of c.forkTasks){const d=[];if(s(u||[],i,d))return r.push({task:c,isConditional:i}),r.push(...d),!0}if(c.loopOver){const u=[];if(s(c.loopOver,i,u))return r.push({task:c,isConditional:i}),r.push(...u),!0}kt(c,r,i)}return!1}function s(o,i,l){for(let c=0;c<o.length;c++){const u=o[c];if(u.taskReferenceName===t)return!0;if(u.decisionCases||u.defaultCase){for(const d of Object.values(u.decisionCases||{})){const p=[];if(s(d||[],!0,p))return l.push({task:u,isConditional:i}),l.push(...p),!0}if(u.defaultCase){const d=[];if(s(u.defaultCase,!0,d))return l.push({task:u,isConditional:i}),l.push(...d),!0}}if(u.forkTasks)for(const d of u.forkTasks){const p=[];if(s(d||[],i,p))return l.push({task:u,isConditional:i}),l.push(...p),!0}if(u.loopOver){const d=[];if(s(u.loopOver,i,d))return l.push({task:u,isConditional:i}),l.push(...d),!0}kt(u,l,i)}return!1}return n(e.tasks,!1),r}function gl(e,t){return um(e,t).map(r=>r.task)}function hr(e){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string")return e.length>32?`"${e.slice(0,32)}..."`:`"${e}"`;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return`Array(${e.length})`;if(typeof e=="object"){const t=Object.keys(e);return`{ ${t.slice(0,3).join(", ")}${t.length>3?", ...":""} }`}return String(e)}function yl(e){if(e==null)return"any";if(Array.isArray(e))return"array";const t=typeof e;return t==="string"||t==="number"||t==="boolean"||t==="object"?t:"any"}function xl(e,t,r="",n=0,s=3,o=[]){if(!e||typeof e!="object"||n>s)return o;for(const[i,l]of Object.entries(e)){const c=r?`${r}.${i}`:i,u=yl(l);o.push({path:c,expression:`\${${t}.output.${c}}`,valueType:u,sampleValue:hr(l),source:"runtime_sample"}),u==="object"&&l!==null&&Object.keys(l).length>0&&n<s?xl(l,t,c,n+1,s,o):u==="array"&&Array.isArray(l)&&l.length>0&&typeof l[0]=="object"&&l[0]!==null&&n<s&&xl(l[0],t,`${c}[0]`,n+1,s,o)}return o}function pm(e,t){const r=e.taskReferenceName,n=new Map,s=t?.[r]?.output;if(s&&typeof s=="object"){const l=xl(s,r);for(const c of l)n.set(c.path,c)}const o=ov.get(e.name);if(o?.outputSchema){for(const[l,c]of Object.entries(o.outputSchema))if(!n.has(l)){const u=c.toLowerCase(),d=u.includes("number")||u.includes("int")?"number":u.includes("bool")?"boolean":u.includes("array")||u.includes("[]")?"array":u.includes("object")?"object":"string";n.set(l,{path:l,expression:`\${${r}.output.${l}}`,valueType:d,description:c,source:"schema_registry"})}}const i=(l,c,u)=>{n.has(l)||n.set(l,{path:l,expression:`\${${r}.output.${l}}`,valueType:c,description:u,source:"task_type_contract"})};switch(e.type){case"HTTP":i("response.body","object","HTTP 响应体 JSON 数据"),i("response.statusCode","number","HTTP 状态码 (如 200)"),i("response.headers","object","HTTP 响应头");break;case"JSON_JQ_TRANSFORM":i("result","any","JQ 表达式单值计算结果"),i("resultList","array","JQ 表达式列表计算结果");break;case"DO_WHILE":i("iteration","number","当前循环迭代轮次 (从 1 开始)");break;case"SUB_WORKFLOW":i("workflowId","string","子工作流实例 ID"),i("result","object","子工作流返回输出");break;case"HUMAN":i("approved","boolean","人工审批结果"),i("comment","string","审批意见备注"),i("assignee","string","实际审批人");break;default:n.size===0&&(i("result","any",`${e.name||r} 默认执行结果`),i("data","object",`${e.name||r} 业务输出对象`));break}return Array.from(n.values())}function fm(e,t,r,n){if(!e)return[];const s=[],o=qt(e.inputParameters);if(o.length>0)for(const u of o){const d=n?.[u.name]??u.defaultValue;s.push({label:`workflow.input.${u.name}`,value:`\${workflow.input.${u.name}}`,category:"workflow_input",valueType:u.type==="number"?"number":u.type==="boolean"?"boolean":u.type==="object"?"object":u.type==="array"?"array":"string",sourceRef:"workflow.input",sourceLabel:"工作流输入",description:u.description||`工作流启动参数 ${u.name}`,sampleValue:d!==void 0&&d!==""?hr(d):void 0})}else if(n&&typeof n=="object")for(const[u,d]of Object.entries(n))s.push({label:`workflow.input.${u}`,value:`\${workflow.input.${u}}`,category:"workflow_input",valueType:yl(d),sourceRef:"workflow.input",sourceLabel:"工作流输入",description:`工作流运行态输入字段 ${u}`,sampleValue:hr(d)});else s.push({label:"workflow.input.data",value:"${workflow.input.data}",category:"workflow_input",valueType:"any",sourceRef:"workflow.input",sourceLabel:"工作流输入",description:"引用工作流启动时传入的参数(可在全局设置中定义 inputParameters)"});const i=um(e,t),l=new Set;for(let u=i.length-1;u>=0;u--){const{task:d,isConditional:p}=i[u];if(d.type==="SET_VARIABLE"&&d.inputParameters){for(const[f,m]of Object.entries(d.inputParameters))l.has(f)||(l.add(f),s.push({label:`workflow.variables.${f}`,value:`\${workflow.variables.${f}}`,category:"variable",valueType:yl(m),sourceRef:d.taskReferenceName,sourceLabel:`变量 (${d.name||d.taskReferenceName})`,description:`由上游 SET_VARIABLE 节点 [${d.taskReferenceName}] 设置的全局变量`,sampleValue:hr(m),isConditional:p}));continue}if(d.type==="JOIN"||d.type==="TERMINATE")continue;const h=pm(d,r);for(const f of h)s.push({label:`${d.taskReferenceName}.output.${f.path}`,value:f.expression,category:"upstream",valueType:f.valueType,sourceRef:d.taskReferenceName,sourceLabel:`${d.name||d.taskReferenceName} (${d.type})`,description:f.description||`来自上游任务 [${d.name||d.taskReferenceName}] 的输出字段`,sampleValue:f.sampleValue,isConditional:p})}const c=[{key:"workflow.workflowId",desc:"当前工作流执行实例唯一 ID"},{key:"workflow.correlationId",desc:"外部业务关联 ID (Correlation ID)"},{key:"workflow.status",desc:"当前工作流状态"},{key:"workflow.version",desc:"当前工作流定义版本号"}];for(const u of c)s.push({label:u.key,value:`\${${u.key}}`,category:"system",valueType:"string",sourceRef:"workflow",sourceLabel:"系统元数据",description:u.desc});return s}function dt(e,t=[]){if(!e)return t;for(const r of e){if(t.push(r),r.decisionCases)for(const n of Object.values(r.decisionCases))dt(n,t);if(r.defaultCase&&dt(r.defaultCase,t),r.forkTasks)for(const n of r.forkTasks)dt(n,t);r.loopOver&&dt(r.loopOver,t)}return t}function St(e,t=[]){if(typeof e=="string"){const r=/\$\{([^}]+)\}/g;let n;for(;(n=r.exec(e))!==null;)t.push(n[1].trim())}else if(Array.isArray(e))for(const r of e)St(r,t);else if(e&&typeof e=="object")for(const r of Object.values(e))St(r,t);return t}function hm(e){if(!e||!Array.isArray(e.tasks))return{edges:[],diagnostics:[]};const t=dt(e.tasks),r=new Map,n=new Map;for(const l of t)if(r.set(l.taskReferenceName,l),l.type==="SET_VARIABLE"&&l.inputParameters)for(const c of Object.keys(l.inputParameters))n.set(c,l.taskReferenceName);const s=[],o=[],i=new Set;for(const l of t){const c=l.taskReferenceName,u=new Set(gl(e,c).map(p=>p.taskReferenceName)),d=[];St(l.inputParameters,d),St(l.httpRequest,d),l.loopCondition&&St(l.loopCondition,d),l.expression&&St(l.expression,d);for(const p of d){if(p.startsWith("workflow.input.")||p==="workflow.input")continue;if(p.startsWith("workflow.variables.")){const f=p.slice(19).split(".")[0],m=n.get(f);if(m&&m!==c){const g=u.has(m),y=`dfg-${m}->${c}-var:${f}`;i.has(y)||(i.add(y),s.push({id:y,sourceRef:m,targetRef:c,fieldPath:`variables.${f}`,expression:`\${${p}}`,sourceType:"workflow_variable",isValidUpstream:g,issue:g?void 0:"forward_ref"}))}continue}if(p.startsWith("workflow."))continue;const h=p.split(".");if(h.length>=2&&(h[1]==="output"||h[1]==="input")){const f=h[0],m=h.slice(2).join(".")||h[1];if(f===c)continue;const g=r.has(f),y=u.has(f);let b;g?y||(b="forward_ref",o.push({taskRef:c,expression:`\${${p}}`,issue:"forward_ref",message:`任务 [${c}] 引用了非上游或互斥分支任务 "${f}" 的输出`})):(b="undefined_ref",o.push({taskRef:c,expression:`\${${p}}`,issue:"undefined_ref",message:`任务 [${c}] 引用了不存在的任务 "${f}"`}));const x=`dfg-${f}->${c}-${m}`;i.has(x)||(i.add(x),s.push({id:x,sourceRef:f,targetRef:c,fieldPath:m,expression:`\${${p}}`,sourceType:"task_output",isValidUpstream:g&&y,issue:b}))}}}return{edges:s,diagnostics:o}}function mm(e,t,r){const n=t.trim(),s=r.trim();if(!n||!s||n===s)return{updatedDef:e,replacedCount:0,affectedTaskRefs:[]};const o=JSON.parse(JSON.stringify(e));let i=0;const l=new Set,c=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),u=new RegExp(`\\$\\{\\s*${c}(\\.|\\s*\\})`,"g"),d=new RegExp(`\\$\\.\\b${c}\\b`,"g");function p(f,m){if(typeof f=="string"){let g=f;return u.lastIndex=0,u.test(g)&&(g=g.replace(u,(y,b)=>(i++,l.add(m),`\${${s}${b}`))),d.lastIndex=0,d.test(g)&&(g=g.replace(d,()=>(i++,l.add(m),`$.${s}`))),g}if(Array.isArray(f))return f.map(g=>p(g,m));if(f&&typeof f=="object"){const g={};for(const[y,b]of Object.entries(f))g[y]=p(b,m);return g}return f}const h=dt(o.tasks);for(const f of h){const m=f.taskReferenceName===n?s:f.taskReferenceName;f.taskReferenceName===n&&(f.taskReferenceName=s),f.inputParameters&&(f.inputParameters=p(f.inputParameters,m)),f.httpRequest&&(f.httpRequest=p(f.httpRequest,m)),f.loopCondition&&(f.loopCondition=p(f.loopCondition,m)),f.expression&&(f.expression=p(f.expression,m)),Array.isArray(f.joinOn)&&(f.joinOn=f.joinOn.map(g=>g===n?(i++,l.add(m),s):g)),Array.isArray(f.defaultExclusiveJoinTask)&&(f.defaultExclusiveJoinTask=f.defaultExclusiveJoinTask.map(g=>g===n?(i++,l.add(m),s):g))}return o.outputParameters&&(o.outputParameters=p(o.outputParameters,"__workflow_output__")),l.delete(s),{updatedDef:o,replacedCount:i,affectedTaskRefs:Array.from(l)}}function gm(e){return!e||typeof e!="object"?null:e.__isMockOverride||"outputData"in e||"forceCase"in e||"durationMs"in e||"status"in e&&(e.status==="COMPLETED"||e.status==="FAILED"||e.status==="TIMED_OUT"||e.status==="COMPLETED_WITH_ERRORS")&&Object.keys(e).every(t=>["__isMockOverride","status","durationMs","forceCase","outputData","reasonForIncompletion"].includes(t))?e:{__isMockOverride:!0,outputData:e}}function mr(e,t){if(!e||!t)return;const r=t.split(".");let n=e;for(const s of r){if(n==null)return;n=n[s]}return n}function gr(e,t){if(typeof e=="string"){const r=e.match(/^\$\{([^}]+)\}$/);if(r){const n=ym(r[1].trim(),t);return n!==void 0?n:e}return e.replace(/\$\{([^}]+)\}/g,(n,s)=>{const o=ym(s.trim(),t);return o===void 0?n:typeof o=="object"?JSON.stringify(o):String(o)})}if(Array.isArray(e))return e.map(r=>gr(r,t));if(e&&typeof e=="object"){const r={};for(const[n,s]of Object.entries(e))r[n]=gr(s,t);return r}return e}function ym(e,t){if(e==="workflow.input")return t.workflowInput;if(e.startsWith("workflow.input."))return mr(t.workflowInput,e.slice(15));if(e==="workflow.variables")return t.variables;if(e.startsWith("workflow.variables."))return mr(t.variables,e.slice(19));if(e==="workflow.workflowId")return"sandbox-dryrun-wf-001";if(e==="workflow.correlationId")return"corr-sandbox-9921";const r=e.indexOf(".output");if(r>0){const n=e.slice(0,r),s=e.slice(r+7),o=t.taskOutputs[n];if(!o)return;if(!s||s==="")return o;if(s.startsWith("."))return mr(o,s.slice(1))}}function yr(e,t={},r){switch(e.type){case"HTTP":{const n=t.http_request||e.httpRequest||t;return{response:{statusCode:200,headers:{"content-type":"application/json","x-sandbox":"true"},body:{code:0,status:"SUCCESS",message:`Simulated HTTP ${n?.method||"GET"} response for ${e.name}`,requestEcho:n?.uri||"/api/v1/resource",data:{id:`res_${e.taskReferenceName}_${r||1}`,verified:!0,score:95,items:[{id:1,name:"item-alpha"},{id:2,name:"item-beta"}]}}}}}case"JSON_JQ_TRANSFORM":{const n=t.queryExpression||e.inputParameters?.queryExpression||".";if(n==="."||!n){const s={...t};return delete s.queryExpression,{result:s,resultList:[s]}}if(typeof n=="string"&&n.startsWith(".")){const s=n.slice(1).replace(/\[\]/g,""),o=s?mr(t,s):t;return{result:o!==void 0?o:{transformed:!0,expression:n},resultList:Array.isArray(o)?o:[o??{transformed:!0}]}}return{result:{transformed:!0,queryExpression:n,sourceKeys:Object.keys(t)},resultList:[{transformed:!0}]}}case"SET_VARIABLE":return{variables:{...Object.keys(t).length?t:e.inputParameters||{}}};case"INLINE":return{result:{evaluated:!0,evaluatorType:t.evaluatorType||e.evaluatorType||"graaljs",summary:`Executed inline script for ${e.taskReferenceName}`,...t}};case"EVENT":return{event_produced:`conductor:event:${e.sink||e.name}`,payload:t};case"WAIT":return{waited:!0,duration:t.duration||"1s"};case"TERMINATE":return{terminationStatus:t.terminationStatus||"COMPLETED",terminationReason:t.terminationReason||"Terminated in sandbox dry-run",output:t.workflowOutput||{}};default:return{code:0,status:"OK",result:`Simulated output from ${e.name}`,processedAt:new Date().toISOString(),iteration:r??1,inputEcho:t,data:{id:`${e.taskReferenceName}_out_${r||1}`,approved:!0,amount:t.amount??100}}}}function iv(e,t,r,n){const s=gm(r.taskMocks[e.taskReferenceName]);if(s?.outputData)return e.type==="SET_VARIABLE"&&Object.assign(r.variables,s.outputData),structuredClone(s.outputData);e.type==="SET_VARIABLE"&&Object.assign(r.variables,t);const o=yr(e,t,n);return o.processedAt&&(o.processedAt=new Date(r.currentTimeMs).toISOString()),o}function lv(e,t,r,n){if(n)return n;const s=Object.keys(r);if(s.length===0)return"default";const o=e.caseValueParam||"case_value",i=t[o]??e.expression;if(i!=null){const l=String(i).trim();if(r[l])return l;for(const c of s)if(l.includes(c))return c}return s[0]}function xr(e,t,r){for(const n of e){const s=cv(n,t,r);if(s==="FAILED"||s==="TERMINATED")return s}return"COMPLETED"}function cv(e,t,r){t.seqCounter+=1;const n=t.seqCounter,s=t.currentTimeMs,o=8+n%5*4,i=s+o;t.currentTimeMs=i;const l=gm(t.taskMocks[e.taskReferenceName]),c=gr(e.inputParameters||{},t),u=r&&r>1?`${e.taskReferenceName}__${r}`:e.taskReferenceName;if(e.type==="SWITCH"||e.type==="DECISION"){const x=e.decisionCases||{},v=lv(e,c,x,l?.forceCase),k=v==="__default__"?e.defaultCase||[]:x[v]||e.defaultCase||[],_={taskId:`sandbox-task-${n}`,taskType:e.type,taskDefName:e.name,referenceTaskName:u,status:"COMPLETED",scheduledTime:s,startTime:i,endTime:i+(l?.durationMs??12),seq:n,pollCount:1,retryCount:0,iteration:r,inputData:{...c,case_value_param:v},outputData:l?.outputData||{selectedCase:v==="__default__"?"defaultCase":v,evaluatedExpression:e.expression||e.caseValueParam||"default"},workflowTask:e};return t.currentTimeMs=_.endTime,t.taskOutputs[e.taskReferenceName]=_.outputData,t.tasks.push(_),xr(k,t,r)}if(e.type==="FORK_JOIN"){const x=e.forkTasks||[],v=i,k={taskId:`sandbox-task-${n}`,taskType:"FORK_JOIN",taskDefName:e.name,referenceTaskName:u,status:"COMPLETED",scheduledTime:s,startTime:v,endTime:v+10,seq:n,pollCount:1,retryCount:0,iteration:r,inputData:c,outputData:{forkedBranches:x.length},workflowTask:e};t.tasks.push(k);const _=v+10;let S=_;for(const j of x){t.currentTimeMs=_;const R=xr(j,t,r);if(t.currentTimeMs>S&&(S=t.currentTimeMs),R!=="COMPLETED")return R}return t.currentTimeMs=S,t.taskOutputs[e.taskReferenceName]=k.outputData,"COMPLETED"}if(e.type==="JOIN"){const x=e.joinOn||[],v={};for(const S of x)t.taskOutputs[S]&&(v[S]=t.taskOutputs[S]);const k=i+15,_={taskId:`sandbox-task-${n}`,taskType:"JOIN",taskDefName:e.name,referenceTaskName:u,status:"COMPLETED",scheduledTime:s,startTime:i,endTime:k,seq:n,pollCount:1,retryCount:0,iteration:r,inputData:{joinOn:x},outputData:v,workflowTask:e};return t.currentTimeMs=k,t.taskOutputs[e.taskReferenceName]=v,t.tasks.push(_),"COMPLETED"}if(e.type==="DO_WHILE"){const x=e.loopOver||[],v=Math.max(1,Math.min(t.maxLoopIterations,10)),k={taskId:`sandbox-task-${n}`,taskType:"DO_WHILE",taskDefName:e.name,referenceTaskName:u,status:"COMPLETED",scheduledTime:s,startTime:i,endTime:i,seq:n,pollCount:1,retryCount:0,iteration:v,inputData:{loopCondition:e.loopCondition,resolvedInput:c},outputData:{iteration:v},workflowTask:e};t.tasks.push(k);const _={};for(let S=1;S<=v;S++){const j=xr(x,t,S);_[String(S)]={};for(const R of x)t.taskOutputs[R.taskReferenceName]&&(_[String(S)][R.taskReferenceName]=t.taskOutputs[R.taskReferenceName]);if(j!=="COMPLETED")return k.endTime=t.currentTimeMs,j}return k.endTime=t.currentTimeMs+10,k.outputData={iteration:v,..._},t.currentTimeMs=k.endTime,t.taskOutputs[e.taskReferenceName]=k.outputData,"COMPLETED"}const d=e.type==="HTTP"?145+n%4*35:e.type==="SIMPLE"?85+n%5*30:28+n%3*12,p=typeof l?.durationMs=="number"&&l.durationMs>=0?l.durationMs:d,h=i+p,f=iv(e,c,t,r),m=e.type==="TERMINATE"&&c.terminationStatus==="FAILED",g=l?.status||(m?"FAILED_WITH_TERMINAL_ERROR":"COMPLETED"),y=g==="FAILED"||g==="FAILED_WITH_TERMINAL_ERROR"||g==="TIMED_OUT",b={taskId:`sandbox-task-${n}`,taskType:e.type,taskDefName:e.name,referenceTaskName:u,status:g,scheduledTime:s,startTime:i,endTime:h,seq:n,pollCount:1,retryCount:0,iteration:r,workerId:"browser-local-sandbox-worker",inputData:c,outputData:f,reasonForIncompletion:y?l?.reasonForIncompletion||(m?c.terminationReason||"Terminated with FAILED status":`沙箱人工模拟任务异常 (${g})`):void 0,workflowTask:e};return t.currentTimeMs=h,t.taskOutputs[e.taskReferenceName]=f,t.tasks.push(b),y?"FAILED":e.type==="TERMINATE"?m?"FAILED":"TERMINATED":"COMPLETED"}function zt(e){const t={orderId:"ORD-2026-88412",userId:"usr_99201",amount:299,currency:"CNY",env:"sandbox"};if(Array.isArray(e.inputParameters))for(const r of e.inputParameters){const n=typeof r=="string"?r:r?.name,s=typeof r=="object"&&r!==null?r.example??r.defaultValue??`sample_${n}`:`sample_${n}`;n&&!(n in t)&&(t[n]=s)}try{const r=JSON.stringify(e.tasks||[]),n=/\$\{\s*workflow\.input\.([a-zA-Z0-9_]+)/g;let s;for(;(s=n.exec(r))!==null;){const o=s[1];o&&!(o in t)&&(t[o]=`mock_${o}`)}}catch{}return t}function $t(e,t={}){const r=Date.now()-2e3,n=t.workflowInput||zt(e),s={workflowInput:n,variables:{},taskOutputs:{},taskMocks:t.taskMocks||{},tasks:[],currentTimeMs:r,maxLoopIterations:t.maxLoopIterations??2,seqCounter:0},o=xr(e.tasks||[],s),i={};if(e.outputParameters&&Object.keys(e.outputParameters).length>0)Object.assign(i,gr(e.outputParameters,s));else{const c=s.tasks[s.tasks.length-1];c?.outputData&&Object.assign(i,c.outputData)}const l=o==="FAILED"?"FAILED":o==="TERMINATED"?"TERMINATED":"COMPLETED";return{workflowId:`sandbox-dryrun-${Date.now().toString(36)}`,workflowName:e.name||"sandbox_workflow",workflowVersion:e.version||1,status:l,startTime:r,endTime:s.currentTimeMs,createTime:r,updateTime:s.currentTimeMs,input:n,output:i,variables:s.variables,tasks:s.tasks,workflowDefinition:structuredClone(e)}}function Wt(e,t=[]){return Array.isArray(e)&&e.forEach((r,n)=>{if(r){if(r.type==="FORK_JOIN_DYNAMIC"){for(let s=n+1;s<e.length;s++)if(e[s]?.type==="JOIN"||e[s]?.type==="EXCLUSIVE_JOIN"){t.push({forkRef:r.taskReferenceName,joinRef:e[s].taskReferenceName});break}}r.decisionCases&&Object.values(r.decisionCases).forEach(s=>Wt(s,t)),r.defaultCase&&Wt(r.defaultCase,t),Array.isArray(r.forkTasks)&&r.forkTasks.forEach(s=>Wt(s,t)),Array.isArray(r.loopOver)&&Wt(r.loopOver,t)}}),t}const le=Ir()(Ll(Ig((e,t)=>({mode:"view",workflowDef:null,workflowInstance:null,nodes:[],edges:[],taskMap:{},layoutDirection:"TB",selectedTask:null,selectedTaskInstance:null,isDetailPanelOpen:!1,executionData:null,dynamicRuntimeTasksByFork:{},validationResults:{isValid:!0,errors:[],warnings:[]},theme:"dark",themeColor:"blue",edgeType:"smoothstep",nodesLocked:!0,copiedTask:null,viewMode:"business",simState:{},isSimRunning:!1,workflowLoadKey:0,runState:"idle",pendingExecutionId:null,executionError:null,showRunPanel:!1,showAnalysisPanel:!1,focusedParamKey:null,showDataLineage:!1,lastRefactorNotice:null,showWaterfallPanel:!1,timeTravelTimestamp:null,activeLoopIterations:{},inlineCopilotTaskRef:null,setWorkflow:(r,n)=>{const s=n||t().layoutDirection,o=JSON.parse(JSON.stringify(r));Ae(o.tasks);const{nodes:i,edges:l,taskMap:c}=De(o,s,{hideEmptyBranches:t().mode!=="edit"}),{nodes:u,edges:d}=Ne(i,l,{direction:s,mode:t().mode}),p=We(o);e({workflowDef:o,nodes:u,edges:d,taskMap:c,validationResults:p,layoutDirection:s,workflowLoadKey:t().workflowLoadKey+1})},setMode:r=>{t().mode==="run"&&r!=="run"&&e({executionData:null,workflowInstance:null,dynamicRuntimeTasksByFork:{},timeTravelTimestamp:null,showWaterfallPanel:!1,activeLoopIterations:{}}),e({mode:r});const{workflowDef:s,layoutDirection:o}=t();if(s){const{nodes:i,edges:l,taskMap:c}=De(s,o,{hideEmptyBranches:r!=="edit"}),{nodes:u,edges:d}=Ne(i,l,{direction:o,mode:r});e({nodes:u,edges:d,taskMap:c})}},setExecutionData:r=>e({executionData:r,dynamicRuntimeTasksByFork:r===null?{}:t().dynamicRuntimeTasksByFork}),updateTaskStatus:(r,n)=>{const{executionData:s}=t();if(!s)return;const o={...s};o[r]&&(o[r]={...o[r],status:n},e({executionData:o}))},loadSampleExecution:async()=>{try{const n=await(await fetch("/sample-workflows/sample-execution.json")).json();t().importExecutionJSON(n)}catch(r){console.error("Failed to load sample execution:",r),alert("加载示例运行数据失败")}},importExecutionJSON:r=>{if(!r)return;let n=[],s=null,o=t().workflowDef;if(Array.isArray(r.tasks)?(n=r.tasks,r.workflowId&&r.status&&(s=r,r.workflowDefinition&&(o=r.workflowDefinition))):Array.isArray(r)&&(n=r),n.length===0)return;o&&JSON.stringify(o)!==JSON.stringify(t().workflowDef)&&t().setWorkflow(o);const i=t().taskMap,l={},c=(f,m,g)=>{const y=g!==void 0&&m.iteration===void 0?{...m,iteration:g}:m;l[f]||(l[f]={taskReferenceName:f,status:y.status,attempts:[],startTime:y.startTime,endTime:y.endTime,output:y.outputData,input:y.inputData,reasonForIncompletion:y.reasonForIncompletion,iteration:y.iteration}),l[f].attempts.push(y)};n.forEach(f=>{const m=f.referenceTaskName;if(!m)return;const g=m.match(/^(.+)__(\d+)$/);if(g&&i[g[1]]){const y=g[1],b=parseInt(g[2],10);c(y,f,b)}c(m,f)}),Object.values(l).forEach(f=>{f.attempts.some(y=>y.iteration!==void 0&&y.iteration>0)?(f.attempts.sort((y,b)=>(y.iteration??0)-(b.iteration??0)),f.totalIterations=f.attempts.reduce((y,b)=>Math.max(y,b.iteration??0),0),f.startTime=f.attempts[0]?.startTime):f.attempts.sort((y,b)=>(y.retryCount??0)-(b.retryCount??0));const g=f.attempts[f.attempts.length-1];g&&(f.status=g.status,f.endTime=g.endTime,f.output=g.outputData,f.input=g.inputData,f.reasonForIncompletion=g.reasonForIncompletion,f.iteration=g.iteration)});const d=t().workflowDef?.tasks||[],p=Wt(d),h={};p.forEach(({forkRef:f,joinRef:m})=>{const g=n.findIndex(x=>x.referenceTaskName===f),y=n.findIndex(x=>x.referenceTaskName===m);if(g<0||y<0)return;const b=new Set;h[f]=n.slice(g+1,y).filter(x=>!x.referenceTaskName||!x.taskId||i[x.referenceTaskName]||b.has(x.referenceTaskName)?!1:(b.add(x.referenceTaskName),!0)).map(x=>x)}),e({executionData:l,dynamicRuntimeTasksByFork:h,workflowInstance:s,timeTravelTimestamp:null,activeLoopIterations:{},mode:"run"})},setSelectedTask:r=>e({selectedTask:r?{...r}:null}),setIsDetailPanelOpen:r=>e({isDetailPanelOpen:r}),selectTaskAction:(r,n=!0)=>{e({selectedTask:r?{...r}:null,isDetailPanelOpen:r?n:!1,selectedTaskInstance:null})},setSelectedTaskInstance:r=>e({selectedTaskInstance:r}),setLayoutDirection:r=>{const{workflowDef:n}=t();if(n){const{nodes:s,edges:o,taskMap:i}=De(n,r,{hideEmptyBranches:t().mode!=="edit"}),{nodes:l,edges:c}=Ne(s,o,{direction:r,mode:t().mode});e({nodes:l,edges:c,taskMap:i,layoutDirection:r})}else e({layoutDirection:r})},onNodesChange:r=>{const n=t().nodes,s=new Set(n.map(i=>i.id)),o=r.filter(i=>"id"in i&&s.has(i.id));o.length!==0&&e({nodes:q.applyNodeChanges(o,n)})},onEdgesChange:r=>{const n=t().edges,s=q.applyEdgeChanges(r,n);s!==n&&e({edges:s})},onConnect:r=>{const{edges:n,layoutDirection:s}=t(),o=q.addEdge(r,n),{nodes:i,edges:l}=Ne(t().nodes,o,{direction:s,mode:t().mode});e({edges:l,nodes:i})},checkTaskRefUniqueness:(r,n)=>{if(r===n)return!0;const{taskMap:s}=t();return!s[r]},updateTask:(r,n,s)=>{const{workflowDef:o,layoutDirection:i}=t();if(!o)return;let l=JSON.parse(JSON.stringify(o)),c=t().lastRefactorNotice;const u=typeof n=="object"?Object.keys(n):[n],d=typeof n=="object"?n.taskReferenceName:n==="taskReferenceName"?s:void 0;let p=r;if(typeof d=="string"&&d.trim()&&d.trim()!==r){const f=d.trim(),m=mm(l,r,f);l=m.updatedDef,p=f,m.replacedCount>0&&(c={oldRef:r,newRef:f,replacedCount:m.replacedCount,affectedTasks:m.affectedTaskRefs,timestamp:Date.now()})}const h=qe(l.tasks,p);if(h){typeof n=="object"?Object.assign(h,n,{taskReferenceName:p}):n!=="taskReferenceName"&&(h[n]=s),Ae(l.tasks);const f=We(l),m=new Set(["taskReferenceName","type","decisionCases","defaultCase","forkTasks","loopOver","joinOn"]);if(u.some(y=>m.has(y))){const{nodes:y,edges:b,taskMap:x}=De(l,i,{hideEmptyBranches:t().mode!=="edit"}),{nodes:v,edges:k}=Ne(y,b,{direction:i,mode:t().mode}),_=t().selectedTask?.taskReferenceName===r?h:t().selectedTask;e({workflowDef:l,nodes:v,edges:k,taskMap:x,selectedTask:_,validationResults:f,lastRefactorNotice:c})}else{const y=t().nodes.map(v=>v.data?.taskReferenceName===r?{...v,data:{...v.data,label:h.name||v.data.label,task:h,loopCondition:h.loopCondition??v.data.loopCondition,subWorkflowName:h.subWorkflowParam?.name??v.data.subWorkflowName}}:v),b={...t().taskMap,[r]:h},x=t().selectedTask?.taskReferenceName===r?h:t().selectedTask;e({workflowDef:l,nodes:y,taskMap:b,selectedTask:x,validationResults:f})}}},updateWorkflowProperties:r=>{const{workflowDef:n,layoutDirection:s}=t();if(!n)return;const o=JSON.parse(JSON.stringify(n));Object.assign(o,r),Ae(o.tasks);const i=We(o);if("tasks"in r){const{nodes:l,edges:c,taskMap:u}=De(o,s,{hideEmptyBranches:t().mode!=="edit"}),{nodes:d,edges:p}=Ne(l,c,{direction:s,mode:t().mode});e({workflowDef:o,nodes:d,edges:p,taskMap:u,validationResults:i})}else e({workflowDef:o,validationResults:i})},addNode:(r,n,s,o,i={})=>{const{workflowDef:l,layoutDirection:c}=t();if(!l)return;const u=JSON.parse(JSON.stringify(l)),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 b={name:`${d.name}_join`,taskReferenceName:`${d.taskReferenceName}_join`,type:"JOIN",joinOn:[]};if(i.isWorkflowStart)u.tasks.unshift(b),u.tasks.unshift(d);else if(i.isLoopBodyStart){const x=qe(u.tasks,n);x&&(x.loopOver||(x.loopOver=[]),x.loopOver.unshift(b),x.loopOver.unshift(d))}else i.branchCase!==void 0||i.forkIndex!==void 0||i.isLoopAdd?(vt(u.tasks,n,i,d),Je(u.tasks,d.taskReferenceName,b)):u.tasks.length===0?u.tasks.push(d,b):(Je(u.tasks,n,d),Je(u.tasks,d.taskReferenceName,b))}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) {
|
|
12
12
|
return { result: input };
|
|
13
13
|
}
|
|
14
|
-
execute($.input);`}):u.type==="DYNAMIC"?(u.dynamicTaskNameParam="taskToExecute",u.inputParameters={taskToExecute:"${workflow.input.taskName}"}):u.type==="HUMAN"?u.humanTaskDef={userFormTemplate:"",assignmentCompletionStrategy:"LEAVE_OPEN"}:u.type==="START_WORKFLOW"?u.inputParameters={startWorkflow:{name:"",version:1,input:{},correlationId:""}}:u.type==="NOOP"&&(u.inputParameters={}),i.isWorkflowStart)d.tasks.unshift(u);else if(i.isLoopBodyStart){const v=Me(d.tasks,n);v&&(v.loopOver||(v.loopOver=[]),v.loopOver.unshift(u))}else i.branchCase!==void 0||i.forkIndex!==void 0||i.isLoopAdd?yt(d.tasks,n,i,u):d.tasks.length===0?d.tasks.push(u):Je(d.tasks,n,u);Le(d.tasks);const{nodes:f,edges:h,taskMap:p}=Ae(d,c,{hideEmptyBranches:t().mode!=="edit"}),{nodes:m,edges:g}=je(f,h,{direction:c,mode:t().mode}),x=We(d);e({workflowDef:d,nodes:m,edges:g,taskMap:p,validationResults:x})},removeNode:r=>{const{workflowDef:n,layoutDirection:s,nodes:a}=t();if(!n)return;const i=JSON.parse(JSON.stringify(n)),l=gt(i.tasks,r);if(l){const m=a.find(g=>g.id===r)?.data?.taskType;if(m==="FORK_JOIN"||m==="FORK_JOIN_DYNAMIC"){const g=Yh(l,r);g&&Ge(i.tasks,g)}else if(m==="JOIN"||m==="EXCLUSIVE_JOIN"){const g=Xh(l,r);g&&Ge(i.tasks,g)}}Ge(i.tasks,r),Le(i.tasks);const{nodes:c,edges:d,taskMap:u}=Ae(i,s,{hideEmptyBranches:t().mode!=="edit"}),{nodes:f,edges:h}=je(c,d,{direction:s,mode:t().mode}),p=We(i);e({workflowDef:i,nodes:f,edges:h,taskMap:u,validationResults:p})},addLoopTask:(r,n)=>{const{workflowDef:s,layoutDirection:a}=t();if(!s)return;const i=JSON.parse(JSON.stringify(s)),l=Me(i.tasks,r);if(l&&l.type==="DO_WHILE"){l.loopOver||(l.loopOver=[]);const c={name:`new_${n.toLowerCase()}`,taskReferenceName:`${r}_sub_${Date.now()}`,type:n,inputParameters:{}};l.loopOver.push(c),Le(i.tasks);const{nodes:d,edges:u,taskMap:f}=Ae(i,a,{hideEmptyBranches:t().mode!=="edit"}),{nodes:h,edges:p}=je(d,u,{direction:a,mode:t().mode}),m=We(i);e({workflowDef:i,nodes:h,edges:p,taskMap:f,validationResults:m})}},removeLoopTask:(r,n)=>{const{workflowDef:s,layoutDirection:a}=t();if(!s)return;const i=JSON.parse(JSON.stringify(s)),l=Me(i.tasks,r);if(l&&l.type==="DO_WHILE"&&l.loopOver){const c=gt(l.loopOver,n);if(c){const g=c.find(x=>x.taskReferenceName===n);if(g?.type==="FORK_JOIN"||g?.type==="FORK_JOIN_DYNAMIC"){const x=Yh(c,n);x&&Ge(l.loopOver,x)}else if(g?.type==="JOIN"||g?.type==="EXCLUSIVE_JOIN"){const x=Xh(c,n);x&&Ge(l.loopOver,x)}}Ge(l.loopOver,n),Le(i.tasks);const{nodes:d,edges:u,taskMap:f}=Ae(i,a,{hideEmptyBranches:t().mode!=="edit"}),{nodes:h,edges:p}=je(d,u,{direction:a,mode:t().mode}),m=We(i);e({workflowDef:i,nodes:h,edges:p,taskMap:f,validationResults:m})}},addDecisionBranch:(r,n)=>{const{workflowDef:s,layoutDirection:a}=t();if(!s)return;const i=JSON.parse(JSON.stringify(s)),l=Me(i.tasks,r);if(l&&(l.type==="DECISION"||l.type==="SWITCH")){n==="default"?l.defaultCase||(l.defaultCase=[]):(l.decisionCases||(l.decisionCases={}),l.decisionCases[n]||(l.decisionCases[n]=[])),Le(i.tasks);const{nodes:c,edges:d,taskMap:u}=Ae(i,a,{hideEmptyBranches:t().mode!=="edit"}),{nodes:f,edges:h}=je(c,d,{direction:a,mode:t().mode}),p=We(i);e({workflowDef:i,nodes:f,edges:h,taskMap:u,validationResults:p})}},removeDecisionBranch:(r,n)=>{const{workflowDef:s,layoutDirection:a}=t();if(!s)return;const i=JSON.parse(JSON.stringify(s)),l=Me(i.tasks,r);if(l&&(l.type==="DECISION"||l.type==="SWITCH")){n==="default"?l.defaultCase=[]:l.decisionCases&&delete l.decisionCases[n],Le(i.tasks);const{nodes:c,edges:d,taskMap:u}=Ae(i,a,{hideEmptyBranches:t().mode!=="edit"}),{nodes:f,edges:h}=je(c,d,{direction:a,mode:t().mode}),p=We(i);e({workflowDef:i,nodes:f,edges:h,taskMap:u,validationResults:p})}},renameDecisionBranch:(r,n,s)=>{const{workflowDef:a,layoutDirection:i}=t();if(!a||!s.trim()||n===s)return;const l=JSON.parse(JSON.stringify(a)),c=Me(l.tasks,r);if(c&&(c.type==="DECISION"||c.type==="SWITCH")){if(!c.decisionCases||!c.decisionCases[n])return;c.decisionCases[s.trim()]=c.decisionCases[n],delete c.decisionCases[n],Le(l.tasks);const{nodes:d,edges:u,taskMap:f}=Ae(l,i,{hideEmptyBranches:t().mode!=="edit"}),{nodes:h,edges:p}=je(d,u,{direction:i,mode:t().mode}),m=We(l);e({workflowDef:l,nodes:h,edges:p,taskMap:f,validationResults:m})}},addForkBranch:r=>{const{workflowDef:n,layoutDirection:s}=t();if(!n)return;const a=JSON.parse(JSON.stringify(n)),i=Me(a.tasks,r);if(i&&i.type==="FORK_JOIN"){i.forkTasks||(i.forkTasks=[]),i.forkTasks.push([]),Le(a.tasks);const{nodes:l,edges:c,taskMap:d}=Ae(a,s,{hideEmptyBranches:t().mode!=="edit"}),{nodes:u,edges:f}=je(l,c,{direction:s,mode:t().mode}),h=We(a);e({workflowDef:a,nodes:u,edges:f,taskMap:d,validationResults:h})}},copyTask:r=>e({copiedTask:r}),pasteTask:r=>{const{workflowDef:n,layoutDirection:s,selectedTask:a}=t();if(!n)return;const i=JSON.parse(JSON.stringify(n)),c=`_copy_${Date.now()}`,d=JSON.parse(JSON.stringify(r)),u=y=>{y.taskReferenceName=`${y.taskReferenceName}${c}`,y.decisionCases&&Object.values(y.decisionCases).forEach(b=>b.forEach(u)),y.defaultCase&&y.defaultCase.forEach(u),y.forkTasks&&y.forkTasks.forEach(b=>b.forEach(u)),y.loopOver&&y.loopOver.forEach(u)};u(d);const f=a?a.taskReferenceName:i.tasks.length>0?i.tasks[i.tasks.length-1].taskReferenceName:"start";if(d.type==="FORK_JOIN"){d.forkTasks||(d.forkTasks=[[],[]]);const y={name:`${d.name}_join`,taskReferenceName:`${d.taskReferenceName}_join`,type:"JOIN",joinOn:[]};i.tasks.length===0?i.tasks.push(d,y):(Je(i.tasks,f,d),Je(i.tasks,d.taskReferenceName,y))}else i.tasks.length===0?i.tasks.push(d):Je(i.tasks,f,d);Le(i.tasks);const{nodes:h,edges:p,taskMap:m}=Ae(i,s,{hideEmptyBranches:t().mode!=="edit"}),{nodes:g,edges:x}=je(h,p,{direction:s,mode:t().mode}),v=We(i);e({workflowDef:i,nodes:g,edges:x,taskMap:m,validationResults:v})},flashNodes:r=>{if(r.length===0)return;const n=t().__flashTimeout;n&&clearTimeout(n);const s=new Set(r),a={};t().nodes.forEach(l=>{s.has(l.id)&&(a[l.id]=l.selected??!1)}),e(l=>({nodes:l.nodes.map(c=>s.has(c.id)?{...c,selected:!0}:c)}));const i=setTimeout(()=>{e(l=>({nodes:l.nodes.map(c=>s.has(c.id)?{...c,selected:a[c.id]??!1}:c)}))},2500);t().__flashTimeout=i},setTheme:r=>e({theme:r}),setThemeColor:r=>e({themeColor:r}),setEdgeType:r=>e({edgeType:r}),setNodesLocked:r=>e({nodesLocked:r}),setViewMode:r=>e({viewMode:r}),startSimulation:()=>{const{edges:r,nodes:n,isSimRunning:s}=t();if(s)return;const a=n.filter(f=>!["plusNode","dynamicPlaceholderNode"].includes(f.type??"")).map(f=>f.id),i=r.map(f=>({source:f.source,target:f.target})),l=Nv(a,i);e({isSimRunning:!0,simState:{}});const c={timer:null};t().__simHandle=c;let d=0;const u=()=>{if(d>=l.length||!t().isSimRunning){e({isSimRunning:!1});return}const f=l[d];e(h=>{const p={...h.simState};return f.forEach(m=>p[m]="running"),{simState:p}}),c.timer=setTimeout(()=>{t().isSimRunning&&(e(h=>{const p={...h.simState};return f.forEach(m=>p[m]="done"),{simState:p}}),d++,c.timer=setTimeout(u,280))},700)};u()},stopSimulation:()=>{const r=t().__simHandle;r?.timer&&clearTimeout(r.timer),e({isSimRunning:!1,simState:{}})},createBlankWorkflow:r=>{const n={name:r||"new_workflow",description:"",tasks:[],version:1,schemaVersion:2};t().setWorkflow(n),e({mode:"edit"})},applyAIGeneratedWorkflow:r=>{const{tasks:n,...s}=r,a={...s,name:r.name||"AI_Generated_Workflow",tasks:n||[],version:r.version||1,schemaVersion:2};t().setWorkflow(a)},setShowRunPanel:r=>e({showRunPanel:r}),setShowAnalysisPanel:r=>e({showAnalysisPanel:r}),setRunState:(r,n,s)=>{e({runState:r,pendingExecutionId:n!==void 0?n:t().pendingExecutionId,executionError:s!==void 0?s:t().executionError})},switchToEditAndFocusParam:(r,n)=>{const{workflowDef:s,layoutDirection:a,taskMap:i}=t();if(!s)return;e({mode:"edit",focusedParamKey:n??null});const{nodes:l,edges:c,taskMap:d}=Ae(s,a,{hideEmptyBranches:!1}),{nodes:u,edges:f}=je(l,c,{direction:a,mode:"edit"});e({nodes:u,edges:f,taskMap:d});const h=i[r]||d[r];h&&e({selectedTask:{...h},isDetailPanelOpen:!0,showAnalysisPanel:!1})},setShowDataLineage:r=>e({showDataLineage:r}),clearRefactorNotice:()=>e({lastRefactorNotice:null}),setShowWaterfallPanel:r=>e({showWaterfallPanel:r}),setTimeTravelTimestamp:r=>e({timeTravelTimestamp:r}),setLoopIteration:(r,n)=>e({activeLoopIterations:{...t().activeLoopIterations,[r]:n}}),runLocalSandboxDryRun:(r,n,s)=>{const{workflowDef:a}=t();if(!a)return;const i=im(a,{workflowInput:r,taskMocks:n,maxLoopIterations:s});t().importExecutionJSON(i),e({showWaterfallPanel:!0})},setInlineCopilotTaskRef:r=>e({inlineCopilotTaskRef:r})}),{partialize:e=>({workflowDef:e.workflowDef,layoutDirection:e.layoutDirection,nodes:e.nodes.map(t=>Object.assign({},t,{selected:!1})),edges:e.edges,taskMap:e.taskMap,theme:e.theme,themeColor:e.themeColor,mode:e.mode,edgeType:e.edgeType,nodesLocked:e.nodesLocked,copiedTask:e.copiedTask}),equality:(e,t)=>JSON.stringify(e.workflowDef)===JSON.stringify(t.workflowDef)}),{name:"conductor-ui-prefs",version:1,storage:br(()=>localStorage),migrate:(e,t)=>(t===0&&e.edgeType==="default"&&(e.edgeType="smoothstep"),e),partialize:e=>({theme:e.theme,themeColor:e.themeColor,layoutDirection:e.layoutDirection,edgeType:e.edgeType,nodesLocked:e.nodesLocked,copiedTask:e.copiedTask,viewMode:e.viewMode})}));const Pv=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Av=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,n)=>n?n.toUpperCase():r.toLowerCase()),lm=e=>{const t=Av(e);return t.charAt(0).toUpperCase()+t.slice(1)},cm=(...e)=>e.filter((t,r,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===r).join(" ").trim(),Lv=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var Dv={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Mv=I.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:s="",children:a,iconNode:i,...l},c)=>I.createElement("svg",{ref:c,...Dv,width:t,height:t,stroke:e,strokeWidth:n?Number(r)*24/Number(t):r,className:cm("lucide",s),...!a&&!Lv(l)&&{"aria-hidden":"true"},...l},[...i.map(([d,u])=>I.createElement(d,u)),...Array.isArray(a)?a:[a]]));const Oe=(e,t)=>{const r=I.forwardRef(({className:n,...s},a)=>I.createElement(Mv,{ref:a,iconNode:t,className:cm(`lucide-${Pv(lm(e))}`,`lucide-${e}`,n),...s}));return r.displayName=lm(e),r};const dm=Oe("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const qv=Oe("circle-stop",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]]);const $v=Oe("clock",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const um=Oe("code-xml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);const Wv=Oe("database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);const pr=Oe("git-branch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);const hr=Oe("git-merge",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]]);const Fv=Oe("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);const Bv=Oe("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]);const zv=Oe("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);const Hv=Oe("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]);const Jv=Oe("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const fm=Oe("repeat",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]);const fl=Oe("shuffle",[["path",{d:"m18 14 4 4-4 4",key:"10pe0f"}],["path",{d:"m18 2 4 4-4 4",key:"pucp1d"}],["path",{d:"M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22",key:"1ailkh"}],["path",{d:"M2 6h1.972a4 4 0 0 1 3.6 2.2",key:"km57vx"}],["path",{d:"M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45",key:"os18l9"}]]);const Uv=Oe("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);const Kv=Oe("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);const Gv=Oe("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),Vv={business:["business"],standard:["business","control"],developer:["business","control","data"]},Ue=[{type:"SIMPLE",label:"任务节点 (Worker)",description:"在远程 Worker 上执行的任务",category:"CORE",icon:dm,viewCategory:"business"},{type:"SUB_WORKFLOW",label:"子工作流 (Sub Workflow)",description:"调用并执行另一个工作流",category:"CORE",icon:hr,viewCategory:"business"},{type:"START_WORKFLOW",label:"启动工作流 (Start Workflow)",description:"启动另一个工作流(不等待结果)",category:"SYSTEM",icon:Hv,viewCategory:"business"},{type:"HTTP",label:"HTTP 请求",description:"发起 REST/HTTP 调用",category:"SYSTEM",icon:Fv,viewCategory:"business"},{type:"INLINE",label:"内联脚本 (Inline)",description:"执行内联脚本(JS/Python/GraalJS)",category:"SYSTEM",icon:um,viewCategory:"data"},{type:"JSON_JQ_TRANSFORM",label:"JSON 转换 (JQ)",description:"使用 JQ 表达式转换 JSON 数据",category:"SYSTEM",icon:Uv,viewCategory:"data"},{type:"KAFKA_PUBLISH",label:"Kafka 推送",description:"向 Kafka 主题推送消息",category:"SYSTEM",icon:Bv,viewCategory:"data"},{type:"EVENT",label:"事件 (Event)",description:"向外部队列系统发布事件",category:"SYSTEM",icon:Gv,viewCategory:"data"},{type:"WAIT",label:"等待 (Wait)",description:"暂停流程,直到特定时间或时长",category:"SYSTEM",icon:$v,viewCategory:"control"},{type:"SET_VARIABLE",label:"设置变量 (Set Variable)",description:"设置工作流上下文变量",category:"SYSTEM",icon:Wv,viewCategory:"data"},{type:"TERMINATE",label:"终止 (Terminate)",description:"提前结束工作流执行",category:"SYSTEM",icon:qv,viewCategory:"control"},{type:"HUMAN",label:"人工审批 (Human)",description:"等待人工审核或表单提交",category:"SYSTEM",icon:Kv,viewCategory:"business"},{type:"DYNAMIC",label:"动态任务 (Dynamic)",description:"运行时动态决定任务类型",category:"SYSTEM",icon:fl,viewCategory:"data"},{type:"NOOP",label:"空操作 (Noop)",description:"占位符任务,无实际操作",category:"SYSTEM",icon:zv,viewCategory:"data"},{type:"LAMBDA",label:"Lambda 脚本 (旧)",description:"已被 INLINE 取代",category:"SYSTEM",icon:um,hidden:!0,viewCategory:"data"},{type:"SWITCH",label:"条件分支 (Switch)",description:"基于条件的逻辑分支 (Switch/Case)",category:"FLOW",icon:fl,viewCategory:"control"},{type:"DECISION",label:"判断 (Decision,旧)",description:"基于条件的逻辑分支(旧版,推荐改用 Switch)",category:"FLOW",icon:fl,hidden:!0,viewCategory:"control"},{type:"FORK_JOIN",label:"静态并行 (Fork)",description:"并行执行多个预定义任务分支",category:"FLOW",icon:pr,viewCategory:"control"},{type:"FORK_JOIN_DYNAMIC",label:"动态并行 (Dynamic Fork)",description:"运行时动态生成并行分支",category:"FLOW",icon:pr,viewCategory:"control"},{type:"DO_WHILE",label:"循环 (Do-While)",description:"循环执行直到满足条件",category:"FLOW",icon:fm,viewCategory:"control"},{type:"JOIN",label:"汇聚 (Join)",description:"等待所有并行分支执行完成",category:"FLOW",icon:hr,viewCategory:"control"}],Yv=[{key:"CORE",label:"基础任务"},{key:"FLOW",label:"逻辑控制"},{key:"SYSTEM",label:"系统集成"}],mr=({message:e,onConfirm:t,onCancel:r})=>{const n=I.useRef(null),{theme:s,themeColor:a}=oe();return I.useEffect(()=>{n.current?.focus({preventScroll:!0});const i=l=>{l.key==="Escape"&&r()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[r]),_t.createPortal(o.jsx("div",{"data-mode":s,"data-brand":a,onClick:r,style:{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",backgroundColor:"rgba(0, 0, 0, 0.45)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:2e3},children:o.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"确认操作",onClick:i=>i.stopPropagation(),style:{backgroundColor:"var(--bg-secondary)",border:"1px solid var(--border-primary)",borderRadius:"8px",padding:"24px 28px",maxWidth:"380px",width:"90%",boxShadow:"0 8px 32px rgba(0, 0, 0, 0.18)"},children:[o.jsx("div",{style:{fontSize:"14px",color:"var(--text-primary)",marginBottom:"24px",lineHeight:"1.6"},children:e}),o.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"10px"},children:[o.jsx("button",{ref:n,onClick:r,style:{padding:"7px 18px",backgroundColor:"var(--bg-tertiary)",border:"1px solid var(--border-primary)",borderRadius:"6px",color:"var(--text-primary)",cursor:"pointer",fontSize:"13px",fontWeight:500},children:"取消"}),o.jsx("button",{onClick:t,style:{padding:"7px 18px",backgroundColor:"var(--color-accent)",border:"none",borderRadius:"6px",color:"#ffffff",cursor:"pointer",fontSize:"13px",fontWeight:600},children:"确定"})]})]})}),document.body)},Mt=({children:e,nodeId:t,selected:r=!1,isStartOrEnd:n=!1,isError:s=!1,hasWarning:a=!1,isDecision:i=!1,isHighlighted:l=!1,executionStatus:c,simRunning:d=!1,simDone:u=!1,proposalStatus:f})=>{const{mode:h,removeNode:p}=oe(),[m,g]=I.useState(!1),x=_=>{_.stopPropagation(),g(!0)},v=h==="edit"&&!n,b=[i?"decision-node-wrapper":"node-wrapper-glass",r?"node-wrapper-selected":"",l?"node-wrapper-highlighted":"",d?"node-sim-running":"",u?"node-sim-done":"",f?`node-proposal-${f}`:""].filter(Boolean).join(" "),k=I.useMemo(()=>{if(h!=="run")return{};if(!c)return{opacity:.4};switch(c){case"FAILED":case"FAILED_WITH_TERMINAL_ERROR":return{borderColor:"var(--status-failed)",boxShadow:"0 0 12px rgba(239, 68, 68, 0.5), 0 0 24px rgba(239, 68, 68, 0.2)"};case"TIMED_OUT":return{borderColor:"var(--status-timed-out)",boxShadow:"0 0 8px rgba(249, 115, 22, 0.4)"};case"IN_PROGRESS":case"SCHEDULED":return{borderColor:"var(--status-in-progress)",animation:"status-pulse 1.5s ease-in-out infinite"};case"COMPLETED":return{borderColor:"var(--status-completed)",opacity:.85};case"COMPLETED_WITH_ERRORS":return{borderColor:"var(--status-completed-with-errors)"};case"SKIPPED":case"CANCELED":return{opacity:.5};default:return{}}},[h,c]);return o.jsxs("div",{className:b,style:{position:"relative",...k},children:[v&&o.jsx("button",{onClick:x,"aria-label":"删除任务",style:{position:"absolute",top:"-10px",right:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"2px solid white",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:100,boxShadow:"0 2px 8px rgba(0,0,0,0.2)",animation:"popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275)",padding:0},title:"删除任务",children:"×"}),s&&o.jsx("div",{style:{position:"absolute",top:"-10px",left:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"2px solid white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:101,boxShadow:"0 2px 8px rgba(0,0,0,0.2)"},title:"此节点配置有误",children:"❗"}),!s&&a&&o.jsx("div",{style:{position:"absolute",top:"-10px",left:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#f59e0b",color:"white",border:"2px solid white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:101,boxShadow:"0 2px 8px rgba(0,0,0,0.2)"},title:"此节点有警告信息",children:"⚠️"}),f&&o.jsx("div",{className:`node-proposal-badge node-proposal-badge-${f}`,children:f==="added"?"+":f==="modified"?"~":"−"}),e,m&&o.jsx(mr,{message:"确定要删除此任务吗?",onConfirm:()=>{p(t),g(!1)},onCancel:()=>g(!1)})]})},Xv=({status:e})=>{const t=()=>{switch(e){case"SCHEDULED":return{icon:"○",className:"scheduled"};case"IN_PROGRESS":return{icon:"◐",className:"in-progress"};case"COMPLETED":return{icon:"✓",className:"completed"};case"COMPLETED_WITH_ERRORS":return{icon:"⚠",className:"completed-with-errors"};case"FAILED":case"FAILED_WITH_TERMINAL_ERROR":return{icon:"✗",className:"failed"};case"TIMED_OUT":return{icon:"⏱",className:"timed-out"};case"SKIPPED":return{icon:"⤳",className:"skipped"};case"CANCELED":return{icon:"⊘",className:"canceled"};default:return{icon:"?",className:"unknown"}}},{icon:r,className:n}=t();return o.jsx("div",{className:`execution-status-badge ${n}`,title:e,children:o.jsx("span",{className:"badge-icon",children:r})})},pl=I.memo(Xv),Qv=/[一-龥]/,Zv=({icon:e,header:t,title:r,subTitle:n,meta:s,duration:a,color:i,status:l,isRunning:c,children:d,width:u="240px"})=>{const f=c&&l?l==="COMPLETED"?"var(--status-completed)":l==="FAILED"||l==="FAILED_WITH_TERMINAL_ERROR"?"var(--status-failed)":l==="IN_PROGRESS"||l==="SCHEDULED"?"var(--status-in-progress)":l==="TIMED_OUT"||l==="COMPLETED_WITH_ERRORS"?"var(--status-timed-out)":i:i,h=u==="240px"||u===240?"237px":u;return o.jsxs("div",{style:{display:"flex",flexDirection:"row",width:h,height:d?void 0:"81px",minHeight:"81px",boxSizing:"border-box",position:"relative",overflow:"hidden",borderRadius:"10px"},children:[o.jsx("div",{style:{width:"44px",display:"flex",alignItems:"center",justifyContent:"center",background:"color-mix(in srgb, var(--color-accent) 8%, transparent)",borderLeft:`3px solid ${f}`,borderRight:"1px solid var(--border-primary)",color:f,flexShrink:0},children:o.jsx(e,{size:18,strokeWidth:1.75})}),o.jsxs("div",{style:{flex:1,padding:"6px 12px",display:"flex",flexDirection:"column",justifyContent:"center",overflow:"hidden",minWidth:0},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"6px",marginBottom:"2px",paddingRight:c&&l?"20px":0},children:[o.jsx("div",{style:{fontSize:"10px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.5px",lineHeight:1.2,opacity:.85,color:i,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",...Qv.test(t)&&{letterSpacing:"0.2px",fontSize:"11px"}},children:t}),c&&a&&o.jsx("span",{style:{fontSize:"10px",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)",background:"var(--bg-tertiary)",padding:"1px 5px",borderRadius:"4px",flexShrink:0,lineHeight:1.2},children:a})]}),o.jsx("div",{style:{fontSize:"13.5px",fontWeight:600,color:"var(--text-primary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",lineHeight:1.25,marginBottom:n||s?"1px":0},title:r,children:r}),n&&n!==r&&n!==s&&o.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",lineHeight:1.25},title:n,children:n}),s&&o.jsx("div",{style:{fontSize:"11px",color:"var(--text-muted)",lineHeight:1.25,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},title:s,children:s}),d&&o.jsx("div",{style:{marginTop:"6px"},children:d})]}),c&&l&&o.jsx("div",{style:{position:"absolute",top:"7px",right:"7px"},children:o.jsx(pl,{status:l})})]})},gr=I.memo(Zv),lt=e=>{const t=e.layoutDirection||"TB",r=e.sourcePosition||(t==="LR"?M.Position.Right:M.Position.Bottom),n=e.targetPosition||(t==="LR"?M.Position.Left:M.Position.Top);return{layoutDirection:t,sourcePosition:r,targetPosition:n}},bt=e=>{const{mode:t,executionData:r,workflowDef:n,activeLoopIterations:s,timeTravelTimestamp:a}=oe(),i=t==="run"?r?.[e]:null,l=t==="run";let c=i?{...i}:null;if(l&&c&&c.attempts.length>1&&n?.tasks){let p=0;for(const[m,g]of Object.entries(s)){if(!g)continue;if(r?.[m]||c.attempts.some(v=>v.iteration===g)){p=g;break}}if(p>0){const m=c.attempts.find(g=>g.iteration===p)||c.attempts[p-1];m&&(c={...c,status:m.status,startTime:m.startTime,endTime:m.endTime,input:m.inputData,output:m.outputData,iteration:m.iteration??p})}}if(l&&c&&a!==null){const p=c.startTime??0,m=c.endTime??p;p>a?c={...c,status:"SCHEDULED"}:p<=a&&m>a&&(c={...c,status:"IN_PROGRESS"})}const d=c?.attempts.some(p=>p.iteration!==void 0&&p.iteration>1)??!1,u=c?.attempts[c.attempts.length-1],f=d?0:u?.retryCount??0;let h;if(l&&c?.startTime)if(a!==null&&c.startTime>a)h="待执行";else if(a!==null&&c.startTime<=a&&(c.endTime??c.startTime)>a)h=`${a-c.startTime}ms...`;else if(c.endTime&&c.endTime>=c.startTime){const p=c.endTime-c.startTime;h=p<1e3?`${p}ms`:`${(p/1e3).toFixed(2)}s`}else(c.status==="IN_PROGRESS"||c.status==="SCHEDULED")&&(h="运行中");return{mode:t,execution:c,isRunning:l,retryCount:f,durationText:h}};function et(e,t){return e.length>t?e.slice(0,t)+"…":e}function qt(e,t,r,n){if(r==="business")return t.task?.description?.trim()||n;if(r==="standard")return n;const s=t.task;if(!s)return n;const a=s.inputParameters||{};switch(e){case"HTTP":case"HTTP_POLL":{const i=s.httpRequest||a.http_request;if(!i)return n;const l=(i.method||"GET").toUpperCase(),c=i.uri?et(String(i.uri),28):"";return c?`${l} ${c}`:l}case"SWITCH":{const i=s.caseExpression||a.expression,l=s.evaluatorType||a.evaluatorType;return i?et(i,35):l||n}case"DECISION":return s.caseValueParam?`param: ${s.caseValueParam}`:n;case"SIMPLE":return s.name?`worker: ${et(s.name,28)}`:n;case"INLINE":case"LAMBDA":{const i=s.evaluatorType||a.evaluatorType;return i?`${i} script`:n}case"SUB_WORKFLOW":{const i=s.subWorkflowParam;return i?`${i.name}${i.version?` v${i.version}`:""}`:n}case"DO_WHILE":{const i=s.loopCondition;return i?et(i,35):n}case"JSON_JQ_TRANSFORM":{const i=a.queryExpression||a.query_expression;return i?et(i,35):n}case"SET_VARIABLE":{const i=Object.keys(a);return i.length?`set: ${i.slice(0,2).join(", ")}${i.length>2?"…":""}`:n}case"EVENT":{const i=s.sink||a.sink;return i?`→ ${et(i,32)}`:n}case"KAFKA_PUBLISH":{const i=a.topic||a.kafka_request?.topic;return i?`topic: ${et(i,28)}`:n}case"START_WORKFLOW":{const i=s.startWorkflow?.name??a.startWorkflow?.name??a.start_workflow?.name;return i?`→ ${i}`:n}default:return n}}function kt(e,t){if(t!=="business")return e;const r=Ue.find(n=>n.type===e);return r?r.label.replace(/\s*\([^)]+\)$/,""):e==="JOIN"?"汇聚":e==="EXCLUSIVE_JOIN"?"排他汇聚":e}const eb=({id:e,data:t,selected:r})=>{const n=t.taskType||"SIMPLE",{sourcePosition:s,targetPosition:a}=lt(t),{execution:i,isRunning:l,retryCount:c,durationText:d}=bt(t.taskReferenceName),u=oe(w=>w.viewMode),f=oe(w=>w.mode),h=oe(w=>w.setInlineCopilotTaskRef),m=M.useStore(w=>w.transform[2])>=1.15,g=I.useMemo(()=>Ue.find(w=>w.type===n),[n]),x=g?.icon||dm,v=n==="NOOP",y=t.isDynamicRuntime===!0,b=v?"var(--text-secondary)":"var(--color-accent)",k=I.useMemo(()=>{let w;return y?w=`Dynamic (${n})`:n==="SIMPLE"?w=t.label==="Worker Task"?"Execute on Worker":"Worker Task":n==="HTTP"?w="REST API Call":n==="JSON_JQ_TRANSFORM"?w="JQ Expression":n==="INLINE"||n==="LAMBDA"?w="Inline Script":n==="START_WORKFLOW"?w="Launch Workflow (no wait)":n==="DYNAMIC"?w="Dynamic Task Type":n==="HUMAN"?w="Human Approval":n==="NOOP"?w="No Operation":w=g?.label||n,qt(n,t,u,w)},[n,g,t,u,y]),_=I.useMemo(()=>!m||!t.task?.inputParameters?[]:Object.entries(t.task.inputParameters).slice(0,2).map(([T,O])=>({key:T,val:typeof O=="object"?JSON.stringify(O).slice(0,28):String(O).slice(0,28)})),[m,t.task?.inputParameters]);return o.jsx(Mt,{nodeId:e,selected:r,isError:t.isError,hasWarning:t.hasWarning,isHighlighted:t.isHighlighted,executionStatus:i?.status,simRunning:t.simRunning,simDone:t.simDone,proposalStatus:t.proposalStatus,children:o.jsxs("div",{style:{borderRadius:"10px",background:v?"var(--bg-tertiary)":"transparent",opacity:v?.75:1,position:"relative",outline:y?"2px dashed var(--color-accent)":"none",outlineOffset:"-2px"},children:[o.jsx(gr,{icon:x,header:kt(n,u),title:t.taskReferenceName,subTitle:t.label&&t.label!==t.taskReferenceName?t.label:void 0,meta:k,duration:d,color:b,status:i?.status,isRunning:l}),_.length>0&&o.jsx("div",{style:{padding:"4px 10px 6px",borderTop:"1px dashed var(--border-primary)",fontSize:"9px",fontFamily:"monospace",color:"var(--text-secondary)",display:"flex",flexDirection:"column",gap:"2px"},children:_.map(w=>o.jsxs("div",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[o.jsx("span",{style:{color:"#38bdf8"},children:w.key}),": ",w.val]},w.key))}),r&&f==="edit"&&o.jsx("button",{type:"button",onClick:w=>{w.stopPropagation(),h(t.taskReferenceName)},title:"在此节点触发 ⌘K 画布内联 AI 指令",style:{position:"absolute",top:"-10px",right:"20px",padding:"1px 6px",borderRadius:"999px",border:"1px solid rgba(99, 102, 241, 0.6)",background:"linear-gradient(135deg, #6366f1, #38bdf8)",color:"#fff",fontSize:"9px",fontWeight:700,cursor:"pointer",zIndex:102,boxShadow:"0 2px 6px rgba(0,0,0,0.3)"},children:"⌘K"}),l&&c>0&&o.jsxs("div",{style:{position:"absolute",bottom:"4px",right:"4px",background:"var(--status-failed, #ef4444)",color:"#fff",borderRadius:"10px",fontSize:"10px",fontWeight:"700",padding:"1px 6px",zIndex:10,lineHeight:"1.4",pointerEvents:"none"},children:["×",c]}),y&&o.jsx("div",{style:{position:"absolute",top:"4px",right:"4px",background:"var(--color-accent)",color:"#fff",borderRadius:"4px",fontSize:"9px",fontWeight:"700",padding:"1px 5px",zIndex:10,pointerEvents:"none",opacity:.9},children:"动态"}),o.jsx(M.Handle,{type:"target",position:a,style:{background:"#fff"}}),o.jsx(M.Handle,{type:"source",position:s,style:{background:"#fff"}})]})})},tb=I.memo(eb),pm=({title:e,label:t,defaultValue:r="",placeholder:n="",confirmText:s="确定",cancelText:a="取消",onConfirm:i,onCancel:l})=>{const{theme:c,themeColor:d}=oe(),[u,f]=I.useState(r),h=I.useRef(null);I.useEffect(()=>{h.current&&(h.current.focus({preventScroll:!0}),h.current.select());const m=g=>{g.key==="Escape"&&(g.stopPropagation(),l())};return window.addEventListener("keydown",m,!0),()=>window.removeEventListener("keydown",m,!0)},[l]);const p=()=>{const m=u.trim();m&&i(m)};return _t.createPortal(o.jsx("div",{"data-mode":c,"data-brand":d,onClick:l,style:{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",backgroundColor:"rgba(0, 0, 0, 0.45)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:2e3},children:o.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":e,onClick:m=>m.stopPropagation(),style:{backgroundColor:"var(--bg-secondary)",border:"1px solid var(--border-primary)",borderRadius:"10px",padding:"24px 28px",maxWidth:"400px",width:"90%",boxShadow:"0 8px 32px rgba(0, 0, 0, 0.22)"},children:[o.jsx("div",{style:{fontSize:"15px",fontWeight:600,color:"var(--text-primary)",marginBottom:"16px"},children:e}),t&&o.jsx("div",{style:{fontSize:"12px",color:"var(--text-secondary)",marginBottom:"8px"},children:t}),o.jsx("input",{ref:h,type:"text",value:u,placeholder:n,onChange:m=>f(m.target.value),onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),p()),m.stopPropagation()},style:{width:"100%",padding:"9px 12px",borderRadius:"6px",border:"1px solid var(--border-primary)",background:"var(--bg-tertiary)",color:"var(--text-primary)",fontSize:"13px",outline:"none",boxSizing:"border-box",marginBottom:"20px",transition:"border-color 0.15s"},onFocus:m=>{m.currentTarget.style.borderColor="var(--color-accent)"},onBlur:m=>{m.currentTarget.style.borderColor="var(--border-primary)"}}),o.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"10px"},children:[o.jsx("button",{onClick:l,style:{padding:"7px 18px",backgroundColor:"var(--bg-tertiary)",border:"1px solid var(--border-primary)",borderRadius:"6px",color:"var(--text-primary)",cursor:"pointer",fontSize:"13px",fontWeight:500},children:a}),o.jsx("button",{onClick:p,disabled:!u.trim(),style:{padding:"7px 18px",backgroundColor:u.trim()?"var(--color-accent)":"var(--bg-tertiary)",border:"none",borderRadius:"6px",color:u.trim()?"#ffffff":"var(--text-secondary)",cursor:u.trim()?"pointer":"not-allowed",fontSize:"13px",fontWeight:600,transition:"background-color 0.15s, color 0.15s"},children:s})]})]})}),document.body)},rb=({id:e,data:t,selected:r})=>{const{layoutDirection:n}=lt(t),{mode:s,execution:a,isRunning:i,durationText:l}=bt(t.taskReferenceName),{addDecisionBranch:c,removeDecisionBranch:d,renameDecisionBranch:u,viewMode:f}=oe(),[h,p]=I.useState(!1),[m,g]=I.useState({type:"none"}),x=n==="LR"?M.Position.Left:M.Position.Top,v=Object.keys(t.decisionCases||t.task?.decisionCases||{}),y=()=>{p(!1),g({type:"add"})},b=(S,R)=>{S.stopPropagation(),g({type:"delete",branch:R})},k=(S,R)=>{S.stopPropagation(),p(!1),g({type:"rename",branch:R})},_=S=>{S&&c(e,S),g({type:"none"})},w=S=>{m.type==="rename"&&(S&&S!==m.branch&&u(e,m.branch,S),g({type:"none"}))},T=()=>{m.type==="delete"&&(d(e,m.branch),g({type:"none"}))},O=()=>g({type:"none"}),N=i?(S=>S&&{SCHEDULED:"execution-node-scheduled",IN_PROGRESS:"execution-node-in-progress",COMPLETED:"execution-node-completed",COMPLETED_WITH_ERRORS:"execution-node-completed-with-errors",FAILED:"execution-node-failed",FAILED_WITH_TERMINAL_ERROR:"execution-node-failed-terminal",TIMED_OUT:"execution-node-timed-out",SKIPPED:"execution-node-skipped",CANCELED:"execution-node-canceled"}[S]||"")(a?.status):"";return o.jsxs(Mt,{nodeId:e,selected:r,isError:t.isError,hasWarning:t.hasWarning,isDecision:!0,isHighlighted:t.isHighlighted,executionStatus:a?.status,simRunning:t.simRunning,simDone:t.simDone,proposalStatus:t.proposalStatus,children:[o.jsxs("div",{style:{position:"relative",width:"164px",height:"164px",display:"flex",alignItems:"center",justifyContent:"center"},children:[o.jsx(M.Handle,{type:"target",position:x,style:{background:"#fff",[n==="LR"?"left":"top"]:"-3px",zIndex:15}}),i&&a?.status&&o.jsx("div",{style:{position:"absolute",top:"12px",right:"12px",zIndex:20},children:o.jsx(pl,{status:a.status})}),o.jsx("div",{className:N,style:{width:"122px",height:"122px",boxSizing:"border-box",borderRadius:"10px",background:i&&a?.status?void 0:"var(--glass-bg)",backdropFilter:"var(--glass-blur)",WebkitBackdropFilter:"var(--glass-blur)",border:r?"2.5px solid var(--color-accent)":i&&a?.status?void 0:"2px solid rgba(var(--color-accent-rgb), 0.45)",transform:"rotate(45deg)",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:r?"0 8px 26px rgba(0,0,0,0.35), 0 0 0 3px var(--node-glow-color)":i&&a?.status?void 0:"var(--node-shadow)",transition:"all 0.25s ease",cursor:"pointer",flexShrink:0},onClick:()=>s==="edit"&&p(!h),children:o.jsxs("div",{style:{transform:"rotate(-45deg)",color:"#fff",textAlign:"center",padding:"6px",width:"116px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},children:[o.jsx("div",{style:{fontSize:"10px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.5px",opacity:.85,marginBottom:"2px",color:"var(--color-accent)"},children:kt(t.taskType,f)}),o.jsx("div",{style:{fontSize:"12px",fontWeight:600,color:"var(--text-primary)",lineHeight:1.25,maxWidth:"104px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:t.taskReferenceName,children:t.taskReferenceName}),t.label&&t.label!==t.taskReferenceName&&o.jsx("div",{style:{fontSize:"10px",color:"var(--text-secondary)",maxWidth:"98px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:"1px"},title:t.label,children:t.label}),s==="edit"&&o.jsx("div",{style:{width:"18px",height:"18px",fontSize:"12px",background:"color-mix(in srgb, var(--color-accent) 18%, transparent)",border:"1px solid rgba(var(--color-accent-rgb), 0.4)",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",margin:"4px auto 0",color:"var(--color-accent)",fontWeight:700},title:"管理决策分支",children:"+"}),i&&l&&o.jsx("div",{style:{fontSize:"10px",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)",background:"var(--bg-tertiary)",padding:"1px 5px",borderRadius:"4px",marginTop:"3px"},children:l})]})}),s==="edit"&&h&&o.jsxs("div",{className:"glass-panel",style:{position:"absolute",top:"170px",left:"50%",transform:"translateX(-50%)",backgroundColor:"var(--glass-surface)",border:"1px solid var(--glass-border)",borderRadius:"8px",padding:"8px",zIndex:1e3,minWidth:"200px",boxShadow:"0 10px 25px rgba(0,0,0,0.5)",animation:"popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275)",backdropFilter:"blur(12px)"},children:[o.jsx("div",{style:{padding:"4px 8px 6px",fontSize:"11px",color:"var(--text-secondary)",borderBottom:"1px solid var(--glass-border)",marginBottom:"4px",fontWeight:600,letterSpacing:"0.05em"},children:"分支管理"}),v.map(S=>o.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"5px 6px",borderRadius:"4px",gap:"4px"},children:[o.jsx("span",{style:{flex:1,fontSize:"12px",color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:S}),o.jsx("button",{onClick:R=>k(R,S),style:{width:"22px",height:"22px",borderRadius:"4px",backgroundColor:"var(--color-accent)",color:"white",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"11px",padding:0,flexShrink:0,opacity:.85},title:`重命名分支 "${S}"`,children:"✏"}),o.jsx("button",{onClick:R=>b(R,S),style:{width:"22px",height:"22px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"13px",padding:0,flexShrink:0,opacity:.9},title:`删除分支 "${S}"`,children:"×"})]},S)),o.jsx("button",{onClick:y,style:{width:"100%",marginTop:"6px",padding:"8px",backgroundColor:"var(--color-accent)",border:"none",borderRadius:"4px",color:"#fff",cursor:"pointer",fontSize:"12px",fontWeight:"bold"},children:"+ 添加新分支"})]}),f==="developer"&&(()=>{const S=t.task?.caseExpression||t.task?.inputParameters?.expression,R=t.task?.caseValueParam;return!S&&!R?null:o.jsx("div",{style:{position:"absolute",top:"166px",left:"50%",transform:"translateX(-50%)",textAlign:"center",fontSize:10,color:"var(--text-secondary)",maxWidth:150,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",pointerEvents:"none",fontFamily:"var(--font-mono, monospace)"},children:S?et(S,22):`param: ${R}`})})(),n==="TB"?o.jsxs(o.Fragment,{children:[o.jsx(M.Handle,{type:"source",position:M.Position.Bottom,style:{background:"#fff",bottom:"-3px",zIndex:15}}),o.jsx(M.Handle,{type:"source",position:M.Position.Left,id:"left",style:{background:"#fff",left:"-3px",zIndex:15}}),o.jsx(M.Handle,{type:"source",position:M.Position.Right,id:"right",style:{background:"#fff",right:"-3px",zIndex:15}})]}):o.jsxs(o.Fragment,{children:[o.jsx(M.Handle,{type:"source",position:M.Position.Right,style:{background:"#fff",right:"-3px",zIndex:15}}),o.jsx(M.Handle,{type:"source",position:M.Position.Top,id:"top",style:{background:"#fff",top:"-3px",zIndex:15}}),o.jsx(M.Handle,{type:"source",position:M.Position.Bottom,id:"bottom",style:{background:"#fff",bottom:"-3px",zIndex:15}})]})]}),m.type==="add"&&o.jsx(pm,{title:"添加新分支",label:"分支条件值(Case Value)",defaultValue:`case_${v.length+1}`,placeholder:"例如:approved、rejected、pending",confirmText:"添加",onConfirm:_,onCancel:O}),m.type==="rename"&&o.jsx(pm,{title:"重命名分支",label:`当前名称:${m.branch}`,defaultValue:m.branch,placeholder:"输入新的分支条件值",confirmText:"重命名",onConfirm:w,onCancel:O}),m.type==="delete"&&o.jsx(mr,{message:`确定要删除分支 "${m.branch}" 及其下的所有任务吗?此操作不可撤销。`,onConfirm:T,onCancel:O})]})},nb=I.memo(rb),hm="var(--color-accent)",mm=I.memo(({id:e,data:t,selected:r})=>{const{layoutDirection:n,sourcePosition:s,targetPosition:a}=lt(t),{mode:i,execution:l,isRunning:c,durationText:d}=bt(t.taskReferenceName),{addForkBranch:u}=oe(),f=M.useUpdateNodeInternals(),h=t.task?.forkTasks?.length||0;I.useEffect(()=>{f(e)},[h,e,f]);const p=t.isDynamic||t.taskType==="FORK_JOIN_DYNAMIC",m=oe(v=>v.viewMode),x=I.useMemo(()=>Ue.find(v=>v.type==="FORK_JOIN"),[])?.icon||pr;return o.jsx(Mt,{isHighlighted:t.isHighlighted,nodeId:e,selected:r,isError:t.isError,hasWarning:t.hasWarning,executionStatus:l?.status,simRunning:t.simRunning,simDone:t.simDone,proposalStatus:t.proposalStatus,children:o.jsxs("div",{className:`fork-node ${p?"dynamic":"static"}`,style:{borderRadius:"10px",background:"transparent",position:"relative"},children:[o.jsx(gr,{icon:x,header:kt(p?"FORK_JOIN_DYNAMIC":"FORK_JOIN",m),title:t.taskReferenceName,subTitle:t.label&&t.label!==t.taskReferenceName?t.label:void 0,meta:qt(t.taskType,t,m,p?"Dynamic Parallel Execution":"Parallel Execution"),duration:d,color:hm,status:l?.status,isRunning:c}),i==="edit"&&!p&&o.jsx("div",{style:{position:"absolute",...n==="LR"?{top:"50%",right:-12,transform:"translateY(-50%)"}:{bottom:-12,left:"50%",transform:"translateX(-50%)"},width:20,height:20,background:"var(--color-accent)",borderRadius:"50%",color:"#fff",fontSize:"14px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",zIndex:1e3,boxShadow:"0 2px 5px rgba(0,0,0,0.2)",border:"2px solid var(--bg-primary)"},onClick:v=>{v.stopPropagation(),u(e)},title:"添加分支",children:"+"}),o.jsx(M.Handle,{type:"target",position:a,style:{background:"#fff"}}),!p&&(t.task?.forkTasks||[]).map((v,y,b)=>{if(i!=="edit"&&(!v||v.length===0))return null;const k=i!=="edit"?b.filter(O=>O&&O.length>0):b,_=k.length,T=(k.indexOf(v)+1)/(_+1)*100;return o.jsx(M.Handle,{id:`branch_${y}`,type:"source",position:s,style:{background:"#fff",[n==="LR"?"top":"left"]:`${T}%`,[n==="LR"?"left":"top"]:void 0,[n==="LR"?"right":"bottom"]:"-4px",zIndex:10}},`branch_${y}`)}),!p&&(!t.task?.forkTasks||t.task.forkTasks.length===0)&&o.jsx(M.Handle,{type:"source",position:s,style:{background:"#fff"}}),p&&o.jsx(M.Handle,{type:"source",position:s,style:{background:"#fff"}})]})})});mm.displayName="ForkNode";const gm=I.memo(({id:e,data:t,selected:r})=>{const{layoutDirection:n,sourcePosition:s,targetPosition:a}=lt(t),{execution:i,isRunning:l,durationText:c}=bt(t.taskReferenceName),d=oe(h=>h.viewMode),f=I.useMemo(()=>Ue.find(h=>h.type==="JOIN"),[])?.icon||hr;return o.jsx(Mt,{isHighlighted:t.isHighlighted,nodeId:e,selected:r,isError:t.isError,hasWarning:t.hasWarning,executionStatus:i?.status,simRunning:t.simRunning,simDone:t.simDone,proposalStatus:t.proposalStatus,children:o.jsxs("div",{style:{borderRadius:"10px",background:"transparent",position:"relative"},children:[o.jsx(gr,{icon:f,header:kt(t.taskType==="EXCLUSIVE_JOIN"?"EXCLUSIVE_JOIN":"JOIN",d),title:t.taskReferenceName,subTitle:t.label&&t.label!==t.taskReferenceName?t.label:void 0,meta:qt(t.taskType,t,d,t.taskType==="EXCLUSIVE_JOIN"?"Wait for any task":"Wait for tasks"),duration:c,color:hm,status:i?.status,isRunning:l}),o.jsx(M.Handle,{type:"target",position:a,style:{background:"#fff"}}),n==="TB"&&o.jsxs(o.Fragment,{children:[o.jsx(M.Handle,{type:"target",position:M.Position.Left,id:"left",style:{background:"#fff"}}),o.jsx(M.Handle,{type:"target",position:M.Position.Right,id:"right",style:{background:"#fff"}})]}),n==="LR"&&o.jsxs(o.Fragment,{children:[o.jsx(M.Handle,{type:"target",position:M.Position.Top,id:"top",style:{background:"#fff"}}),o.jsx(M.Handle,{type:"target",position:M.Position.Bottom,id:"bottom",style:{background:"#fff"}})]}),o.jsx(M.Handle,{type:"source",position:s,style:{background:"#fff"}})]})})});gm.displayName="JoinNode";const ym={ForkNode:mm,JoinNode:gm},sb=({id:e,data:t,selected:r})=>{const{sourcePosition:n,targetPosition:s}=lt(t),{execution:a,isRunning:i,durationText:l}=bt(t.taskReferenceName),{executionData:c,selectTaskAction:d,mode:u,viewMode:f,removeNode:h,activeLoopIterations:p,setLoopIteration:m}=oe(),[g,x]=I.useState(!1),v=t.task,y=v?.loopOver||[],k=I.useMemo(()=>Ue.find(j=>j.type==="DO_WHILE"),[])?.icon||fm,_=I.useMemo(()=>{if(!i||!c)return 0;let j=a?.iteration??0;return y.forEach(E=>{const q=c[E.taskReferenceName];q?.totalIterations?j=Math.max(j,q.totalIterations):q?.attempts.some($=>($.iteration??0)>0)&&(j=Math.max(j,q.attempts.length))}),j},[i,c,y,a?.iteration]),w=p[t.taskReferenceName]||_,T=t.loopCondition||v?.loopCondition||"",O=I.useMemo(()=>{const j=T?T.length>35?T.slice(0,35)+"…":T:"循环直到条件满足";return qt("DO_WHILE",t,f,j)},[t,f,T]),D=a?.status==="COMPLETED"?"var(--status-completed)":a?.status==="FAILED"||a?.status==="FAILED_WITH_TERMINAL_ERROR"?"var(--status-failed)":a?.status==="IN_PROGRESS"||a?.status==="SCHEDULED"?"var(--status-in-progress)":"var(--color-accent)",N=r?`2px solid ${D}`:`1.5px dashed ${i&&a?.status?D:"var(--color-accent)"}`,S=u==="edit",R=f==="developer"&&T;return o.jsxs("div",{style:{width:"100%",height:"100%",border:N,borderRadius:"10px",background:"transparent",display:"flex",flexDirection:"column",position:"relative",overflow:"visible",boxSizing:"border-box",pointerEvents:"none"},children:[S&&o.jsx("button",{onClick:j=>{j.stopPropagation(),x(!0)},"aria-label":"删除循环任务",style:{position:"absolute",top:"-10px",right:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"2px solid white",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:100,boxShadow:"0 2px 8px rgba(0,0,0,0.2)",padding:0,pointerEvents:"auto"},title:"删除循环任务",children:"×"}),t.isError&&o.jsx("div",{style:{position:"absolute",top:"-10px",left:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"2px solid white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:101,boxShadow:"0 2px 8px rgba(0,0,0,0.2)",pointerEvents:"auto"},title:"此节点配置有误",children:"❗"}),!t.isError&&t.hasWarning&&o.jsx("div",{style:{position:"absolute",top:"-10px",left:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#f59e0b",color:"white",border:"2px solid white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:101,boxShadow:"0 2px 8px rgba(0,0,0,0.2)",pointerEvents:"auto"},title:"此节点有警告信息",children:"⚠️"}),t.proposalStatus&&o.jsx("div",{className:`node-proposal-badge node-proposal-badge-${t.proposalStatus}`,style:{pointerEvents:"auto"},children:t.proposalStatus==="added"?"+":t.proposalStatus==="modified"?"~":"−"}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:"var(--glass-surface)",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",borderBottom:"1px solid var(--border-primary)",borderRadius:"8px 8px 0 0",flexShrink:0,minHeight:"44px",pointerEvents:"auto"},children:[o.jsx("div",{style:{color:"var(--color-accent)",display:"flex",alignItems:"center",flexShrink:0},children:o.jsx(k,{size:15})}),o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[o.jsx("span",{style:{fontSize:"9px",fontWeight:700,color:"var(--color-accent)",letterSpacing:"0.08em",textTransform:"uppercase"},children:kt("DO_WHILE",f)}),o.jsxs("span",{style:{fontSize:"9px",color:"var(--text-muted)"},children:["↻ ",y.length," 个子任务"]})]}),o.jsx("div",{style:{fontSize:"12px",fontWeight:600,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.taskReferenceName}),(f==="business"||f==="developer")&&O&&o.jsx("div",{style:{fontSize:"9px",color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:"1px",fontStyle:"italic"},children:O})]}),i&&l&&o.jsx("span",{style:{fontSize:"10px",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)",background:"var(--bg-secondary)",padding:"1px 6px",borderRadius:"4px",flexShrink:0},children:l}),i&&_>0&&o.jsxs("div",{onClick:()=>d(v||null),style:{padding:"2px 8px",borderRadius:"12px",background:"var(--color-accent)",color:"#fff",fontSize:"10px",fontWeight:700,cursor:"pointer",flexShrink:0},title:`共执行 ${_} 次迭代`,children:["×",_]}),i&&a?.status&&o.jsx("div",{style:{position:"relative",width:20,height:20,flexShrink:0},children:o.jsx(pl,{status:a.status})})]}),i&&_>1&&o.jsxs("div",{onClick:j=>j.stopPropagation(),style:{display:"flex",alignItems:"center",gap:"4px",padding:"4px 10px",background:"rgba(15, 23, 42, 0.72)",borderBottom:"1px solid var(--border-primary)",flexShrink:0,pointerEvents:"auto",overflowX:"auto"},children:[o.jsx("span",{style:{fontSize:"9px",color:"#94a3b8",fontWeight:600,marginRight:"2px"},children:"切换轮次:"}),Array.from({length:_},(j,E)=>E+1).map(j=>{const E=w===j;return o.jsxs("button",{type:"button",onClick:q=>{q.stopPropagation(),m(t.taskReferenceName,j)},style:{fontSize:"9px",padding:"1px 7px",borderRadius:"999px",border:E?"1px solid #38bdf8":"1px solid rgba(148, 163, 184, 0.25)",background:E?"rgba(56, 189, 248, 0.22)":"rgba(30, 41, 59, 0.6)",color:E?"#38bdf8":"#cbd5e1",fontWeight:E?700:500,cursor:"pointer"},children:["#",j]},j)})]}),R&&o.jsxs("div",{style:{padding:"3px 12px",fontSize:"9px",color:"var(--text-secondary)",background:"var(--bg-tertiary)",borderBottom:"1px solid var(--border-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flexShrink:0,pointerEvents:"auto"},children:["until: ",T]}),o.jsx("div",{style:{flex:1,position:"relative",background:"var(--loop-body-bg, rgba(99,102,241,0.04))",borderRadius:"0 0 8px 8px",pointerEvents:"none"}}),o.jsx(M.Handle,{type:"target",position:s,style:{background:"var(--color-accent)",zIndex:10}}),o.jsx(M.Handle,{type:"source",position:n,style:{background:"var(--color-accent)",zIndex:10}}),g&&o.jsx(mr,{message:"确定要删除此循环任务吗?循环体内的任务也会一并删除。",onConfirm:()=>{h(e),x(!1)},onCancel:()=>x(!1)})]})},ab=I.memo(sb),ob="var(--color-accent)",ib=({id:e,data:t,selected:r})=>{const{sourcePosition:n,targetPosition:s}=lt(t),{execution:a,isRunning:i,durationText:l}=bt(t.taskReferenceName),c=oe(p=>p.viewMode),u=I.useMemo(()=>Ue.find(p=>p.type==="SUB_WORKFLOW"),[])?.icon||hr,f=t.task?.subWorkflowParam?.name||t.subWorkflowName||"Unknown",h=t.task?.subWorkflowParam?.version;return o.jsx(Mt,{nodeId:e,selected:r,isError:t.isError,hasWarning:t.hasWarning,isHighlighted:t.isHighlighted,executionStatus:a?.status,simRunning:t.simRunning,simDone:t.simDone,proposalStatus:t.proposalStatus,children:o.jsxs("div",{style:{borderRadius:"10px",background:"transparent",position:"relative"},children:[o.jsx(gr,{icon:u,header:kt("SUB_WORKFLOW",c),title:t.taskReferenceName,subTitle:t.label&&t.label!==t.taskReferenceName?t.label:void 0,meta:qt("SUB_WORKFLOW",t,c,`Flow: ${f}${h!==void 0?` (v${h})`:""}`),duration:l,color:ob,status:a?.status,isRunning:i}),o.jsx(M.Handle,{type:"target",position:s,style:{background:"#fff"}}),o.jsx(M.Handle,{type:"source",position:n,style:{background:"#fff"}})]})})},lb=I.memo(ib),cb=({data:e})=>{const r=(e.layoutDirection||"TB")==="LR";return o.jsxs("div",{className:"plus-node-container",style:{width:"32px",height:"32px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",background:"var(--bg-secondary, #1e293b)",border:"2px dashed var(--color-accent, #3b82f6)",color:"var(--color-accent, #3b82f6)",cursor:"pointer",transition:"all 0.2s ease",padding:e.label&&e.label!=="+"?"0 12px":"0",minWidth:e.label&&e.label!=="+"?"80px":"32px",gap:"4px"},children:[o.jsx(Jv,{size:16}),e.label&&e.label!=="+"&&o.jsx("span",{style:{fontSize:"12px",fontWeight:500},children:e.label}),o.jsx(M.Handle,{type:"target",position:r?M.Position.Left:M.Position.Top,style:{opacity:0}}),o.jsx("style",{dangerouslySetInnerHTML:{__html:`
|
|
14
|
+
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={}),i.isWorkflowStart)u.tasks.unshift(d);else if(i.isLoopBodyStart){const b=qe(u.tasks,n);b&&(b.loopOver||(b.loopOver=[]),b.loopOver.unshift(d))}else i.branchCase!==void 0||i.forkIndex!==void 0||i.isLoopAdd?vt(u.tasks,n,i,d):u.tasks.length===0?u.tasks.push(d):Je(u.tasks,n,d);Ae(u.tasks);const{nodes:p,edges:h,taskMap:f}=De(u,c,{hideEmptyBranches:t().mode!=="edit"}),{nodes:m,edges:g}=Ne(p,h,{direction:c,mode:t().mode}),y=We(u);e({workflowDef:u,nodes:m,edges:g,taskMap:f,validationResults:y})},removeNode:r=>{const{workflowDef:n,layoutDirection:s,nodes:o}=t();if(!n)return;const i=JSON.parse(JSON.stringify(n)),l=bt(i.tasks,r);if(l){const m=o.find(g=>g.id===r)?.data?.taskType;if(m==="FORK_JOIN"||m==="FORK_JOIN_DYNAMIC"){const g=im(l,r);g&&Ge(i.tasks,g)}else if(m==="JOIN"||m==="EXCLUSIVE_JOIN"){const g=lm(l,r);g&&Ge(i.tasks,g)}}Ge(i.tasks,r),Ae(i.tasks);const{nodes:c,edges:u,taskMap:d}=De(i,s,{hideEmptyBranches:t().mode!=="edit"}),{nodes:p,edges:h}=Ne(c,u,{direction:s,mode:t().mode}),f=We(i);e({workflowDef:i,nodes:p,edges:h,taskMap:d,validationResults:f})},addLoopTask:(r,n)=>{const{workflowDef:s,layoutDirection:o}=t();if(!s)return;const i=JSON.parse(JSON.stringify(s)),l=qe(i.tasks,r);if(l&&l.type==="DO_WHILE"){l.loopOver||(l.loopOver=[]);const c={name:`new_${n.toLowerCase()}`,taskReferenceName:`${r}_sub_${Date.now()}`,type:n,inputParameters:{}};l.loopOver.push(c),Ae(i.tasks);const{nodes:u,edges:d,taskMap:p}=De(i,o,{hideEmptyBranches:t().mode!=="edit"}),{nodes:h,edges:f}=Ne(u,d,{direction:o,mode:t().mode}),m=We(i);e({workflowDef:i,nodes:h,edges:f,taskMap:p,validationResults:m})}},removeLoopTask:(r,n)=>{const{workflowDef:s,layoutDirection:o}=t();if(!s)return;const i=JSON.parse(JSON.stringify(s)),l=qe(i.tasks,r);if(l&&l.type==="DO_WHILE"&&l.loopOver){const c=bt(l.loopOver,n);if(c){const g=c.find(y=>y.taskReferenceName===n);if(g?.type==="FORK_JOIN"||g?.type==="FORK_JOIN_DYNAMIC"){const y=im(c,n);y&&Ge(l.loopOver,y)}else if(g?.type==="JOIN"||g?.type==="EXCLUSIVE_JOIN"){const y=lm(c,n);y&&Ge(l.loopOver,y)}}Ge(l.loopOver,n),Ae(i.tasks);const{nodes:u,edges:d,taskMap:p}=De(i,o,{hideEmptyBranches:t().mode!=="edit"}),{nodes:h,edges:f}=Ne(u,d,{direction:o,mode:t().mode}),m=We(i);e({workflowDef:i,nodes:h,edges:f,taskMap:p,validationResults:m})}},addDecisionBranch:(r,n)=>{const{workflowDef:s,layoutDirection:o}=t();if(!s)return;const i=JSON.parse(JSON.stringify(s)),l=qe(i.tasks,r);if(l&&(l.type==="DECISION"||l.type==="SWITCH")){n==="default"?l.defaultCase||(l.defaultCase=[]):(l.decisionCases||(l.decisionCases={}),l.decisionCases[n]||(l.decisionCases[n]=[])),Ae(i.tasks);const{nodes:c,edges:u,taskMap:d}=De(i,o,{hideEmptyBranches:t().mode!=="edit"}),{nodes:p,edges:h}=Ne(c,u,{direction:o,mode:t().mode}),f=We(i);e({workflowDef:i,nodes:p,edges:h,taskMap:d,validationResults:f})}},removeDecisionBranch:(r,n)=>{const{workflowDef:s,layoutDirection:o}=t();if(!s)return;const i=JSON.parse(JSON.stringify(s)),l=qe(i.tasks,r);if(l&&(l.type==="DECISION"||l.type==="SWITCH")){n==="default"?l.defaultCase=[]:l.decisionCases&&delete l.decisionCases[n],Ae(i.tasks);const{nodes:c,edges:u,taskMap:d}=De(i,o,{hideEmptyBranches:t().mode!=="edit"}),{nodes:p,edges:h}=Ne(c,u,{direction:o,mode:t().mode}),f=We(i);e({workflowDef:i,nodes:p,edges:h,taskMap:d,validationResults:f})}},renameDecisionBranch:(r,n,s)=>{const{workflowDef:o,layoutDirection:i}=t();if(!o||!s.trim()||n===s)return;const l=JSON.parse(JSON.stringify(o)),c=qe(l.tasks,r);if(c&&(c.type==="DECISION"||c.type==="SWITCH")){if(!c.decisionCases||!c.decisionCases[n])return;c.decisionCases[s.trim()]=c.decisionCases[n],delete c.decisionCases[n],Ae(l.tasks);const{nodes:u,edges:d,taskMap:p}=De(l,i,{hideEmptyBranches:t().mode!=="edit"}),{nodes:h,edges:f}=Ne(u,d,{direction:i,mode:t().mode}),m=We(l);e({workflowDef:l,nodes:h,edges:f,taskMap:p,validationResults:m})}},addForkBranch:r=>{const{workflowDef:n,layoutDirection:s}=t();if(!n)return;const o=JSON.parse(JSON.stringify(n)),i=qe(o.tasks,r);if(i&&i.type==="FORK_JOIN"){i.forkTasks||(i.forkTasks=[]),i.forkTasks.push([]),Ae(o.tasks);const{nodes:l,edges:c,taskMap:u}=De(o,s,{hideEmptyBranches:t().mode!=="edit"}),{nodes:d,edges:p}=Ne(l,c,{direction:s,mode:t().mode}),h=We(o);e({workflowDef:o,nodes:d,edges:p,taskMap:u,validationResults:h})}},copyTask:r=>e({copiedTask:r}),pasteTask:r=>{const{workflowDef:n,layoutDirection:s,selectedTask:o}=t();if(!n)return;const i=JSON.parse(JSON.stringify(n)),c=`_copy_${Date.now()}`,u=JSON.parse(JSON.stringify(r)),d=x=>{x.taskReferenceName=`${x.taskReferenceName}${c}`,x.decisionCases&&Object.values(x.decisionCases).forEach(v=>v.forEach(d)),x.defaultCase&&x.defaultCase.forEach(d),x.forkTasks&&x.forkTasks.forEach(v=>v.forEach(d)),x.loopOver&&x.loopOver.forEach(d)};d(u);const p=o?o.taskReferenceName:i.tasks.length>0?i.tasks[i.tasks.length-1].taskReferenceName:"start";if(u.type==="FORK_JOIN"){u.forkTasks||(u.forkTasks=[[],[]]);const x={name:`${u.name}_join`,taskReferenceName:`${u.taskReferenceName}_join`,type:"JOIN",joinOn:[]};i.tasks.length===0?i.tasks.push(u,x):(Je(i.tasks,p,u),Je(i.tasks,u.taskReferenceName,x))}else i.tasks.length===0?i.tasks.push(u):Je(i.tasks,p,u);Ae(i.tasks);const{nodes:h,edges:f,taskMap:m}=De(i,s,{hideEmptyBranches:t().mode!=="edit"}),{nodes:g,edges:y}=Ne(h,f,{direction:s,mode:t().mode}),b=We(i);e({workflowDef:i,nodes:g,edges:y,taskMap:m,validationResults:b})},flashNodes:r=>{if(r.length===0)return;const n=t().__flashTimeout;n&&clearTimeout(n);const s=new Set(r),o={};t().nodes.forEach(l=>{s.has(l.id)&&(o[l.id]=l.selected??!1)}),e(l=>({nodes:l.nodes.map(c=>s.has(c.id)?{...c,selected:!0}:c)}));const i=setTimeout(()=>{e(l=>({nodes:l.nodes.map(c=>s.has(c.id)?{...c,selected:o[c.id]??!1}:c)}))},2500);t().__flashTimeout=i},setTheme:r=>e({theme:r}),setThemeColor:r=>e({themeColor:r}),setEdgeType:r=>e({edgeType:r}),setNodesLocked:r=>e({nodesLocked:r}),setViewMode:r=>e({viewMode:r}),startSimulation:()=>{const{edges:r,nodes:n,isSimRunning:s}=t();if(s)return;const o=n.filter(p=>!["plusNode","dynamicPlaceholderNode"].includes(p.type??"")).map(p=>p.id),i=r.map(p=>({source:p.source,target:p.target})),l=av(o,i);e({isSimRunning:!0,simState:{}});const c={timer:null};t().__simHandle=c;let u=0;const d=()=>{if(u>=l.length||!t().isSimRunning){e({isSimRunning:!1});return}const p=l[u];e(h=>{const f={...h.simState};return p.forEach(m=>f[m]="running"),{simState:f}}),c.timer=setTimeout(()=>{t().isSimRunning&&(e(h=>{const f={...h.simState};return p.forEach(m=>f[m]="done"),{simState:f}}),u++,c.timer=setTimeout(d,280))},700)};d()},stopSimulation:()=>{const r=t().__simHandle;r?.timer&&clearTimeout(r.timer),e({isSimRunning:!1,simState:{}})},createBlankWorkflow:r=>{const n={name:r||"new_workflow",description:"",tasks:[],version:1,schemaVersion:2};t().setWorkflow(n),e({mode:"edit"})},applyAIGeneratedWorkflow:r=>{const{tasks:n,...s}=r,o={...s,name:r.name||"AI_Generated_Workflow",tasks:n||[],version:r.version||1,schemaVersion:2};t().setWorkflow(o)},setShowRunPanel:r=>e({showRunPanel:r}),setShowAnalysisPanel:r=>e({showAnalysisPanel:r}),setRunState:(r,n,s)=>{e({runState:r,pendingExecutionId:n!==void 0?n:t().pendingExecutionId,executionError:s!==void 0?s:t().executionError})},switchToEditAndFocusParam:(r,n)=>{const{workflowDef:s,layoutDirection:o,taskMap:i}=t();if(!s)return;e({mode:"edit",focusedParamKey:n??null});const{nodes:l,edges:c,taskMap:u}=De(s,o,{hideEmptyBranches:!1}),{nodes:d,edges:p}=Ne(l,c,{direction:o,mode:"edit"});e({nodes:d,edges:p,taskMap:u});const h=i[r]||u[r];h&&e({selectedTask:{...h},isDetailPanelOpen:!0,showAnalysisPanel:!1})},setShowDataLineage:r=>e({showDataLineage:r}),clearRefactorNotice:()=>e({lastRefactorNotice:null}),setShowWaterfallPanel:r=>e({showWaterfallPanel:r}),setTimeTravelTimestamp:r=>e({timeTravelTimestamp:r}),setLoopIteration:(r,n)=>e({activeLoopIterations:{...t().activeLoopIterations,[r]:n}}),runLocalSandboxDryRun:(r,n,s)=>{const{workflowDef:o}=t();if(!o)return;const i=$t(o,{workflowInput:r,taskMocks:n,maxLoopIterations:s});t().importExecutionJSON(i),e({showWaterfallPanel:!0})},setInlineCopilotTaskRef:r=>e({inlineCopilotTaskRef:r})}),{partialize:e=>({workflowDef:e.workflowDef,layoutDirection:e.layoutDirection,nodes:e.nodes.map(t=>Object.assign({},t,{selected:!1})),edges:e.edges,taskMap:e.taskMap,theme:e.theme,themeColor:e.themeColor,mode:e.mode,edgeType:e.edgeType,nodesLocked:e.nodesLocked,copiedTask:e.copiedTask}),equality:(e,t)=>JSON.stringify(e.workflowDef)===JSON.stringify(t.workflowDef)}),{name:"conductor-ui-prefs",version:1,storage:Tr(()=>localStorage),migrate:(e,t)=>(t===0&&e.edgeType==="default"&&(e.edgeType="smoothstep"),e),partialize:e=>({theme:e.theme,themeColor:e.themeColor,layoutDirection:e.layoutDirection,edgeType:e.edgeType,nodesLocked:e.nodesLocked,copiedTask:e.copiedTask,viewMode:e.viewMode})}));const dv=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),uv=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,n)=>n?n.toUpperCase():r.toLowerCase()),xm=e=>{const t=uv(e);return t.charAt(0).toUpperCase()+t.slice(1)},bm=(...e)=>e.filter((t,r,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===r).join(" ").trim(),pv=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var fv={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 hv=N.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:s="",children:o,iconNode:i,...l},c)=>N.createElement("svg",{ref:c,...fv,width:t,height:t,stroke:e,strokeWidth:n?Number(r)*24/Number(t):r,className:bm("lucide",s),...!o&&!pv(l)&&{"aria-hidden":"true"},...l},[...i.map(([u,d])=>N.createElement(u,d)),...Array.isArray(o)?o:[o]]));const Pe=(e,t)=>{const r=N.forwardRef(({className:n,...s},o)=>N.createElement(hv,{ref:o,iconNode:t,className:bm(`lucide-${dv(xm(e))}`,`lucide-${e}`,n),...s}));return r.displayName=xm(e),r};const vm=Pe("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 mv=Pe("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 gv=Pe("clock",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const km=Pe("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 yv=Pe("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 br=Pe("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=Pe("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 xv=Pe("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);const bv=Pe("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 vv=Pe("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);const kv=Pe("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 Sv=Pe("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const Sm=Pe("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 bl=Pe("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 _v=Pe("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);const jv=Pe("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 wv=Pe("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"}]]),Iv={business:["business"],standard:["business","control"],developer:["business","control","data"]},Ke=[{type:"SIMPLE",label:"任务节点 (Worker)",description:"在远程 Worker 上执行的任务",category:"CORE",icon:vm,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:kv,viewCategory:"business"},{type:"HTTP",label:"HTTP 请求",description:"发起 REST/HTTP 调用",category:"SYSTEM",icon:xv,viewCategory:"business"},{type:"INLINE",label:"内联脚本 (Inline)",description:"执行内联脚本(JS/Python/GraalJS)",category:"SYSTEM",icon:km,viewCategory:"data"},{type:"JSON_JQ_TRANSFORM",label:"JSON 转换 (JQ)",description:"使用 JQ 表达式转换 JSON 数据",category:"SYSTEM",icon:_v,viewCategory:"data"},{type:"KAFKA_PUBLISH",label:"Kafka 推送",description:"向 Kafka 主题推送消息",category:"SYSTEM",icon:bv,viewCategory:"data"},{type:"EVENT",label:"事件 (Event)",description:"向外部队列系统发布事件",category:"SYSTEM",icon:wv,viewCategory:"data"},{type:"WAIT",label:"等待 (Wait)",description:"暂停流程,直到特定时间或时长",category:"SYSTEM",icon:gv,viewCategory:"control"},{type:"SET_VARIABLE",label:"设置变量 (Set Variable)",description:"设置工作流上下文变量",category:"SYSTEM",icon:yv,viewCategory:"data"},{type:"TERMINATE",label:"终止 (Terminate)",description:"提前结束工作流执行",category:"SYSTEM",icon:mv,viewCategory:"control"},{type:"HUMAN",label:"人工审批 (Human)",description:"等待人工审核或表单提交",category:"SYSTEM",icon:jv,viewCategory:"business"},{type:"DYNAMIC",label:"动态任务 (Dynamic)",description:"运行时动态决定任务类型",category:"SYSTEM",icon:bl,viewCategory:"data"},{type:"NOOP",label:"空操作 (Noop)",description:"占位符任务,无实际操作",category:"SYSTEM",icon:vv,viewCategory:"data"},{type:"LAMBDA",label:"Lambda 脚本 (旧)",description:"已被 INLINE 取代",category:"SYSTEM",icon:km,hidden:!0,viewCategory:"data"},{type:"SWITCH",label:"条件分支 (Switch)",description:"基于条件的逻辑分支 (Switch/Case)",category:"FLOW",icon:bl,viewCategory:"control"},{type:"DECISION",label:"判断 (Decision,旧)",description:"基于条件的逻辑分支(旧版,推荐改用 Switch)",category:"FLOW",icon:bl,hidden:!0,viewCategory:"control"},{type:"FORK_JOIN",label:"静态并行 (Fork)",description:"并行执行多个预定义任务分支",category:"FLOW",icon:br,viewCategory:"control"},{type:"FORK_JOIN_DYNAMIC",label:"动态并行 (Dynamic Fork)",description:"运行时动态生成并行分支",category:"FLOW",icon:br,viewCategory:"control"},{type:"DO_WHILE",label:"循环 (Do-While)",description:"循环执行直到满足条件",category:"FLOW",icon:Sm,viewCategory:"control"},{type:"JOIN",label:"汇聚 (Join)",description:"等待所有并行分支执行完成",category:"FLOW",icon:vr,viewCategory:"control"}],Tv=[{key:"CORE",label:"基础任务"},{key:"FLOW",label:"逻辑控制"},{key:"SYSTEM",label:"系统集成"}],kr=({message:e,onConfirm:t,onCancel:r})=>{const n=N.useRef(null),{theme:s,themeColor:o}=le();return N.useEffect(()=>{n.current?.focus({preventScroll:!0});const i=l=>{l.key==="Escape"&&r()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[r]),Ye.createPortal(a.jsx("div",{"data-mode":s,"data-brand":o,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:a.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:[a.jsx("div",{style:{fontSize:"14px",color:"var(--text-primary)",marginBottom:"24px",lineHeight:"1.6"},children:e}),a.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"10px"},children:[a.jsx("button",{ref:n,onClick:r,style:{padding:"7px 18px",backgroundColor:"var(--bg-tertiary)",border:"1px solid var(--border-primary)",borderRadius:"6px",color:"var(--text-primary)",cursor:"pointer",fontSize:"13px",fontWeight:500},children:"取消"}),a.jsx("button",{onClick:t,style:{padding:"7px 18px",backgroundColor:"var(--color-accent)",border:"none",borderRadius:"6px",color:"#ffffff",cursor:"pointer",fontSize:"13px",fontWeight:600},children:"确定"})]})]})}),document.body)},Ft=({children:e,nodeId:t,selected:r=!1,isStartOrEnd:n=!1,isError:s=!1,hasWarning:o=!1,isDecision:i=!1,isHighlighted:l=!1,executionStatus:c,simRunning:u=!1,simDone:d=!1,proposalStatus:p})=>{const{mode:h,removeNode:f}=le(),[m,g]=N.useState(!1),y=_=>{_.stopPropagation(),g(!0)},b=h==="edit"&&!n,v=[i?"decision-node-wrapper":"node-wrapper-glass",r?"node-wrapper-selected":"",l?"node-wrapper-highlighted":"",u?"node-sim-running":"",d?"node-sim-done":"",p?`node-proposal-${p}`:""].filter(Boolean).join(" "),k=N.useMemo(()=>{if(h!=="run")return{};if(!c)return{opacity:.4};switch(c){case"FAILED":case"FAILED_WITH_TERMINAL_ERROR":return{borderColor:"var(--status-failed)",boxShadow:"0 0 12px rgba(239, 68, 68, 0.5), 0 0 24px rgba(239, 68, 68, 0.2)"};case"TIMED_OUT":return{borderColor:"var(--status-timed-out)",boxShadow:"0 0 8px rgba(249, 115, 22, 0.4)"};case"IN_PROGRESS":case"SCHEDULED":return{borderColor:"var(--status-in-progress)",animation:"status-pulse 1.5s ease-in-out infinite"};case"COMPLETED":return{borderColor:"var(--status-completed)",opacity:.85};case"COMPLETED_WITH_ERRORS":return{borderColor:"var(--status-completed-with-errors)"};case"SKIPPED":case"CANCELED":return{opacity:.5};default:return{}}},[h,c]);return a.jsxs("div",{className:v,style:{position:"relative",...k},children:[b&&a.jsx("button",{onClick:y,"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&&a.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&&o&&a.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:"⚠️"}),p&&a.jsx("div",{className:`node-proposal-badge node-proposal-badge-${p}`,children:p==="added"?"+":p==="modified"?"~":"−"}),e,m&&a.jsx(kr,{message:"确定要删除此任务吗?",onConfirm:()=>{f(t),g(!1)},onCancel:()=>g(!1)})]})},Cv=({status:e})=>{const t=()=>{switch(e){case"SCHEDULED":return{icon:"○",className:"scheduled"};case"IN_PROGRESS":return{icon:"◐",className:"in-progress"};case"COMPLETED":return{icon:"✓",className:"completed"};case"COMPLETED_WITH_ERRORS":return{icon:"⚠",className:"completed-with-errors"};case"FAILED":case"FAILED_WITH_TERMINAL_ERROR":return{icon:"✗",className:"failed"};case"TIMED_OUT":return{icon:"⏱",className:"timed-out"};case"SKIPPED":return{icon:"⤳",className:"skipped"};case"CANCELED":return{icon:"⊘",className:"canceled"};default:return{icon:"?",className:"unknown"}}},{icon:r,className:n}=t();return a.jsx("div",{className:`execution-status-badge ${n}`,title:e,children:a.jsx("span",{className:"badge-icon",children:r})})},vl=N.memo(Cv),Nv=/[一-龥]/,Rv=({icon:e,header:t,title:r,subTitle:n,meta:s,duration:o,color:i,status:l,isRunning:c,children:u,width:d="240px"})=>{const p=c&&l?l==="COMPLETED"?"var(--status-completed)":l==="FAILED"||l==="FAILED_WITH_TERMINAL_ERROR"?"var(--status-failed)":l==="IN_PROGRESS"||l==="SCHEDULED"?"var(--status-in-progress)":l==="TIMED_OUT"||l==="COMPLETED_WITH_ERRORS"?"var(--status-timed-out)":i:i,h=d==="240px"||d===240?"237px":d;return a.jsxs("div",{style:{display:"flex",flexDirection:"row",width:h,height:u?void 0:"81px",minHeight:"81px",boxSizing:"border-box",position:"relative",overflow:"hidden",borderRadius:"10px"},children:[a.jsx("div",{style:{width:"44px",display:"flex",alignItems:"center",justifyContent:"center",background:"color-mix(in srgb, var(--color-accent) 8%, transparent)",borderLeft:`3px solid ${p}`,borderRight:"1px solid var(--border-primary)",color:p,flexShrink:0},children:a.jsx(e,{size:18,strokeWidth:1.75})}),a.jsxs("div",{style:{flex:1,padding:"6px 12px",display:"flex",flexDirection:"column",justifyContent:"center",overflow:"hidden",minWidth:0},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"6px",marginBottom:"2px",paddingRight:c&&l?"20px":0},children:[a.jsx("div",{style:{fontSize:"10px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.5px",lineHeight:1.2,opacity:.85,color:i,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",...Nv.test(t)&&{letterSpacing:"0.2px",fontSize:"11px"}},children:t}),c&&o&&a.jsx("span",{style:{fontSize:"10px",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)",background:"var(--bg-tertiary)",padding:"1px 5px",borderRadius:"4px",flexShrink:0,lineHeight:1.2},children:o})]}),a.jsx("div",{style:{fontSize:"13.5px",fontWeight:600,color:"var(--text-primary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",lineHeight:1.25,marginBottom:n||s?"1px":0},title:r,children:r}),n&&n!==r&&n!==s&&a.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",lineHeight:1.25},title:n,children:n}),s&&a.jsx("div",{style:{fontSize:"11px",color:"var(--text-muted)",lineHeight:1.25,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},title:s,children:s}),u&&a.jsx("div",{style:{marginTop:"6px"},children:u})]}),c&&l&&a.jsx("div",{style:{position:"absolute",top:"7px",right:"7px"},children:a.jsx(vl,{status:l})})]})},Sr=N.memo(Rv),ut=e=>{const t=e.layoutDirection||"TB",r=e.sourcePosition||(t==="LR"?q.Position.Right:q.Position.Bottom),n=e.targetPosition||(t==="LR"?q.Position.Left:q.Position.Top);return{layoutDirection:t,sourcePosition:r,targetPosition:n}},_t=e=>{const{mode:t,executionData:r,workflowDef:n,activeLoopIterations:s,timeTravelTimestamp:o}=le(),i=t==="run"?r?.[e]:null,l=t==="run";let c=i?{...i}:null;if(l&&c&&c.attempts.length>1&&n?.tasks){let f=0;for(const[m,g]of Object.entries(s)){if(!g)continue;if(r?.[m]||c.attempts.some(b=>b.iteration===g)){f=g;break}}if(f>0){const m=c.attempts.find(g=>g.iteration===f)||c.attempts[f-1];m&&(c={...c,status:m.status,startTime:m.startTime,endTime:m.endTime,input:m.inputData,output:m.outputData,iteration:m.iteration??f})}}if(l&&c&&o!==null){const f=c.startTime??0,m=c.endTime??f;f>o?c={...c,status:"SCHEDULED"}:f<=o&&m>o&&(c={...c,status:"IN_PROGRESS"})}const u=c?.attempts.some(f=>f.iteration!==void 0&&f.iteration>1)??!1,d=c?.attempts[c.attempts.length-1],p=u?0:d?.retryCount??0;let h;if(l&&c?.startTime)if(o!==null&&c.startTime>o)h="待执行";else if(o!==null&&c.startTime<=o&&(c.endTime??c.startTime)>o)h=`${o-c.startTime}ms...`;else if(c.endTime&&c.endTime>=c.startTime){const f=c.endTime-c.startTime;h=f<1e3?`${f}ms`:`${(f/1e3).toFixed(2)}s`}else(c.status==="IN_PROGRESS"||c.status==="SCHEDULED")&&(h="运行中");return{mode:t,execution:c,isRunning:l,retryCount:p,durationText:h}};function rt(e,t){return e.length>t?e.slice(0,t)+"…":e}function Bt(e,t,r,n){if(r==="business")return t.task?.description?.trim()||n;if(r==="standard")return n;const s=t.task;if(!s)return n;const o=s.inputParameters||{};switch(e){case"HTTP":case"HTTP_POLL":{const i=s.httpRequest||o.http_request;if(!i)return n;const l=(i.method||"GET").toUpperCase(),c=i.uri?rt(String(i.uri),28):"";return c?`${l} ${c}`:l}case"SWITCH":{const i=s.caseExpression||o.expression,l=s.evaluatorType||o.evaluatorType;return i?rt(i,35):l||n}case"DECISION":return s.caseValueParam?`param: ${s.caseValueParam}`:n;case"SIMPLE":return s.name?`worker: ${rt(s.name,28)}`:n;case"INLINE":case"LAMBDA":{const i=s.evaluatorType||o.evaluatorType;return i?`${i} script`:n}case"SUB_WORKFLOW":{const i=s.subWorkflowParam;return i?`${i.name}${i.version?` v${i.version}`:""}`:n}case"DO_WHILE":{const i=s.loopCondition;return i?rt(i,35):n}case"JSON_JQ_TRANSFORM":{const i=o.queryExpression||o.query_expression;return i?rt(i,35):n}case"SET_VARIABLE":{const i=Object.keys(o);return i.length?`set: ${i.slice(0,2).join(", ")}${i.length>2?"…":""}`:n}case"EVENT":{const i=s.sink||o.sink;return i?`→ ${rt(i,32)}`:n}case"KAFKA_PUBLISH":{const i=o.topic||o.kafka_request?.topic;return i?`topic: ${rt(i,28)}`:n}case"START_WORKFLOW":{const i=s.startWorkflow?.name??o.startWorkflow?.name??o.start_workflow?.name;return i?`→ ${i}`:n}default:return n}}function jt(e,t){if(t!=="business")return e;const r=Ke.find(n=>n.type===e);return r?r.label.replace(/\s*\([^)]+\)$/,""):e==="JOIN"?"汇聚":e==="EXCLUSIVE_JOIN"?"排他汇聚":e}const Ev=({id:e,data:t,selected:r})=>{const n=t.taskType||"SIMPLE",{sourcePosition:s,targetPosition:o}=ut(t),{execution:i,isRunning:l,retryCount:c,durationText:u}=_t(t.taskReferenceName),d=le(S=>S.viewMode),p=le(S=>S.mode),h=le(S=>S.setInlineCopilotTaskRef),m=q.useStore(S=>S.transform[2])>=1.15,g=N.useMemo(()=>Ke.find(S=>S.type===n),[n]),y=g?.icon||vm,b=n==="NOOP",x=t.isDynamicRuntime===!0,v=b?"var(--text-secondary)":"var(--color-accent)",k=N.useMemo(()=>{let S;return x?S=`Dynamic (${n})`:n==="SIMPLE"?S=t.label==="Worker Task"?"Execute on Worker":"Worker Task":n==="HTTP"?S="REST API Call":n==="JSON_JQ_TRANSFORM"?S="JQ Expression":n==="INLINE"||n==="LAMBDA"?S="Inline Script":n==="START_WORKFLOW"?S="Launch Workflow (no wait)":n==="DYNAMIC"?S="Dynamic Task Type":n==="HUMAN"?S="Human Approval":n==="NOOP"?S="No Operation":S=g?.label||n,Bt(n,t,d,S)},[n,g,t,d,x]),_=N.useMemo(()=>!m||!t.task?.inputParameters?[]:Object.entries(t.task.inputParameters).slice(0,2).map(([j,R])=>({key:j,val:typeof R=="object"?JSON.stringify(R).slice(0,28):String(R).slice(0,28)})),[m,t.task?.inputParameters]);return a.jsx(Ft,{nodeId:e,selected:r,isError:t.isError,hasWarning:t.hasWarning,isHighlighted:t.isHighlighted,executionStatus:i?.status,simRunning:t.simRunning,simDone:t.simDone,proposalStatus:t.proposalStatus,children:a.jsxs("div",{style:{borderRadius:"10px",background:b?"var(--bg-tertiary)":"transparent",opacity:b?.75:1,position:"relative",outline:x?"2px dashed var(--color-accent)":"none",outlineOffset:"-2px"},children:[a.jsx(Sr,{icon:y,header:jt(n,d),title:t.taskReferenceName,subTitle:t.label&&t.label!==t.taskReferenceName?t.label:void 0,meta:k,duration:u,color:v,status:i?.status,isRunning:l}),_.length>0&&a.jsx("div",{style:{padding:"4px 10px 6px",borderTop:"1px dashed var(--border-primary)",fontSize:"9px",fontFamily:"monospace",color:"var(--text-secondary)",display:"flex",flexDirection:"column",gap:"2px"},children:_.map(S=>a.jsxs("div",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[a.jsx("span",{style:{color:"#38bdf8"},children:S.key}),": ",S.val]},S.key))}),r&&p==="edit"&&a.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),h(t.taskReferenceName)},title:"在此节点触发 ⌘K 画布内联 AI 指令",style:{position:"absolute",top:"-10px",right:"20px",padding:"1px 6px",borderRadius:"999px",border:"1px solid rgba(99, 102, 241, 0.6)",background:"linear-gradient(135deg, #6366f1, #38bdf8)",color:"#fff",fontSize:"9px",fontWeight:700,cursor:"pointer",zIndex:102,boxShadow:"0 2px 6px rgba(0,0,0,0.3)"},children:"⌘K"}),l&&c>0&&a.jsxs("div",{style:{position:"absolute",bottom:"4px",right:"4px",background:"var(--status-failed, #ef4444)",color:"#fff",borderRadius:"10px",fontSize:"10px",fontWeight:"700",padding:"1px 6px",zIndex:10,lineHeight:"1.4",pointerEvents:"none"},children:["×",c]}),x&&a.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:"动态"}),a.jsx(q.Handle,{type:"target",position:o,style:{background:"#fff"}}),a.jsx(q.Handle,{type:"source",position:s,style:{background:"#fff"}})]})})},Pv=N.memo(Ev),_m=({title:e,label:t,defaultValue:r="",placeholder:n="",confirmText:s="确定",cancelText:o="取消",onConfirm:i,onCancel:l})=>{const{theme:c,themeColor:u}=le(),[d,p]=N.useState(r),h=N.useRef(null);N.useEffect(()=>{h.current&&(h.current.focus({preventScroll:!0}),h.current.select());const m=g=>{g.key==="Escape"&&(g.stopPropagation(),l())};return window.addEventListener("keydown",m,!0),()=>window.removeEventListener("keydown",m,!0)},[l]);const f=()=>{const m=d.trim();m&&i(m)};return Ye.createPortal(a.jsx("div",{"data-mode":c,"data-brand":u,onClick:l,style:{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",backgroundColor:"rgba(0, 0, 0, 0.45)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:2e3},children:a.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":e,onClick:m=>m.stopPropagation(),style:{backgroundColor:"var(--bg-secondary)",border:"1px solid var(--border-primary)",borderRadius:"10px",padding:"24px 28px",maxWidth:"400px",width:"90%",boxShadow:"0 8px 32px rgba(0, 0, 0, 0.22)"},children:[a.jsx("div",{style:{fontSize:"15px",fontWeight:600,color:"var(--text-primary)",marginBottom:"16px"},children:e}),t&&a.jsx("div",{style:{fontSize:"12px",color:"var(--text-secondary)",marginBottom:"8px"},children:t}),a.jsx("input",{ref:h,type:"text",value:d,placeholder:n,onChange:m=>p(m.target.value),onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),f()),m.stopPropagation()},style:{width:"100%",padding:"9px 12px",borderRadius:"6px",border:"1px solid var(--border-primary)",background:"var(--bg-tertiary)",color:"var(--text-primary)",fontSize:"13px",outline:"none",boxSizing:"border-box",marginBottom:"20px",transition:"border-color 0.15s"},onFocus:m=>{m.currentTarget.style.borderColor="var(--color-accent)"},onBlur:m=>{m.currentTarget.style.borderColor="var(--border-primary)"}}),a.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"10px"},children:[a.jsx("button",{onClick:l,style:{padding:"7px 18px",backgroundColor:"var(--bg-tertiary)",border:"1px solid var(--border-primary)",borderRadius:"6px",color:"var(--text-primary)",cursor:"pointer",fontSize:"13px",fontWeight:500},children:o}),a.jsx("button",{onClick:f,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)},Ov=({id:e,data:t,selected:r})=>{const{layoutDirection:n}=ut(t),{mode:s,execution:o,isRunning:i,durationText:l}=_t(t.taskReferenceName),{addDecisionBranch:c,removeDecisionBranch:u,renameDecisionBranch:d,viewMode:p}=le(),[h,f]=N.useState(!1),[m,g]=N.useState({type:"none"}),y=n==="LR"?q.Position.Left:q.Position.Top,b=Object.keys(t.decisionCases||t.task?.decisionCases||{}),x=()=>{f(!1),g({type:"add"})},v=(w,D)=>{w.stopPropagation(),g({type:"delete",branch:D})},k=(w,D)=>{w.stopPropagation(),f(!1),g({type:"rename",branch:D})},_=w=>{w&&c(e,w),g({type:"none"})},S=w=>{m.type==="rename"&&(w&&w!==m.branch&&d(e,m.branch,w),g({type:"none"}))},j=()=>{m.type==="delete"&&(u(e,m.branch),g({type:"none"}))},R=()=>g({type:"none"}),T=i?(w=>w&&{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"}[w]||"")(o?.status):"";return a.jsxs(Ft,{nodeId:e,selected:r,isError:t.isError,hasWarning:t.hasWarning,isDecision:!0,isHighlighted:t.isHighlighted,executionStatus:o?.status,simRunning:t.simRunning,simDone:t.simDone,proposalStatus:t.proposalStatus,children:[a.jsxs("div",{style:{position:"relative",width:"164px",height:"164px",display:"flex",alignItems:"center",justifyContent:"center"},children:[a.jsx(q.Handle,{type:"target",position:y,style:{background:"#fff",[n==="LR"?"left":"top"]:"-3px",zIndex:15}}),i&&o?.status&&a.jsx("div",{style:{position:"absolute",top:"12px",right:"12px",zIndex:20},children:a.jsx(vl,{status:o.status})}),a.jsx("div",{className:T,style:{width:"122px",height:"122px",boxSizing:"border-box",borderRadius:"10px",background:i&&o?.status?void 0:"var(--glass-bg)",backdropFilter:"var(--glass-blur)",WebkitBackdropFilter:"var(--glass-blur)",border:r?"2.5px solid var(--color-accent)":i&&o?.status?void 0:"2px solid rgba(var(--color-accent-rgb), 0.45)",transform:"rotate(45deg)",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:r?"0 8px 26px rgba(0,0,0,0.35), 0 0 0 3px var(--node-glow-color)":i&&o?.status?void 0:"var(--node-shadow)",transition:"all 0.25s ease",cursor:"pointer",flexShrink:0},onClick:()=>s==="edit"&&f(!h),children:a.jsxs("div",{style:{transform:"rotate(-45deg)",color:"#fff",textAlign:"center",padding:"6px",width:"116px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},children:[a.jsx("div",{style:{fontSize:"10px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.5px",opacity:.85,marginBottom:"2px",color:"var(--color-accent)"},children:jt(t.taskType,p)}),a.jsx("div",{style:{fontSize:"12px",fontWeight:600,color:"var(--text-primary)",lineHeight:1.25,maxWidth:"104px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:t.taskReferenceName,children:t.taskReferenceName}),t.label&&t.label!==t.taskReferenceName&&a.jsx("div",{style:{fontSize:"10px",color:"var(--text-secondary)",maxWidth:"98px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:"1px"},title:t.label,children:t.label}),s==="edit"&&a.jsx("div",{style:{width:"18px",height:"18px",fontSize:"12px",background:"color-mix(in srgb, var(--color-accent) 18%, transparent)",border:"1px solid rgba(var(--color-accent-rgb), 0.4)",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",margin:"4px auto 0",color:"var(--color-accent)",fontWeight:700},title:"管理决策分支",children:"+"}),i&&l&&a.jsx("div",{style:{fontSize:"10px",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)",background:"var(--bg-tertiary)",padding:"1px 5px",borderRadius:"4px",marginTop:"3px"},children:l})]})}),s==="edit"&&h&&a.jsxs("div",{className:"glass-panel",style:{position:"absolute",top:"170px",left:"50%",transform:"translateX(-50%)",backgroundColor:"var(--glass-surface)",border:"1px solid var(--glass-border)",borderRadius:"8px",padding:"8px",zIndex:1e3,minWidth:"200px",boxShadow:"0 10px 25px rgba(0,0,0,0.5)",animation:"popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275)",backdropFilter:"blur(12px)"},children:[a.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:"分支管理"}),b.map(w=>a.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"5px 6px",borderRadius:"4px",gap:"4px"},children:[a.jsx("span",{style:{flex:1,fontSize:"12px",color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:w}),a.jsx("button",{onClick:D=>k(D,w),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:`重命名分支 "${w}"`,children:"✏"}),a.jsx("button",{onClick:D=>v(D,w),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:`删除分支 "${w}"`,children:"×"})]},w)),a.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:"+ 添加新分支"})]}),p==="developer"&&(()=>{const w=t.task?.caseExpression||t.task?.inputParameters?.expression,D=t.task?.caseValueParam;return!w&&!D?null:a.jsx("div",{style:{position:"absolute",top:"166px",left:"50%",transform:"translateX(-50%)",textAlign:"center",fontSize:10,color:"var(--text-secondary)",maxWidth:150,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",pointerEvents:"none",fontFamily:"var(--font-mono, monospace)"},children:w?rt(w,22):`param: ${D}`})})(),n==="TB"?a.jsxs(a.Fragment,{children:[a.jsx(q.Handle,{type:"source",position:q.Position.Bottom,style:{background:"#fff",bottom:"-3px",zIndex:15}}),a.jsx(q.Handle,{type:"source",position:q.Position.Left,id:"left",style:{background:"#fff",left:"-3px",zIndex:15}}),a.jsx(q.Handle,{type:"source",position:q.Position.Right,id:"right",style:{background:"#fff",right:"-3px",zIndex:15}})]}):a.jsxs(a.Fragment,{children:[a.jsx(q.Handle,{type:"source",position:q.Position.Right,style:{background:"#fff",right:"-3px",zIndex:15}}),a.jsx(q.Handle,{type:"source",position:q.Position.Top,id:"top",style:{background:"#fff",top:"-3px",zIndex:15}}),a.jsx(q.Handle,{type:"source",position:q.Position.Bottom,id:"bottom",style:{background:"#fff",bottom:"-3px",zIndex:15}})]})]}),m.type==="add"&&a.jsx(_m,{title:"添加新分支",label:"分支条件值(Case Value)",defaultValue:`case_${b.length+1}`,placeholder:"例如:approved、rejected、pending",confirmText:"添加",onConfirm:_,onCancel:R}),m.type==="rename"&&a.jsx(_m,{title:"重命名分支",label:`当前名称:${m.branch}`,defaultValue:m.branch,placeholder:"输入新的分支条件值",confirmText:"重命名",onConfirm:S,onCancel:R}),m.type==="delete"&&a.jsx(kr,{message:`确定要删除分支 "${m.branch}" 及其下的所有任务吗?此操作不可撤销。`,onConfirm:j,onCancel:R})]})},Dv=N.memo(Ov),jm="var(--color-accent)",wm=N.memo(({id:e,data:t,selected:r})=>{const{layoutDirection:n,sourcePosition:s,targetPosition:o}=ut(t),{mode:i,execution:l,isRunning:c,durationText:u}=_t(t.taskReferenceName),{addForkBranch:d}=le(),p=q.useUpdateNodeInternals(),h=t.task?.forkTasks?.length||0;N.useEffect(()=>{p(e)},[h,e,p]);const f=t.isDynamic||t.taskType==="FORK_JOIN_DYNAMIC",m=le(b=>b.viewMode),y=N.useMemo(()=>Ke.find(b=>b.type==="FORK_JOIN"),[])?.icon||br;return a.jsx(Ft,{isHighlighted:t.isHighlighted,nodeId:e,selected:r,isError:t.isError,hasWarning:t.hasWarning,executionStatus:l?.status,simRunning:t.simRunning,simDone:t.simDone,proposalStatus:t.proposalStatus,children:a.jsxs("div",{className:`fork-node ${f?"dynamic":"static"}`,style:{borderRadius:"10px",background:"transparent",position:"relative"},children:[a.jsx(Sr,{icon:y,header:jt(f?"FORK_JOIN_DYNAMIC":"FORK_JOIN",m),title:t.taskReferenceName,subTitle:t.label&&t.label!==t.taskReferenceName?t.label:void 0,meta:Bt(t.taskType,t,m,f?"Dynamic Parallel Execution":"Parallel Execution"),duration:u,color:jm,status:l?.status,isRunning:c}),i==="edit"&&!f&&a.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:b=>{b.stopPropagation(),d(e)},title:"添加分支",children:"+"}),a.jsx(q.Handle,{type:"target",position:o,style:{background:"#fff"}}),!f&&(t.task?.forkTasks||[]).map((b,x,v)=>{if(i!=="edit"&&(!b||b.length===0))return null;const k=i!=="edit"?v.filter(R=>R&&R.length>0):v,_=k.length,j=(k.indexOf(b)+1)/(_+1)*100;return a.jsx(q.Handle,{id:`branch_${x}`,type:"source",position:s,style:{background:"#fff",[n==="LR"?"top":"left"]:`${j}%`,[n==="LR"?"left":"top"]:void 0,[n==="LR"?"right":"bottom"]:"-4px",zIndex:10}},`branch_${x}`)}),!f&&(!t.task?.forkTasks||t.task.forkTasks.length===0)&&a.jsx(q.Handle,{type:"source",position:s,style:{background:"#fff"}}),f&&a.jsx(q.Handle,{type:"source",position:s,style:{background:"#fff"}})]})})});wm.displayName="ForkNode";const Im=N.memo(({id:e,data:t,selected:r})=>{const{layoutDirection:n,sourcePosition:s,targetPosition:o}=ut(t),{execution:i,isRunning:l,durationText:c}=_t(t.taskReferenceName),u=le(h=>h.viewMode),p=N.useMemo(()=>Ke.find(h=>h.type==="JOIN"),[])?.icon||vr;return a.jsx(Ft,{isHighlighted:t.isHighlighted,nodeId:e,selected:r,isError:t.isError,hasWarning:t.hasWarning,executionStatus:i?.status,simRunning:t.simRunning,simDone:t.simDone,proposalStatus:t.proposalStatus,children:a.jsxs("div",{style:{borderRadius:"10px",background:"transparent",position:"relative"},children:[a.jsx(Sr,{icon:p,header:jt(t.taskType==="EXCLUSIVE_JOIN"?"EXCLUSIVE_JOIN":"JOIN",u),title:t.taskReferenceName,subTitle:t.label&&t.label!==t.taskReferenceName?t.label:void 0,meta:Bt(t.taskType,t,u,t.taskType==="EXCLUSIVE_JOIN"?"Wait for any task":"Wait for tasks"),duration:c,color:jm,status:i?.status,isRunning:l}),a.jsx(q.Handle,{type:"target",position:o,style:{background:"#fff"}}),n==="TB"&&a.jsxs(a.Fragment,{children:[a.jsx(q.Handle,{type:"target",position:q.Position.Left,id:"left",style:{background:"#fff"}}),a.jsx(q.Handle,{type:"target",position:q.Position.Right,id:"right",style:{background:"#fff"}})]}),n==="LR"&&a.jsxs(a.Fragment,{children:[a.jsx(q.Handle,{type:"target",position:q.Position.Top,id:"top",style:{background:"#fff"}}),a.jsx(q.Handle,{type:"target",position:q.Position.Bottom,id:"bottom",style:{background:"#fff"}})]}),a.jsx(q.Handle,{type:"source",position:s,style:{background:"#fff"}})]})})});Im.displayName="JoinNode";const Tm={ForkNode:wm,JoinNode:Im},Av=({id:e,data:t,selected:r})=>{const{sourcePosition:n,targetPosition:s}=ut(t),{execution:o,isRunning:i,durationText:l}=_t(t.taskReferenceName),{executionData:c,selectTaskAction:u,mode:d,viewMode:p,removeNode:h,activeLoopIterations:f,setLoopIteration:m}=le(),[g,y]=N.useState(!1),b=t.task,x=b?.loopOver||[],k=N.useMemo(()=>Ke.find(E=>E.type==="DO_WHILE"),[])?.icon||Sm,_=N.useMemo(()=>{if(!i||!c)return 0;let E=o?.iteration??0;return x.forEach(C=>{const z=c[C.taskReferenceName];z?.totalIterations?E=Math.max(E,z.totalIterations):z?.attempts.some(W=>(W.iteration??0)>0)&&(E=Math.max(E,z.attempts.length))}),E},[i,c,x,o?.iteration]),S=f[t.taskReferenceName]||_,j=t.loopCondition||b?.loopCondition||"",R=N.useMemo(()=>{const E=j?j.length>35?j.slice(0,35)+"…":j:"循环直到条件满足";return Bt("DO_WHILE",t,p,E)},[t,p,j]),L=o?.status==="COMPLETED"?"var(--status-completed)":o?.status==="FAILED"||o?.status==="FAILED_WITH_TERMINAL_ERROR"?"var(--status-failed)":o?.status==="IN_PROGRESS"||o?.status==="SCHEDULED"?"var(--status-in-progress)":"var(--color-accent)",T=r?`2px solid ${L}`:`1.5px dashed ${i&&o?.status?L:"var(--color-accent)"}`,w=d==="edit",D=p==="developer"&&j;return a.jsxs("div",{style:{width:"100%",height:"100%",border:T,borderRadius:"10px",background:"transparent",display:"flex",flexDirection:"column",position:"relative",overflow:"visible",boxSizing:"border-box",pointerEvents:"none"},children:[w&&a.jsx("button",{onClick:E=>{E.stopPropagation(),y(!0)},"aria-label":"删除循环任务",style:{position:"absolute",top:"-10px",right:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"2px solid white",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:100,boxShadow:"0 2px 8px rgba(0,0,0,0.2)",padding:0,pointerEvents:"auto"},title:"删除循环任务",children:"×"}),t.isError&&a.jsx("div",{style:{position:"absolute",top:"-10px",left:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"2px solid white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:101,boxShadow:"0 2px 8px rgba(0,0,0,0.2)",pointerEvents:"auto"},title:"此节点配置有误",children:"❗"}),!t.isError&&t.hasWarning&&a.jsx("div",{style:{position:"absolute",top:"-10px",left:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#f59e0b",color:"white",border:"2px solid white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:101,boxShadow:"0 2px 8px rgba(0,0,0,0.2)",pointerEvents:"auto"},title:"此节点有警告信息",children:"⚠️"}),t.proposalStatus&&a.jsx("div",{className:`node-proposal-badge node-proposal-badge-${t.proposalStatus}`,style:{pointerEvents:"auto"},children:t.proposalStatus==="added"?"+":t.proposalStatus==="modified"?"~":"−"}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:"var(--glass-surface)",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",borderBottom:"1px solid var(--border-primary)",borderRadius:"8px 8px 0 0",flexShrink:0,minHeight:"44px",pointerEvents:"auto"},children:[a.jsx("div",{style:{color:"var(--color-accent)",display:"flex",alignItems:"center",flexShrink:0},children:a.jsx(k,{size:15})}),a.jsxs("div",{style:{flex:1,minWidth:0},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[a.jsx("span",{style:{fontSize:"9px",fontWeight:700,color:"var(--color-accent)",letterSpacing:"0.08em",textTransform:"uppercase"},children:jt("DO_WHILE",p)}),a.jsxs("span",{style:{fontSize:"9px",color:"var(--text-muted)"},children:["↻ ",x.length," 个子任务"]})]}),a.jsx("div",{style:{fontSize:"12px",fontWeight:600,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.taskReferenceName}),(p==="business"||p==="developer")&&R&&a.jsx("div",{style:{fontSize:"9px",color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:"1px",fontStyle:"italic"},children:R})]}),i&&l&&a.jsx("span",{style:{fontSize:"10px",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)",background:"var(--bg-secondary)",padding:"1px 6px",borderRadius:"4px",flexShrink:0},children:l}),i&&_>0&&a.jsxs("div",{onClick:()=>u(b||null),style:{padding:"2px 8px",borderRadius:"12px",background:"var(--color-accent)",color:"#fff",fontSize:"10px",fontWeight:700,cursor:"pointer",flexShrink:0},title:`共执行 ${_} 次迭代`,children:["×",_]}),i&&o?.status&&a.jsx("div",{style:{position:"relative",width:20,height:20,flexShrink:0},children:a.jsx(vl,{status:o.status})})]}),i&&_>1&&a.jsxs("div",{onClick:E=>E.stopPropagation(),style:{display:"flex",alignItems:"center",gap:"4px",padding:"4px 10px",background:"rgba(15, 23, 42, 0.72)",borderBottom:"1px solid var(--border-primary)",flexShrink:0,pointerEvents:"auto",overflowX:"auto"},children:[a.jsx("span",{style:{fontSize:"9px",color:"#94a3b8",fontWeight:600,marginRight:"2px"},children:"切换轮次:"}),Array.from({length:_},(E,C)=>C+1).map(E=>{const C=S===E;return a.jsxs("button",{type:"button",onClick:z=>{z.stopPropagation(),m(t.taskReferenceName,E)},style:{fontSize:"9px",padding:"1px 7px",borderRadius:"999px",border:C?"1px solid #38bdf8":"1px solid rgba(148, 163, 184, 0.25)",background:C?"rgba(56, 189, 248, 0.22)":"rgba(30, 41, 59, 0.6)",color:C?"#38bdf8":"#cbd5e1",fontWeight:C?700:500,cursor:"pointer"},children:["#",E]},E)})]}),D&&a.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: ",j]}),a.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"}}),a.jsx(q.Handle,{type:"target",position:s,style:{background:"var(--color-accent)",zIndex:10}}),a.jsx(q.Handle,{type:"source",position:n,style:{background:"var(--color-accent)",zIndex:10}}),g&&a.jsx(kr,{message:"确定要删除此循环任务吗?循环体内的任务也会一并删除。",onConfirm:()=>{h(e),y(!1)},onCancel:()=>y(!1)})]})},Lv=N.memo(Av),Mv="var(--color-accent)",qv=({id:e,data:t,selected:r})=>{const{sourcePosition:n,targetPosition:s}=ut(t),{execution:o,isRunning:i,durationText:l}=_t(t.taskReferenceName),c=le(f=>f.viewMode),d=N.useMemo(()=>Ke.find(f=>f.type==="SUB_WORKFLOW"),[])?.icon||vr,p=t.task?.subWorkflowParam?.name||t.subWorkflowName||"Unknown",h=t.task?.subWorkflowParam?.version;return a.jsx(Ft,{nodeId:e,selected:r,isError:t.isError,hasWarning:t.hasWarning,isHighlighted:t.isHighlighted,executionStatus:o?.status,simRunning:t.simRunning,simDone:t.simDone,proposalStatus:t.proposalStatus,children:a.jsxs("div",{style:{borderRadius:"10px",background:"transparent",position:"relative"},children:[a.jsx(Sr,{icon:d,header:jt("SUB_WORKFLOW",c),title:t.taskReferenceName,subTitle:t.label&&t.label!==t.taskReferenceName?t.label:void 0,meta:Bt("SUB_WORKFLOW",t,c,`Flow: ${p}${h!==void 0?` (v${h})`:""}`),duration:l,color:Mv,status:o?.status,isRunning:i}),a.jsx(q.Handle,{type:"target",position:s,style:{background:"#fff"}}),a.jsx(q.Handle,{type:"source",position:n,style:{background:"#fff"}})]})})},zv=N.memo(qv),$v=({data:e})=>{const r=(e.layoutDirection||"TB")==="LR";return a.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:[a.jsx(Sv,{size:16}),e.label&&e.label!=="+"&&a.jsx("span",{style:{fontSize:"12px",fontWeight:500},children:e.label}),a.jsx(q.Handle,{type:"target",position:r?q.Position.Left:q.Position.Top,style:{opacity:0}}),a.jsx("style",{dangerouslySetInnerHTML:{__html:`
|
|
15
15
|
.plus-node-container:hover {
|
|
16
16
|
transform: scale(1.1);
|
|
17
17
|
background: var(--color-accent);
|
|
@@ -19,12 +19,12 @@ execute($.input);`}):u.type==="DYNAMIC"?(u.dynamicTaskNameParam="taskToExecute",
|
|
|
19
19
|
border-style: solid;
|
|
20
20
|
box-shadow: 0 0 10px var(--color-accent);
|
|
21
21
|
}
|
|
22
|
-
`}})]})},
|
|
22
|
+
`}})]})},Wv=N.memo($v),Fv=({data:e})=>{const{sourcePosition:t,targetPosition:r}=ut(e);return a.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:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[a.jsx(br,{size:14,style:{color:"var(--color-accent)"}}),a.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:"var(--color-accent)"},children:"动态分支"})]}),a.jsx("span",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:"运行时生成"}),a.jsx(q.Handle,{type:"target",position:r,style:{background:"var(--color-accent)",width:8,height:8}}),a.jsx(q.Handle,{type:"source",position:t,style:{background:"var(--color-accent)",width:8,height:8}})]})},Bv=N.memo(Fv),Hv=({onSelect:e,onCancel:t})=>{const[r,n]=N.useState("CORE");N.useEffect(()=>{const o=i=>{i.key==="Escape"&&t()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[t]);const s=Ke.filter(o=>o.category===r&&!o.hidden);return a.jsxs("div",{style:{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",backgroundColor:"rgba(0,0,0,0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:2e3,backdropFilter:"blur(4px)",animation:"fadeIn 0.2s ease-out"},onClick:t,children:[a.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:o=>o.stopPropagation(),children:[a.jsxs("div",{style:{padding:"20px 24px 0",borderBottom:"1px solid var(--border-primary)",backgroundColor:"var(--bg-secondary)"},children:[a.jsx("h3",{style:{marginTop:0,marginBottom:"16px",color:"var(--text-primary)",fontSize:"18px",fontWeight:"600"},children:"添加任务"}),a.jsx("div",{style:{display:"flex",gap:"24px"},children:Tv.map(o=>a.jsx("button",{onClick:()=>n(o.key),style:{background:"none",border:"none",padding:"0 0 12px 0",fontSize:"14px",fontWeight:r===o.key?"600":"500",color:r===o.key?"var(--color-accent)":"var(--text-secondary)",borderBottom:r===o.key?"2px solid var(--color-accent)":"2px solid transparent",cursor:"pointer",transition:"all 0.2s"},children:o.label},o.key))})]}),a.jsx("div",{style:{flex:1,overflowY:"auto",padding:"24px",backgroundColor:"var(--bg-primary)"},children:a.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"12px"},children:s.map(o=>{const i=o.icon;return a.jsxs("button",{onClick:()=>e(o.type),style:{display:"flex",alignItems:"flex-start",gap:"16px",padding:"16px",backgroundColor:"var(--bg-tertiary)",border:"1px solid var(--border-primary)",borderRadius:"12px",cursor:"pointer",textAlign:"left",transition:"all 0.2s",color:"var(--text-primary)",position:"relative",overflow:"hidden"},onMouseEnter:l=>{l.currentTarget.style.borderColor="var(--color-accent)",l.currentTarget.style.backgroundColor="var(--bg-highlight)",l.currentTarget.style.transform="translateY(-2px)",l.currentTarget.style.boxShadow="0 4px 12px rgba(0,0,0,0.1)"},onMouseLeave:l=>{l.currentTarget.style.borderColor="var(--border-primary)",l.currentTarget.style.backgroundColor="var(--bg-tertiary)",l.currentTarget.style.transform="translateY(0)",l.currentTarget.style.boxShadow="none"},children:[a.jsx("div",{style:{padding:"10px",borderRadius:"8px",backgroundColor:"var(--bg-secondary)",color:"var(--color-accent)",display:"flex",alignItems:"center",justifyContent:"center"},children:a.jsx(i,{size:24,strokeWidth:1.5})}),a.jsxs("div",{children:[a.jsx("div",{style:{fontWeight:"600",fontSize:"14px",marginBottom:"4px"},children:o.label}),a.jsx("div",{style:{fontSize:"12px",color:"var(--text-secondary)",lineHeight:"1.4"},children:o.description})]})]},o.type)})})}),a.jsx("div",{style:{padding:"16px 24px",borderTop:"1px solid var(--border-primary)",backgroundColor:"var(--bg-secondary)",display:"flex",justifyContent:"flex-end"},children:a.jsx("button",{onClick:t,style:{padding:"8px 24px",backgroundColor:"transparent",border:"1px solid var(--border-primary)",borderRadius:"6px",color:"var(--text-primary)",cursor:"pointer",fontSize:"13px",fontWeight:"500",transition:"all 0.2s"},onMouseEnter:o=>o.currentTarget.style.backgroundColor="var(--bg-tertiary)",onMouseLeave:o=>o.currentTarget.style.backgroundColor="transparent",children:"取消"})})]}),a.jsx("style",{children:`
|
|
23
23
|
@keyframes fadeIn {
|
|
24
24
|
from { opacity: 0; }
|
|
25
25
|
to { opacity: 1; }
|
|
26
26
|
}
|
|
27
|
-
`})]})},
|
|
27
|
+
`})]})},Uv=()=>{const{executionData:e,loadSampleExecution:t,importExecutionJSON:r,workflowInstance:n,setSelectedTask:s,nodes:o}=le(),{fitView:i}=q.useReactFlow(),l=m=>{const g=m.target.files?.[0];if(g){const y=new FileReader;y.onload=b=>{try{const x=JSON.parse(b.target?.result);r(x)}catch(x){console.error("Failed to parse execution JSON:",x)}},y.readAsText(g)}};if(!e)return a.jsxs("div",{className:"execution-status-bar",children:[a.jsx("input",{type:"file",id:"execution-json-upload",accept:".json",onChange:l,style:{display:"none"}}),a.jsx("div",{className:"status-item",children:a.jsx("span",{className:"status-label",children:"准备就绪"})}),a.jsxs("div",{style:{display:"flex",gap:"8px"},children:[a.jsx("button",{onClick:t,style:{background:"var(--color-accent)",color:"#fff",border:"none",padding:"6px 14px",borderRadius:"8px",cursor:"pointer",fontSize:"13px",fontWeight:"600",boxShadow:"0 4px 12px rgba(0,0,0,0.2)",transition:"all 0.2s ease"},children:"🚀 加载示例运行"}),a.jsx("button",{onClick:()=>document.getElementById("execution-json-upload")?.click(),title:"上传 Conductor 运行态 JSON",style:{background:"rgba(255,255,255,0.1)",color:"var(--text-primary)",border:"1px solid var(--border-primary)",padding:"6px 14px",borderRadius:"8px",cursor:"pointer",fontSize:"13px",fontWeight:"500",transition:"all 0.2s ease"},children:"📁 导入执行 JSON"})]})]});const c=Object.values(e),u=c.filter(m=>m.status==="COMPLETED").length,d=c.filter(m=>m.status==="FAILED"||m.status==="FAILED_WITH_TERMINAL_ERROR"||m.status==="TIMED_OUT"),p=d.length,h=c.filter(m=>m.status==="IN_PROGRESS"||m.status==="SCHEDULED").length,f=N.useCallback(()=>{if(p===0)return;const m=new Set(d.map(y=>y.taskReferenceName)),g=o.filter(y=>m.has(y.data?.taskReferenceName)).map(y=>y.id);g.length>0&&i({nodes:g.map(y=>({id:y})),duration:500,padding:.3})},[d,o,i,p]);return a.jsxs("div",{className:"execution-status-bar",children:[n&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"status-item",children:[a.jsx("span",{className:"status-label",children:" Workflow ID:"}),a.jsx("span",{className:"status-value highlight",style:{color:"var(--text-primary)",opacity:.8},children:n.workflowId})]}),a.jsx("div",{className:"status-divider"})]}),a.jsxs("div",{className:"status-item",children:[a.jsx("span",{className:"status-label",children:"状态:"}),a.jsx("span",{className:"status-value highlight",style:{color:n?.status==="COMPLETED"?"var(--status-completed)":"var(--status-in-progress)"},children:n?.status||"运行中"})]}),a.jsx("div",{className:"status-divider"}),a.jsxs("div",{className:"status-item",children:[a.jsx("span",{className:"status-label",children:"已完成:"}),a.jsx("span",{className:"status-value",children:u})]}),a.jsxs("div",{className:"status-item",onClick:p>0?f:void 0,style:{cursor:p>0?"pointer":"default",borderRadius:"4px",padding:"2px 6px",transition:"background 0.2s",...p>0?{background:"rgba(239, 68, 68, 0.1)"}:{}},title:p>0?"点击聚焦失败节点":void 0,children:[a.jsx("span",{className:"status-label",style:{color:"var(--status-failed)"},children:"失败:"}),a.jsx("span",{className:"status-value",style:{color:"var(--status-failed)"},children:p})]}),a.jsxs("div",{className:"status-item",children:[a.jsx("span",{className:"status-label",style:{color:"var(--status-in-progress)"},children:"处理中:"}),a.jsx("span",{className:"status-value",style:{color:"var(--status-in-progress)"},children:h})]}),a.jsx("div",{className:"status-divider"}),a.jsx("div",{style:{display:"flex",gap:"8px"},children:a.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"})})]})},Jv=({isOpen:e,onClose:t,theme:r="dark",onTaskSelect:n})=>{const{validationResults:s,setSelectedTask:o,taskMap:i}=le(),{errors:l,warnings:c}=s||{errors:[],warnings:[]},u=m=>{if(m&&m!=="UNKNOWN"){const g=i[m];g&&(n?n(g):o(g))}},d="var(--glass-surface)",p="var(--text-primary)",h="var(--glass-border)",f="var(--text-secondary)";return e?a.jsxs("div",{style:{position:"absolute",top:"80px",right:"24px",width:"320px",maxHeight:"500px",backgroundColor:d,border:`1px solid ${h}`,borderRadius:"12px",boxShadow:"0 10px 25px rgba(0,0,0,0.2)",zIndex:1100,display:"flex",flexDirection:"column",overflow:"hidden",animation:"fadeInSlide 0.2s ease-out"},children:[a.jsx("style",{children:`
|
|
28
28
|
@keyframes fadeInSlide {
|
|
29
29
|
from { opacity: 0; transform: translateY(-10px); }
|
|
30
30
|
to { opacity: 1; transform: translateY(0); }
|
|
@@ -32,7 +32,7 @@ execute($.input);`}):u.type==="DYNAMIC"?(u.dynamicTaskNameParam="taskToExecute",
|
|
|
32
32
|
.health-item:hover {
|
|
33
33
|
background-color: ${r==="light"?"#f1f5f9":"rgba(255,255,255,0.05)"};
|
|
34
34
|
}
|
|
35
|
-
`}),o.jsxs("div",{style:{padding:"16px",borderBottom:`1px solid ${h}`,display:"flex",justifyContent:"space-between",alignItems:"center",backgroundColor:"rgba(0,0,0,0.02)"},children:[o.jsxs("div",{style:{fontWeight:"bold",fontSize:"14px",display:"flex",alignItems:"center",gap:"8px"},children:[o.jsx("span",{children:"🩺"})," 工作流体检报告"]}),o.jsx("button",{onClick:t,style:{background:"none",border:"none",color:p,cursor:"pointer",fontSize:"18px"},children:"✕"})]}),o.jsx("div",{style:{flex:1,overflowY:"auto",padding:"8px"},children:l.length===0&&c.length===0?o.jsxs("div",{style:{padding:"32px 16px",textAlign:"center",color:"#10b981"},children:[o.jsx("div",{style:{fontSize:"32px",marginBottom:"12px"},children:"✅"}),o.jsx("div",{style:{fontWeight:"bold"},children:"未发现问题"}),o.jsx("div",{style:{fontSize:"12px",opacity:.7,marginTop:"4px"},children:"工作流逻辑看起来很完美"})]}):o.jsxs(o.Fragment,{children:[l.map((m,g)=>o.jsxs("div",{className:"health-item",role:"button",tabIndex:m.ref?0:void 0,onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&d(m.ref)},onClick:()=>d(m.ref),style:{padding:"12px",borderRadius:"8px",marginBottom:"4px",cursor:m.ref?"pointer":"default",borderLeft:"4px solid #ef4444",transition:"background 0.2s"},children:[o.jsxs("div",{style:{fontSize:"12px",color:"#ef4444",fontWeight:"bold",marginBottom:"2px"},children:["ERROR ",m.ref!=="UNKNOWN"&&`[${m.ref}]`]}),o.jsx("div",{style:{fontSize:"13px",color:f},children:m.message})]},`err-${g}`)),c.map((m,g)=>o.jsxs("div",{className:"health-item",role:"button",tabIndex:m.ref?0:void 0,onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&d(m.ref)},onClick:()=>d(m.ref),style:{padding:"12px",borderRadius:"8px",marginBottom:"4px",cursor:m.ref?"pointer":"default",borderLeft:"4px solid #f59e0b",transition:"background 0.2s"},children:[o.jsxs("div",{style:{fontSize:"12px",color:"#f59e0b",fontWeight:"bold",marginBottom:"2px"},children:["WARNING ",m.ref!=="UNKNOWN"&&`[${m.ref}]`]}),o.jsx("div",{style:{fontSize:"13px",color:f},children:m.message})]},`warn-${g}`))]})}),o.jsxs("div",{style:{padding:"12px 16px",fontSize:"11px",color:p,borderTop:`1px solid ${h}`,backgroundColor:"rgba(0,0,0,0.02)",display:"flex",justifyContent:"space-between"},children:[o.jsxs("span",{children:["共 ",l.length," 个错误, ",c.length," 个警告"]}),l.length>0&&o.jsx("span",{style:{color:"#ef4444"},children:"无法保存/导出"})]})]}):null},gb=({id:e,source:t,target:r,sourceX:n,sourceY:s,targetX:a,targetY:i,sourcePosition:l,targetPosition:c,style:d={},markerEnd:u,data:f})=>{const[h,p]=I.useState(!1),m=I.useRef(null),g=()=>{const N=f?.edgeType||"default",S={sourceX:n,sourceY:s,sourcePosition:l,targetX:a,targetY:i,targetPosition:c};switch(N){case"step":case"smoothstep":return M.getSmoothStepPath(S);case"straight":return M.getStraightPath(S);default:return M.getBezierPath(S)}},[x,v,y]=g(),b=N=>{N.stopPropagation(),N.preventDefault();const S=new CustomEvent("edgeAddNode",{detail:{id:e,source:t,target:r,edgeData:f}});window.dispatchEvent(S)},k=()=>{m.current&&clearTimeout(m.current),p(!0)},_=()=>{m.current=setTimeout(()=>{p(!1)},100)},w=!!(f?.isAddable??f?.mode==="edit"),T=!!f?.label,O=typeof d?.strokeWidth=="number"?d.strokeWidth:2.2,D=typeof d?.opacity=="number"?d.opacity:1;return o.jsxs(o.Fragment,{children:[o.jsx(M.BaseEdge,{path:x,markerEnd:u,style:{...d,strokeWidth:w&&h?O+1.4:O,stroke:w&&h?"var(--color-accent)":d?.stroke,transition:"stroke 0.2s ease, stroke-width 0.2s ease, opacity 0.25s ease",pointerEvents:"none"}}),w&&o.jsx("path",{d:x,fill:"none",stroke:"transparent",strokeWidth:22,style:{cursor:"pointer",pointerEvents:"all"},onMouseEnter:k,onMouseLeave:_}),(T||w&&h)&&o.jsx(M.EdgeLabelRenderer,{children:o.jsxs("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${v}px,${y}px)`,fontSize:12,pointerEvents:w?"all":"none",zIndex:h?2e3:10,display:"flex",flexDirection:"column",alignItems:"center",gap:"6px",opacity:h?1:D,transition:"opacity 0.2s ease"},className:"nodrag nopan",onMouseEnter:w?k:void 0,onMouseLeave:w?_:void 0,children:[T&&o.jsx("div",{style:{background:"var(--glass-bg-accent)",backdropFilter:"var(--glass-blur)",WebkitBackdropFilter:"var(--glass-blur)",color:"var(--text-primary)",padding:"2px 8px",borderRadius:"999px",fontSize:"11px",fontWeight:600,border:`1px solid ${h?"var(--color-accent)":"var(--border-secondary)"}`,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.22)",whiteSpace:"nowrap",letterSpacing:"0.3px",lineHeight:1.4},children:f.label}),w&&h&&o.jsx("button",{style:{width:"28px",height:"28px",backgroundColor:"var(--color-accent)",color:"#fff",border:"2px solid rgba(255,255,255,0.85)",borderRadius:"50%",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontWeight:700,fontSize:"18px",lineHeight:1,boxShadow:"0 4px 14px rgba(var(--color-accent-rgb), 0.5)",transition:"all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275)",padding:0},className:"edge-add-button",onClick:b,onMouseDown:N=>N.stopPropagation(),title:"在此处添加任务",children:"+"})]})})]})},Ie=({onClick:e,icon:t,label:r,title:n,disabled:s=!1,active:a=!1,variant:i="default",style:l})=>{let c="var(--bg-tertiary)",d="var(--text-primary)",u="1px solid var(--border-primary)";return i==="primary"?(c="var(--color-accent)",d="#fff",u="none"):i==="danger"?(c=s?"rgba(239, 68, 68, 0.1)":"var(--status-failed)",d=s?"var(--text-secondary)":"#fff",u="none"):a&&(c="var(--bg-secondary)",d="var(--color-accent)",u="1px solid var(--color-accent)"),o.jsxs("button",{onClick:e,disabled:s,title:n,"aria-label":n||r,"aria-pressed":a,"aria-disabled":s,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:r?"6px":"0",background:c,color:d,border:u,borderRadius:"7px",padding:r?"4px 10px":"6px",cursor:s?"not-allowed":"pointer",opacity:s?.45:1,fontSize:"12px",fontWeight:500,transition:"all 0.18s",minWidth:r?"auto":"30px",height:"30px",whiteSpace:"nowrap",boxShadow:i==="default"?"0 1px 2px rgba(0,0,0,0.05)":"none",...l},children:[t&&o.jsx("span",{style:{fontSize:"13px",display:"flex",alignItems:"center"},children:t}),r&&o.jsx("span",{children:r})]})},yb=()=>{const{zoomIn:e,zoomOut:t,fitView:r}=M.useReactFlow();return o.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"10px"},children:o.jsxs("div",{style:{display:"flex",background:"var(--bg-tertiary)",padding:"4px",borderRadius:"8px",border:"1px solid var(--border-primary)",gap:"4px",boxShadow:"0 2px 5px rgba(0,0,0,0.05)"},children:[o.jsx(Ie,{icon:"➕",title:"放大",onClick:()=>e()}),o.jsx(Ie,{icon:"➖",title:"缩小",onClick:()=>t()}),o.jsx(Ie,{icon:"⤢",title:"适应屏幕",onClick:()=>r({duration:600})})]})})},xm=[{id:"business",label:"业务",title:"仅展示核心业务节点"},{id:"standard",label:"标准",title:"业务 + 控制流节点"},{id:"developer",label:"全开发",title:"展示所有节点(含数据转换)"}];function xb(){const e=oe(a=>a.viewMode),t=oe(a=>a.setViewMode),r=I.useRef([]),[n,s]=I.useState({x:2,w:0});return I.useEffect(()=>{const a=xm.findIndex(l=>l.id===e),i=r.current[a];i&&s({x:i.offsetLeft,w:i.offsetWidth})},[e]),o.jsxs("div",{className:"mode-slider",role:"group","aria-label":"视图模式",children:[o.jsx("div",{className:"mode-slider-knob",style:{width:n.w,transform:`translateX(${n.x-2}px)`}}),xm.map((a,i)=>o.jsxs("button",{ref:l=>{r.current[i]=l},className:`mode-slider-opt${e===a.id?" active":""}`,onClick:()=>t(a.id),title:a.title,"aria-pressed":e===a.id,children:[o.jsx("span",{className:"mode-dot"}),a.label]},a.id))]})}const vm={enabled:!1,status:"COMPLETED",durationMs:"",forceCase:"",reasonForIncompletion:"",outputJsonText:""},vb=({isOpen:e,onClose:t})=>{const{workflowDef:r,theme:n,runLocalSandboxDryRun:s}=oe(),a=n==="light",[i,l]=I.useState("input"),[c,d]=I.useState(""),[u,f]=I.useState(null),[h,p]=I.useState({}),[m,g]=I.useState(""),[x,v]=I.useState(null),[y,b]=I.useState(2),k=I.useMemo(()=>r?.tasks?it(r.tasks):[],[r]),_=I.useMemo(()=>`sandbox_mock_cfg_${r?.name||"default"}`,[r?.name]);I.useEffect(()=>{if(!e||!r)return;const A=Lt(r);let B=!1;try{const P=sessionStorage.getItem(_);if(P){const U=JSON.parse(P);U.inputJsonText?d(U.inputJsonText):d(JSON.stringify(A,null,2)),U.taskDrafts&&typeof U.taskDrafts=="object"&&p(U.taskDrafts),typeof U.maxLoopIterations=="number"&&b(U.maxLoopIterations),B=!0}}catch{}B||(d(JSON.stringify(A,null,2)),p({}),b(2)),f(null),v(null),k.length>0&&!m&&g(k[0].taskReferenceName)},[e,r,_]),I.useEffect(()=>{k.length>0&&!k.some(A=>A.taskReferenceName===m)&&g(k[0].taskReferenceName)},[k,m]);const w=I.useMemo(()=>{const A=[];for(const B of k)if(B.type==="SWITCH"||B.type==="DECISION"){const P=Object.keys(B.decisionCases||{});if(P.length===0)continue;const U=B.caseValueParam||"case_value",L=String(B.inputParameters?.[U]??B.expression??"").match(/\$\{\s*workflow\.input\.([a-zA-Z0-9_]+)\s*\}/);A.push({switchRef:B.taskReferenceName,switchName:B.name||B.taskReferenceName,inputField:L?L[1]:null,cases:P})}return A},[k]);if(!e||!r||typeof document>"u")return null;const T=k.find(A=>A.taskReferenceName===m)||k[0]||null,O=T&&h[T.taskReferenceName]||vm,D=A=>{if(!T)return;const B=T.taskReferenceName,U={...h[B]||{...vm,outputJsonText:JSON.stringify(ur(T),null,2)},...A,enabled:A.enabled!==void 0?A.enabled:!0};p(se=>({...se,[B]:U})),v(null)},N=Object.values(h).filter(A=>A.enabled).length,S=(A,B)=>{try{const P=JSON.parse(c||"{}");P[A]=B,d(JSON.stringify(P,null,2)),f(null)}catch{f("请先修复当前 JSON 语法错误后再点击快捷赋值")}},R=()=>{let A={};try{if(A=c.trim()?JSON.parse(c):{},typeof A!="object"||Array.isArray(A)||A===null){f("workflow.input 必须是一个 JSON 对象 {...}"),l("input");return}}catch(P){f(`JSON 语法错误: ${P?.message||"格式不合法"}`),l("input");return}const B={};for(const[P,U]of Object.entries(h)){if(!U.enabled)continue;let se;if(U.outputJsonText.trim())try{se=JSON.parse(U.outputJsonText)}catch(F){g(P),l("tasks"),v(`节点 [${P}] 的自定义输出 JSON 语法有误: ${F?.message||""}`);return}const L=U.durationMs.trim()!==""&&!Number.isNaN(Number(U.durationMs))?Number(U.durationMs):void 0;B[P]={__isMockOverride:!0,status:U.status,durationMs:L,forceCase:U.forceCase||void 0,reasonForIncompletion:U.reasonForIncompletion.trim()||void 0,outputData:se}}try{sessionStorage.setItem(_,JSON.stringify({inputJsonText:c,taskDrafts:h,maxLoopIterations:y}))}catch{}s(A,B,y),t()},j=a?"#ffffff":"#0f172a",E=a?"#f8fafc":"#1e293b",q=a?"#f1f5f9":"#020617",$=a?"#0f172a":"#f8fafc",J=a?"#64748b":"#94a3b8",V=a?"rgba(148, 163, 184, 0.3)":"rgba(148, 163, 184, 0.18)";return _t.createPortal(o.jsx("div",{style:{position:"fixed",inset:0,zIndex:9500,background:"rgba(2, 6, 23, 0.65)",backdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",padding:20},onClick:t,children:o.jsxs("div",{style:{width:"min(920px, 96vw)",height:"min(660px, 90vh)",background:j,color:$,borderRadius:14,border:`1px solid ${V}`,boxShadow:"0 24px 64px rgba(0, 0, 0, 0.5)",display:"flex",flexDirection:"column",overflow:"hidden"},onClick:A=>A.stopPropagation(),children:[o.jsxs("div",{style:{padding:"16px 20px",borderBottom:`1px solid ${V}`,display:"flex",alignItems:"center",justifyContent:"space-between",background:E},children:[o.jsxs("div",{children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:15,fontWeight:700},children:[o.jsx("span",{children:"🧪 本地沙箱试运行 · 人工模拟数据控制台"}),o.jsx("span",{style:{fontSize:11,padding:"2px 8px",borderRadius:999,background:"rgba(16, 185, 129, 0.14)",color:"#10b981",fontWeight:600},children:"0ms 确定性求值"})]}),o.jsxs("div",{style:{fontSize:12,color:J,marginTop:4},children:["自定义工作流启动入参 (",o.jsx("code",{children:"workflow.input"}),")、指定任意节点的 Mock 输出、模拟节点异常中断或强制切换 ",o.jsx("code",{children:"SWITCH"})," 分支走向"]})]}),o.jsx("button",{type:"button",onClick:t,style:{background:"none",border:"none",color:J,fontSize:18,cursor:"pointer",padding:"4px 8px"},children:"✕"})]}),o.jsx("div",{style:{display:"flex",gap:8,padding:"10px 20px",borderBottom:`1px solid ${V}`,background:j},children:[{id:"input",label:"📥 1. 工作流启动入参 (workflow.input)"},{id:"tasks",label:`🎯 2. 节点级人工 Mock & 故障注入 ${N>0?`(${N} 个已启用)`:""}`},{id:"engine",label:`⚙️ 3. 循环轮次与引擎参数 (${y} 轮)`}].map(A=>{const B=i===A.id;return o.jsx("button",{type:"button",onClick:()=>l(A.id),style:{padding:"7px 14px",borderRadius:8,border:B?"1px solid #3b82f6":`1px solid ${V}`,background:B?"rgba(59, 130, 246, 0.14)":"transparent",color:B?"#3b82f6":J,fontSize:12,fontWeight:B?700:500,cursor:"pointer"},children:A.label},A.id)})}),o.jsxs("div",{style:{flex:1,minHeight:0,display:"flex",overflow:"hidden"},children:[i==="input"&&o.jsxs("div",{style:{flex:1,padding:20,display:"flex",flexDirection:"column",gap:12,overflowY:"auto"},children:[w.length>0&&o.jsxs("div",{style:{padding:"10px 14px",borderRadius:10,background:"rgba(59, 130, 246, 0.08)",border:"1px solid rgba(59, 130, 246, 0.25)",display:"flex",flexDirection:"column",gap:8},children:[o.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#38bdf8"},children:"🧭 条件分支 (SWITCH) 快速路由切换器"}),w.map(A=>o.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:6,fontSize:12},children:[o.jsxs("span",{style:{color:J},children:["节点 ",o.jsx("b",{children:A.switchName})," (",o.jsx("code",{children:A.switchRef}),")",A.inputField?` 绑定入参字段 "${A.inputField}" — 点击一键切换分支:`:" 可选分支 (可在 Tab 2 强制指定):"]}),A.cases.map(B=>o.jsx("button",{type:"button",onClick:()=>{A.inputField?S(A.inputField,B):(g(A.switchRef),l("tasks"))},style:{padding:"2px 9px",borderRadius:999,border:"1px solid rgba(56, 189, 248, 0.45)",background:"rgba(56, 189, 248, 0.14)",color:"#38bdf8",fontSize:11,fontFamily:"monospace",fontWeight:600,cursor:"pointer"},children:A.inputField?`${A.inputField} = "${B}"`:`走分支: ${B}`},B))]},A.switchRef))]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("span",{style:{fontSize:12,fontWeight:600,color:J},children:["编辑 ",o.jsx("code",{children:"workflow.input"})," JSON(所有节点的 ",o.jsx("code",{children:"${workflow.input.*}"})," 将实时读取此处的值):"]}),o.jsx("button",{type:"button",onClick:()=>{const A=Lt(r);d(JSON.stringify(A,null,2)),f(null)},style:{fontSize:11,padding:"4px 10px",borderRadius:6,border:`1px solid ${V}`,background:E,color:J,cursor:"pointer"},children:"↺ 重置为默认推导值"})]}),u&&o.jsxs("div",{style:{padding:"8px 12px",borderRadius:8,background:"rgba(239, 68, 68, 0.14)",border:"1px solid rgba(239, 68, 68, 0.4)",color:"#f87171",fontSize:12},children:["⚠️ ",u]}),o.jsx("textarea",{value:c,onChange:A=>{d(A.target.value),f(null)},spellCheck:!1,style:{flex:1,minHeight:240,width:"100%",boxSizing:"border-box",padding:14,borderRadius:10,border:`1px solid ${u?"#ef4444":V}`,background:q,color:$,fontFamily:"monospace",fontSize:13,lineHeight:1.55,resize:"none",outline:"none"}})]}),i==="tasks"&&o.jsxs("div",{style:{flex:1,display:"grid",gridTemplateColumns:"260px 1fr",minHeight:0},children:[o.jsxs("div",{style:{borderRight:`1px solid ${V}`,overflowY:"auto",padding:"10px 8px",background:E,display:"flex",flexDirection:"column",gap:4},children:[o.jsxs("div",{style:{fontSize:11,fontWeight:700,color:J,padding:"4px 8px 8px",textTransform:"uppercase"},children:["选择要定制 Mock 的节点 (",k.length,")"]}),k.map(A=>{const B=A.taskReferenceName,P=T?.taskReferenceName===B,U=h[B],se=!!U?.enabled;return o.jsxs("div",{onClick:()=>{g(B),v(null)},style:{padding:"8px 10px",borderRadius:8,cursor:"pointer",background:P?"rgba(59, 130, 246, 0.16)":"transparent",border:P?"1px solid rgba(59, 130, 246, 0.45)":"1px solid transparent",display:"flex",alignItems:"center",justifyContent:"space-between",gap:6},children:[o.jsxs("div",{style:{minWidth:0},children:[o.jsx("div",{style:{fontSize:12,fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:A.name||B}),o.jsxs("div",{style:{fontSize:10,color:J,fontFamily:"monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[B," · ",A.type]})]}),se&&o.jsx("span",{style:{fontSize:10,padding:"2px 6px",borderRadius:999,background:U.status==="FAILED"||U.status==="TIMED_OUT"?"rgba(239, 68, 68, 0.2)":"rgba(16, 185, 129, 0.2)",color:U.status==="FAILED"||U.status==="TIMED_OUT"?"#f87171":"#34d399",fontWeight:700,flexShrink:0},children:U.status==="COMPLETED"?"已定制":U.status})]},B)})]}),T?o.jsxs("div",{style:{padding:18,overflowY:"auto",display:"flex",flexDirection:"column",gap:14},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingBottom:10,borderBottom:`1px solid ${V}`},children:[o.jsxs("div",{children:[o.jsxs("div",{style:{fontSize:14,fontWeight:700},children:[T.name||T.taskReferenceName," ",o.jsxs("code",{style:{fontSize:12,color:"#38bdf8",fontWeight:500},children:["(",T.taskReferenceName,")"]})]}),o.jsxs("div",{style:{fontSize:11,color:J,marginTop:2},children:["节点类型: ",o.jsx("b",{children:T.type})]})]}),o.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12,fontWeight:700,cursor:"pointer",padding:"6px 12px",borderRadius:8,background:O.enabled?"rgba(16, 185, 129, 0.14)":E,border:`1px solid ${O.enabled?"#10b981":V}`,color:O.enabled?"#10b981":J},children:[o.jsx("input",{type:"checkbox",checked:O.enabled,onChange:A=>D({enabled:A.target.checked})}),"启用该节点人工 Mock"]})]}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 200px",gap:12},children:[o.jsxs("div",{children:[o.jsx("label",{style:{display:"block",fontSize:11,fontWeight:600,color:J,marginBottom:6},children:"模拟执行状态 (可注入异常以测试断路与错误诊断)"}),o.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[{id:"COMPLETED",label:"✅ 正常成功"},{id:"FAILED",label:"❌ 失败中断 (FAILED)"},{id:"TIMED_OUT",label:"⏱️ 超时中断 (TIMED_OUT)"},{id:"COMPLETED_WITH_ERRORS",label:"⚠️ 带错完成"}].map(A=>{const B=O.status===A.id;return o.jsx("button",{type:"button",onClick:()=>D({status:A.id}),style:{padding:"5px 10px",borderRadius:6,fontSize:11,fontWeight:B?700:500,cursor:"pointer",border:B?"1px solid #38bdf8":`1px solid ${V}`,background:B?"rgba(56, 189, 248, 0.16)":E,color:B?"#38bdf8":$},children:A.label},A.id)})})]}),o.jsxs("div",{children:[o.jsx("label",{style:{display:"block",fontSize:11,fontWeight:600,color:J,marginBottom:6},children:"模拟耗时 (ms,可制造并发瓶颈)"}),o.jsx("input",{type:"number",min:0,placeholder:"默认自动耗时 (如 120)",value:O.durationMs,onChange:A=>D({durationMs:A.target.value}),style:{width:"100%",boxSizing:"border-box",padding:"6px 10px",borderRadius:6,border:`1px solid ${V}`,background:q,color:$,fontSize:12}})]})]}),(O.status==="FAILED"||O.status==="TIMED_OUT")&&o.jsxs("div",{children:[o.jsx("label",{style:{display:"block",fontSize:11,fontWeight:600,color:"#f87171",marginBottom:6},children:"模拟异常原因 (reasonForIncompletion)"}),o.jsx("input",{type:"text",placeholder:"例如: Connection refused to upstream payment gateway (502)",value:O.reasonForIncompletion,onChange:A=>D({reasonForIncompletion:A.target.value}),style:{width:"100%",boxSizing:"border-box",padding:"7px 10px",borderRadius:6,border:"1px solid rgba(239, 68, 68, 0.45)",background:q,color:$,fontSize:12}})]}),(T.type==="SWITCH"||T.type==="DECISION")&&o.jsxs("div",{style:{padding:"10px 12px",borderRadius:8,background:"rgba(245, 158, 11, 0.1)",border:"1px solid rgba(245, 158, 11, 0.35)"},children:[o.jsx("label",{style:{display:"block",fontSize:11,fontWeight:700,color:"#fbbf24",marginBottom:6},children:"🔀 强制指定 SWITCH 路由分支 (无视入参表达式直接走指定分支)"}),o.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[o.jsx("button",{type:"button",onClick:()=>D({forceCase:""}),style:{padding:"4px 10px",borderRadius:6,fontSize:11,cursor:"pointer",border:O.forceCase?`1px solid ${V}`:"1px solid #fbbf24",background:O.forceCase?E:"rgba(245, 158, 11, 0.2)",color:O.forceCase?J:"#fbbf24",fontWeight:O.forceCase?500:700},children:"🔄 根据入参自动求值"}),Object.keys(T.decisionCases||{}).map(A=>{const B=O.forceCase===A;return o.jsxs("button",{type:"button",onClick:()=>D({forceCase:A}),style:{padding:"4px 10px",borderRadius:6,fontSize:11,fontFamily:"monospace",cursor:"pointer",border:B?"1px solid #fbbf24":`1px solid ${V}`,background:B?"rgba(245, 158, 11, 0.22)":E,color:B?"#fbbf24":$,fontWeight:B?700:500},children:["分支: ",A]},A)}),T.defaultCase&&o.jsx("button",{type:"button",onClick:()=>D({forceCase:"__default__"}),style:{padding:"4px 10px",borderRadius:6,fontSize:11,fontFamily:"monospace",cursor:"pointer",border:O.forceCase==="__default__"?"1px solid #fbbf24":`1px solid ${V}`,background:O.forceCase==="__default__"?"rgba(245, 158, 11, 0.22)":E,color:O.forceCase==="__default__"?"#fbbf24":$},children:"默认分支 (defaultCase)"})]})]}),o.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:6},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("label",{style:{fontSize:11,fontWeight:600,color:J},children:["自定义节点输出数据 (",o.jsx("code",{children:`\${${T.taskReferenceName}.output.*}`})," 将读取此 JSON):"]}),o.jsx("button",{type:"button",onClick:()=>{const A=ur(T);D({outputJsonText:JSON.stringify(A,null,2)})},style:{fontSize:11,padding:"3px 9px",borderRadius:6,border:`1px solid ${V}`,background:E,color:"#38bdf8",cursor:"pointer",fontWeight:600},children:"📋 填入默认合成输出模板"})]}),x&&o.jsxs("div",{style:{padding:"6px 10px",borderRadius:6,background:"rgba(239, 68, 68, 0.14)",border:"1px solid rgba(239, 68, 68, 0.4)",color:"#f87171",fontSize:11},children:["⚠️ ",x]}),o.jsx("textarea",{value:O.outputJsonText,placeholder:`留空则自动按 ${T.type} 类型合成输出,或点击右上角「填入默认合成输出模板」进行修改...`,onChange:A=>D({outputJsonText:A.target.value}),spellCheck:!1,style:{flex:1,minHeight:160,width:"100%",boxSizing:"border-box",padding:12,borderRadius:8,border:`1px solid ${x?"#ef4444":V}`,background:q,color:$,fontFamily:"monospace",fontSize:12,lineHeight:1.5,resize:"vertical",outline:"none"}})]})]}):o.jsx("div",{style:{padding:32,color:J},children:"当前工作流暂无任务节点"})]}),i==="engine"&&o.jsx("div",{style:{flex:1,padding:24,display:"flex",flexDirection:"column",gap:18},children:o.jsxs("div",{style:{padding:16,borderRadius:10,border:`1px solid ${V}`,background:E,display:"flex",flexDirection:"column",gap:10},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("div",{children:[o.jsx("div",{style:{fontSize:13,fontWeight:700},children:"🔄 DO_WHILE 循环容器最大模拟迭代轮次"}),o.jsxs("div",{style:{fontSize:12,color:J,marginTop:2},children:["控制沙箱遇到 ",o.jsx("code",{children:"DO_WHILE"})," 节点时自动展开执行的循环轮次数(可在画布循环容器头部切换查看每一轮的子任务状态)"]})]}),o.jsxs("span",{style:{fontSize:16,fontWeight:800,color:"#38bdf8",fontFamily:"monospace"},children:[y," 轮"]})]}),o.jsx("input",{type:"range",min:1,max:8,value:y,onChange:A=>b(Number(A.target.value)),style:{width:"100%",accentColor:"#38bdf8",cursor:"pointer"}}),o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:11,color:J},children:[o.jsx("span",{children:"1 轮 (单次验证)"}),o.jsx("span",{children:"2 轮 (默认推荐)"}),o.jsx("span",{children:"5 轮"}),o.jsx("span",{children:"8 轮 (压测多轮轨迹)"})]})]})})]}),o.jsxs("div",{style:{padding:"12px 20px",borderTop:`1px solid ${V}`,background:E,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsx("button",{type:"button",onClick:()=>{p({});const A=Lt(r);d(JSON.stringify(A,null,2)),b(2),sessionStorage.removeItem(_)},style:{padding:"7px 12px",borderRadius:8,border:`1px solid ${V}`,background:"transparent",color:J,fontSize:12,cursor:"pointer"},children:"🧹 清空全部人工 Mock 配置"}),o.jsxs("div",{style:{display:"flex",gap:10},children:[o.jsx("button",{type:"button",onClick:t,style:{padding:"8px 16px",borderRadius:8,border:`1px solid ${V}`,background:"transparent",color:$,fontSize:12,fontWeight:600,cursor:"pointer"},children:"取消"}),o.jsx("button",{type:"button",onClick:R,style:{padding:"8px 20px",borderRadius:8,border:"none",background:"linear-gradient(135deg, #2563eb, #0284c7)",color:"#ffffff",fontSize:12,fontWeight:700,cursor:"pointer",boxShadow:"0 4px 14px rgba(37, 99, 235, 0.35)"},children:"⚡ 应用模拟数据并启动沙箱试运行"})]})]})]})}),document.body)},yr=()=>o.jsx("div",{style:{width:"1px",height:"18px",background:"var(--border-primary)",margin:"0 2px",alignSelf:"center",flexShrink:0}}),bb=({onShowHealthCheck:e,showHealthCheck:t,onShowSettings:r,executionActions:n})=>{const{mode:s,setMode:a,validationResults:i,workflowInstance:l,workflowDef:c,showDataLineage:d,setShowDataLineage:u,showWaterfallPanel:f,setShowWaterfallPanel:h,runLocalSandboxDryRun:p,inlineCopilotTaskRef:m,setInlineCopilotTaskRef:g,selectedTask:x}=oe(),v=oe.temporal,{undo:y,redo:b,pastStates:k,futureStates:_}=xr(v,B=>B),[w,T]=I.useState(!1),[O,D]=I.useState(!1),N=I.useRef(null);I.useEffect(()=>{if(!w)return;const B=P=>{N.current&&!N.current.contains(P.target)&&T(!1)};return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[w]);const S=(i?.errors?.length||0)>0,R=l?.status,j=l?.workflowId??"",E=R==="RUNNING",q=R==="PAUSED",$=R==="FAILED"||R==="TIMED_OUT"||R==="TERMINATED",J=R==="COMPLETED",V=c?.restartable===!0&&($||J),A=n?.allowOperations!==!1;return o.jsxs("div",{className:"action-bar",style:{display:"flex",gap:"6px",alignItems:"center",flexWrap:"wrap",padding:"5px 8px",borderRadius:"10px",background:"var(--bg-secondary)",backdropFilter:"blur(14px)",border:"1px solid var(--border-primary)",boxShadow:"0 6px 24px rgba(0, 0, 0, 0.18)"},children:[o.jsx(xb,{}),c&&o.jsxs(o.Fragment,{children:[o.jsx(yr,{}),o.jsx(Ie,{icon:"🔗",label:"数据血缘",title:"W-LSP 数据流血缘图谱 (Data Flow Graph)",onClick:()=>u(!d),active:d}),s==="edit"&&o.jsx(Ie,{icon:"⌘K",label:"AI微调",title:"画布内联 AI 指令栏 (Cmd+K)",onClick:()=>g(m?null:x?.taskReferenceName||"__canvas_root__"),active:!!m})]}),s==="edit"&&o.jsxs(o.Fragment,{children:[o.jsx(yr,{}),o.jsxs("div",{style:{display:"inline-flex",gap:"3px",alignItems:"center"},children:[o.jsx(Ie,{icon:"↺",title:"撤销 (Cmd+Z)",onClick:()=>y(),disabled:k.length===0}),o.jsx(Ie,{icon:"↻",title:"重做 (Cmd+Shift+Z)",onClick:()=>b(),disabled:_.length===0})]}),o.jsx(Ie,{icon:"🩺",label:S?`错误 (${i.errors.length})`:"诊断",title:"流程健康检查",onClick:e,active:t,variant:S?"danger":"secondary"}),o.jsx(Ie,{icon:"⚙️",label:"配置",title:"工作流全局配置",onClick:()=>r?.()})]}),c&&s!=="run"&&o.jsxs(o.Fragment,{children:[o.jsx(yr,{}),o.jsxs("div",{style:{display:"inline-flex",alignItems:"center"},children:[o.jsx(Ie,{icon:"⚡",label:"沙箱试运行",title:"一键启动浏览器本地确定性沙箱试运行 (0ms Dry-Run)",onClick:()=>p(),variant:"primary",style:{borderRadius:"7px 0 0 7px",borderRight:"1px solid rgba(255, 255, 255, 0.25)"}}),o.jsx(Ie,{icon:"🧪",title:"人工模拟数据配置台 (自定义 workflow.input / 节点 Mock 输出 / 故障注入 / 分支路由)",onClick:()=>D(!0),variant:"primary",style:{borderRadius:"0 7px 7px 0",padding:"4px 7px",minWidth:"26px"}})]})]}),s==="run"&&o.jsxs(o.Fragment,{children:[o.jsx(yr,{}),o.jsx(Ie,{icon:"🧪",label:"模拟数据重跑",title:"打开沙箱人工模拟数据配置台,调整入参、分支或注入节点故障后重跑",onClick:()=>D(!0)}),o.jsx(Ie,{icon:"📊",label:"瀑布流回放",title:"并发甘特瀑布流与时间旅行调试器 (Time-Travel)",onClick:()=>h(!f),active:f}),o.jsx(Ie,{icon:"✏️",label:"返回编辑",title:"退出试跑/运行态视图,返回工作流编排画布",onClick:()=>a("edit")})]}),o.jsx(vb,{isOpen:O,onClose:()=>D(!1)}),s==="run"&&l&&n&&o.jsxs(o.Fragment,{children:[q&&n.onResume&&o.jsx(Ie,{icon:o.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:o.jsx("path",{d:"M4 3l9 5-9 5z"})}),label:"继续",title:A?"继续执行工作流":"操作权限受限",onClick:()=>A&&n.onResume(j),disabled:!A,variant:"primary"}),E&&n.onPause&&o.jsx(Ie,{icon:o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:[o.jsx("rect",{x:"4",y:"3",width:"3",height:"10",rx:"1"}),o.jsx("rect",{x:"9",y:"3",width:"3",height:"10",rx:"1"})]}),label:"暂停",title:A?"暂停工作流执行":"操作权限受限",onClick:()=>A&&n.onPause(j),disabled:!A}),(E||q)&&n.onTerminate&&o.jsx(Ie,{icon:o.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:o.jsx("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"})}),label:"终止",title:A?"终止工作流执行":"操作权限受限",onClick:()=>A&&n.onTerminate(j),disabled:!A,variant:"danger"}),$&&n.onRetry&&o.jsx(Ie,{icon:o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[o.jsx("path",{d:"M13 2v4h-4"}),o.jsx("path",{d:"M13 6A7 7 0 1 1 9.5 2.5"})]}),label:"重试",title:A?"重试失败的工作流":"操作权限受限",onClick:()=>A&&n.onRetry(j),disabled:!A,variant:"primary"}),V&&n.onRestart&&o.jsxs("div",{ref:N,style:{position:"relative",display:"flex"},children:[o.jsxs("button",{disabled:!A,onClick:()=>A&&n.onRestart(j,{useLatestDef:!0}),title:A?"使用当前最新定义版本重新运行":"操作权限受限",style:{display:"flex",alignItems:"center",gap:"6px",background:"var(--bg-tertiary)",color:"var(--text-primary)",border:"1px solid var(--border-primary)",borderRight:"none",borderRadius:"6px 0 0 6px",padding:"6px 10px",cursor:A?"pointer":"not-allowed",opacity:A?1:.5,fontSize:"13px",fontWeight:500,height:"32px"},children:[o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[o.jsx("path",{d:"M3 14v-4h4"}),o.jsx("path",{d:"M3 10A7 7 0 1 1 6.5 13.5"})]}),"重启"]}),o.jsx("button",{disabled:!A,onClick:()=>A&&T(B=>!B),title:A?"展开重启版本选项":"操作权限受限",style:{display:"flex",alignItems:"center",justifyContent:"center",background:A&&w?"var(--bg-secondary)":"var(--bg-tertiary)",color:"var(--text-secondary)",border:"1px solid var(--border-primary)",borderRadius:"0 6px 6px 0",padding:"6px 6px",cursor:A?"pointer":"not-allowed",opacity:A?1:.5,height:"32px",width:"22px",fontSize:"10px"},children:o.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",children:o.jsx("path",{d:"M1 3l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",fill:"none"})})}),w&&o.jsxs("div",{style:{position:"absolute",top:"36px",right:0,background:"var(--glass-surface)",backdropFilter:"blur(12px)",border:"1px solid var(--glass-border)",borderRadius:"10px",boxShadow:"0 8px 24px rgba(0,0,0,0.25)",zIndex:2e3,minWidth:"180px",overflow:"hidden"},children:[o.jsx("div",{style:{padding:"6px 12px 4px",fontSize:"11px",color:"var(--text-secondary)",fontWeight:600,letterSpacing:"0.5px",textTransform:"uppercase"},children:"选择版本"}),o.jsxs("button",{onClick:()=>{n.onRestart(j,{useLatestDef:!0}),T(!1)},style:bm,onMouseEnter:B=>B.currentTarget.style.background="var(--bg-secondary)",onMouseLeave:B=>B.currentTarget.style.background="transparent",children:[o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[o.jsx("circle",{cx:"8",cy:"8",r:"6"}),o.jsx("path",{d:"M8 5v3l2 1"})]}),o.jsxs("div",{children:[o.jsx("div",{style:{fontWeight:600,fontSize:"13px"},children:"当前版本"}),o.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:"使用最新工作流定义"})]})]}),o.jsxs("button",{onClick:()=>{n.onRestart(j,{useLatestDef:!1}),T(!1)},style:bm,onMouseEnter:B=>B.currentTarget.style.background="var(--bg-secondary)",onMouseLeave:B=>B.currentTarget.style.background="transparent",children:[o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[o.jsx("rect",{x:"3",y:"2",width:"10",height:"12",rx:"1"}),o.jsx("path",{d:"M6 6h4M6 9h3"})]}),o.jsxs("div",{children:[o.jsx("div",{style:{fontWeight:600,fontSize:"13px"},children:"执行版本"}),o.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:"使用本次运行时的定义"})]})]})]})]})]})]})},bm={display:"flex",alignItems:"center",gap:"10px",width:"100%",padding:"8px 12px",background:"transparent",border:"none",cursor:"pointer",textAlign:"left",color:"var(--text-primary)",transition:"background 0.15s"},kb=[{id:"basic",label:"基本信息"},{id:"timeout",label:"超时与容错"},{id:"params",label:"参数配置"},{id:"advanced",label:"高级设置"}],Sb=({isOpen:e,onClose:t})=>{const{workflowDef:r,updateWorkflowProperties:n,mode:s}=oe(),[a,i]=I.useState(r),[l,c]=I.useState("basic"),d=s!=="edit";I.useEffect(()=>{r&&i(r)},[r,e]);const u=I.useCallback(j=>{j.key==="Escape"&&t()},[t]);if(I.useEffect(()=>{if(e)return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[e,u]),!e||!a)return null;const f="var(--text-primary)",h="var(--glass-border)",p="var(--bg-tertiary)",m="var(--text-secondary)",g=(j,E)=>{if(!a||d)return;const q={...a,[j]:E};i(q),n({[j]:E})},x=(j,E,q)=>{if(!a||d)return;const J={...a[j]||{},[E]:q};i(V=>({...V,[j]:J})),n({[j]:J})},v=(j,E)=>{if(!(!a||d))try{const q=JSON.parse(E),$={...a,[j]:q};i($),n({[j]:q})}catch{i(q=>({...q,[`_${j}_str`]:E}))}},y={width:"100%",padding:"10px 14px",borderRadius:"8px",border:`1px solid ${h}`,background:p,color:f,fontSize:"14px",outline:"none",boxSizing:"border-box"},b={display:"block",fontSize:"11px",color:m,marginBottom:"8px",fontWeight:600},k=(j,E,q="text",$)=>o.jsxs("div",{style:{marginBottom:"20px"},children:[o.jsx("label",{style:b,children:j.toUpperCase()}),o.jsx("input",{className:"wsp-input",type:q,value:a?.[E]??"",onChange:J=>g(E,q==="number"?J.target.value===""?0:parseInt(J.target.value):J.target.value),disabled:d||$?.readOnly,placeholder:$?.placeholder,style:{...y,opacity:d||$?.readOnly?.6:1}})]}),_=(j,E,q=!1,$=6)=>{const J=a?.[`_${E}_str`]!==void 0?a[`_${E}_str`]:typeof a?.[E]=="object"?JSON.stringify(a[E],null,2):a?.[E];return o.jsxs("div",{style:{marginBottom:"20px"},children:[o.jsxs("label",{style:b,children:[j.toUpperCase()," ",q&&"(JSON)"]}),o.jsx("textarea",{className:"wsp-input",value:J||"",onChange:V=>q?v(E,V.target.value):g(E,V.target.value),rows:$,disabled:d,style:{...y,fontSize:"13px",fontFamily:q?"var(--font-mono)":"inherit",resize:"vertical",opacity:d?.6:1}})]})},w=(j,E,q)=>o.jsxs("div",{style:{marginBottom:"20px"},children:[o.jsx("label",{style:b,children:j.toUpperCase()}),o.jsx("select",{className:"wsp-input",value:a?.[E]??q[0]?.value,onChange:$=>g(E,$.target.value),disabled:d,style:{...y,opacity:d?.6:1,cursor:d?"not-allowed":"pointer"},children:q.map($=>o.jsx("option",{value:$.value,children:$.label},$.value))})]}),T=(j,E)=>{const q=!!a?.[E];return o.jsxs("div",{style:{marginBottom:"20px",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsx("label",{style:{fontSize:"13px",color:f},children:j}),o.jsx("button",{type:"button",role:"switch","aria-checked":q,onClick:()=>!d&&g(E,!q),disabled:d,style:{width:"44px",height:"24px",borderRadius:"12px",border:"none",background:q?"var(--color-accent)":"var(--border-primary)",position:"relative",cursor:d?"not-allowed":"pointer",transition:"background 0.2s",opacity:d?.6:1,flexShrink:0},children:o.jsx("span",{style:{position:"absolute",top:"2px",left:q?"22px":"2px",width:"20px",height:"20px",borderRadius:"50%",background:"var(--text-inverse)",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)"}})})]})},O=()=>o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"3fr 1fr",gap:"20px"},children:[k("工作流名称","name"),k("版本号","version","number")]}),_("描述信息","description",!1,3),k("负责人邮箱","ownerEmail","text",{placeholder:"owner@example.com"}),k("Schema 版本","schemaVersion","number",{readOnly:!0})]}),D=()=>o.jsxs(o.Fragment,{children:[w("超时策略","timeoutPolicy",[{value:"ALERT_ONLY",label:"ALERT_ONLY — 仅告警"},{value:"TIME_OUT_WF",label:"TIME_OUT_WF — 超时终止"}]),o.jsxs("div",{children:[k("超时秒数","timeoutSeconds","number",{placeholder:"0 表示不超时"}),a?.timeoutPolicy==="ALERT_ONLY"&&o.jsx("p",{style:{fontSize:"11px",color:m,marginTop:"-12px",marginBottom:"20px"},children:"当前策略为 ALERT_ONLY,超时仅触发告警,不会终止工作流。"})]}),k("失败补偿工作流","failureWorkflow","text",{placeholder:"输入补偿工作流名称"}),T("允许重启 (restartable)","restartable")]}),N=()=>{const j=At(a?.inputParameters),E=A=>{d||g("inputParameters",A)},q=()=>{const A=[...j,{name:`param_${j.length+1}`,type:"string",required:!1}];E(A)},$=A=>{const B=j.filter((P,U)=>U!==A);E(B)},J=(A,B,P)=>{const U=j.map((se,L)=>L===A?{...se,[B]:P}:se);E(U)},V={padding:"6px 10px",borderRadius:"6px",border:`1px solid ${h}`,background:p,color:f,fontSize:"12px",outline:"none",fontFamily:"inherit"};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{marginBottom:"20px"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},children:[o.jsx("label",{style:b,children:"入参声明 (INPUT PARAMETERS)"}),!d&&o.jsx("button",{onClick:q,style:{background:"var(--color-accent)",color:"var(--text-inverse)",border:"none",borderRadius:"6px",padding:"5px 12px",fontSize:"12px",fontWeight:600,cursor:"pointer",fontFamily:"inherit"},children:"+ 添加参数"})]}),j.length===0?o.jsx("p",{style:{fontSize:"12px",color:m,margin:0,padding:"12px",background:"var(--bg-secondary)",borderRadius:"8px",border:`1px solid ${h}`},children:'暂无入参声明。点击"+ 添加参数"来定义工作流的输入参数,这些参数将在执行验证时作为表单字段展示。'}):o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:j.map((A,B)=>o.jsxs("div",{style:{background:"var(--bg-secondary)",border:`1px solid ${h}`,borderRadius:"10px",padding:"12px"},children:[o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"2fr 1fr auto auto",gap:"8px",alignItems:"center"},children:[o.jsx("input",{style:V,placeholder:"参数名",value:A.name,onChange:P=>J(B,"name",P.target.value),disabled:d}),o.jsx("select",{style:{...V,cursor:d?"not-allowed":"pointer"},value:A.type??"string",onChange:P=>J(B,"type",P.target.value),disabled:d,children:["string","number","boolean","object","array"].map(P=>o.jsx("option",{value:P,children:P},P))}),o.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"4px",fontSize:"12px",color:m,cursor:d?"not-allowed":"pointer",whiteSpace:"nowrap"},children:[o.jsx("input",{type:"checkbox",checked:!!A.required,onChange:P=>J(B,"required",P.target.checked),disabled:d,style:{accentColor:"var(--color-accent)"}}),"必填"]}),!d&&o.jsx("button",{onClick:()=>$(B),style:{background:"none",border:"none",color:"var(--status-failed)",cursor:"pointer",fontSize:"16px",padding:"0 4px",opacity:.7,lineHeight:1},children:"✕"})]}),o.jsxs("div",{style:{marginTop:"8px",display:"flex",flexDirection:"column",gap:"6px"},children:[o.jsx("input",{style:V,placeholder:"说明(可选)",value:A.description??"",onChange:P=>J(B,"description",P.target.value),disabled:d}),o.jsx("input",{style:V,placeholder:`示例值(如 ${A.type==="number"?"42":A.type==="boolean"?"true":'"value"'})`,value:A.example!==void 0?typeof A.example=="object"?JSON.stringify(A.example):String(A.example):"",onChange:P=>{let U=P.target.value;try{U=JSON.parse(P.target.value)}catch{}J(B,"example",U)},disabled:d})]})]},B))})]}),_("输出参数映射 (outputParameters)","outputParameters",!0),_("默认输入模板 (inputTemplate)","inputTemplate",!0),_("工作流级变量 (variables)","variables",!0)]})},S=()=>o.jsxs(o.Fragment,{children:[T("启用状态监听 (workflowStatusListenerEnabled)","workflowStatusListenerEnabled"),a?.workflowStatusListenerEnabled&&k("状态事件目标 (Listener Sink)","workflowStatusListenerSink","text",{placeholder:"conductor:workflow_status_event"}),o.jsxs("div",{style:{borderTop:`1px solid ${h}`,marginTop:"8px",paddingTop:"20px"},children:[T("强制 Schema 校验 (enforceSchema)","enforceSchema"),a?.enforceSchema&&o.jsxs(o.Fragment,{children:[_("输入 Schema (inputSchema)","inputSchema",!0,4),_("输出 Schema (outputSchema)","outputSchema",!0,4)]})]}),o.jsxs("div",{style:{borderTop:`1px solid ${h}`,marginTop:"8px",paddingTop:"20px"},children:[o.jsx("label",{style:{...b,marginBottom:"16px"},children:"并发限流 (RATE LIMIT)"}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"2fr 1fr",gap:"20px"},children:[o.jsxs("div",{children:[o.jsx("label",{style:b,children:"RATE LIMIT KEY"}),o.jsx("input",{className:"wsp-input",type:"text",value:a?.rateLimitConfig?.rateLimitKey??"",onChange:j=>x("rateLimitConfig","rateLimitKey",j.target.value),disabled:d,placeholder:"限流键",style:{...y,opacity:d?.6:1}})]}),o.jsxs("div",{children:[o.jsx("label",{style:b,children:"并发上限"}),o.jsx("input",{className:"wsp-input",type:"number",value:a?.rateLimitConfig?.concurrentExecLimit??"",onChange:j=>x("rateLimitConfig","concurrentExecLimit",j.target.value===""?0:parseInt(j.target.value)),disabled:d,placeholder:"0",style:{...y,opacity:d?.6:1}})]})]})]})]}),R=()=>{switch(l){case"basic":return O();case"timeout":return D();case"params":return N();case"advanced":return S()}};return o.jsx("div",{role:"dialog","aria-modal":"true","aria-label":"工作流全局配置",onClick:t,style:{position:"fixed",left:0,top:0,width:"100vw",height:"100vh",backgroundColor:"rgba(0,0,0,0.5)",zIndex:1300,display:"flex",justifyContent:"center",alignItems:"center",backdropFilter:"blur(4px)",animation:"fadeIn 0.2s ease"},children:o.jsxs("div",{onClick:j=>j.stopPropagation(),style:{width:"680px",maxHeight:"85vh",background:"var(--glass-surface)",borderRadius:"16px",boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.5)",display:"flex",flexDirection:"column",overflow:"hidden",animation:"slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1)",border:`1px solid ${h}`,backdropFilter:"blur(20px)"},children:[o.jsxs("div",{style:{padding:"24px 32px 0 32px",background:"var(--bg-highlight)"},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px"},children:[o.jsxs("div",{children:[o.jsx("h2",{style:{margin:0,fontSize:"20px",color:f},children:"工作流全局配置"}),o.jsx("p",{style:{margin:"4px 0 0 0",fontSize:"12px",color:m},children:d?"当前为只读模式":"配置工作流级属性,所有更改将实时保存"})]}),o.jsx("button",{className:"wsp-close",onClick:t,"aria-label":"关闭",style:{background:"none",border:"none",color:f,fontSize:"24px",cursor:"pointer",opacity:.6},children:"✕"})]}),o.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${h}`},children:kb.map(j=>o.jsx("button",{className:"wsp-tab",onClick:()=>c(j.id),style:{padding:"10px 20px",fontSize:"13px",fontWeight:l===j.id?600:400,color:l===j.id?"var(--color-accent)":m,background:"none",border:"none",borderBottom:l===j.id?"2px solid var(--color-accent)":"2px solid transparent",cursor:"pointer",transition:"all 0.2s",marginBottom:"-1px"},children:j.label},j.id))})]}),o.jsx("div",{style:{flex:1,overflowY:"auto",padding:"28px 32px"},children:R()}),o.jsx("div",{style:{padding:"20px 32px",borderTop:`1px solid ${h}`,background:"var(--bg-highlight)",display:"flex",justifyContent:"flex-end"},children:o.jsx("button",{className:"wsp-footer-btn",onClick:t,style:{padding:"12px 32px",background:"var(--color-accent)",color:"var(--text-inverse)",border:"none",borderRadius:"12px",fontWeight:"bold",cursor:"pointer",boxShadow:"0 4px 12px var(--color-accent-bg)"},children:"完成并关闭"})})]})})},_b=({size:e=26,className:t,style:r})=>{const n=I.useId().replace(/:/g,"");return o.jsxs("svg",{width:e,height:e,viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,style:{flexShrink:0,display:"inline-block",verticalAlign:"middle",...r},"aria-label":"Conductor Workflow IDE Logo",children:[o.jsxs("defs",{children:[o.jsxs("linearGradient",{id:`bg-${n}`,x1:"0",y1:"0",x2:"32",y2:"32",gradientUnits:"userSpaceOnUse",children:[o.jsx("stop",{offset:"0%",stopColor:"#11172B"}),o.jsx("stop",{offset:"100%",stopColor:"#090D18"})]}),o.jsxs("linearGradient",{id:`bd-${n}`,x1:"0",y1:"0",x2:"32",y2:"32",gradientUnits:"userSpaceOnUse",children:[o.jsx("stop",{offset:"0%",stopColor:"#6366F1",stopOpacity:"0.8"}),o.jsx("stop",{offset:"100%",stopColor:"#06B6D4",stopOpacity:"0.5"})]}),o.jsxs("linearGradient",{id:`top-${n}`,x1:"9",y1:"16",x2:"23",y2:"10",gradientUnits:"userSpaceOnUse",children:[o.jsx("stop",{offset:"0%",stopColor:"#818CF8"}),o.jsx("stop",{offset:"100%",stopColor:"#22D3EE"})]}),o.jsxs("linearGradient",{id:`bot-${n}`,x1:"9",y1:"16",x2:"23",y2:"22",gradientUnits:"userSpaceOnUse",children:[o.jsx("stop",{offset:"0%",stopColor:"#6366F1"}),o.jsx("stop",{offset:"100%",stopColor:"#34D399"})]})]}),o.jsx("rect",{x:"1.25",y:"1.25",width:"29.5",height:"29.5",rx:"8",fill:`url(#bg-${n})`,stroke:`url(#bd-${n})`,strokeWidth:"1.5"}),o.jsx("path",{d:"M 9.5 16 C 15 16, 15.5 10, 22.5 10",stroke:`url(#top-${n})`,strokeWidth:"2.4",strokeLinecap:"round"}),o.jsx("path",{d:"M 9.5 16 C 15 16, 15.5 22, 22.5 22",stroke:`url(#bot-${n})`,strokeWidth:"2.4",strokeLinecap:"round"}),o.jsx("circle",{cx:"9.5",cy:"16",r:"3.4",fill:"#6366F1"}),o.jsx("circle",{cx:"9.5",cy:"16",r:"1.4",fill:"#F8FAFC"}),o.jsx("circle",{cx:"22.5",cy:"10",r:"2.7",fill:"#22D3EE"}),o.jsx("circle",{cx:"22.5",cy:"22",r:"2.7",fill:"#34D399"})]})},wb=({onRequestImport:e})=>{const{createBlankWorkflow:t}=oe(),[r,n]=I.useState(""),s=()=>{t(r||void 0),oe.temporal.getState().clear()},a=()=>{t(r||void 0),oe.temporal.getState().clear(),window.dispatchEvent(new CustomEvent("open-ai-chat"))};return o.jsxs("div",{className:"empty-state-panel",children:[o.jsx("div",{style:{marginBottom:12},children:o.jsx(_b,{size:46})}),o.jsx("h2",{className:"empty-state-title",children:"创建新工作流"}),o.jsx("p",{className:"empty-state-subtitle",children:"从空白画布开始设计,或让 AI 帮你生成完整流程"}),o.jsx("input",{className:"empty-state-name-input",type:"text",placeholder:"工作流名称(可选)",value:r,onChange:i=>n(i.target.value),onKeyDown:i=>{i.key==="Enter"&&s()}}),o.jsxs("div",{className:"empty-state-actions",children:[o.jsxs("button",{className:"empty-state-btn primary",onClick:s,children:[o.jsx("span",{className:"empty-state-btn-icon",children:"📄"}),"空白工作流"]}),o.jsxs("button",{className:"empty-state-btn",onClick:a,children:[o.jsx("span",{className:"empty-state-btn-icon",children:"✨"}),"AI 生成"]}),e&&o.jsxs("button",{className:"empty-state-btn",onClick:e,children:[o.jsx("span",{className:"empty-state-btn-icon",children:"📤"}),"导入 JSON"]})]})]})},Tb={success:{bg:"#10b981",text:"#fff"},error:{bg:"#ef4444",text:"#fff"},info:{bg:"var(--color-accent)",text:"#fff"}},Eb=({messages:e,onDismiss:t})=>e.length===0?null:o.jsx("div",{style:{position:"fixed",bottom:"24px",left:"50%",transform:"translateX(-50%)",zIndex:3e3,display:"flex",flexDirection:"column",gap:"8px",pointerEvents:"none"},children:e.map(r=>o.jsx(Nb,{message:r,onDismiss:t},r.id))}),Nb=({message:e,onDismiss:t})=>{const r=Tb[e.type||"info"];return I.useEffect(()=>{const n=setTimeout(()=>t(e.id),2500);return()=>clearTimeout(n)},[e.id,t]),o.jsx("div",{role:"status","aria-live":"polite",style:{backgroundColor:r.bg,color:r.text,padding:"10px 20px",borderRadius:"8px",fontSize:"13px",fontWeight:500,boxShadow:"0 4px 16px rgba(0,0,0,0.2)",animation:"toastSlideUp 0.3s ease-out",pointerEvents:"auto",cursor:"pointer",whiteSpace:"nowrap"},onClick:()=>t(e.id),children:e.text})},km=["shift","alt","meta","mod","ctrl","control"],jb={esc:"escape",return:"enter",left:"arrowleft",right:"arrowright",up:"arrowup",down:"arrowdown",ShiftLeft:"shift",ShiftRight:"shift",AltLeft:"alt",AltRight:"alt",MetaLeft:"meta",MetaRight:"meta",OSLeft:"meta",OSRight:"meta",ControlLeft:"ctrl",ControlRight:"ctrl"};function tt(e){return(jb[e.trim()]||e.trim()).toLowerCase().replace(/key|digit|numpad/,"")}function Sm(e){return km.includes(e)}function hl(e,t=","){return e.toLowerCase().split(t)}function ml(e,t="+",r=">",n=!1,s){let a=[],i=!1;e=e.trim(),e.includes(r)?(i=!0,a=e.toLocaleLowerCase().split(r).map(d=>tt(d))):a=e.toLocaleLowerCase().split(t).map(d=>tt(d));const l={alt:a.includes("alt"),ctrl:a.includes("ctrl")||a.includes("control"),shift:a.includes("shift"),meta:a.includes("meta"),mod:a.includes("mod"),useKey:n},c=a.filter(d=>!km.includes(d));return{...l,keys:c,description:s,isSequence:i,hotkey:e}}typeof document<"u"&&(document.addEventListener("keydown",e=>{e.code!==void 0&&_m([tt(e.code)])}),document.addEventListener("keyup",e=>{e.code!==void 0&&wm([tt(e.code)])})),typeof window<"u"&&(window.addEventListener("blur",()=>{Xe.clear()}),window.addEventListener("contextmenu",()=>{setTimeout(()=>{Xe.clear()},0)}));const Xe=new Set;function gl(e){return Array.isArray(e)}function Cb(e,t=","){return(gl(e)?e:e.split(t)).every(r=>Xe.has(r.trim().toLowerCase()))}function _m(e){const t=Array.isArray(e)?e:[e];Xe.has("meta")&&Xe.forEach(r=>!Sm(r)&&Xe.delete(r.toLowerCase())),t.forEach(r=>Xe.add(r.toLowerCase()))}function wm(e){const t=Array.isArray(e)?e:[e];e==="meta"?Xe.clear():t.forEach(r=>Xe.delete(r.toLowerCase()))}function Ib(e,t,r){(typeof r=="function"&&r(e,t)||r===!0)&&e.preventDefault()}function Rb(e,t,r){return typeof r=="function"?r(e,t):r===!0||r===void 0}const Ob=["input","textarea","select","searchbox","slider","spinbutton","menuitem","menuitemcheckbox","menuitemradio","option","radio","textbox"];function Pb(e){return Tm(e,Ob)}function Tm(e,t=!1){const{target:r,composed:n}=e;let s,a;return Ab(r)&&n?(s=e.composedPath()[0]&&e.composedPath()[0].tagName,a=e.composedPath()[0]&&e.composedPath()[0].role):(s=r&&r.tagName,a=r&&r.role),gl(t)?!!(s&&t&&t.some(i=>i.toLowerCase()===s.toLowerCase()||i===a)):!!(s&&t&&t)}function Ab(e){return!!e.tagName&&!e.tagName.startsWith("-")&&e.tagName.includes("-")}function Lb(e,t){return e.length===0&&t?(console.warn('A hotkey has the "scopes" option set, however no active scopes were found. If you want to use the global scopes feature, you need to wrap your app in a <HotkeysProvider>'),!0):t?e.some(r=>t.includes(r))||e.includes("*"):!0}const Db=(e,t,r=!1)=>{const{alt:n,meta:s,mod:a,shift:i,ctrl:l,keys:c,useKey:d}=t,{code:u,key:f,ctrlKey:h,metaKey:p,shiftKey:m,altKey:g}=e,x=tt(u);if(d&&c?.length===1&&c.includes(f))return!0;if(!c?.includes(x)&&!["ctrl","control","unknown","meta","alt","shift","os"].includes(x))return!1;if(!r){if(n!==g&&x!=="alt"||i!==m&&x!=="shift")return!1;if(a){if(!p&&!h)return!1}else if(s!==p&&x!=="meta"&&x!=="os"||l!==h&&x!=="ctrl"&&x!=="control")return!1}return c&&c.length===1&&c.includes(x)?!0:c?Cb(c):!c},Mb=I.createContext(void 0),qb=()=>I.useContext(Mb);function Em(e,t){return e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(e).length===Object.keys(t).length&&Object.keys(e).reduce((r,n)=>r&&Em(e[n],t[n]),!0):e===t}const $b=I.createContext({hotkeys:[],activeScopes:[],toggleScope:()=>{},enableScope:()=>{},disableScope:()=>{}}),Wb=()=>I.useContext($b);function Fb(e){const t=I.useRef(void 0);return Em(t.current,e)||(t.current=e),t.current}const Nm=e=>{e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation()},Bb=typeof window<"u"?I.useLayoutEffect:I.useEffect;function St(e,t,r,n){const s=I.useRef(null),a=I.useRef(!1),i=Array.isArray(r)?Array.isArray(n)?void 0:n:r,l=gl(e)?e.join(i?.delimiter):e,c=Array.isArray(r)?r:Array.isArray(n)?n:void 0,d=I.useCallback(t,c??[]),u=I.useRef(d);c?u.current=d:u.current=t;const f=Fb(i),{activeScopes:h}=Wb(),p=qb();return Bb(()=>{if(f?.enabled===!1||!Lb(h,f?.scopes))return;let m=[],g;const x=(k,_=!1)=>{if(!(Pb(k)&&!Tm(k,f?.enableOnFormTags))){if(s.current!==null){const w=s.current.getRootNode();if((w instanceof Document||w instanceof ShadowRoot)&&w.activeElement!==s.current&&!s.current.contains(w.activeElement)){Nm(k);return}}k.target?.isContentEditable&&!f?.enableOnContentEditable||hl(l,f?.delimiter).forEach(w=>{if(w.includes(f?.splitKey??"+")&&w.includes(f?.sequenceSplitKey??">")){console.warn(`Hotkey ${w} contains both ${f?.splitKey??"+"} and ${f?.sequenceSplitKey??">"} which is not supported.`);return}const T=ml(w,f?.splitKey,f?.sequenceSplitKey,f?.useKey,f?.description);if(T.isSequence){g=setTimeout(()=>{m=[]},f?.sequenceTimeoutMs??1e3);const O=T.useKey?k.key:tt(k.code);if(Sm(O.toLowerCase()))return;m.push(O);const D=T.keys?.[m.length-1];if(O!==D){m=[],g&&clearTimeout(g);return}m.length===T.keys?.length&&(u.current(k,T),g&&clearTimeout(g),m=[])}else if(Db(k,T,f?.ignoreModifiers)||T.keys?.includes("*")){if(f?.ignoreEventWhen?.(k)||_&&a.current)return;if(Ib(k,T,f?.preventDefault),!Rb(k,T,f?.enabled)){Nm(k);return}u.current(k,T),_||(a.current=!0)}})}},v=k=>{k.code!==void 0&&(_m(tt(k.code)),(f?.keydown===void 0&&f?.keyup!==!0||f?.keydown)&&x(k))},y=k=>{k.code!==void 0&&(wm(tt(k.code)),a.current=!1,f?.keyup&&x(k,!0))},b=s.current||i?.document||document;return b.addEventListener("keyup",y,i?.eventListenerOptions),b.addEventListener("keydown",v,i?.eventListenerOptions),p&&hl(l,f?.delimiter).forEach(k=>p.addHotkey(ml(k,f?.splitKey,f?.sequenceSplitKey,f?.useKey,f?.description))),()=>{b.removeEventListener("keyup",y,i?.eventListenerOptions),b.removeEventListener("keydown",v,i?.eventListenerOptions),p&&hl(l,f?.delimiter).forEach(k=>p.removeHotkey(ml(k,f?.splitKey,f?.sequenceSplitKey,f?.useKey,f?.description))),m=[],g&&clearTimeout(g)}},[l,f,h]),s}const zb=e=>{const{mode:t,removeNode:r,selectedTask:n,pasteTask:s}=oe(),a=oe.temporal,{undo:i,redo:l}=xr(a,h=>h),c=e?.confirm||(h=>Promise.resolve(window.confirm(h))),d=e?.showToast,u=h=>{const p=h.target;return p.tagName==="INPUT"||p.tagName==="TEXTAREA"||p.isContentEditable},f=()=>{requestAnimationFrame(()=>{const h=oe.getState(),{nodes:p,edges:m}=je(h.nodes,h.edges,{direction:h.layoutDirection,mode:h.mode});oe.setState({nodes:p,edges:m})})};return St("mod+z",h=>{t==="edit"&&(u(h)||(h.preventDefault(),i(),f()))},[t,i]),St(["mod+shift+z","mod+y"],h=>{t==="edit"&&(u(h)||(h.preventDefault(),l(),f()))},[t,l]),St("delete, backspace",h=>{t!=="edit"||!n||u(h)||(h.preventDefault(),c("确定要删除此任务吗?").then(p=>{p&&r(n.taskReferenceName)}))},[t,n,r,c]),St("mod+c",h=>{if(!(t!=="edit"||!n)&&!u(h)){if(n.type==="JOIN"){d?.("JOIN 任务不能独立复制","error");return}h.preventDefault();try{localStorage.setItem("conductor-clipboard",JSON.stringify(n)),d?.("任务已复制","success")}catch{d?.("复制失败","error")}}},[t,n,d]),St("mod+v",h=>{if(t==="edit"&&!u(h)){h.preventDefault();try{const p=localStorage.getItem("conductor-clipboard");if(p){const m=JSON.parse(p);s(m),d?.("任务已粘贴","success")}}catch{d?.("粘贴失败","error")}}},[t,s,d]),St("mod+s",h=>{h.preventDefault();const p=oe.getState().workflowDef;p&&e?.onSave&&e.onSave(p)},[e?.onSave]),{}},Hb=()=>{const[e,t]=I.useState(null),r=I.useCallback(a=>new Promise(i=>{t({message:a,resolve:i})}),[]),n=I.useCallback(()=>{e?.resolve(!0),t(null)},[e]),s=I.useCallback(()=>{e?.resolve(!1),t(null)},[e]);return{confirm:r,confirmState:e,handleConfirm:n,handleCancel:s}},Jb=()=>{const[e,t]=I.useState([]),r=I.useCallback((s,a="info")=>{const i=Date.now().toString();t(l=>[...l,{id:i,text:s,type:a}])},[]),n=I.useCallback(s=>{t(a=>a.filter(i=>i.id!==s))},[]);return{toasts:e,showToast:r,dismissToast:n}},yl={id:"welcome",role:"assistant",content:`你好!我是 AI 工作流助手。
|
|
35
|
+
`}),a.jsxs("div",{style:{padding:"16px",borderBottom:`1px solid ${h}`,display:"flex",justifyContent:"space-between",alignItems:"center",backgroundColor:"rgba(0,0,0,0.02)"},children:[a.jsxs("div",{style:{fontWeight:"bold",fontSize:"14px",display:"flex",alignItems:"center",gap:"8px"},children:[a.jsx("span",{children:"🩺"})," 工作流体检报告"]}),a.jsx("button",{onClick:t,style:{background:"none",border:"none",color:f,cursor:"pointer",fontSize:"18px"},children:"✕"})]}),a.jsx("div",{style:{flex:1,overflowY:"auto",padding:"8px"},children:l.length===0&&c.length===0?a.jsxs("div",{style:{padding:"32px 16px",textAlign:"center",color:"#10b981"},children:[a.jsx("div",{style:{fontSize:"32px",marginBottom:"12px"},children:"✅"}),a.jsx("div",{style:{fontWeight:"bold"},children:"未发现问题"}),a.jsx("div",{style:{fontSize:"12px",opacity:.7,marginTop:"4px"},children:"工作流逻辑看起来很完美"})]}):a.jsxs(a.Fragment,{children:[l.map((m,g)=>a.jsxs("div",{className:"health-item",role:"button",tabIndex:m.ref?0:void 0,onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&u(m.ref)},onClick:()=>u(m.ref),style:{padding:"12px",borderRadius:"8px",marginBottom:"4px",cursor:m.ref?"pointer":"default",borderLeft:"4px solid #ef4444",transition:"background 0.2s"},children:[a.jsxs("div",{style:{fontSize:"12px",color:"#ef4444",fontWeight:"bold",marginBottom:"2px"},children:["ERROR ",m.ref!=="UNKNOWN"&&`[${m.ref}]`]}),a.jsx("div",{style:{fontSize:"13px",color:p},children:m.message})]},`err-${g}`)),c.map((m,g)=>a.jsxs("div",{className:"health-item",role:"button",tabIndex:m.ref?0:void 0,onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&u(m.ref)},onClick:()=>u(m.ref),style:{padding:"12px",borderRadius:"8px",marginBottom:"4px",cursor:m.ref?"pointer":"default",borderLeft:"4px solid #f59e0b",transition:"background 0.2s"},children:[a.jsxs("div",{style:{fontSize:"12px",color:"#f59e0b",fontWeight:"bold",marginBottom:"2px"},children:["WARNING ",m.ref!=="UNKNOWN"&&`[${m.ref}]`]}),a.jsx("div",{style:{fontSize:"13px",color:p},children:m.message})]},`warn-${g}`))]})}),a.jsxs("div",{style:{padding:"12px 16px",fontSize:"11px",color:f,borderTop:`1px solid ${h}`,backgroundColor:"rgba(0,0,0,0.02)",display:"flex",justifyContent:"space-between"},children:[a.jsxs("span",{children:["共 ",l.length," 个错误, ",c.length," 个警告"]}),l.length>0&&a.jsx("span",{style:{color:"#ef4444"},children:"无法保存/导出"})]})]}):null},Kv=({id:e,source:t,target:r,sourceX:n,sourceY:s,targetX:o,targetY:i,sourcePosition:l,targetPosition:c,style:u={},markerEnd:d,data:p})=>{const[h,f]=N.useState(!1),m=N.useRef(null),g=()=>{const T=p?.edgeType||"default",w={sourceX:n,sourceY:s,sourcePosition:l,targetX:o,targetY:i,targetPosition:c};switch(T){case"step":case"smoothstep":return q.getSmoothStepPath(w);case"straight":return q.getStraightPath(w);default:return q.getBezierPath(w)}},[y,b,x]=g(),v=T=>{T.stopPropagation(),T.preventDefault();const w=new CustomEvent("edgeAddNode",{detail:{id:e,source:t,target:r,edgeData:p}});window.dispatchEvent(w)},k=()=>{m.current&&clearTimeout(m.current),f(!0)},_=()=>{m.current=setTimeout(()=>{f(!1)},100)},S=!!(p?.isAddable??p?.mode==="edit"),j=!!p?.label,R=typeof u?.strokeWidth=="number"?u.strokeWidth:2.2,L=typeof u?.opacity=="number"?u.opacity:1;return a.jsxs(a.Fragment,{children:[a.jsx(q.BaseEdge,{path:y,markerEnd:d,style:{...u,strokeWidth:S&&h?R+1.4:R,stroke:S&&h?"var(--color-accent)":u?.stroke,transition:"stroke 0.2s ease, stroke-width 0.2s ease, opacity 0.25s ease",pointerEvents:"none"}}),S&&a.jsx("path",{d:y,fill:"none",stroke:"transparent",strokeWidth:22,style:{cursor:"pointer",pointerEvents:"all"},onMouseEnter:k,onMouseLeave:_}),(j||S&&h)&&a.jsx(q.EdgeLabelRenderer,{children:a.jsxs("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${b}px,${x}px)`,fontSize:12,pointerEvents:S?"all":"none",zIndex:h?2e3:10,display:"flex",flexDirection:"column",alignItems:"center",gap:"6px",opacity:h?1:L,transition:"opacity 0.2s ease"},className:"nodrag nopan",onMouseEnter:S?k:void 0,onMouseLeave:S?_:void 0,children:[j&&a.jsx("div",{style:{background:"var(--glass-bg-accent)",backdropFilter:"var(--glass-blur)",WebkitBackdropFilter:"var(--glass-blur)",color:"var(--text-primary)",padding:"2px 8px",borderRadius:"999px",fontSize:"11px",fontWeight:600,border:`1px solid ${h?"var(--color-accent)":"var(--border-secondary)"}`,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.22)",whiteSpace:"nowrap",letterSpacing:"0.3px",lineHeight:1.4},children:p.label}),S&&h&&a.jsx("button",{style:{width:"28px",height:"28px",backgroundColor:"var(--color-accent)",color:"#fff",border:"2px solid rgba(255,255,255,0.85)",borderRadius:"50%",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontWeight:700,fontSize:"18px",lineHeight:1,boxShadow:"0 4px 14px rgba(var(--color-accent-rgb), 0.5)",transition:"all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275)",padding:0},className:"edge-add-button",onClick:v,onMouseDown:T=>T.stopPropagation(),title:"在此处添加任务",children:"+"})]})})]})},Re=({onClick:e,icon:t,label:r,title:n,disabled:s=!1,active:o=!1,variant:i="default",style:l})=>{let c="var(--bg-tertiary)",u="var(--text-primary)",d="1px solid var(--border-primary)";return i==="primary"?(c="var(--color-accent)",u="#fff",d="none"):i==="danger"?(c=s?"rgba(239, 68, 68, 0.1)":"var(--status-failed)",u=s?"var(--text-secondary)":"#fff",d="none"):o&&(c="var(--bg-secondary)",u="var(--color-accent)",d="1px solid var(--color-accent)"),a.jsxs("button",{onClick:e,disabled:s,title:n,"aria-label":n||r,"aria-pressed":o,"aria-disabled":s,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:r?"6px":"0",background:c,color:u,border:d,borderRadius:"7px",padding:r?"4px 10px":"6px",cursor:s?"not-allowed":"pointer",opacity:s?.45:1,fontSize:"12px",fontWeight:500,transition:"all 0.18s",minWidth:r?"auto":"30px",height:"30px",whiteSpace:"nowrap",boxShadow:i==="default"?"0 1px 2px rgba(0,0,0,0.05)":"none",...l},children:[t&&a.jsx("span",{style:{fontSize:"13px",display:"flex",alignItems:"center"},children:t}),r&&a.jsx("span",{children:r})]})},Vv=()=>{const{zoomIn:e,zoomOut:t,fitView:r}=q.useReactFlow();return a.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"10px"},children:a.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:[a.jsx(Re,{icon:"➕",title:"放大",onClick:()=>e()}),a.jsx(Re,{icon:"➖",title:"缩小",onClick:()=>t()}),a.jsx(Re,{icon:"⤢",title:"适应屏幕",onClick:()=>r({duration:600})})]})})},Cm={enabled:!1,status:"COMPLETED",durationMs:"",forceCase:"",reasonForIncompletion:"",outputJsonText:""},Gv=({isOpen:e,onClose:t})=>{const{workflowDef:r,theme:n,runLocalSandboxDryRun:s}=le(),o=n==="light",[i,l]=N.useState("input"),[c,u]=N.useState(""),[d,p]=N.useState(null),[h,f]=N.useState({}),[m,g]=N.useState(""),[y,b]=N.useState(null),[x,v]=N.useState(2),k=N.useMemo(()=>r?.tasks?dt(r.tasks):[],[r]),_=N.useMemo(()=>`sandbox_mock_cfg_${r?.name||"default"}`,[r?.name]);N.useEffect(()=>{if(!e||!r)return;const I=zt(r);let F=!1;try{const O=sessionStorage.getItem(_);if(O){const J=JSON.parse(O);J.inputJsonText?u(J.inputJsonText):u(JSON.stringify(I,null,2)),J.taskDrafts&&typeof J.taskDrafts=="object"&&f(J.taskDrafts),typeof J.maxLoopIterations=="number"&&v(J.maxLoopIterations),F=!0}}catch{}F||(u(JSON.stringify(I,null,2)),f({}),v(2)),p(null),b(null),k.length>0&&!m&&g(k[0].taskReferenceName)},[e,r,_]),N.useEffect(()=>{k.length>0&&!k.some(I=>I.taskReferenceName===m)&&g(k[0].taskReferenceName)},[k,m]);const S=N.useMemo(()=>{const I=[];for(const F of k)if(F.type==="SWITCH"||F.type==="DECISION"){const O=Object.keys(F.decisionCases||{});if(O.length===0)continue;const J=F.caseValueParam||"case_value",A=String(F.inputParameters?.[J]??F.expression??"").match(/\$\{\s*workflow\.input\.([a-zA-Z0-9_]+)\s*\}/);I.push({switchRef:F.taskReferenceName,switchName:F.name||F.taskReferenceName,inputField:A?A[1]:null,cases:O})}return I},[k]);if(!e||!r||typeof document>"u")return null;const j=k.find(I=>I.taskReferenceName===m)||k[0]||null,R=j&&h[j.taskReferenceName]||Cm,L=I=>{if(!j)return;const F=j.taskReferenceName,J={...h[F]||{...Cm,outputJsonText:JSON.stringify(yr(j),null,2)},...I,enabled:I.enabled!==void 0?I.enabled:!0};f(Z=>({...Z,[F]:J})),b(null)},T=Object.values(h).filter(I=>I.enabled).length,w=(I,F)=>{try{const O=JSON.parse(c||"{}");O[I]=F,u(JSON.stringify(O,null,2)),p(null)}catch{p("请先修复当前 JSON 语法错误后再点击快捷赋值")}},D=()=>{let I={};try{if(I=c.trim()?JSON.parse(c):{},typeof I!="object"||Array.isArray(I)||I===null){p("workflow.input 必须是一个 JSON 对象 {...}"),l("input");return}}catch(O){p(`JSON 语法错误: ${O?.message||"格式不合法"}`),l("input");return}const F={};for(const[O,J]of Object.entries(h)){if(!J.enabled)continue;let Z;if(J.outputJsonText.trim())try{Z=JSON.parse(J.outputJsonText)}catch(B){g(O),l("tasks"),b(`节点 [${O}] 的自定义输出 JSON 语法有误: ${B?.message||""}`);return}const A=J.durationMs.trim()!==""&&!Number.isNaN(Number(J.durationMs))?Number(J.durationMs):void 0;F[O]={__isMockOverride:!0,status:J.status,durationMs:A,forceCase:J.forceCase||void 0,reasonForIncompletion:J.reasonForIncompletion.trim()||void 0,outputData:Z}}try{sessionStorage.setItem(_,JSON.stringify({inputJsonText:c,taskDrafts:h,maxLoopIterations:x}))}catch{}s(I,F,x),t()},E=o?"#ffffff":"#0f172a",C=o?"#f8fafc":"#1e293b",z=o?"#f1f5f9":"#020617",W=o?"#0f172a":"#f8fafc",K=o?"#64748b":"#94a3b8",M=o?"rgba(148, 163, 184, 0.3)":"rgba(148, 163, 184, 0.18)";return Ye.createPortal(a.jsx("div",{style:{position:"fixed",inset:0,zIndex:9500,background:"rgba(2, 6, 23, 0.65)",backdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",padding:20},onClick:t,children:a.jsxs("div",{style:{width:"min(920px, 96vw)",height:"min(660px, 90vh)",background:E,color:W,borderRadius:14,border:`1px solid ${M}`,boxShadow:"0 24px 64px rgba(0, 0, 0, 0.5)",display:"flex",flexDirection:"column",overflow:"hidden"},onClick:I=>I.stopPropagation(),children:[a.jsxs("div",{style:{padding:"16px 20px",borderBottom:`1px solid ${M}`,display:"flex",alignItems:"center",justifyContent:"space-between",background:C},children:[a.jsxs("div",{children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:15,fontWeight:700},children:[a.jsx("span",{children:"🧪 本地沙箱试运行 · 人工模拟数据控制台"}),a.jsx("span",{style:{fontSize:11,padding:"2px 8px",borderRadius:999,background:"rgba(16, 185, 129, 0.14)",color:"#10b981",fontWeight:600},children:"0ms 确定性求值"})]}),a.jsxs("div",{style:{fontSize:12,color:K,marginTop:4},children:["自定义工作流启动入参 (",a.jsx("code",{children:"workflow.input"}),")、指定任意节点的 Mock 输出、模拟节点异常中断或强制切换 ",a.jsx("code",{children:"SWITCH"})," 分支走向"]})]}),a.jsx("button",{type:"button",onClick:t,style:{background:"none",border:"none",color:K,fontSize:18,cursor:"pointer",padding:"4px 8px"},children:"✕"})]}),a.jsx("div",{style:{display:"flex",gap:8,padding:"10px 20px",borderBottom:`1px solid ${M}`,background:E},children:[{id:"input",label:"📥 1. 工作流启动入参 (workflow.input)"},{id:"tasks",label:`🎯 2. 节点级人工 Mock & 故障注入 ${T>0?`(${T} 个已启用)`:""}`},{id:"engine",label:`⚙️ 3. 循环轮次与引擎参数 (${x} 轮)`}].map(I=>{const F=i===I.id;return a.jsx("button",{type:"button",onClick:()=>l(I.id),style:{padding:"7px 14px",borderRadius:8,border:F?"1px solid #3b82f6":`1px solid ${M}`,background:F?"rgba(59, 130, 246, 0.14)":"transparent",color:F?"#3b82f6":K,fontSize:12,fontWeight:F?700:500,cursor:"pointer"},children:I.label},I.id)})}),a.jsxs("div",{style:{flex:1,minHeight:0,display:"flex",overflow:"hidden"},children:[i==="input"&&a.jsxs("div",{style:{flex:1,padding:20,display:"flex",flexDirection:"column",gap:12,overflowY:"auto"},children:[S.length>0&&a.jsxs("div",{style:{padding:"10px 14px",borderRadius:10,background:"rgba(59, 130, 246, 0.08)",border:"1px solid rgba(59, 130, 246, 0.25)",display:"flex",flexDirection:"column",gap:8},children:[a.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#38bdf8"},children:"🧭 条件分支 (SWITCH) 快速路由切换器"}),S.map(I=>a.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:6,fontSize:12},children:[a.jsxs("span",{style:{color:K},children:["节点 ",a.jsx("b",{children:I.switchName})," (",a.jsx("code",{children:I.switchRef}),")",I.inputField?` 绑定入参字段 "${I.inputField}" — 点击一键切换分支:`:" 可选分支 (可在 Tab 2 强制指定):"]}),I.cases.map(F=>a.jsx("button",{type:"button",onClick:()=>{I.inputField?w(I.inputField,F):(g(I.switchRef),l("tasks"))},style:{padding:"2px 9px",borderRadius:999,border:"1px solid rgba(56, 189, 248, 0.45)",background:"rgba(56, 189, 248, 0.14)",color:"#38bdf8",fontSize:11,fontFamily:"monospace",fontWeight:600,cursor:"pointer"},children:I.inputField?`${I.inputField} = "${F}"`:`走分支: ${F}`},F))]},I.switchRef))]}),a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[a.jsxs("span",{style:{fontSize:12,fontWeight:600,color:K},children:["编辑 ",a.jsx("code",{children:"workflow.input"})," JSON(所有节点的 ",a.jsx("code",{children:"${workflow.input.*}"})," 将实时读取此处的值):"]}),a.jsx("button",{type:"button",onClick:()=>{const I=zt(r);u(JSON.stringify(I,null,2)),p(null)},style:{fontSize:11,padding:"4px 10px",borderRadius:6,border:`1px solid ${M}`,background:C,color:K,cursor:"pointer"},children:"↺ 重置为默认推导值"})]}),d&&a.jsxs("div",{style:{padding:"8px 12px",borderRadius:8,background:"rgba(239, 68, 68, 0.14)",border:"1px solid rgba(239, 68, 68, 0.4)",color:"#f87171",fontSize:12},children:["⚠️ ",d]}),a.jsx("textarea",{value:c,onChange:I=>{u(I.target.value),p(null)},spellCheck:!1,style:{flex:1,minHeight:240,width:"100%",boxSizing:"border-box",padding:14,borderRadius:10,border:`1px solid ${d?"#ef4444":M}`,background:z,color:W,fontFamily:"monospace",fontSize:13,lineHeight:1.55,resize:"none",outline:"none"}})]}),i==="tasks"&&a.jsxs("div",{style:{flex:1,display:"grid",gridTemplateColumns:"260px 1fr",minHeight:0},children:[a.jsxs("div",{style:{borderRight:`1px solid ${M}`,overflowY:"auto",padding:"10px 8px",background:C,display:"flex",flexDirection:"column",gap:4},children:[a.jsxs("div",{style:{fontSize:11,fontWeight:700,color:K,padding:"4px 8px 8px",textTransform:"uppercase"},children:["选择要定制 Mock 的节点 (",k.length,")"]}),k.map(I=>{const F=I.taskReferenceName,O=j?.taskReferenceName===F,J=h[F],Z=!!J?.enabled;return a.jsxs("div",{onClick:()=>{g(F),b(null)},style:{padding:"8px 10px",borderRadius:8,cursor:"pointer",background:O?"rgba(59, 130, 246, 0.16)":"transparent",border:O?"1px solid rgba(59, 130, 246, 0.45)":"1px solid transparent",display:"flex",alignItems:"center",justifyContent:"space-between",gap:6},children:[a.jsxs("div",{style:{minWidth:0},children:[a.jsx("div",{style:{fontSize:12,fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:I.name||F}),a.jsxs("div",{style:{fontSize:10,color:K,fontFamily:"monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[F," · ",I.type]})]}),Z&&a.jsx("span",{style:{fontSize:10,padding:"2px 6px",borderRadius:999,background:J.status==="FAILED"||J.status==="TIMED_OUT"?"rgba(239, 68, 68, 0.2)":"rgba(16, 185, 129, 0.2)",color:J.status==="FAILED"||J.status==="TIMED_OUT"?"#f87171":"#34d399",fontWeight:700,flexShrink:0},children:J.status==="COMPLETED"?"已定制":J.status})]},F)})]}),j?a.jsxs("div",{style:{padding:18,overflowY:"auto",display:"flex",flexDirection:"column",gap:14},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingBottom:10,borderBottom:`1px solid ${M}`},children:[a.jsxs("div",{children:[a.jsxs("div",{style:{fontSize:14,fontWeight:700},children:[j.name||j.taskReferenceName," ",a.jsxs("code",{style:{fontSize:12,color:"#38bdf8",fontWeight:500},children:["(",j.taskReferenceName,")"]})]}),a.jsxs("div",{style:{fontSize:11,color:K,marginTop:2},children:["节点类型: ",a.jsx("b",{children:j.type})]})]}),a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12,fontWeight:700,cursor:"pointer",padding:"6px 12px",borderRadius:8,background:R.enabled?"rgba(16, 185, 129, 0.14)":C,border:`1px solid ${R.enabled?"#10b981":M}`,color:R.enabled?"#10b981":K},children:[a.jsx("input",{type:"checkbox",checked:R.enabled,onChange:I=>L({enabled:I.target.checked})}),"启用该节点人工 Mock"]})]}),a.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 200px",gap:12},children:[a.jsxs("div",{children:[a.jsx("label",{style:{display:"block",fontSize:11,fontWeight:600,color:K,marginBottom:6},children:"模拟执行状态 (可注入异常以测试断路与错误诊断)"}),a.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[{id:"COMPLETED",label:"✅ 正常成功"},{id:"FAILED",label:"❌ 失败中断 (FAILED)"},{id:"TIMED_OUT",label:"⏱️ 超时中断 (TIMED_OUT)"},{id:"COMPLETED_WITH_ERRORS",label:"⚠️ 带错完成"}].map(I=>{const F=R.status===I.id;return a.jsx("button",{type:"button",onClick:()=>L({status:I.id}),style:{padding:"5px 10px",borderRadius:6,fontSize:11,fontWeight:F?700:500,cursor:"pointer",border:F?"1px solid #38bdf8":`1px solid ${M}`,background:F?"rgba(56, 189, 248, 0.16)":C,color:F?"#38bdf8":W},children:I.label},I.id)})})]}),a.jsxs("div",{children:[a.jsx("label",{style:{display:"block",fontSize:11,fontWeight:600,color:K,marginBottom:6},children:"模拟耗时 (ms,可制造并发瓶颈)"}),a.jsx("input",{type:"number",min:0,placeholder:"默认自动耗时 (如 120)",value:R.durationMs,onChange:I=>L({durationMs:I.target.value}),style:{width:"100%",boxSizing:"border-box",padding:"6px 10px",borderRadius:6,border:`1px solid ${M}`,background:z,color:W,fontSize:12}})]})]}),(R.status==="FAILED"||R.status==="TIMED_OUT")&&a.jsxs("div",{children:[a.jsx("label",{style:{display:"block",fontSize:11,fontWeight:600,color:"#f87171",marginBottom:6},children:"模拟异常原因 (reasonForIncompletion)"}),a.jsx("input",{type:"text",placeholder:"例如: Connection refused to upstream payment gateway (502)",value:R.reasonForIncompletion,onChange:I=>L({reasonForIncompletion:I.target.value}),style:{width:"100%",boxSizing:"border-box",padding:"7px 10px",borderRadius:6,border:"1px solid rgba(239, 68, 68, 0.45)",background:z,color:W,fontSize:12}})]}),(j.type==="SWITCH"||j.type==="DECISION")&&a.jsxs("div",{style:{padding:"10px 12px",borderRadius:8,background:"rgba(245, 158, 11, 0.1)",border:"1px solid rgba(245, 158, 11, 0.35)"},children:[a.jsx("label",{style:{display:"block",fontSize:11,fontWeight:700,color:"#fbbf24",marginBottom:6},children:"🔀 强制指定 SWITCH 路由分支 (无视入参表达式直接走指定分支)"}),a.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[a.jsx("button",{type:"button",onClick:()=>L({forceCase:""}),style:{padding:"4px 10px",borderRadius:6,fontSize:11,cursor:"pointer",border:R.forceCase?`1px solid ${M}`:"1px solid #fbbf24",background:R.forceCase?C:"rgba(245, 158, 11, 0.2)",color:R.forceCase?K:"#fbbf24",fontWeight:R.forceCase?500:700},children:"🔄 根据入参自动求值"}),Object.keys(j.decisionCases||{}).map(I=>{const F=R.forceCase===I;return a.jsxs("button",{type:"button",onClick:()=>L({forceCase:I}),style:{padding:"4px 10px",borderRadius:6,fontSize:11,fontFamily:"monospace",cursor:"pointer",border:F?"1px solid #fbbf24":`1px solid ${M}`,background:F?"rgba(245, 158, 11, 0.22)":C,color:F?"#fbbf24":W,fontWeight:F?700:500},children:["分支: ",I]},I)}),j.defaultCase&&a.jsx("button",{type:"button",onClick:()=>L({forceCase:"__default__"}),style:{padding:"4px 10px",borderRadius:6,fontSize:11,fontFamily:"monospace",cursor:"pointer",border:R.forceCase==="__default__"?"1px solid #fbbf24":`1px solid ${M}`,background:R.forceCase==="__default__"?"rgba(245, 158, 11, 0.22)":C,color:R.forceCase==="__default__"?"#fbbf24":W},children:"默认分支 (defaultCase)"})]})]}),a.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:6},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[a.jsxs("label",{style:{fontSize:11,fontWeight:600,color:K},children:["自定义节点输出数据 (",a.jsx("code",{children:`\${${j.taskReferenceName}.output.*}`})," 将读取此 JSON):"]}),a.jsx("button",{type:"button",onClick:()=>{const I=yr(j);L({outputJsonText:JSON.stringify(I,null,2)})},style:{fontSize:11,padding:"3px 9px",borderRadius:6,border:`1px solid ${M}`,background:C,color:"#38bdf8",cursor:"pointer",fontWeight:600},children:"📋 填入默认合成输出模板"})]}),y&&a.jsxs("div",{style:{padding:"6px 10px",borderRadius:6,background:"rgba(239, 68, 68, 0.14)",border:"1px solid rgba(239, 68, 68, 0.4)",color:"#f87171",fontSize:11},children:["⚠️ ",y]}),a.jsx("textarea",{value:R.outputJsonText,placeholder:`留空则自动按 ${j.type} 类型合成输出,或点击右上角「填入默认合成输出模板」进行修改...`,onChange:I=>L({outputJsonText:I.target.value}),spellCheck:!1,style:{flex:1,minHeight:160,width:"100%",boxSizing:"border-box",padding:12,borderRadius:8,border:`1px solid ${y?"#ef4444":M}`,background:z,color:W,fontFamily:"monospace",fontSize:12,lineHeight:1.5,resize:"vertical",outline:"none"}})]})]}):a.jsx("div",{style:{padding:32,color:K},children:"当前工作流暂无任务节点"})]}),i==="engine"&&a.jsx("div",{style:{flex:1,padding:24,display:"flex",flexDirection:"column",gap:18},children:a.jsxs("div",{style:{padding:16,borderRadius:10,border:`1px solid ${M}`,background:C,display:"flex",flexDirection:"column",gap:10},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[a.jsxs("div",{children:[a.jsx("div",{style:{fontSize:13,fontWeight:700},children:"🔄 DO_WHILE 循环容器最大模拟迭代轮次"}),a.jsxs("div",{style:{fontSize:12,color:K,marginTop:2},children:["控制沙箱遇到 ",a.jsx("code",{children:"DO_WHILE"})," 节点时自动展开执行的循环轮次数(可在画布循环容器头部切换查看每一轮的子任务状态)"]})]}),a.jsxs("span",{style:{fontSize:16,fontWeight:800,color:"#38bdf8",fontFamily:"monospace"},children:[x," 轮"]})]}),a.jsx("input",{type:"range",min:1,max:8,value:x,onChange:I=>v(Number(I.target.value)),style:{width:"100%",accentColor:"#38bdf8",cursor:"pointer"}}),a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:11,color:K},children:[a.jsx("span",{children:"1 轮 (单次验证)"}),a.jsx("span",{children:"2 轮 (默认推荐)"}),a.jsx("span",{children:"5 轮"}),a.jsx("span",{children:"8 轮 (压测多轮轨迹)"})]})]})})]}),a.jsxs("div",{style:{padding:"12px 20px",borderTop:`1px solid ${M}`,background:C,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[a.jsx("button",{type:"button",onClick:()=>{f({});const I=zt(r);u(JSON.stringify(I,null,2)),v(2),sessionStorage.removeItem(_)},style:{padding:"7px 12px",borderRadius:8,border:`1px solid ${M}`,background:"transparent",color:K,fontSize:12,cursor:"pointer"},children:"🧹 清空全部人工 Mock 配置"}),a.jsxs("div",{style:{display:"flex",gap:10},children:[a.jsx("button",{type:"button",onClick:t,style:{padding:"8px 16px",borderRadius:8,border:`1px solid ${M}`,background:"transparent",color:W,fontSize:12,fontWeight:600,cursor:"pointer"},children:"取消"}),a.jsx("button",{type:"button",onClick:D,style:{padding:"8px 20px",borderRadius:8,border:"none",background:"linear-gradient(135deg, #2563eb, #0284c7)",color:"#ffffff",fontSize:12,fontWeight:700,cursor:"pointer",boxShadow:"0 4px 14px rgba(37, 99, 235, 0.35)"},children:"⚡ 应用模拟数据并启动沙箱试运行"})]})]})]})}),document.body)},kl=()=>a.jsx("div",{style:{width:"1px",height:"18px",background:"var(--border-primary)",margin:"0 2px",alignSelf:"center",flexShrink:0}}),Yv=({onShowHealthCheck:e,showHealthCheck:t,onShowSettings:r,executionActions:n})=>{const{mode:s,setMode:o,validationResults:i,workflowInstance:l,workflowDef:c,showDataLineage:u,setShowDataLineage:d,showWaterfallPanel:p,setShowWaterfallPanel:h,runLocalSandboxDryRun:f,inlineCopilotTaskRef:m,setInlineCopilotTaskRef:g,selectedTask:y}=le(),b=le.temporal,{undo:x,redo:v,pastStates:k,futureStates:_}=wr(b,F=>F),[S,j]=N.useState(!1),[R,L]=N.useState(!1),T=N.useRef(null);N.useEffect(()=>{if(!S)return;const F=O=>{T.current&&!T.current.contains(O.target)&&j(!1)};return document.addEventListener("mousedown",F),()=>document.removeEventListener("mousedown",F)},[S]);const w=(i?.errors?.length||0)>0,D=l?.status,E=l?.workflowId??"",C=D==="RUNNING",z=D==="PAUSED",W=D==="FAILED"||D==="TIMED_OUT"||D==="TERMINATED",K=D==="COMPLETED",M=c?.restartable===!0&&(W||K),I=n?.allowOperations!==!1;return a.jsxs("div",{className:"action-bar",style:{display:"flex",gap:"6px",alignItems:"center",flexWrap:"wrap",padding:"5px 8px",borderRadius:"10px",background:"var(--bg-secondary)",backdropFilter:"blur(14px)",border:"1px solid var(--border-primary)",boxShadow:"0 6px 24px rgba(0, 0, 0, 0.18)"},children:[c&&a.jsxs(a.Fragment,{children:[a.jsx(Re,{icon:"🔗",label:"数据血缘",title:"W-LSP 数据流血缘图谱 (Data Flow Graph)",onClick:()=>d(!u),active:u}),s==="edit"&&a.jsx(Re,{icon:"⌘K",label:"AI微调",title:"画布内联 AI 指令栏 (Cmd+K)",onClick:()=>g(m?null:y?.taskReferenceName||"__canvas_root__"),active:!!m})]}),s==="edit"&&a.jsxs(a.Fragment,{children:[a.jsx(kl,{}),a.jsxs("div",{style:{display:"inline-flex",gap:"3px",alignItems:"center"},children:[a.jsx(Re,{icon:"↺",title:"撤销 (Cmd+Z)",onClick:()=>x(),disabled:k.length===0}),a.jsx(Re,{icon:"↻",title:"重做 (Cmd+Shift+Z)",onClick:()=>v(),disabled:_.length===0})]}),a.jsx(Re,{icon:"🩺",label:w?`错误 (${i.errors.length})`:"诊断",title:"流程健康检查",onClick:e,active:t,variant:w?"danger":"secondary"}),a.jsx(Re,{icon:"⚙️",label:"配置",title:"工作流全局配置",onClick:()=>r?.()})]}),c&&s!=="run"&&a.jsxs(a.Fragment,{children:[a.jsx(kl,{}),a.jsxs("div",{style:{display:"inline-flex",alignItems:"center"},children:[a.jsx(Re,{icon:"⚡",label:"沙箱试运行",title:"一键启动浏览器本地确定性沙箱试运行 (0ms Dry-Run)",onClick:()=>f(),variant:"primary",style:{borderRadius:"7px 0 0 7px",borderRight:"1px solid rgba(255, 255, 255, 0.25)"}}),a.jsx(Re,{icon:"🧪",title:"人工模拟数据配置台 (自定义 workflow.input / 节点 Mock 输出 / 故障注入 / 分支路由)",onClick:()=>L(!0),variant:"primary",style:{borderRadius:"0 7px 7px 0",padding:"4px 7px",minWidth:"26px"}})]})]}),s==="run"&&a.jsxs(a.Fragment,{children:[a.jsx(kl,{}),a.jsx(Re,{icon:"🧪",label:"模拟数据重跑",title:"打开沙箱人工模拟数据配置台,调整入参、分支或注入节点故障后重跑",onClick:()=>L(!0)}),a.jsx(Re,{icon:"📊",label:"瀑布流回放",title:"并发甘特瀑布流与时间旅行调试器 (Time-Travel)",onClick:()=>h(!p),active:p}),a.jsx(Re,{icon:"✏️",label:"返回编辑",title:"退出试跑/运行态视图,返回工作流编排画布",onClick:()=>o("edit")})]}),a.jsx(Gv,{isOpen:R,onClose:()=>L(!1)}),s==="run"&&l&&n&&a.jsxs(a.Fragment,{children:[z&&n.onResume&&a.jsx(Re,{icon:a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:a.jsx("path",{d:"M4 3l9 5-9 5z"})}),label:"继续",title:I?"继续执行工作流":"操作权限受限",onClick:()=>I&&n.onResume(E),disabled:!I,variant:"primary"}),C&&n.onPause&&a.jsx(Re,{icon:a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:[a.jsx("rect",{x:"4",y:"3",width:"3",height:"10",rx:"1"}),a.jsx("rect",{x:"9",y:"3",width:"3",height:"10",rx:"1"})]}),label:"暂停",title:I?"暂停工作流执行":"操作权限受限",onClick:()=>I&&n.onPause(E),disabled:!I}),(C||z)&&n.onTerminate&&a.jsx(Re,{icon:a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:a.jsx("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"})}),label:"终止",title:I?"终止工作流执行":"操作权限受限",onClick:()=>I&&n.onTerminate(E),disabled:!I,variant:"danger"}),W&&n.onRetry&&a.jsx(Re,{icon:a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[a.jsx("path",{d:"M13 2v4h-4"}),a.jsx("path",{d:"M13 6A7 7 0 1 1 9.5 2.5"})]}),label:"重试",title:I?"重试失败的工作流":"操作权限受限",onClick:()=>I&&n.onRetry(E),disabled:!I,variant:"primary"}),M&&n.onRestart&&a.jsxs("div",{ref:T,style:{position:"relative",display:"flex"},children:[a.jsxs("button",{disabled:!I,onClick:()=>I&&n.onRestart(E,{useLatestDef:!0}),title:I?"使用当前最新定义版本重新运行":"操作权限受限",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:I?"pointer":"not-allowed",opacity:I?1:.5,fontSize:"13px",fontWeight:500,height:"32px"},children:[a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[a.jsx("path",{d:"M3 14v-4h4"}),a.jsx("path",{d:"M3 10A7 7 0 1 1 6.5 13.5"})]}),"重启"]}),a.jsx("button",{disabled:!I,onClick:()=>I&&j(F=>!F),title:I?"展开重启版本选项":"操作权限受限",style:{display:"flex",alignItems:"center",justifyContent:"center",background:I&&S?"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:I?"pointer":"not-allowed",opacity:I?1:.5,height:"32px",width:"22px",fontSize:"10px"},children:a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",children:a.jsx("path",{d:"M1 3l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",fill:"none"})})}),S&&a.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:[a.jsx("div",{style:{padding:"6px 12px 4px",fontSize:"11px",color:"var(--text-secondary)",fontWeight:600,letterSpacing:"0.5px",textTransform:"uppercase"},children:"选择版本"}),a.jsxs("button",{onClick:()=>{n.onRestart(E,{useLatestDef:!0}),j(!1)},style:Nm,onMouseEnter:F=>F.currentTarget.style.background="var(--bg-secondary)",onMouseLeave:F=>F.currentTarget.style.background="transparent",children:[a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[a.jsx("circle",{cx:"8",cy:"8",r:"6"}),a.jsx("path",{d:"M8 5v3l2 1"})]}),a.jsxs("div",{children:[a.jsx("div",{style:{fontWeight:600,fontSize:"13px"},children:"当前版本"}),a.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:"使用最新工作流定义"})]})]}),a.jsxs("button",{onClick:()=>{n.onRestart(E,{useLatestDef:!1}),j(!1)},style:Nm,onMouseEnter:F=>F.currentTarget.style.background="var(--bg-secondary)",onMouseLeave:F=>F.currentTarget.style.background="transparent",children:[a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[a.jsx("rect",{x:"3",y:"2",width:"10",height:"12",rx:"1"}),a.jsx("path",{d:"M6 6h4M6 9h3"})]}),a.jsxs("div",{children:[a.jsx("div",{style:{fontWeight:600,fontSize:"13px"},children:"执行版本"}),a.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:"使用本次运行时的定义"})]})]})]})]})]})]})},Nm={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"},Xv=[{id:"basic",label:"基本信息"},{id:"timeout",label:"超时与容错"},{id:"params",label:"参数配置"},{id:"advanced",label:"高级设置"}],Zv=({isOpen:e,onClose:t})=>{const{workflowDef:r,updateWorkflowProperties:n,mode:s}=le(),[o,i]=N.useState(r),[l,c]=N.useState("basic"),u=s!=="edit";N.useEffect(()=>{r&&i(r)},[r,e]);const d=N.useCallback(E=>{E.key==="Escape"&&t()},[t]);if(N.useEffect(()=>{if(e)return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[e,d]),!e||!o)return null;const p="var(--text-primary)",h="var(--glass-border)",f="var(--bg-tertiary)",m="var(--text-secondary)",g=(E,C)=>{if(!o||u)return;const z={...o,[E]:C};i(z),n({[E]:C})},y=(E,C,z)=>{if(!o||u)return;const K={...o[E]||{},[C]:z};i(M=>({...M,[E]:K})),n({[E]:K})},b=(E,C)=>{if(!(!o||u))try{const z=JSON.parse(C),W={...o,[E]:z};i(W),n({[E]:z})}catch{i(z=>({...z,[`_${E}_str`]:C}))}},x={width:"100%",padding:"10px 14px",borderRadius:"8px",border:`1px solid ${h}`,background:f,color:p,fontSize:"14px",outline:"none",boxSizing:"border-box"},v={display:"block",fontSize:"11px",color:m,marginBottom:"8px",fontWeight:600},k=(E,C,z="text",W)=>a.jsxs("div",{style:{marginBottom:"20px"},children:[a.jsx("label",{style:v,children:E.toUpperCase()}),a.jsx("input",{className:"wsp-input",type:z,value:o?.[C]??"",onChange:K=>g(C,z==="number"?K.target.value===""?0:parseInt(K.target.value):K.target.value),disabled:u||W?.readOnly,placeholder:W?.placeholder,style:{...x,opacity:u||W?.readOnly?.6:1}})]}),_=(E,C,z=!1,W=6)=>{const K=o?.[`_${C}_str`]!==void 0?o[`_${C}_str`]:typeof o?.[C]=="object"?JSON.stringify(o[C],null,2):o?.[C];return a.jsxs("div",{style:{marginBottom:"20px"},children:[a.jsxs("label",{style:v,children:[E.toUpperCase()," ",z&&"(JSON)"]}),a.jsx("textarea",{className:"wsp-input",value:K||"",onChange:M=>z?b(C,M.target.value):g(C,M.target.value),rows:W,disabled:u,style:{...x,fontSize:"13px",fontFamily:z?"var(--font-mono)":"inherit",resize:"vertical",opacity:u?.6:1}})]})},S=(E,C,z)=>a.jsxs("div",{style:{marginBottom:"20px"},children:[a.jsx("label",{style:v,children:E.toUpperCase()}),a.jsx("select",{className:"wsp-input",value:o?.[C]??z[0]?.value,onChange:W=>g(C,W.target.value),disabled:u,style:{...x,opacity:u?.6:1,cursor:u?"not-allowed":"pointer"},children:z.map(W=>a.jsx("option",{value:W.value,children:W.label},W.value))})]}),j=(E,C)=>{const z=!!o?.[C];return a.jsxs("div",{style:{marginBottom:"20px",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[a.jsx("label",{style:{fontSize:"13px",color:p},children:E}),a.jsx("button",{type:"button",role:"switch","aria-checked":z,onClick:()=>!u&&g(C,!z),disabled:u,style:{width:"44px",height:"24px",borderRadius:"12px",border:"none",background:z?"var(--color-accent)":"var(--border-primary)",position:"relative",cursor:u?"not-allowed":"pointer",transition:"background 0.2s",opacity:u?.6:1,flexShrink:0},children:a.jsx("span",{style:{position:"absolute",top:"2px",left:z?"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)"}})})]})},R=()=>a.jsxs(a.Fragment,{children:[a.jsxs("div",{style:{display:"grid",gridTemplateColumns:"3fr 1fr",gap:"20px"},children:[k("工作流名称","name"),k("版本号","version","number")]}),_("描述信息","description",!1,3),k("负责人邮箱","ownerEmail","text",{placeholder:"owner@example.com"}),k("Schema 版本","schemaVersion","number",{readOnly:!0})]}),L=()=>a.jsxs(a.Fragment,{children:[S("超时策略","timeoutPolicy",[{value:"ALERT_ONLY",label:"ALERT_ONLY — 仅告警"},{value:"TIME_OUT_WF",label:"TIME_OUT_WF — 超时终止"}]),a.jsxs("div",{children:[k("超时秒数","timeoutSeconds","number",{placeholder:"0 表示不超时"}),o?.timeoutPolicy==="ALERT_ONLY"&&a.jsx("p",{style:{fontSize:"11px",color:m,marginTop:"-12px",marginBottom:"20px"},children:"当前策略为 ALERT_ONLY,超时仅触发告警,不会终止工作流。"})]}),k("失败补偿工作流","failureWorkflow","text",{placeholder:"输入补偿工作流名称"}),j("允许重启 (restartable)","restartable")]}),T=()=>{const E=qt(o?.inputParameters),C=I=>{u||g("inputParameters",I)},z=()=>{const I=[...E,{name:`param_${E.length+1}`,type:"string",required:!1}];C(I)},W=I=>{const F=E.filter((O,J)=>J!==I);C(F)},K=(I,F,O)=>{const J=E.map((Z,A)=>A===I?{...Z,[F]:O}:Z);C(J)},M={padding:"6px 10px",borderRadius:"6px",border:`1px solid ${h}`,background:f,color:p,fontSize:"12px",outline:"none",fontFamily:"inherit"};return a.jsxs(a.Fragment,{children:[a.jsxs("div",{style:{marginBottom:"20px"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},children:[a.jsx("label",{style:v,children:"入参声明 (INPUT PARAMETERS)"}),!u&&a.jsx("button",{onClick:z,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:"+ 添加参数"})]}),E.length===0?a.jsx("p",{style:{fontSize:"12px",color:m,margin:0,padding:"12px",background:"var(--bg-secondary)",borderRadius:"8px",border:`1px solid ${h}`},children:'暂无入参声明。点击"+ 添加参数"来定义工作流的输入参数,这些参数将在执行验证时作为表单字段展示。'}):a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:E.map((I,F)=>a.jsxs("div",{style:{background:"var(--bg-secondary)",border:`1px solid ${h}`,borderRadius:"10px",padding:"12px"},children:[a.jsxs("div",{style:{display:"grid",gridTemplateColumns:"2fr 1fr auto auto",gap:"8px",alignItems:"center"},children:[a.jsx("input",{style:M,placeholder:"参数名",value:I.name,onChange:O=>K(F,"name",O.target.value),disabled:u}),a.jsx("select",{style:{...M,cursor:u?"not-allowed":"pointer"},value:I.type??"string",onChange:O=>K(F,"type",O.target.value),disabled:u,children:["string","number","boolean","object","array"].map(O=>a.jsx("option",{value:O,children:O},O))}),a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"4px",fontSize:"12px",color:m,cursor:u?"not-allowed":"pointer",whiteSpace:"nowrap"},children:[a.jsx("input",{type:"checkbox",checked:!!I.required,onChange:O=>K(F,"required",O.target.checked),disabled:u,style:{accentColor:"var(--color-accent)"}}),"必填"]}),!u&&a.jsx("button",{onClick:()=>W(F),style:{background:"none",border:"none",color:"var(--status-failed)",cursor:"pointer",fontSize:"16px",padding:"0 4px",opacity:.7,lineHeight:1},children:"✕"})]}),a.jsxs("div",{style:{marginTop:"8px",display:"flex",flexDirection:"column",gap:"6px"},children:[a.jsx("input",{style:M,placeholder:"说明(可选)",value:I.description??"",onChange:O=>K(F,"description",O.target.value),disabled:u}),a.jsx("input",{style:M,placeholder:`示例值(如 ${I.type==="number"?"42":I.type==="boolean"?"true":'"value"'})`,value:I.example!==void 0?typeof I.example=="object"?JSON.stringify(I.example):String(I.example):"",onChange:O=>{let J=O.target.value;try{J=JSON.parse(O.target.value)}catch{}K(F,"example",J)},disabled:u})]})]},F))})]}),_("输出参数映射 (outputParameters)","outputParameters",!0),_("默认输入模板 (inputTemplate)","inputTemplate",!0),_("工作流级变量 (variables)","variables",!0)]})},w=()=>a.jsxs(a.Fragment,{children:[j("启用状态监听 (workflowStatusListenerEnabled)","workflowStatusListenerEnabled"),o?.workflowStatusListenerEnabled&&k("状态事件目标 (Listener Sink)","workflowStatusListenerSink","text",{placeholder:"conductor:workflow_status_event"}),a.jsxs("div",{style:{borderTop:`1px solid ${h}`,marginTop:"8px",paddingTop:"20px"},children:[j("强制 Schema 校验 (enforceSchema)","enforceSchema"),o?.enforceSchema&&a.jsxs(a.Fragment,{children:[_("输入 Schema (inputSchema)","inputSchema",!0,4),_("输出 Schema (outputSchema)","outputSchema",!0,4)]})]}),a.jsxs("div",{style:{borderTop:`1px solid ${h}`,marginTop:"8px",paddingTop:"20px"},children:[a.jsx("label",{style:{...v,marginBottom:"16px"},children:"并发限流 (RATE LIMIT)"}),a.jsxs("div",{style:{display:"grid",gridTemplateColumns:"2fr 1fr",gap:"20px"},children:[a.jsxs("div",{children:[a.jsx("label",{style:v,children:"RATE LIMIT KEY"}),a.jsx("input",{className:"wsp-input",type:"text",value:o?.rateLimitConfig?.rateLimitKey??"",onChange:E=>y("rateLimitConfig","rateLimitKey",E.target.value),disabled:u,placeholder:"限流键",style:{...x,opacity:u?.6:1}})]}),a.jsxs("div",{children:[a.jsx("label",{style:v,children:"并发上限"}),a.jsx("input",{className:"wsp-input",type:"number",value:o?.rateLimitConfig?.concurrentExecLimit??"",onChange:E=>y("rateLimitConfig","concurrentExecLimit",E.target.value===""?0:parseInt(E.target.value)),disabled:u,placeholder:"0",style:{...x,opacity:u?.6:1}})]})]})]})]}),D=()=>{switch(l){case"basic":return R();case"timeout":return L();case"params":return T();case"advanced":return w()}};return a.jsx("div",{role:"dialog","aria-modal":"true","aria-label":"工作流全局配置",onClick:t,style:{position:"fixed",left:0,top:0,width:"100vw",height:"100vh",backgroundColor:"rgba(0,0,0,0.5)",zIndex:1300,display:"flex",justifyContent:"center",alignItems:"center",backdropFilter:"blur(4px)",animation:"fadeIn 0.2s ease"},children:a.jsxs("div",{onClick:E=>E.stopPropagation(),style:{width:"680px",maxHeight:"85vh",background:"var(--glass-surface)",borderRadius:"16px",boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.5)",display:"flex",flexDirection:"column",overflow:"hidden",animation:"slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1)",border:`1px solid ${h}`,backdropFilter:"blur(20px)"},children:[a.jsxs("div",{style:{padding:"24px 32px 0 32px",background:"var(--bg-highlight)"},children:[a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px"},children:[a.jsxs("div",{children:[a.jsx("h2",{style:{margin:0,fontSize:"20px",color:p},children:"工作流全局配置"}),a.jsx("p",{style:{margin:"4px 0 0 0",fontSize:"12px",color:m},children:u?"当前为只读模式":"配置工作流级属性,所有更改将实时保存"})]}),a.jsx("button",{className:"wsp-close",onClick:t,"aria-label":"关闭",style:{background:"none",border:"none",color:p,fontSize:"24px",cursor:"pointer",opacity:.6},children:"✕"})]}),a.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${h}`},children:Xv.map(E=>a.jsx("button",{className:"wsp-tab",onClick:()=>c(E.id),style:{padding:"10px 20px",fontSize:"13px",fontWeight:l===E.id?600:400,color:l===E.id?"var(--color-accent)":m,background:"none",border:"none",borderBottom:l===E.id?"2px solid var(--color-accent)":"2px solid transparent",cursor:"pointer",transition:"all 0.2s",marginBottom:"-1px"},children:E.label},E.id))})]}),a.jsx("div",{style:{flex:1,overflowY:"auto",padding:"28px 32px"},children:D()}),a.jsx("div",{style:{padding:"20px 32px",borderTop:`1px solid ${h}`,background:"var(--bg-highlight)",display:"flex",justifyContent:"flex-end"},children:a.jsx("button",{className:"wsp-footer-btn",onClick:t,style:{padding:"12px 32px",background:"var(--color-accent)",color:"var(--text-inverse)",border:"none",borderRadius:"12px",fontWeight:"bold",cursor:"pointer",boxShadow:"0 4px 12px var(--color-accent-bg)"},children:"完成并关闭"})})]})})},Qv=({size:e=26,className:t,style:r})=>{const n=N.useId().replace(/:/g,"");return a.jsxs("svg",{width:e,height:e,viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,style:{flexShrink:0,display:"inline-block",verticalAlign:"middle",...r},"aria-label":"Conductor Workflow IDE Logo",children:[a.jsxs("defs",{children:[a.jsxs("linearGradient",{id:`bg-${n}`,x1:"0",y1:"0",x2:"32",y2:"32",gradientUnits:"userSpaceOnUse",children:[a.jsx("stop",{offset:"0%",stopColor:"#11172B"}),a.jsx("stop",{offset:"100%",stopColor:"#090D18"})]}),a.jsxs("linearGradient",{id:`bd-${n}`,x1:"0",y1:"0",x2:"32",y2:"32",gradientUnits:"userSpaceOnUse",children:[a.jsx("stop",{offset:"0%",stopColor:"#6366F1",stopOpacity:"0.8"}),a.jsx("stop",{offset:"100%",stopColor:"#06B6D4",stopOpacity:"0.5"})]}),a.jsxs("linearGradient",{id:`top-${n}`,x1:"9",y1:"16",x2:"23",y2:"10",gradientUnits:"userSpaceOnUse",children:[a.jsx("stop",{offset:"0%",stopColor:"#818CF8"}),a.jsx("stop",{offset:"100%",stopColor:"#22D3EE"})]}),a.jsxs("linearGradient",{id:`bot-${n}`,x1:"9",y1:"16",x2:"23",y2:"22",gradientUnits:"userSpaceOnUse",children:[a.jsx("stop",{offset:"0%",stopColor:"#6366F1"}),a.jsx("stop",{offset:"100%",stopColor:"#34D399"})]})]}),a.jsx("rect",{x:"1.25",y:"1.25",width:"29.5",height:"29.5",rx:"8",fill:`url(#bg-${n})`,stroke:`url(#bd-${n})`,strokeWidth:"1.5"}),a.jsx("path",{d:"M 9.5 16 C 15 16, 15.5 10, 22.5 10",stroke:`url(#top-${n})`,strokeWidth:"2.4",strokeLinecap:"round"}),a.jsx("path",{d:"M 9.5 16 C 15 16, 15.5 22, 22.5 22",stroke:`url(#bot-${n})`,strokeWidth:"2.4",strokeLinecap:"round"}),a.jsx("circle",{cx:"9.5",cy:"16",r:"3.4",fill:"#6366F1"}),a.jsx("circle",{cx:"9.5",cy:"16",r:"1.4",fill:"#F8FAFC"}),a.jsx("circle",{cx:"22.5",cy:"10",r:"2.7",fill:"#22D3EE"}),a.jsx("circle",{cx:"22.5",cy:"22",r:"2.7",fill:"#34D399"})]})},e1=({onRequestImport:e})=>{const{createBlankWorkflow:t}=le(),[r,n]=N.useState(""),s=()=>{t(r||void 0),le.temporal.getState().clear()},o=()=>{t(r||void 0),le.temporal.getState().clear(),window.dispatchEvent(new CustomEvent("open-ai-chat"))};return a.jsxs("div",{className:"empty-state-panel",children:[a.jsx("div",{style:{marginBottom:12},children:a.jsx(Qv,{size:46})}),a.jsx("h2",{className:"empty-state-title",children:"创建新工作流"}),a.jsx("p",{className:"empty-state-subtitle",children:"从空白画布开始设计,或让 AI 帮你生成完整流程"}),a.jsx("input",{className:"empty-state-name-input",type:"text",placeholder:"工作流名称(可选)",value:r,onChange:i=>n(i.target.value),onKeyDown:i=>{i.key==="Enter"&&s()}}),a.jsxs("div",{className:"empty-state-actions",children:[a.jsxs("button",{className:"empty-state-btn primary",onClick:s,children:[a.jsx("span",{className:"empty-state-btn-icon",children:"📄"}),"空白工作流"]}),a.jsxs("button",{className:"empty-state-btn",onClick:o,children:[a.jsx("span",{className:"empty-state-btn-icon",children:"✨"}),"AI 生成"]}),e&&a.jsxs("button",{className:"empty-state-btn",onClick:e,children:[a.jsx("span",{className:"empty-state-btn-icon",children:"📤"}),"导入 JSON"]})]})]})},t1={success:{bg:"#10b981",text:"#fff"},error:{bg:"#ef4444",text:"#fff"},info:{bg:"var(--color-accent)",text:"#fff"}},r1=({messages:e,onDismiss:t})=>e.length===0?null:a.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=>a.jsx(n1,{message:r,onDismiss:t},r.id))}),n1=({message:e,onDismiss:t})=>{const r=t1[e.type||"info"];return N.useEffect(()=>{const n=setTimeout(()=>t(e.id),2500);return()=>clearTimeout(n)},[e.id,t]),a.jsx("div",{role:"status","aria-live":"polite",style:{backgroundColor:r.bg,color:r.text,padding:"10px 20px",borderRadius:"8px",fontSize:"13px",fontWeight:500,boxShadow:"0 4px 16px rgba(0,0,0,0.2)",animation:"toastSlideUp 0.3s ease-out",pointerEvents:"auto",cursor:"pointer",whiteSpace:"nowrap"},onClick:()=>t(e.id),children:e.text})},Rm=["shift","alt","meta","mod","ctrl","control"],a1={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 nt(e){return(a1[e.trim()]||e.trim()).toLowerCase().replace(/key|digit|numpad/,"")}function Em(e){return Rm.includes(e)}function Sl(e,t=","){return e.toLowerCase().split(t)}function _l(e,t="+",r=">",n=!1,s){let o=[],i=!1;e=e.trim(),e.includes(r)?(i=!0,o=e.toLocaleLowerCase().split(r).map(u=>nt(u))):o=e.toLocaleLowerCase().split(t).map(u=>nt(u));const l={alt:o.includes("alt"),ctrl:o.includes("ctrl")||o.includes("control"),shift:o.includes("shift"),meta:o.includes("meta"),mod:o.includes("mod"),useKey:n},c=o.filter(u=>!Rm.includes(u));return{...l,keys:c,description:s,isSequence:i,hotkey:e}}typeof document<"u"&&(document.addEventListener("keydown",e=>{e.code!==void 0&&Pm([nt(e.code)])}),document.addEventListener("keyup",e=>{e.code!==void 0&&Om([nt(e.code)])})),typeof window<"u"&&(window.addEventListener("blur",()=>{Qe.clear()}),window.addEventListener("contextmenu",()=>{setTimeout(()=>{Qe.clear()},0)}));const Qe=new Set;function jl(e){return Array.isArray(e)}function s1(e,t=","){return(jl(e)?e:e.split(t)).every(r=>Qe.has(r.trim().toLowerCase()))}function Pm(e){const t=Array.isArray(e)?e:[e];Qe.has("meta")&&Qe.forEach(r=>!Em(r)&&Qe.delete(r.toLowerCase())),t.forEach(r=>Qe.add(r.toLowerCase()))}function Om(e){const t=Array.isArray(e)?e:[e];e==="meta"?Qe.clear():t.forEach(r=>Qe.delete(r.toLowerCase()))}function o1(e,t,r){(typeof r=="function"&&r(e,t)||r===!0)&&e.preventDefault()}function i1(e,t,r){return typeof r=="function"?r(e,t):r===!0||r===void 0}const l1=["input","textarea","select","searchbox","slider","spinbutton","menuitem","menuitemcheckbox","menuitemradio","option","radio","textbox"];function c1(e){return Dm(e,l1)}function Dm(e,t=!1){const{target:r,composed:n}=e;let s,o;return d1(r)&&n?(s=e.composedPath()[0]&&e.composedPath()[0].tagName,o=e.composedPath()[0]&&e.composedPath()[0].role):(s=r&&r.tagName,o=r&&r.role),jl(t)?!!(s&&t&&t.some(i=>i.toLowerCase()===s.toLowerCase()||i===o)):!!(s&&t&&t)}function d1(e){return!!e.tagName&&!e.tagName.startsWith("-")&&e.tagName.includes("-")}function u1(e,t){return e.length===0&&t?(console.warn('A hotkey has the "scopes" option set, however no active scopes were found. If you want to use the global scopes feature, you need to wrap your app in a <HotkeysProvider>'),!0):t?e.some(r=>t.includes(r))||e.includes("*"):!0}const p1=(e,t,r=!1)=>{const{alt:n,meta:s,mod:o,shift:i,ctrl:l,keys:c,useKey:u}=t,{code:d,key:p,ctrlKey:h,metaKey:f,shiftKey:m,altKey:g}=e,y=nt(d);if(u&&c?.length===1&&c.includes(p))return!0;if(!c?.includes(y)&&!["ctrl","control","unknown","meta","alt","shift","os"].includes(y))return!1;if(!r){if(n!==g&&y!=="alt"||i!==m&&y!=="shift")return!1;if(o){if(!f&&!h)return!1}else if(s!==f&&y!=="meta"&&y!=="os"||l!==h&&y!=="ctrl"&&y!=="control")return!1}return c&&c.length===1&&c.includes(y)?!0:c?s1(c):!c},f1=N.createContext(void 0),h1=()=>N.useContext(f1);function Am(e,t){return e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(e).length===Object.keys(t).length&&Object.keys(e).reduce((r,n)=>r&&Am(e[n],t[n]),!0):e===t}const m1=N.createContext({hotkeys:[],activeScopes:[],toggleScope:()=>{},enableScope:()=>{},disableScope:()=>{}}),g1=()=>N.useContext(m1);function y1(e){const t=N.useRef(void 0);return Am(t.current,e)||(t.current=e),t.current}const Lm=e=>{e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation()},x1=typeof window<"u"?N.useLayoutEffect:N.useEffect;function wt(e,t,r,n){const s=N.useRef(null),o=N.useRef(!1),i=Array.isArray(r)?Array.isArray(n)?void 0:n:r,l=jl(e)?e.join(i?.delimiter):e,c=Array.isArray(r)?r:Array.isArray(n)?n:void 0,u=N.useCallback(t,c??[]),d=N.useRef(u);c?d.current=u:d.current=t;const p=y1(i),{activeScopes:h}=g1(),f=h1();return x1(()=>{if(p?.enabled===!1||!u1(h,p?.scopes))return;let m=[],g;const y=(k,_=!1)=>{if(!(c1(k)&&!Dm(k,p?.enableOnFormTags))){if(s.current!==null){const S=s.current.getRootNode();if((S instanceof Document||S instanceof ShadowRoot)&&S.activeElement!==s.current&&!s.current.contains(S.activeElement)){Lm(k);return}}k.target?.isContentEditable&&!p?.enableOnContentEditable||Sl(l,p?.delimiter).forEach(S=>{if(S.includes(p?.splitKey??"+")&&S.includes(p?.sequenceSplitKey??">")){console.warn(`Hotkey ${S} contains both ${p?.splitKey??"+"} and ${p?.sequenceSplitKey??">"} which is not supported.`);return}const j=_l(S,p?.splitKey,p?.sequenceSplitKey,p?.useKey,p?.description);if(j.isSequence){g=setTimeout(()=>{m=[]},p?.sequenceTimeoutMs??1e3);const R=j.useKey?k.key:nt(k.code);if(Em(R.toLowerCase()))return;m.push(R);const L=j.keys?.[m.length-1];if(R!==L){m=[],g&&clearTimeout(g);return}m.length===j.keys?.length&&(d.current(k,j),g&&clearTimeout(g),m=[])}else if(p1(k,j,p?.ignoreModifiers)||j.keys?.includes("*")){if(p?.ignoreEventWhen?.(k)||_&&o.current)return;if(o1(k,j,p?.preventDefault),!i1(k,j,p?.enabled)){Lm(k);return}d.current(k,j),_||(o.current=!0)}})}},b=k=>{k.code!==void 0&&(Pm(nt(k.code)),(p?.keydown===void 0&&p?.keyup!==!0||p?.keydown)&&y(k))},x=k=>{k.code!==void 0&&(Om(nt(k.code)),o.current=!1,p?.keyup&&y(k,!0))},v=s.current||i?.document||document;return v.addEventListener("keyup",x,i?.eventListenerOptions),v.addEventListener("keydown",b,i?.eventListenerOptions),f&&Sl(l,p?.delimiter).forEach(k=>f.addHotkey(_l(k,p?.splitKey,p?.sequenceSplitKey,p?.useKey,p?.description))),()=>{v.removeEventListener("keyup",x,i?.eventListenerOptions),v.removeEventListener("keydown",b,i?.eventListenerOptions),f&&Sl(l,p?.delimiter).forEach(k=>f.removeHotkey(_l(k,p?.splitKey,p?.sequenceSplitKey,p?.useKey,p?.description))),m=[],g&&clearTimeout(g)}},[l,p,h]),s}const b1=e=>{const{mode:t,removeNode:r,selectedTask:n,pasteTask:s}=le(),o=le.temporal,{undo:i,redo:l}=wr(o,h=>h),c=e?.confirm||(h=>Promise.resolve(window.confirm(h))),u=e?.showToast,d=h=>{const f=h.target;return f.tagName==="INPUT"||f.tagName==="TEXTAREA"||f.isContentEditable},p=()=>{requestAnimationFrame(()=>{const h=le.getState(),{nodes:f,edges:m}=Ne(h.nodes,h.edges,{direction:h.layoutDirection,mode:h.mode});le.setState({nodes:f,edges:m})})};return wt("mod+z",h=>{t==="edit"&&(d(h)||(h.preventDefault(),i(),p()))},[t,i]),wt(["mod+shift+z","mod+y"],h=>{t==="edit"&&(d(h)||(h.preventDefault(),l(),p()))},[t,l]),wt("delete, backspace",h=>{t!=="edit"||!n||d(h)||(h.preventDefault(),c("确定要删除此任务吗?").then(f=>{f&&r(n.taskReferenceName)}))},[t,n,r,c]),wt("mod+c",h=>{if(!(t!=="edit"||!n)&&!d(h)){if(n.type==="JOIN"){u?.("JOIN 任务不能独立复制","error");return}h.preventDefault();try{localStorage.setItem("conductor-clipboard",JSON.stringify(n)),u?.("任务已复制","success")}catch{u?.("复制失败","error")}}},[t,n,u]),wt("mod+v",h=>{if(t==="edit"&&!d(h)){h.preventDefault();try{const f=localStorage.getItem("conductor-clipboard");if(f){const m=JSON.parse(f);s(m),u?.("任务已粘贴","success")}}catch{u?.("粘贴失败","error")}}},[t,s,u]),wt("mod+s",h=>{h.preventDefault();const f=le.getState().workflowDef;f&&e?.onSave&&e.onSave(f)},[e?.onSave]),{}},v1=()=>{const[e,t]=N.useState(null),r=N.useCallback(o=>new Promise(i=>{t({message:o,resolve:i})}),[]),n=N.useCallback(()=>{e?.resolve(!0),t(null)},[e]),s=N.useCallback(()=>{e?.resolve(!1),t(null)},[e]);return{confirm:r,confirmState:e,handleConfirm:n,handleCancel:s}},k1=()=>{const[e,t]=N.useState([]),r=N.useCallback((s,o="info")=>{const i=Date.now().toString();t(l=>[...l,{id:i,text:s,type:o}])},[]),n=N.useCallback(s=>{t(o=>o.filter(i=>i.id!==s))},[]);return{toasts:e,showToast:r,dismissToast:n}},wl={id:"welcome",role:"assistant",content:`你好!我是 AI 工作流助手。
|
|
36
36
|
|
|
37
37
|
我可以帮你:
|
|
38
38
|
- 🆕 **从零创建**工作流(描述业务场景即可)
|
|
@@ -40,8 +40,8 @@ execute($.input);`}):u.type==="DYNAMIC"?(u.dynamicTaskNameParam="taskToExecute",
|
|
|
40
40
|
- 🔀 **重构拓扑**(如串行改并行)
|
|
41
41
|
- 🔍 **诊断问题**和优化建议
|
|
42
42
|
|
|
43
|
-
直接告诉我你想做什么吧!`,timestamp:Date.now()},Ub=()=>(e,t)=>({config:{provider:"auto",apiKey:""},messages:[yl],isStreaming:!1,streamingText:"",chatPanelOpen:!0,pendingProposal:null,pendingPlan:null,pendingRepair:null,followUpChips:null,undoStack:[],pendingClarification:null,pendingRecommendation:null,pendingAutoSend:null,toolStatus:"",retryInput:null,timelineEntries:[],synthesisPhase:"idle",workingDraft:null,durableCheckpoint:null,metrics:{totalProposals:0,acceptedProposals:0,rejectedProposals:0,totalPromptTokens:0,totalCompletionTokens:0},setConfig:r=>e(n=>({config:{...n.config,...r}})),addMessage:r=>{const n=`msg_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,s={...r,id:n,timestamp:Date.now()};return e(a=>({messages:[...a.messages,s]})),n},updateMessage:(r,n)=>e(s=>({messages:s.messages.map(a=>a.id===r?{...a,content:n}:a)})),setStreaming:r=>e({isStreaming:r}),setStreamingText:r=>e({streamingText:r}),appendStreamingText:r=>e(n=>({streamingText:n.streamingText+r})),clearMessages:()=>e({messages:[yl],streamingText:"",isStreaming:!1,pendingProposal:null,pendingPlan:null,pendingRepair:null,followUpChips:null,pendingClarification:null,pendingRecommendation:null,pendingAutoSend:null,toolStatus:"",retryInput:null,timelineEntries:[],synthesisPhase:"idle",workingDraft:null,durableCheckpoint:null}),setChatPanelOpen:r=>e({chatPanelOpen:r}),toggleChatPanel:()=>e(r=>({chatPanelOpen:!r.chatPanelOpen})),setProposal:r=>{const n=`prop_${Date.now()}`,s=oe.getState().workflowDef,a=JSON.stringify(s);return e(i=>({pendingProposal:{...r,id:n,baselineHash:a},metrics:{...i.metrics,totalProposals:i.metrics.totalProposals+1}})),n},clearProposal:()=>e({pendingProposal:null}),recordAccept:()=>e(r=>({metrics:{...r.metrics,acceptedProposals:r.metrics.acceptedProposals+1},pendingProposal:null,synthesisPhase:"idle",workingDraft:null,durableCheckpoint:null})),recordReject:()=>e(r=>({metrics:{...r.metrics,rejectedProposals:r.metrics.rejectedProposals+1},pendingProposal:null,synthesisPhase:"idle",workingDraft:null,durableCheckpoint:null})),getMetrics:()=>t().metrics,recordUsage:r=>e(n=>({metrics:{...n.metrics,totalPromptTokens:n.metrics.totalPromptTokens+(r.promptTokens??0),totalCompletionTokens:n.metrics.totalCompletionTokens+(r.completionTokens??0)}})),setFollowUpChips:r=>e({followUpChips:r}),clearFollowUpChips:()=>e({followUpChips:null}),setPlan:r=>{const n=`plan_${Date.now()}`;return e({pendingPlan:{...r,id:n}}),n},clearPlan:()=>e({pendingPlan:null}),setRepair:r=>{const n=`repair_${Date.now()}`;return e({pendingRepair:{...r,id:n}}),n},clearRepair:()=>e({pendingRepair:null}),pushUndo:r=>e(n=>({undoStack:[...n.undoStack.slice(-4),r]})),popUndo:()=>{const r=t().undoStack;if(r.length===0)return null;const n=r[r.length-1];return e({undoStack:r.slice(0,-1)}),n},clearUndo:()=>e({undoStack:[]}),canUndo:()=>t().undoStack.length>0,setClarification:r=>{const n=`clarif_${Date.now()}`;return e({pendingClarification:{...r,id:n}}),n},clearClarification:()=>e({pendingClarification:null}),setRecommendation:r=>{const n=`rec_${Date.now()}`;return e({pendingRecommendation:{...r,id:n}}),n},clearRecommendation:()=>e({pendingRecommendation:null}),setPendingAutoSend:r=>e({pendingAutoSend:r}),setToolStatus:r=>e({toolStatus:r}),setRetryInput:r=>e({retryInput:r}),addTimelineEntry:(r,n="done")=>e(s=>({timelineEntries:[...s.timelineEntries,{id:`tl_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,label:r,icon:n}]})),clearTimeline:()=>e({timelineEntries:[]}),setSynthesisStage:(r,n)=>e(s=>({synthesisPhase:r,workingDraft:n!==void 0?n:s.workingDraft})),saveCheckpoint:r=>e({durableCheckpoint:r}),clearCheckpoint:()=>e({durableCheckpoint:null,synthesisPhase:"idle",workingDraft:null}),hydrateFromDraft:(r,n,s)=>e({messages:r.length>0?r:[yl],pendingProposal:n,durableCheckpoint:s??null,synthesisPhase:s?.phase??"idle",workingDraft:s?.workingDraft??null})});function Kb(e="ai-workflow-config"){const t=Ub();return e===!1?vr()(t):vr()(Tl(t,{name:e,storage:br(()=>localStorage),partialize:r=>({config:{...r.config,apiKey:""},metrics:r.metrics})}))}const jm=Kb(),Gb=I.createContext(null);function Cm(){return I.useContext(Gb)}const Vb=()=>{const{mode:e,showWaterfallPanel:t,setShowWaterfallPanel:r,workflowInstance:n,executionData:s,taskMap:a,selectedTask:i,setSelectedTask:l,setSelectedTaskInstance:c,timeTravelTimestamp:d,setTimeTravelTimestamp:u}=oe(),f=I.useMemo(()=>{const y=n?.tasks?.length?n.tasks:s?Object.values(s).flatMap(N=>N.attempts):[];if(y.length===0)return null;const b=y.filter(N=>N.startTime||N.scheduledTime);if(b.length===0)return null;const k=Math.min(...b.map(N=>N.scheduledTime||N.startTime||Date.now())),_=Math.max(...b.map(N=>N.endTime||N.startTime||N.scheduledTime||k+100)),w=Math.max(_-k,50),T=b.filter(N=>!["FORK_JOIN","JOIN","DO_WHILE","SWITCH","DECISION"].includes(N.taskType)).map(N=>Math.max((N.endTime||_)-(N.startTime||N.scheduledTime||k),0)).sort((N,S)=>S-N),O=T.length>0?Math.max(T[Math.floor(T.length*.25)]||80,50):100,D=b.map((N,S)=>{const R=N.scheduledTime||N.startTime||k,j=N.startTime||R,E=N.endTime||_,q=Math.max(j-R,0),$=Math.max(E-j,1),J=!["FORK_JOIN","JOIN","DO_WHILE","SWITCH","DECISION"].includes(N.taskType)&&$>=O,V=(R-k)/w*100,A=q/w*100,B=(j-k)/w*100,P=Math.max($/w*100,1.2);return{key:N.taskId||`${N.referenceTaskName}-${S}`,task:N,sched:R,start:j,end:E,queueMs:q,execMs:$,isCritical:J,queueLeftPct:V,queueWidthPct:A,execLeftPct:B,execWidthPct:P}});return{minTime:k,maxTime:_,totalSpanMs:w,rows:D}},[n,s]);if(e!=="run"||!t||!f)return null;const{minTime:h,totalSpanMs:p,rows:m}=f,g=d!==null?d-h:p,x=Math.min(Math.max(g/p*100,0),100),v=y=>{switch(y){case"COMPLETED":return"#10b981";case"FAILED":case"FAILED_WITH_TERMINAL_ERROR":case"TIMED_OUT":return"#ef4444";case"IN_PROGRESS":return"#38bdf8";default:return"#94a3b8"}};return o.jsxs("div",{style:{position:"absolute",left:16,right:i?466:16,bottom:16,height:255,zIndex:1100,background:"rgba(15, 23, 42, 0.95)",backdropFilter:"blur(16px)",border:"1px solid rgba(56, 189, 248, 0.3)",borderRadius:12,boxShadow:"0 16px 40px rgba(0, 0, 0, 0.45)",display:"flex",flexDirection:"column",overflow:"hidden",transition:"right 0.25s ease"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16,padding:"8px 14px",borderBottom:"1px solid rgba(148, 163, 184, 0.16)",background:"rgba(2, 6, 23, 0.55)",flexShrink:0},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[o.jsx("span",{style:{fontSize:12,fontWeight:700,color:"#f8fafc"},children:"📊 并发执行瀑布流 & 时间旅行调试器"}),o.jsxs("span",{style:{fontSize:10,padding:"2px 7px",borderRadius:999,background:"rgba(56, 189, 248, 0.14)",color:"#38bdf8",fontFamily:"monospace",fontWeight:600},children:["总跨度 ",p,"ms · ",m.length," 个任务步"]}),o.jsx("span",{style:{fontSize:10,padding:"2px 7px",borderRadius:999,background:"rgba(249, 115, 22, 0.15)",color:"#fb923c",fontWeight:600},children:"🔥 关键路径耗时瓶颈高亮"})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flex:1,maxWidth:420},children:[o.jsx("span",{style:{fontSize:10,color:"#94a3b8",whiteSpace:"nowrap"},children:"⏪ 时间旅行指针:"}),o.jsx("input",{type:"range",min:0,max:p,value:g,onChange:y=>{const b=Number(y.target.value);b>=p?u(null):u(h+b)},style:{flex:1,cursor:"pointer",accentColor:"#38bdf8"}}),o.jsx("span",{style:{fontSize:11,fontFamily:"monospace",color:d!==null?"#fbbf24":"#34d399",fontWeight:700,minWidth:74,textAlign:"right"},children:d!==null?`+${g}ms`:"最新态 (Live)"}),d!==null&&o.jsx("button",{type:"button",onClick:()=>u(null),style:{fontSize:10,padding:"2px 7px",borderRadius:4,border:"1px solid rgba(251, 191, 36, 0.4)",background:"rgba(251, 191, 36, 0.12)",color:"#fbbf24",cursor:"pointer"},children:"重置"})]}),o.jsx("button",{type:"button",onClick:()=>r(!1),style:{background:"none",border:"none",color:"#94a3b8",cursor:"pointer",fontSize:15,padding:"2px 6px"},children:"✕"})]}),o.jsx("div",{style:{flex:1,overflowY:"auto",position:"relative",padding:"6px 0"},children:m.map(y=>{const b=y.task.referenceTaskName.replace(/__\d+$/,""),k=i?.taskReferenceName===b,_=d!==null&&y.start>d,w=d!==null&&y.start<=d&&y.end>d;return o.jsxs("div",{onClick:()=>{const T=a[b]||y.task.workflowTask;T&&(l(T),c(y.task))},style:{display:"grid",gridTemplateColumns:"210px 1fr 90px",alignItems:"center",gap:8,padding:"4px 14px",cursor:"pointer",background:k?"rgba(56, 189, 248, 0.14)":"transparent",opacity:_?.35:1,borderLeft:k?"3px solid #38bdf8":"3px solid transparent"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},children:[o.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:w?"#38bdf8":v(y.task.status),flexShrink:0}}),o.jsx("span",{style:{fontSize:11,fontFamily:"monospace",color:"#e2e8f0",fontWeight:k?700:500,overflow:"hidden",textOverflow:"ellipsis"},title:y.task.referenceTaskName,children:y.task.referenceTaskName}),y.isCritical&&o.jsx("span",{title:"关键路径耗时瓶颈节点",style:{fontSize:9,padding:"1px 4px",borderRadius:4,background:"rgba(249, 115, 22, 0.2)",color:"#fb923c",fontWeight:700,flexShrink:0},children:"🔥瓶颈"})]}),o.jsxs("div",{style:{position:"relative",height:14,background:"rgba(15, 23, 42, 0.65)",borderRadius:4,overflow:"hidden",border:"1px solid rgba(148, 163, 184, 0.1)"},children:[y.queueWidthPct>.3&&o.jsx("div",{title:`排队等待: ${y.queueMs}ms`,style:{position:"absolute",left:`${y.queueLeftPct}%`,width:`${y.queueWidthPct}%`,top:3,bottom:3,background:"rgba(148, 163, 184, 0.35)",borderRadius:"2px 0 0 2px"}}),o.jsx("div",{title:`执行耗时: ${y.execMs}ms (排队 ${y.queueMs}ms)`,style:{position:"absolute",left:`${y.execLeftPct}%`,width:`${y.execWidthPct}%`,top:2,bottom:2,borderRadius:3,background:y.isCritical?"linear-gradient(90deg, #f97316, #ef4444)":v(y.task.status),boxShadow:w?"0 0 8px rgba(56, 189, 248, 0.8)":void 0}}),d!==null&&o.jsx("div",{style:{position:"absolute",left:`${x}%`,top:0,bottom:0,width:2,background:"#fbbf24",pointerEvents:"none"}})]}),o.jsxs("div",{style:{fontSize:10,fontFamily:"monospace",color:y.isCritical?"#fb923c":"#94a3b8",textAlign:"right",fontWeight:y.isCritical?700:400},children:[y.execMs,"ms",y.queueMs>0?o.jsxs("span",{style:{opacity:.6,fontSize:9},children:[" (+",y.queueMs,"q)"]}):null]})]},y.key)})})]})};function Im(e){if(!e)return"未设置";if(e<60)return`${e} 秒`;const t=Math.floor(e/60),r=e%60;return r>0?`${t} 分 ${r} 秒`:`${t} 分钟`}function Yb(e,t){const r=[];if(e.name!==t.name&&r.push(`名称:「${e.name}」→「${t.name}」`),e.type!==t.type&&r.push(`类型:${e.type} → ${t.type}`),e.timeoutSeconds!==t.timeoutSeconds&&r.push(`超时:${Im(e.timeoutSeconds)} → ${Im(t.timeoutSeconds)}`),(e.retryCount??0)!==(t.retryCount??0)){const n=e.retryCount??0,s=t.retryCount??0;r.push(s>n?`新增失败重试(${s} 次)`:s===0?"移除了失败重试":`重试次数:${n} → ${s}`)}return JSON.stringify(e.inputParameters??{})!==JSON.stringify(t.inputParameters??{})&&r.push("输入参数已调整"),JSON.stringify(e.decisionCases)!==JSON.stringify(t.decisionCases)&&r.push("分支条件已调整"),JSON.stringify(e.forkTasks)!==JSON.stringify(t.forkTasks)&&r.push("并行分支已调整"),r.length===0&&r.push("配置已调整"),r}function Xb(e,t){const r=t.tasks??[];if(!e)return{added:r.map(p=>p.taskReferenceName),modified:[],removed:[],propsChanged:!1};const n=new Map((e.tasks??[]).map(p=>[p.taskReferenceName,p])),s=new Map(r.map(p=>[p.taskReferenceName,p])),a=[],i=[],l=[],c=[];for(const[p,m]of s)if(!n.has(p))a.push(p);else{const g=n.get(p);JSON.stringify(m)!==JSON.stringify(g)&&(i.push(p),c.push({ref:p,changes:Yb(g,m)}))}for(const p of n.keys())s.has(p)||l.push(p);const d=e.name!==t.name||e.description!==t.description||e.timeoutSeconds!==t.timeoutSeconds||e.version!==t.version||e.ownerEmail!==t.ownerEmail||e.failureWorkflow!==t.failureWorkflow||JSON.stringify(e.inputParameters)!==JSON.stringify(t.inputParameters)||JSON.stringify(e.outputParameters)!==JSON.stringify(t.outputParameters),u=(e.tasks??[]).filter(p=>s.has(p.taskReferenceName)).map(p=>p.taskReferenceName),f=r.filter(p=>n.has(p.taskReferenceName)).map(p=>p.taskReferenceName),h=u.join(",")!==f.join(",");return{added:a,modified:i,removed:l,propsChanged:d,reordered:h,modifiedDetails:c}}const Rm={apiKey:"",baseUrl:"https://api.openai.com/v1",model:"gpt-4o"},xl=async(e,t={},r)=>{const n={...Rm,...t};if(!n.apiKey)throw new Error("Please configure AI API Key in settings.");const s=await fetch(`${n.baseUrl}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n.apiKey}`},body:JSON.stringify({model:n.model,messages:e,temperature:.7,stream:!1}),signal:r});if(!s.ok){const i=await s.json();throw new Error(i.error?.message||"AI request failed")}return(await s.json()).choices[0].message.content},Qb=async(e,t={},r,n,s)=>{const a={...Rm,...t};if(!a.apiKey)throw new Error("Please configure AI API Key in settings.");const i=await fetch(`${a.baseUrl}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a.apiKey}`},body:JSON.stringify({model:a.model,messages:e,temperature:.7,stream:!0}),signal:s});if(!i.ok){const u=await i.json();throw new Error(u.error?.message||"AI request failed")}const l=i.body?.getReader();if(!l)throw new Error("ReadableStream not supported");const c=new TextDecoder;let d="";for(;;){const{done:u,value:f}=await l.read();if(u)break;const p=c.decode(f,{stream:!0}).split(`
|
|
44
|
-
`).filter(m=>m.trim()!=="");for(const m of
|
|
43
|
+
直接告诉我你想做什么吧!`,timestamp:Date.now()},S1=()=>(e,t)=>({config:{provider:"auto",apiKey:""},messages:[wl],isStreaming:!1,streamingText:"",chatPanelOpen:!0,pendingProposal:null,pendingPlan:null,pendingRepair:null,followUpChips:null,undoStack:[],pendingClarification:null,pendingRecommendation:null,pendingAutoSend:null,toolStatus:"",retryInput:null,timelineEntries:[],synthesisPhase:"idle",workingDraft:null,durableCheckpoint:null,metrics:{totalProposals:0,acceptedProposals:0,rejectedProposals:0,totalPromptTokens:0,totalCompletionTokens:0},setConfig:r=>e(n=>({config:{...n.config,...r}})),addMessage:r=>{const n=`msg_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,s={...r,id:n,timestamp:Date.now()};return e(o=>({messages:[...o.messages,s]})),n},updateMessage:(r,n)=>e(s=>({messages:s.messages.map(o=>o.id===r?{...o,content:n}:o)})),setStreaming:r=>e({isStreaming:r}),setStreamingText:r=>e({streamingText:r}),appendStreamingText:r=>e(n=>({streamingText:n.streamingText+r})),clearMessages:()=>e({messages:[wl],streamingText:"",isStreaming:!1,pendingProposal:null,pendingPlan:null,pendingRepair:null,followUpChips:null,pendingClarification:null,pendingRecommendation:null,pendingAutoSend:null,toolStatus:"",retryInput:null,timelineEntries:[],synthesisPhase:"idle",workingDraft:null,durableCheckpoint:null}),setChatPanelOpen:r=>e({chatPanelOpen:r}),toggleChatPanel:()=>e(r=>({chatPanelOpen:!r.chatPanelOpen})),setProposal:r=>{const n=`prop_${Date.now()}`,s=le.getState().workflowDef,o=JSON.stringify(s);return e(i=>({pendingProposal:{...r,id:n,baselineHash:o},metrics:{...i.metrics,totalProposals:i.metrics.totalProposals+1}})),n},clearProposal:()=>e({pendingProposal:null}),recordAccept:()=>e(r=>({metrics:{...r.metrics,acceptedProposals:r.metrics.acceptedProposals+1},pendingProposal:null,synthesisPhase:"idle",workingDraft:null,durableCheckpoint:null})),recordReject:()=>e(r=>({metrics:{...r.metrics,rejectedProposals:r.metrics.rejectedProposals+1},pendingProposal:null,synthesisPhase:"idle",workingDraft:null,durableCheckpoint:null})),getMetrics:()=>t().metrics,recordUsage:r=>e(n=>({metrics:{...n.metrics,totalPromptTokens:n.metrics.totalPromptTokens+(r.promptTokens??0),totalCompletionTokens:n.metrics.totalCompletionTokens+(r.completionTokens??0)}})),setFollowUpChips:r=>e({followUpChips:r}),clearFollowUpChips:()=>e({followUpChips:null}),setPlan:r=>{const n=`plan_${Date.now()}`;return e({pendingPlan:{...r,id:n}}),n},clearPlan:()=>e({pendingPlan:null}),setRepair:r=>{const n=`repair_${Date.now()}`;return e({pendingRepair:{...r,id:n}}),n},clearRepair:()=>e({pendingRepair:null}),pushUndo:r=>e(n=>({undoStack:[...n.undoStack.slice(-4),r]})),popUndo:()=>{const r=t().undoStack;if(r.length===0)return null;const n=r[r.length-1];return e({undoStack:r.slice(0,-1)}),n},clearUndo:()=>e({undoStack:[]}),canUndo:()=>t().undoStack.length>0,setClarification:r=>{const n=`clarif_${Date.now()}`;return e({pendingClarification:{...r,id:n}}),n},clearClarification:()=>e({pendingClarification:null}),setRecommendation:r=>{const n=`rec_${Date.now()}`;return e({pendingRecommendation:{...r,id:n}}),n},clearRecommendation:()=>e({pendingRecommendation:null}),setPendingAutoSend:r=>e({pendingAutoSend:r}),setToolStatus:r=>e({toolStatus:r}),setRetryInput:r=>e({retryInput:r}),addTimelineEntry:(r,n="done")=>e(s=>({timelineEntries:[...s.timelineEntries,{id:`tl_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,label:r,icon:n}]})),clearTimeline:()=>e({timelineEntries:[]}),setSynthesisStage:(r,n)=>e(s=>({synthesisPhase:r,workingDraft:n!==void 0?n:s.workingDraft})),saveCheckpoint:r=>e({durableCheckpoint:r}),clearCheckpoint:()=>e({durableCheckpoint:null,synthesisPhase:"idle",workingDraft:null}),hydrateFromDraft:(r,n,s)=>e({messages:r.length>0?r:[wl],pendingProposal:n,durableCheckpoint:s??null,synthesisPhase:s?.phase??"idle",workingDraft:s?.workingDraft??null})});function _1(e="ai-workflow-config"){const t=S1();return e===!1?Ir()(t):Ir()(Ll(t,{name:e,storage:Tr(()=>localStorage),partialize:r=>({config:{...r.config,apiKey:""},metrics:r.metrics})}))}const Mm=_1(),j1=N.createContext(null);function qm(){return N.useContext(j1)}const w1=()=>{const{mode:e,showWaterfallPanel:t,setShowWaterfallPanel:r,workflowInstance:n,executionData:s,taskMap:o,selectedTask:i,setSelectedTask:l,setSelectedTaskInstance:c,timeTravelTimestamp:u,setTimeTravelTimestamp:d}=le(),p=N.useMemo(()=>{const x=n?.tasks?.length?n.tasks:s?Object.values(s).flatMap(T=>T.attempts):[];if(x.length===0)return null;const v=x.filter(T=>T.startTime||T.scheduledTime);if(v.length===0)return null;const k=Math.min(...v.map(T=>T.scheduledTime||T.startTime||Date.now())),_=Math.max(...v.map(T=>T.endTime||T.startTime||T.scheduledTime||k+100)),S=Math.max(_-k,50),j=v.filter(T=>!["FORK_JOIN","JOIN","DO_WHILE","SWITCH","DECISION"].includes(T.taskType)).map(T=>Math.max((T.endTime||_)-(T.startTime||T.scheduledTime||k),0)).sort((T,w)=>w-T),R=j.length>0?Math.max(j[Math.floor(j.length*.25)]||80,50):100,L=v.map((T,w)=>{const D=T.scheduledTime||T.startTime||k,E=T.startTime||D,C=T.endTime||_,z=Math.max(E-D,0),W=Math.max(C-E,1),K=!["FORK_JOIN","JOIN","DO_WHILE","SWITCH","DECISION"].includes(T.taskType)&&W>=R,M=(D-k)/S*100,I=z/S*100,F=(E-k)/S*100,O=Math.max(W/S*100,1.2);return{key:T.taskId||`${T.referenceTaskName}-${w}`,task:T,sched:D,start:E,end:C,queueMs:z,execMs:W,isCritical:K,queueLeftPct:M,queueWidthPct:I,execLeftPct:F,execWidthPct:O}});return{minTime:k,maxTime:_,totalSpanMs:S,rows:L}},[n,s]);if(e!=="run"||!t||!p)return null;const{minTime:h,totalSpanMs:f,rows:m}=p,g=u!==null?u-h:f,y=Math.min(Math.max(g/f*100,0),100),b=x=>{switch(x){case"COMPLETED":return"#10b981";case"FAILED":case"FAILED_WITH_TERMINAL_ERROR":case"TIMED_OUT":return"#ef4444";case"IN_PROGRESS":return"#38bdf8";default:return"#94a3b8"}};return a.jsxs("div",{style:{position:"absolute",left:16,right:i?466:16,bottom:16,height:255,zIndex:1100,background:"rgba(15, 23, 42, 0.95)",backdropFilter:"blur(16px)",border:"1px solid rgba(56, 189, 248, 0.3)",borderRadius:12,boxShadow:"0 16px 40px rgba(0, 0, 0, 0.45)",display:"flex",flexDirection:"column",overflow:"hidden",transition:"right 0.25s ease"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16,padding:"8px 14px",borderBottom:"1px solid rgba(148, 163, 184, 0.16)",background:"rgba(2, 6, 23, 0.55)",flexShrink:0},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[a.jsx("span",{style:{fontSize:12,fontWeight:700,color:"#f8fafc"},children:"📊 并发执行瀑布流 & 时间旅行调试器"}),a.jsxs("span",{style:{fontSize:10,padding:"2px 7px",borderRadius:999,background:"rgba(56, 189, 248, 0.14)",color:"#38bdf8",fontFamily:"monospace",fontWeight:600},children:["总跨度 ",f,"ms · ",m.length," 个任务步"]}),a.jsx("span",{style:{fontSize:10,padding:"2px 7px",borderRadius:999,background:"rgba(249, 115, 22, 0.15)",color:"#fb923c",fontWeight:600},children:"🔥 关键路径耗时瓶颈高亮"})]}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flex:1,maxWidth:420},children:[a.jsx("span",{style:{fontSize:10,color:"#94a3b8",whiteSpace:"nowrap"},children:"⏪ 时间旅行指针:"}),a.jsx("input",{type:"range",min:0,max:f,value:g,onChange:x=>{const v=Number(x.target.value);v>=f?d(null):d(h+v)},style:{flex:1,cursor:"pointer",accentColor:"#38bdf8"}}),a.jsx("span",{style:{fontSize:11,fontFamily:"monospace",color:u!==null?"#fbbf24":"#34d399",fontWeight:700,minWidth:74,textAlign:"right"},children:u!==null?`+${g}ms`:"最新态 (Live)"}),u!==null&&a.jsx("button",{type:"button",onClick:()=>d(null),style:{fontSize:10,padding:"2px 7px",borderRadius:4,border:"1px solid rgba(251, 191, 36, 0.4)",background:"rgba(251, 191, 36, 0.12)",color:"#fbbf24",cursor:"pointer"},children:"重置"})]}),a.jsx("button",{type:"button",onClick:()=>r(!1),style:{background:"none",border:"none",color:"#94a3b8",cursor:"pointer",fontSize:15,padding:"2px 6px"},children:"✕"})]}),a.jsx("div",{style:{flex:1,overflowY:"auto",position:"relative",padding:"6px 0"},children:m.map(x=>{const v=x.task.referenceTaskName.replace(/__\d+$/,""),k=i?.taskReferenceName===v,_=u!==null&&x.start>u,S=u!==null&&x.start<=u&&x.end>u;return a.jsxs("div",{onClick:()=>{const j=o[v]||x.task.workflowTask;j&&(l(j),c(x.task))},style:{display:"grid",gridTemplateColumns:"210px 1fr 90px",alignItems:"center",gap:8,padding:"4px 14px",cursor:"pointer",background:k?"rgba(56, 189, 248, 0.14)":"transparent",opacity:_?.35:1,borderLeft:k?"3px solid #38bdf8":"3px solid transparent"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},children:[a.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:S?"#38bdf8":b(x.task.status),flexShrink:0}}),a.jsx("span",{style:{fontSize:11,fontFamily:"monospace",color:"#e2e8f0",fontWeight:k?700:500,overflow:"hidden",textOverflow:"ellipsis"},title:x.task.referenceTaskName,children:x.task.referenceTaskName}),x.isCritical&&a.jsx("span",{title:"关键路径耗时瓶颈节点",style:{fontSize:9,padding:"1px 4px",borderRadius:4,background:"rgba(249, 115, 22, 0.2)",color:"#fb923c",fontWeight:700,flexShrink:0},children:"🔥瓶颈"})]}),a.jsxs("div",{style:{position:"relative",height:14,background:"rgba(15, 23, 42, 0.65)",borderRadius:4,overflow:"hidden",border:"1px solid rgba(148, 163, 184, 0.1)"},children:[x.queueWidthPct>.3&&a.jsx("div",{title:`排队等待: ${x.queueMs}ms`,style:{position:"absolute",left:`${x.queueLeftPct}%`,width:`${x.queueWidthPct}%`,top:3,bottom:3,background:"rgba(148, 163, 184, 0.35)",borderRadius:"2px 0 0 2px"}}),a.jsx("div",{title:`执行耗时: ${x.execMs}ms (排队 ${x.queueMs}ms)`,style:{position:"absolute",left:`${x.execLeftPct}%`,width:`${x.execWidthPct}%`,top:2,bottom:2,borderRadius:3,background:x.isCritical?"linear-gradient(90deg, #f97316, #ef4444)":b(x.task.status),boxShadow:S?"0 0 8px rgba(56, 189, 248, 0.8)":void 0}}),u!==null&&a.jsx("div",{style:{position:"absolute",left:`${y}%`,top:0,bottom:0,width:2,background:"#fbbf24",pointerEvents:"none"}})]}),a.jsxs("div",{style:{fontSize:10,fontFamily:"monospace",color:x.isCritical?"#fb923c":"#94a3b8",textAlign:"right",fontWeight:x.isCritical?700:400},children:[x.execMs,"ms",x.queueMs>0?a.jsxs("span",{style:{opacity:.6,fontSize:9},children:[" (+",x.queueMs,"q)"]}):null]})]},x.key)})})]})};function zm(e){if(!e)return"未设置";if(e<60)return`${e} 秒`;const t=Math.floor(e/60),r=e%60;return r>0?`${t} 分 ${r} 秒`:`${t} 分钟`}function I1(e,t){const r=[];if(e.name!==t.name&&r.push(`名称:「${e.name}」→「${t.name}」`),e.type!==t.type&&r.push(`类型:${e.type} → ${t.type}`),e.timeoutSeconds!==t.timeoutSeconds&&r.push(`超时:${zm(e.timeoutSeconds)} → ${zm(t.timeoutSeconds)}`),(e.retryCount??0)!==(t.retryCount??0)){const n=e.retryCount??0,s=t.retryCount??0;r.push(s>n?`新增失败重试(${s} 次)`:s===0?"移除了失败重试":`重试次数:${n} → ${s}`)}return JSON.stringify(e.inputParameters??{})!==JSON.stringify(t.inputParameters??{})&&r.push("输入参数已调整"),JSON.stringify(e.decisionCases)!==JSON.stringify(t.decisionCases)&&r.push("分支条件已调整"),JSON.stringify(e.forkTasks)!==JSON.stringify(t.forkTasks)&&r.push("并行分支已调整"),r.length===0&&r.push("配置已调整"),r}function T1(e,t){const r=t.tasks??[];if(!e)return{added:r.map(f=>f.taskReferenceName),modified:[],removed:[],propsChanged:!1};const n=new Map((e.tasks??[]).map(f=>[f.taskReferenceName,f])),s=new Map(r.map(f=>[f.taskReferenceName,f])),o=[],i=[],l=[],c=[];for(const[f,m]of s)if(!n.has(f))o.push(f);else{const g=n.get(f);JSON.stringify(m)!==JSON.stringify(g)&&(i.push(f),c.push({ref:f,changes:I1(g,m)}))}for(const f of n.keys())s.has(f)||l.push(f);const u=e.name!==t.name||e.description!==t.description||e.timeoutSeconds!==t.timeoutSeconds||e.version!==t.version||e.ownerEmail!==t.ownerEmail||e.failureWorkflow!==t.failureWorkflow||JSON.stringify(e.inputParameters)!==JSON.stringify(t.inputParameters)||JSON.stringify(e.outputParameters)!==JSON.stringify(t.outputParameters),d=(e.tasks??[]).filter(f=>s.has(f.taskReferenceName)).map(f=>f.taskReferenceName),p=r.filter(f=>n.has(f.taskReferenceName)).map(f=>f.taskReferenceName),h=d.join(",")!==p.join(",");return{added:o,modified:i,removed:l,propsChanged:u,reordered:h,modifiedDetails:c}}const $m={apiKey:"",baseUrl:"https://api.openai.com/v1",model:"gpt-4o"},Il=async(e,t={},r)=>{const n={...$m,...t};if(!n.apiKey)throw new Error("Please configure AI API Key in settings.");const s=await fetch(`${n.baseUrl}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n.apiKey}`},body:JSON.stringify({model:n.model,messages:e,temperature:.7,stream:!1}),signal:r});if(!s.ok){const i=await s.json();throw new Error(i.error?.message||"AI request failed")}return(await s.json()).choices[0].message.content},C1=async(e,t={},r,n,s)=>{const o={...$m,...t};if(!o.apiKey)throw new Error("Please configure AI API Key in settings.");const i=await fetch(`${o.baseUrl}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o.apiKey}`},body:JSON.stringify({model:o.model,messages:e,temperature:.7,stream:!0}),signal:s});if(!i.ok){const d=await i.json();throw new Error(d.error?.message||"AI request failed")}const l=i.body?.getReader();if(!l)throw new Error("ReadableStream not supported");const c=new TextDecoder;let u="";for(;;){const{done:d,value:p}=await l.read();if(d)break;const f=c.decode(p,{stream:!0}).split(`
|
|
44
|
+
`).filter(m=>m.trim()!=="");for(const m of f)if(m.startsWith("data: ")){const g=m.slice(6);if(g==="[DONE]")return u;try{const b=JSON.parse(g).choices?.[0]?.delta?.content;b&&(u+=b,r(b))}catch{console.warn("[AI SSE] malformed chunk:",g)}}}return u},N1=(e,t,r,n,s)=>`
|
|
45
45
|
You are a Netflix Conductor expert. Generate a complete "inputParameters" JSON object for the following task.
|
|
46
46
|
|
|
47
47
|
Task Type: ${e}
|
|
@@ -49,11 +49,11 @@ Task Reference Name: ${t}
|
|
|
49
49
|
Current inputParameters (may be incomplete): ${JSON.stringify(s,null,2)}
|
|
50
50
|
|
|
51
51
|
Available workflow input parameters (accessible via \${workflow.input.XXX}):
|
|
52
|
-
${r.length>0?r.map(
|
|
52
|
+
${r.length>0?r.map(o=>` - ${o}`).join(`
|
|
53
53
|
`):" (none defined)"}
|
|
54
54
|
|
|
55
55
|
Upstream tasks (accessible via \${taskRef.output.XXX}):
|
|
56
|
-
${n.length>0?n.map(
|
|
56
|
+
${n.length>0?n.map(o=>` - ${o.ref} (type: ${o.type})`).join(`
|
|
57
57
|
`):" (no upstream tasks)"}
|
|
58
58
|
|
|
59
59
|
Rules:
|
|
@@ -65,7 +65,7 @@ Rules:
|
|
|
65
65
|
6. Return ONLY the JSON object (no explanation, no markdown code block).
|
|
66
66
|
|
|
67
67
|
Return format: { "paramKey": "paramValue", ... }
|
|
68
|
-
`,
|
|
68
|
+
`,R1=async(e,t,r,n,s,o={})=>{const i=N1(e,t,r,n,s),c=(await Il([{role:"system",content:"You are a Conductor expert. Return only valid JSON objects, no markdown."},{role:"user",content:i}],o)).replace(/```json\n?/g,"").replace(/```\n?/g,"").trim();return JSON.parse(c)},E1=`
|
|
69
69
|
You are an expert in Netflix Conductor Workflow modeling.
|
|
70
70
|
Your goal is to help users design JSON-based workflows.
|
|
71
71
|
|
|
@@ -77,12 +77,12 @@ CONSTRANTS:
|
|
|
77
77
|
5. For FORK_JOIN, ensure a corresponding JOIN task follows.
|
|
78
78
|
|
|
79
79
|
Provide clear, enterprise-grade logic with proper error handling paths.
|
|
80
|
-
`,
|
|
81
|
-
Upstream tasks in scope: ${k.map(
|
|
80
|
+
`,P1=[{label:"➕ 在下方插入 HTTP 请求",type:"HTTP",name:"http_call_task"},{label:"⚖️ 在下方插入条件分支 (SWITCH)",type:"SWITCH",name:"switch_router"},{label:"🔍 在下方插入 JQ 转换节点",type:"JSON_JQ_TRANSFORM",name:"jq_transform_task"},{label:"🛡️ 为当前节点开启自动重试与容错",action:"retry_hardening"}],O1=({aiConfig:e})=>{const{inlineCopilotTaskRef:t,setInlineCopilotTaskRef:r,selectedTask:n,workflowDef:s,taskMap:o,addNode:i,updateTask:l,selectTaskAction:c}=le(),d=(qm()?.aiStore??Mm)(j=>j.setProposal),[p,h]=N.useState(""),[f,m]=N.useState(!1),[g,y]=N.useState(null),b=N.useRef(null),x=t||n?.taskReferenceName||null,v=x?o[x]:null;if(N.useEffect(()=>{const j=R=>{if((R.metaKey||R.ctrlKey)&&R.key.toLowerCase()==="k"){R.preventDefault();const L=le.getState();if(L.inlineCopilotTaskRef)L.setInlineCopilotTaskRef(null);else{const T=L.selectedTask?.taskReferenceName||L.workflowDef?.tasks?.[L.workflowDef.tasks.length-1]?.taskReferenceName||"__canvas_root__";L.setInlineCopilotTaskRef(T)}}else R.key==="Escape"&&t&&r(null)};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[t,r]),N.useEffect(()=>{t&&(y(null),setTimeout(()=>b.current?.focus(),40))},[t]),!t)return null;const k=s&&x&&x!=="__canvas_root__"?gl(s,x):[],_=j=>{if(!(!x||x==="__canvas_root__")){if(j.action==="retry_hardening"&&v){l(x,{retryCount:3,retryLogic:"EXPONENTIAL_BACKOFF",retryDelaySeconds:2,timeoutSeconds:60}),y("✅ 已为当前节点开启指数退避重试 (3次) 与 60s 超时保护"),setTimeout(()=>r(null),900);return}if(j.type){const R=Ke.find(T=>T.type===j.type),L=`${j.name}_${Date.now().toString(36).slice(-4)}`;i({data:{label:R?.label||j.name,taskName:j.name,taskReferenceName:L,taskType:j.type}},x,"",`inline-cmdk-${L}`,{}),y(`✅ 已在 ${x} 后插入 ${j.type} 节点`),setTimeout(()=>r(null),700)}}},S=async j=>{j.preventDefault();const R=p.trim();if(!R||!s)return;const L=e?.apiKey||localStorage.getItem("AI_API_KEY")||"";if(!L){const T=R.toLowerCase(),w=x&&x!=="__canvas_root__"?x:s.tasks[s.tasks.length-1]?.taskReferenceName;if(w){let D="SIMPLE";T.includes("http")||T.includes("接口")||T.includes("请求")?D="HTTP":T.includes("switch")||T.includes("分支")||T.includes("判断")?D="SWITCH":T.includes("loop")||T.includes("循环")?D="DO_WHILE":T.includes("jq")||T.includes("转换")?D="JSON_JQ_TRANSFORM":(T.includes("wait")||T.includes("等待"))&&(D="WAIT");const E=Ke.find(z=>z.type===D),C=`${D.toLowerCase()}_${Date.now().toString(36).slice(-4)}`;i({data:{label:R.slice(0,24)||E?.label||D,taskName:C,taskReferenceName:C,taskType:D}},w,"",`inline-cmdk-${C}`,{}),h(""),r(null);return}}m(!0),y("🤖 正在基于当前节点拓扑上下文生成 Shadow Graph 变更提案...");try{const T=e?.baseUrl||localStorage.getItem("AI_BASE_URL")||"",w=e?.model||localStorage.getItem("AI_MODEL")||"",D={apiKey:L};T&&(D.baseUrl=T),w&&(D.model=w);const E=`You are a Conductor Workflow Architect. The user is invoking inline Cmd+K on task "${x}" (type: ${v?.type||"ROOT"}).
|
|
81
|
+
Upstream tasks in scope: ${k.map(W=>W.taskReferenceName).join(", ")||"none"}.
|
|
82
82
|
Current workflow JSON:
|
|
83
83
|
${JSON.stringify(s,null,2)}
|
|
84
84
|
|
|
85
|
-
Return ONLY the updated full WorkflowDef JSON object (wrapped in \`\`\`json ... \`\`\`) that fulfills the user's instruction.`,E=await xl([{role:"system",content:j},{role:"user",content:O}],R),q=E.match(/```(?:json)?\s*([\s\S]*?)```/)||E.match(/(\{[\s\S]*\})/);if(q){const $=JSON.parse(q[1]);if($&&Array.isArray($.tasks)){const J=Xb(s,$);u({proposedDef:$,diff:J,messageId:`inline-cmdk-${Date.now()}`}),h(""),r(null);return}}x("⚠️ 未能解析 AI 返回的工作流 JSON,请重试")}catch(N){x(`❌ 调用失败: ${N?.message||"未知错误"}`)}finally{m(!1)}};return o.jsxs("div",{style:{position:"absolute",top:68,left:"50%",transform:"translateX(-50%)",width:540,maxWidth:"calc(100vw - 40px)",zIndex:2200,background:"rgba(15, 23, 42, 0.96)",backdropFilter:"blur(20px)",border:"1px solid rgba(99, 102, 241, 0.45)",borderRadius:14,boxShadow:"0 24px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(99, 102, 241, 0.15)",overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 14px",background:"linear-gradient(90deg, rgba(99, 102, 241, 0.18), rgba(56, 189, 248, 0.1))",borderBottom:"1px solid rgba(148, 163, 184, 0.15)"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx("span",{style:{fontSize:10,fontWeight:700,padding:"2px 7px",borderRadius:5,background:"#6366f1",color:"#fff"},children:"⌘K 画布内联指令"}),o.jsxs("span",{style:{fontSize:11,color:"#cbd5e1",fontFamily:"monospace"},children:["锚点:"," ",o.jsx("strong",{style:{color:"#38bdf8"},children:b?`${b.name} (${b.taskReferenceName})`:"画布全局"})]}),k.length>0&&o.jsxs("span",{style:{fontSize:10,color:"#94a3b8"},children:["· 可见上游 ",k.length," 个节点"]})]}),o.jsx("button",{type:"button",onClick:()=>r(null),style:{background:"none",border:"none",color:"#94a3b8",cursor:"pointer",fontSize:13},children:"ESC ✕"})]}),o.jsxs("form",{onSubmit:w,style:{display:"flex",padding:"10px 14px",gap:8},children:[o.jsx("input",{ref:v,type:"text",value:f,onChange:T=>h(T.target.value),disabled:p,placeholder:"输入自然语言指令,如:在此节点后加一个风控 HTTP 校验并判断状态码...",style:{flex:1,padding:"9px 12px",borderRadius:8,border:"1px solid rgba(148, 163, 184, 0.25)",background:"rgba(2, 6, 23, 0.65)",color:"#f8fafc",fontSize:13,outline:"none"}}),o.jsx("button",{type:"submit",disabled:p||!f.trim(),style:{padding:"0 16px",borderRadius:8,border:"none",background:"linear-gradient(135deg, #6366f1, #38bdf8)",color:"#fff",fontSize:12,fontWeight:700,cursor:p||!f.trim()?"not-allowed":"pointer",opacity:p||!f.trim()?.6:1},children:p?"生成中...":"执行 ↵"})]}),b&&o.jsxs("div",{style:{padding:"6px 14px 12px",display:"flex",flexWrap:"wrap",gap:6},children:[r1.map(T=>o.jsx("button",{type:"button",onClick:()=>_(T),style:{fontSize:11,padding:"4px 10px",borderRadius:999,border:"1px solid rgba(148, 163, 184, 0.2)",background:"rgba(30, 41, 59, 0.65)",color:"#cbd5e1",cursor:"pointer"},children:T.label},T.label)),o.jsx("button",{type:"button",onClick:()=>{c(b,!0),r(null)},style:{fontSize:11,padding:"4px 10px",borderRadius:999,border:"1px solid rgba(56, 189, 248, 0.3)",background:"rgba(56, 189, 248, 0.1)",color:"#38bdf8",cursor:"pointer"},children:"⚙️ 打开属性抽屉"})]}),g&&o.jsx("div",{style:{padding:"6px 14px 10px",fontSize:11,color:"#38bdf8",borderTop:"1px solid rgba(148, 163, 184, 0.1)"},children:g})]})},s1={taskNode:tb,decisionNode:nb,forkNode:ym.ForkNode,joinNode:ym.JoinNode,loopNode:ab,subWorkflowNode:lb,plusNode:db,dynamicPlaceholderNode:fb},a1={addableEdge:gb},o1=({onNodeClick:e,searchQuery:t="",onSave:r,onRequestImport:n,executionActions:s})=>{const{nodes:a,edges:i,onNodesChange:l,onEdgesChange:c,onConnect:d,mode:u,viewMode:f,selectedTask:h,setSelectedTask:p,selectTaskAction:m,theme:g,edgeType:x,addNode:v,nodesLocked:y,executionData:b,validationResults:k,isDetailPanelOpen:_,setIsDetailPanelOpen:w,workflowDef:T,setWorkflow:O,dynamicRuntimeTasksByFork:D,layoutDirection:N,simState:S,isSimRunning:R,workflowLoadKey:j,showDataLineage:E}=oe(),q=I.useMemo(()=>{if(f==="developer")return new Set(a.map(te=>te.id));const Q=Vv[f],X=new Set;return a.forEach(te=>{if(te.type==="dynamicPlaceholderNode"){X.add(te.id);return}if(te.type==="plusNode"){u==="edit"&&(!te.data?.parentRef||X.has(te.data.parentRef))&&X.add(te.id);return}if(u==="run"&&b){const le=b[te.id]?.status;if(le==="FAILED"||le==="FAILED_WITH_TERMINAL_ERROR"||le==="TIMED_OUT"||le==="IN_PROGRESS"){X.add(te.id);return}}if(te.parentId)return;const G=Ue.find(le=>le.type===te.data.taskType)?.viewCategory??"business";Q.includes(G)&&X.add(te.id)}),a.forEach(te=>{if(te.parentId&&X.has(te.parentId)){if(te.type==="plusNode"){u==="edit"&&X.add(te.id);return}const G=Ue.find(le=>le.type===te.data.taskType)?.viewCategory??"business";Q.includes(G)&&X.add(te.id)}}),X},[a,f,u,b]),$=I.useCallback(Q=>{if(q.size===a.length)return Q;const X={};Q.forEach(G=>{X[G.source]||(X[G.source]=[]),X[G.source].push(G)});const te=[],de=new Set;return Q.forEach(G=>{if(!q.has(G.source))return;if(q.has(G.target)){const K=`${G.source}->${G.target}`;de.has(K)||(de.add(K),te.push(G));return}const le=[{to:G.target,label:G.label}],C=new Set;for(;le.length;){const K=le.shift();if(!C.has(K.to)){if(C.add(K.to),q.has(K.to)){const ae=`${G.source}->${K.to}`;de.has(ae)||(de.add(ae),te.push({...G,id:ae,target:K.to,label:K.label??G.label}));continue}(X[K.to]??[]).forEach(ae=>le.push({to:ae.target,label:K.label??ae.label}))}}}),te},[q,a.length]),V=Cm()?.aiStore??jm,A=V(Q=>Q.pendingProposal),B=V(Q=>Q.clearProposal),P=V(Q=>Q.recordAccept),U=V(Q=>Q.recordReject),se=V(Q=>Q.pushUndo),L=I.useMemo(()=>{if(!A)return null;try{const{nodes:Q,edges:X}=Ae(A.proposedDef,N,{hideEmptyBranches:!1}),{nodes:te,edges:de}=je(Q,X,{direction:N,mode:"edit"}),G=new Set(A.diff.added),le=new Set(A.diff.modified),C=new Set(A.diff.removed),K=new Map(a.map(Z=>[Z.data?.taskReferenceName,Z])),ae=te.filter(Z=>Z.type!=="plusNode").map(Z=>{const ye=Z.data?.taskReferenceName,xe=G.has(ye)?"added":le.has(ye)?"modified":void 0;return{...Z,draggable:!1,selectable:!1,data:{...Z.data,proposalStatus:xe,layoutDirection:N}}}),re=[...C].map(Z=>K.get(Z)).filter(Z=>Z!=null).map(Z=>({...Z,draggable:!1,selectable:!1,data:{...Z.data,proposalStatus:"removed"}}));return{nodes:[...ae,...re],edges:de}}catch{return null}},[A,a,N]),{fitView:F}=M.useReactFlow(),[z,H]=I.useState(!1),[Y,ie]=I.useState(null),[fe,ve]=I.useState(!1),[be,W]=I.useState(!1),{confirm:ke,confirmState:ee,handleConfirm:me,handleCancel:ne}=Hb(),{toasts:_e,showToast:ce,dismissToast:he}=Jb();zb({confirm:ke,showToast:ce,onSave:r}),I.useEffect(()=>{if(h){const Q=a.find(X=>X.data.taskReferenceName===h.taskReferenceName);Q&&F({nodes:[Q],duration:800,padding:.5})}},[h?.taskReferenceName,F]),I.useEffect(()=>{const Q=()=>{F({duration:800})};return window.addEventListener("workflow-zoom-to-fit",Q),()=>window.removeEventListener("workflow-zoom-to-fit",Q)},[F]),I.useEffect(()=>{if(j===0)return;const Q=setTimeout(()=>{F({duration:600,padding:.12})},50);return()=>clearTimeout(Q)},[j,F]),I.useEffect(()=>{const Q=de=>{e&&de.detail&&de.detail.task&&e(de.detail.task)},X=de=>{if(u==="edit"){const{loopId:G,afterRef:le}=de.detail;ie(le?{sourceId:le,edgeData:{}}:{sourceId:G,edgeData:{isLoopAdd:!0}}),H(!0)}},te=de=>{u==="edit"&&(ie({sourceId:de.detail.source,targetId:de.detail.target,edgeId:de.detail.id,edgeData:de.detail.edgeData}),H(!0))};return document.addEventListener("miniTaskClick",Q),document.addEventListener("loopAddNodeRequested",X),window.addEventListener("edgeAddNode",te),()=>{document.removeEventListener("miniTaskClick",Q),document.removeEventListener("loopAddNodeRequested",X),window.removeEventListener("edgeAddNode",te)}},[u,e]);const Fe=I.useCallback(Q=>{if(Y){const{sourceId:X,targetId:te,edgeId:de,edgeData:G}=Y;v({data:{label:`New ${Q}`,taskReferenceName:`${Q.toLowerCase()}_${Date.now()}`,taskType:Q}},X,te,de,G)}H(!1),ie(null)},[Y,v]),Se=I.useMemo(()=>{const Q={layoutedNodes:null,extraNodes:[],extraEdges:[],removedEdgeIds:new Set,removedNodeIds:new Set};if(u!=="run")return Q;const X=a.filter(K=>K.type==="forkNode"&&K.data.taskType==="FORK_JOIN_DYNAMIC");if(!X.length)return Q;const te=[],de=[],G=new Set,le=new Set;for(const K of X){const ae=D[K.id]||[],re=`${K.id}_dynamic_placeholder`,Z=i.find(ue=>ue.target===re),ye=i.find(ue=>ue.source===re);let xe,pe;if(ye)xe=ye.target,pe=a.find(ue=>ue.id===xe);else{const ue=a.indexOf(K);if(pe=a.slice(ue).find(Te=>Te.type==="joinNode"),!pe)continue;xe=pe.id}pe&&(ye&&G.add(ye.id),Z&&G.add(Z.id),le.add(re),ae.length&&ae.forEach(ue=>{const Te=`dynamic_rt_${ue.referenceTaskName}`;te.push({id:Te,type:"taskNode",data:{label:ue.taskDefName||ue.referenceTaskName,task:{name:ue.taskDefName||ue.referenceTaskName,taskReferenceName:ue.referenceTaskName,type:ue.taskType||"SIMPLE"},taskReferenceName:ue.referenceTaskName,taskType:ue.taskType||"SIMPLE",isDynamicRuntime:!0,layoutDirection:N},position:{x:0,y:0}}),de.push({id:`e-${K.id}-${Te}`,source:K.id,target:Te,style:{strokeDasharray:"4,4"}}),de.push({id:`e-${Te}-${xe}`,source:Te,target:xe,style:{strokeDasharray:"4,4"}})}))}let C=null;if(te.length>0){const K=[...a.filter(Z=>!le.has(Z.id)),...te],ae=[...i.filter(Z=>!G.has(Z.id)),...de];C=je(K,ae,{direction:N,mode:"run"}).nodes}return{layoutedNodes:C,extraNodes:te,extraEdges:de,removedEdgeIds:G,removedNodeIds:le}},[u,D,a,i,N]),ge=I.useMemo(()=>{const X=[...$(i.filter(G=>!Se.removedEdgeIds.has(G.id))),...Se.extraEdges],te=R||Object.keys(S).length>0,de=G=>G.startsWith("dynamic_rt_")?G.slice(11):G;return X.map(G=>{const le=G.id.includes("loop-back"),C=G.source.startsWith("dynamic_rt_")||G.target.startsWith("dynamic_rt_"),K=g==="light"?"#64748b":"#94a3b8";let re={...{...G.style,stroke:K,strokeWidth:2.2,strokeDasharray:le?"5,5":C?"4,4":void 0}},Z=!1;if(u==="run"&&b){const ue=de(G.source),Te=de(G.target),Pe=b[ue]?.status,Re=b[Te]?.status,Be=Pe==="COMPLETED"||Pe==="COMPLETED_WITH_ERRORS";Be&&(Re==="COMPLETED"||Re==="COMPLETED_WITH_ERRORS")?(re={...re,stroke:"var(--status-completed)",strokeWidth:3.2,opacity:1},Z=!1):Be&&(Re==="IN_PROGRESS"||Re==="SCHEDULED")?(re={...re,stroke:"var(--status-in-progress)",strokeWidth:3.5,opacity:1},Z=!0):Be&&(Re==="FAILED"||Re==="FAILED_WITH_TERMINAL_ERROR")?(re={...re,stroke:"var(--status-failed)",strokeWidth:3.5,opacity:1},Z=!1):Be&&Re==="TIMED_OUT"?(re={...re,stroke:"var(--status-timed-out)",strokeWidth:3.5,opacity:1},Z=!1):(re={...re,stroke:K,strokeWidth:1.8,opacity:.28},Z=!1)}else if(te){const ue=S[G.source],Te=S[G.target];ue==="done"&&Te==="done"?(re={...re,stroke:"var(--status-completed)",strokeWidth:3.2},Z=!1):ue==="done"&&Te==="running"&&(re={...re,stroke:"var(--status-in-progress)",strokeWidth:3.5},Z=!0)}const ye=G.source.endsWith("_dynamic_placeholder")||G.target.endsWith("_dynamic_placeholder"),xe=G.source==="__workflow_start__"||G.source.startsWith("__loop_start__")||G.target.startsWith("__loop_end__")||G.target.includes("_empty_"),pe=u==="edit"&&!le&&!ye&&!xe;return{...G,type:"addableEdge",data:{...G.data,mode:u,isAddable:pe,edgeType:x,label:G.label},markerEnd:{type:M.MarkerType.ArrowClosed,width:18,height:18,color:String(re.stroke||K)},style:re,animated:Z}})},[i,x,g,u,b,Se,$,R,S]),Qe=I.useMemo(()=>{if(!E||!T)return[];const Q=nm(T),X=h?.taskReferenceName,te=[],de=new Set;return Q.edges.forEach((G,le)=>{if(!q.has(G.sourceRef)||!q.has(G.targetRef)||X&&G.sourceRef!==X&&G.targetRef!==X)return;const C=`${G.sourceRef}->${G.targetRef}:${G.fieldPath}`;de.has(C)||(de.add(C),te.push({id:`wlsp-dfg-${le}-${C}`,source:G.sourceRef,target:G.targetRef,type:"addableEdge",animated:!0,label:`🔗 ${G.fieldPath}`,data:{mode:"view",isAddable:!1,edgeType:"default",label:`🔗 ${G.fieldPath}`},markerEnd:{type:M.MarkerType.ArrowClosed,width:16,height:16,color:"#38bdf8"},style:{stroke:"#38bdf8",strokeWidth:2.4,strokeDasharray:"6,4",opacity:.95}}))}),te},[E,T,q,h?.taskReferenceName]),Ee="var(--bg-secondary)",rt=I.useMemo(()=>a.filter(Q=>Q.type!=="plusNode").length,[a]);return o.jsxs("div",{style:{width:"100%",height:"100%",position:"relative",background:Ee},children:[o.jsxs(M,{nodes:I.useMemo(()=>{if(L)return L.nodes;const Q=new Set(k.errors.filter(G=>G.type==="TASK").map(G=>G.ref)),X=new Set(k.warnings.filter(G=>G.type==="TASK").map(G=>G.ref)),te=t.toLowerCase();return(Se.layoutedNodes?Se.layoutedNodes.filter(G=>G.id.startsWith("dynamic_rt_")||q.has(G.id)):a.filter(G=>!Se.removedNodeIds.has(G.id)&&q.has(G.id)).concat(Se.extraNodes)).map(G=>{const le=G.data.taskReferenceName,C=S[le];return{...G,selected:h?.taskReferenceName===le,data:{...G.data,isError:u==="edit"&&Q.has(le),hasWarning:u==="edit"&&X.has(le),isHighlighted:t?(G.data.label||"").toLowerCase().includes(te)||(G.data.taskReferenceName||"").toLowerCase().includes(te):!1,simRunning:C==="running",simDone:C==="done"}}})},[a,k,t,h,Se,q,S,u,L]),edges:L?.edges??[...ge,...Qe],onNodesChange:l,onEdgesChange:c,onConnect:d,nodeTypes:s1,edgeTypes:a1,onNodeClick:(Q,X)=>{if(X.type==="plusNode"){ie({sourceId:X.data.parentRef,edgeData:X.data.edgeData||{}}),H(!0);return}if(X.type==="loopNode"){const de=X.data.task||null;p(de),e&&e(de);return}const te=X.data.task||null;p(te),e&&e(te)},onPaneClick:()=>{p(null),u!=="run"&&w(!1)},fitView:!0,nodesDraggable:!y,nodesConnectable:!y,elementsSelectable:!0,minZoom:.2,maxZoom:2,children:[o.jsx(M.Background,{color:"var(--border-primary)",gap:20}),o.jsx(M.Panel,{position:"bottom-left",style:{marginBottom:"20px",marginLeft:"20px",zIndex:1e3},children:o.jsx(yb,{})}),rt>=5&&!_&&!fe&&o.jsx(M.MiniMap,{position:"bottom-right",pannable:!0,zoomable:!0,style:{marginBottom:20,marginRight:20,width:160,height:110,backgroundColor:"var(--glass-surface)"},maskColor:g==="light"?"rgba(241, 245, 249, 0.7)":"rgba(15, 23, 42, 0.7)",nodeColor:Q=>{if(Q.type==="plusNode")return"transparent";if(u==="run"&&b){const X=Q.data?.taskReferenceName,te=b[X]?.status;return te==="COMPLETED"?"#10b981":te==="FAILED"||te==="FAILED_WITH_TERMINAL_ERROR"?"#ef4444":te==="IN_PROGRESS"||te==="SCHEDULED"?"#3b82f6":te==="TIMED_OUT"||te==="COMPLETED_WITH_ERRORS"?"#f59e0b":"#64748b"}return Q.type==="decisionNode"?"#f59e0b":Q.type==="forkNode"||Q.type==="joinNode"?"#10b981":Q.type==="loopNode"?"#8b5cf6":"#3b82f6"}}),u==="run"&&o.jsx(M.Panel,{position:"bottom-center",children:o.jsx(hb,{})}),o.jsx(mb,{isOpen:fe,onClose:()=>ve(!1),theme:g,onTaskSelect:Q=>{m(Q,!0)}}),A&&o.jsx(M.Panel,{position:"top-left",style:{marginTop:"14px",marginLeft:"16px",zIndex:1500},children:o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"8px 16px",borderRadius:"999px",background:"rgba(15, 23, 42, 0.94)",backdropFilter:"blur(16px)",border:"1px solid rgba(99, 102, 241, 0.45)",boxShadow:"0 12px 32px rgba(0, 0, 0, 0.4)",color:"#f8fafc",fontSize:"12px"},children:[o.jsx("span",{style:{fontWeight:700,color:"#a5b4fc"},children:"👻 Shadow Graph 架构变更预览"}),o.jsxs("div",{style:{display:"flex",gap:"8px",fontFamily:"monospace",fontSize:"11px"},children:[A.diff.added.length>0&&o.jsxs("span",{style:{color:"#34d399",fontWeight:700},children:["+",A.diff.added.length," 新增"]}),A.diff.modified.length>0&&o.jsxs("span",{style:{color:"#fbbf24",fontWeight:700},children:["~",A.diff.modified.length," 修改"]}),A.diff.removed.length>0&&o.jsxs("span",{style:{color:"#f87171",fontWeight:700},children:["-",A.diff.removed.length," 移除"]})]}),o.jsxs("div",{style:{display:"flex",gap:"6px"},children:[o.jsx("button",{type:"button",onClick:()=>{T&&se(T),O(A.proposedDef),P(),B()},style:{padding:"4px 12px",borderRadius:"999px",border:"none",background:"#10b981",color:"#fff",fontSize:"11px",fontWeight:700,cursor:"pointer"},children:"✓ 采纳上屏"}),o.jsx("button",{type:"button",onClick:()=>{U(),B()},style:{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(248, 113, 113, 0.4)",background:"rgba(239, 68, 68, 0.14)",color:"#f87171",fontSize:"11px",fontWeight:600,cursor:"pointer"},children:"✕ 拒绝"})]})]})}),o.jsx("div",{style:{position:"absolute",top:14,right:16,zIndex:1e3},children:o.jsx(bb,{onShowHealthCheck:()=>ve(!fe),showHealthCheck:fe,onShowSettings:()=>W(!0),executionActions:s})})]}),o.jsx(Vb,{}),o.jsx(n1,{}),!T&&!A&&o.jsx(wb,{onRequestImport:n}),T&&a.length===0&&u==="edit"&&o.jsx("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:10,display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:o.jsxs("button",{className:"empty-state-btn primary",style:{padding:"12px 24px",borderRadius:"8px",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",fontSize:"16px",fontWeight:500,boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1)"},onClick:()=>{ie({sourceId:"start",targetId:"end",edgeId:"new",edgeData:{}}),H(!0)},children:[o.jsx("span",{style:{fontSize:"20px",lineHeight:1},children:"+"}),"添加第一个任务"]})}),z&&o.jsx(pb,{theme:g,onSelect:Fe,onCancel:()=>H(!1)}),o.jsx(Sb,{isOpen:be,onClose:()=>W(!1)}),ee&&o.jsx(mr,{message:ee.message,onConfirm:me,onCancel:ne}),o.jsx(Eb,{messages:_e,onDismiss:he})]})},i1=(e,t)=>{const r=t?`当前工作流(JSON):
|
|
85
|
+
Return ONLY the updated full WorkflowDef JSON object (wrapped in \`\`\`json ... \`\`\`) that fulfills the user's instruction.`,C=await Il([{role:"system",content:E},{role:"user",content:R}],D),z=C.match(/```(?:json)?\s*([\s\S]*?)```/)||C.match(/(\{[\s\S]*\})/);if(z){const W=JSON.parse(z[1]);if(W&&Array.isArray(W.tasks)){const K=T1(s,W);d({proposedDef:W,diff:K,messageId:`inline-cmdk-${Date.now()}`}),h(""),r(null);return}}y("⚠️ 未能解析 AI 返回的工作流 JSON,请重试")}catch(T){y(`❌ 调用失败: ${T?.message||"未知错误"}`)}finally{m(!1)}};return a.jsxs("div",{style:{position:"absolute",top:68,left:"50%",transform:"translateX(-50%)",width:540,maxWidth:"calc(100vw - 40px)",zIndex:2200,background:"rgba(15, 23, 42, 0.96)",backdropFilter:"blur(20px)",border:"1px solid rgba(99, 102, 241, 0.45)",borderRadius:14,boxShadow:"0 24px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(99, 102, 241, 0.15)",overflow:"hidden"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 14px",background:"linear-gradient(90deg, rgba(99, 102, 241, 0.18), rgba(56, 189, 248, 0.1))",borderBottom:"1px solid rgba(148, 163, 184, 0.15)"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[a.jsx("span",{style:{fontSize:10,fontWeight:700,padding:"2px 7px",borderRadius:5,background:"#6366f1",color:"#fff"},children:"⌘K 画布内联指令"}),a.jsxs("span",{style:{fontSize:11,color:"#cbd5e1",fontFamily:"monospace"},children:["锚点:"," ",a.jsx("strong",{style:{color:"#38bdf8"},children:v?`${v.name} (${v.taskReferenceName})`:"画布全局"})]}),k.length>0&&a.jsxs("span",{style:{fontSize:10,color:"#94a3b8"},children:["· 可见上游 ",k.length," 个节点"]})]}),a.jsx("button",{type:"button",onClick:()=>r(null),style:{background:"none",border:"none",color:"#94a3b8",cursor:"pointer",fontSize:13},children:"ESC ✕"})]}),a.jsxs("form",{onSubmit:S,style:{display:"flex",padding:"10px 14px",gap:8},children:[a.jsx("input",{ref:b,type:"text",value:p,onChange:j=>h(j.target.value),disabled:f,placeholder:"输入自然语言指令,如:在此节点后加一个风控 HTTP 校验并判断状态码...",style:{flex:1,padding:"9px 12px",borderRadius:8,border:"1px solid rgba(148, 163, 184, 0.25)",background:"rgba(2, 6, 23, 0.65)",color:"#f8fafc",fontSize:13,outline:"none"}}),a.jsx("button",{type:"submit",disabled:f||!p.trim(),style:{padding:"0 16px",borderRadius:8,border:"none",background:"linear-gradient(135deg, #6366f1, #38bdf8)",color:"#fff",fontSize:12,fontWeight:700,cursor:f||!p.trim()?"not-allowed":"pointer",opacity:f||!p.trim()?.6:1},children:f?"生成中...":"执行 ↵"})]}),v&&a.jsxs("div",{style:{padding:"6px 14px 12px",display:"flex",flexWrap:"wrap",gap:6},children:[P1.map(j=>a.jsx("button",{type:"button",onClick:()=>_(j),style:{fontSize:11,padding:"4px 10px",borderRadius:999,border:"1px solid rgba(148, 163, 184, 0.2)",background:"rgba(30, 41, 59, 0.65)",color:"#cbd5e1",cursor:"pointer"},children:j.label},j.label)),a.jsx("button",{type:"button",onClick:()=>{c(v,!0),r(null)},style:{fontSize:11,padding:"4px 10px",borderRadius:999,border:"1px solid rgba(56, 189, 248, 0.3)",background:"rgba(56, 189, 248, 0.1)",color:"#38bdf8",cursor:"pointer"},children:"⚙️ 打开属性抽屉"})]}),g&&a.jsx("div",{style:{padding:"6px 14px 10px",fontSize:11,color:"#38bdf8",borderTop:"1px solid rgba(148, 163, 184, 0.1)"},children:g})]})},D1={taskNode:Pv,decisionNode:Dv,forkNode:Tm.ForkNode,joinNode:Tm.JoinNode,loopNode:Lv,subWorkflowNode:zv,plusNode:Wv,dynamicPlaceholderNode:Bv},A1={addableEdge:Kv},L1=({onNodeClick:e,searchQuery:t="",onSave:r,onRequestImport:n,executionActions:s})=>{const{nodes:o,edges:i,onNodesChange:l,onEdgesChange:c,onConnect:u,mode:d,viewMode:p,selectedTask:h,setSelectedTask:f,selectTaskAction:m,theme:g,edgeType:y,addNode:b,nodesLocked:x,executionData:v,validationResults:k,isDetailPanelOpen:_,setIsDetailPanelOpen:S,workflowDef:j,setWorkflow:R,dynamicRuntimeTasksByFork:L,layoutDirection:T,simState:w,isSimRunning:D,workflowLoadKey:E,showDataLineage:C}=le(),z=N.useMemo(()=>{if(p==="developer")return new Set(o.map(ne=>ne.id));const Q=Iv[p],Y=new Set;return o.forEach(ne=>{if(ne.type==="dynamicPlaceholderNode"){Y.add(ne.id);return}if(ne.type==="plusNode"){d==="edit"&&(!ne.data?.parentRef||Y.has(ne.data.parentRef))&&Y.add(ne.id);return}if(d==="run"&&v){const de=v[ne.id]?.status;if(de==="FAILED"||de==="FAILED_WITH_TERMINAL_ERROR"||de==="TIMED_OUT"||de==="IN_PROGRESS"){Y.add(ne.id);return}}if(ne.parentId)return;const G=Ke.find(de=>de.type===ne.data.taskType)?.viewCategory??"business";Q.includes(G)&&Y.add(ne.id)}),o.forEach(ne=>{if(ne.parentId&&Y.has(ne.parentId)){if(ne.type==="plusNode"){d==="edit"&&Y.add(ne.id);return}const G=Ke.find(de=>de.type===ne.data.taskType)?.viewCategory??"business";Q.includes(G)&&Y.add(ne.id)}}),Y},[o,p,d,v]),W=N.useCallback(Q=>{if(z.size===o.length)return Q;const Y={};Q.forEach(G=>{Y[G.source]||(Y[G.source]=[]),Y[G.source].push(G)});const ne=[],fe=new Set;return Q.forEach(G=>{if(!z.has(G.source))return;if(z.has(G.target)){const V=`${G.source}->${G.target}`;fe.has(V)||(fe.add(V),ne.push(G));return}const de=[{to:G.target,label:G.label}],P=new Set;for(;de.length;){const V=de.shift();if(!P.has(V.to)){if(P.add(V.to),z.has(V.to)){const oe=`${G.source}->${V.to}`;fe.has(oe)||(fe.add(oe),ne.push({...G,id:oe,target:V.to,label:V.label??G.label}));continue}(Y[V.to]??[]).forEach(oe=>de.push({to:oe.target,label:V.label??oe.label}))}}}),ne},[z,o.length]),M=qm()?.aiStore??Mm,I=M(Q=>Q.pendingProposal),F=M(Q=>Q.clearProposal),O=M(Q=>Q.recordAccept),J=M(Q=>Q.recordReject),Z=M(Q=>Q.pushUndo),A=N.useMemo(()=>{if(!I)return null;try{const{nodes:Q,edges:Y}=De(I.proposedDef,T,{hideEmptyBranches:!1}),{nodes:ne,edges:fe}=Ne(Q,Y,{direction:T,mode:"edit"}),G=new Set(I.diff.added),de=new Set(I.diff.modified),P=new Set(I.diff.removed),V=new Map(o.map(ee=>[ee.data?.taskReferenceName,ee])),oe=ne.filter(ee=>ee.type!=="plusNode").map(ee=>{const xe=ee.data?.taskReferenceName,be=G.has(xe)?"added":de.has(xe)?"modified":void 0;return{...ee,draggable:!1,selectable:!1,data:{...ee.data,proposalStatus:be,layoutDirection:T}}}),ae=[...P].map(ee=>V.get(ee)).filter(ee=>ee!=null).map(ee=>({...ee,draggable:!1,selectable:!1,data:{...ee.data,proposalStatus:"removed"}}));return{nodes:[...oe,...ae],edges:fe}}catch{return null}},[I,o,T]),{fitView:B}=q.useReactFlow(),[U,H]=N.useState(!1),[X,ie]=N.useState(null),[ge,Se]=N.useState(!1),[we,$]=N.useState(!1),{confirm:ke,confirmState:te,handleConfirm:se,handleCancel:re}=v1(),{toasts:ve,showToast:ue,dismissToast:pe}=k1();b1({confirm:ke,showToast:ue,onSave:r}),N.useEffect(()=>{if(h){const Q=o.find(Y=>Y.data.taskReferenceName===h.taskReferenceName);Q&&B({nodes:[Q],duration:800,padding:.5})}},[h?.taskReferenceName,B]),N.useEffect(()=>{const Q=()=>{B({duration:800})};return window.addEventListener("workflow-zoom-to-fit",Q),()=>window.removeEventListener("workflow-zoom-to-fit",Q)},[B]),N.useEffect(()=>{if(E===0)return;const Q=setTimeout(()=>{B({duration:600,padding:.12})},50);return()=>clearTimeout(Q)},[E,B]),N.useEffect(()=>{const Q=fe=>{e&&fe.detail&&fe.detail.task&&e(fe.detail.task)},Y=fe=>{if(d==="edit"){const{loopId:G,afterRef:de}=fe.detail;ie(de?{sourceId:de,edgeData:{}}:{sourceId:G,edgeData:{isLoopAdd:!0}}),H(!0)}},ne=fe=>{d==="edit"&&(ie({sourceId:fe.detail.source,targetId:fe.detail.target,edgeId:fe.detail.id,edgeData:fe.detail.edgeData}),H(!0))};return document.addEventListener("miniTaskClick",Q),document.addEventListener("loopAddNodeRequested",Y),window.addEventListener("edgeAddNode",ne),()=>{document.removeEventListener("miniTaskClick",Q),document.removeEventListener("loopAddNodeRequested",Y),window.removeEventListener("edgeAddNode",ne)}},[d,e]);const Fe=N.useCallback(Q=>{if(X){const{sourceId:Y,targetId:ne,edgeId:fe,edgeData:G}=X;b({data:{label:`New ${Q}`,taskReferenceName:`${Q.toLowerCase()}_${Date.now()}`,taskType:Q}},Y,ne,fe,G)}H(!1),ie(null)},[X,b]),_e=N.useMemo(()=>{const Q={layoutedNodes:null,extraNodes:[],extraEdges:[],removedEdgeIds:new Set,removedNodeIds:new Set};if(d!=="run")return Q;const Y=o.filter(V=>V.type==="forkNode"&&V.data.taskType==="FORK_JOIN_DYNAMIC");if(!Y.length)return Q;const ne=[],fe=[],G=new Set,de=new Set;for(const V of Y){const oe=L[V.id]||[],ae=`${V.id}_dynamic_placeholder`,ee=i.find(he=>he.target===ae),xe=i.find(he=>he.source===ae);let be,me;if(xe)be=xe.target,me=o.find(he=>he.id===be);else{const he=o.indexOf(V);if(me=o.slice(he).find(Ie=>Ie.type==="joinNode"),!me)continue;be=me.id}me&&(xe&&G.add(xe.id),ee&&G.add(ee.id),de.add(ae),oe.length&&oe.forEach(he=>{const Ie=`dynamic_rt_${he.referenceTaskName}`;ne.push({id:Ie,type:"taskNode",data:{label:he.taskDefName||he.referenceTaskName,task:{name:he.taskDefName||he.referenceTaskName,taskReferenceName:he.referenceTaskName,type:he.taskType||"SIMPLE"},taskReferenceName:he.referenceTaskName,taskType:he.taskType||"SIMPLE",isDynamicRuntime:!0,layoutDirection:T},position:{x:0,y:0}}),fe.push({id:`e-${V.id}-${Ie}`,source:V.id,target:Ie,style:{strokeDasharray:"4,4"}}),fe.push({id:`e-${Ie}-${be}`,source:Ie,target:be,style:{strokeDasharray:"4,4"}})}))}let P=null;if(ne.length>0){const V=[...o.filter(ee=>!de.has(ee.id)),...ne],oe=[...i.filter(ee=>!G.has(ee.id)),...fe];P=Ne(V,oe,{direction:T,mode:"run"}).nodes}return{layoutedNodes:P,extraNodes:ne,extraEdges:fe,removedEdgeIds:G,removedNodeIds:de}},[d,L,o,i,T]),ye=N.useMemo(()=>{const Y=[...W(i.filter(G=>!_e.removedEdgeIds.has(G.id))),..._e.extraEdges],ne=D||Object.keys(w).length>0,fe=G=>G.startsWith("dynamic_rt_")?G.slice(11):G;return Y.map(G=>{const de=G.id.includes("loop-back"),P=G.source.startsWith("dynamic_rt_")||G.target.startsWith("dynamic_rt_"),V=g==="light"?"#64748b":"#94a3b8";let ae={...{...G.style,stroke:V,strokeWidth:2.2,strokeDasharray:de?"5,5":P?"4,4":void 0}},ee=!1;if(d==="run"&&v){const he=fe(G.source),Ie=fe(G.target),Oe=v[he]?.status,Ee=v[Ie]?.status,Be=Oe==="COMPLETED"||Oe==="COMPLETED_WITH_ERRORS";Be&&(Ee==="COMPLETED"||Ee==="COMPLETED_WITH_ERRORS")?(ae={...ae,stroke:"var(--status-completed)",strokeWidth:3.2,opacity:1},ee=!1):Be&&(Ee==="IN_PROGRESS"||Ee==="SCHEDULED")?(ae={...ae,stroke:"var(--status-in-progress)",strokeWidth:3.5,opacity:1},ee=!0):Be&&(Ee==="FAILED"||Ee==="FAILED_WITH_TERMINAL_ERROR")?(ae={...ae,stroke:"var(--status-failed)",strokeWidth:3.5,opacity:1},ee=!1):Be&&Ee==="TIMED_OUT"?(ae={...ae,stroke:"var(--status-timed-out)",strokeWidth:3.5,opacity:1},ee=!1):(ae={...ae,stroke:V,strokeWidth:1.8,opacity:.28},ee=!1)}else if(ne){const he=w[G.source],Ie=w[G.target];he==="done"&&Ie==="done"?(ae={...ae,stroke:"var(--status-completed)",strokeWidth:3.2},ee=!1):he==="done"&&Ie==="running"&&(ae={...ae,stroke:"var(--status-in-progress)",strokeWidth:3.5},ee=!0)}const xe=G.source.endsWith("_dynamic_placeholder")||G.target.endsWith("_dynamic_placeholder"),be=G.source==="__workflow_start__"||G.source.startsWith("__loop_start__")||G.target.startsWith("__loop_end__")||G.target.includes("_empty_"),me=d==="edit"&&!de&&!xe&&!be;return{...G,type:"addableEdge",data:{...G.data,mode:d,isAddable:me,edgeType:y,label:G.label},markerEnd:{type:q.MarkerType.ArrowClosed,width:18,height:18,color:String(ae.stroke||V)},style:ae,animated:ee}})},[i,y,g,d,v,_e,W,D,w]),et=N.useMemo(()=>{if(!C||!j)return[];const Q=hm(j),Y=h?.taskReferenceName,ne=[],fe=new Set;return Q.edges.forEach((G,de)=>{if(!z.has(G.sourceRef)||!z.has(G.targetRef)||Y&&G.sourceRef!==Y&&G.targetRef!==Y)return;const P=`${G.sourceRef}->${G.targetRef}:${G.fieldPath}`;fe.has(P)||(fe.add(P),ne.push({id:`wlsp-dfg-${de}-${P}`,source:G.sourceRef,target:G.targetRef,type:"addableEdge",animated:!0,label:`🔗 ${G.fieldPath}`,data:{mode:"view",isAddable:!1,edgeType:"default",label:`🔗 ${G.fieldPath}`},markerEnd:{type:q.MarkerType.ArrowClosed,width:16,height:16,color:"#38bdf8"},style:{stroke:"#38bdf8",strokeWidth:2.4,strokeDasharray:"6,4",opacity:.95}}))}),ne},[C,j,z,h?.taskReferenceName]),Te="var(--bg-secondary)",st=N.useMemo(()=>o.filter(Q=>Q.type!=="plusNode").length,[o]);return a.jsxs("div",{style:{width:"100%",height:"100%",position:"relative",background:Te},children:[a.jsxs(q,{nodes:N.useMemo(()=>{if(A)return A.nodes;const Q=new Set(k.errors.filter(G=>G.type==="TASK").map(G=>G.ref)),Y=new Set(k.warnings.filter(G=>G.type==="TASK").map(G=>G.ref)),ne=t.toLowerCase();return(_e.layoutedNodes?_e.layoutedNodes.filter(G=>G.id.startsWith("dynamic_rt_")||z.has(G.id)):o.filter(G=>!_e.removedNodeIds.has(G.id)&&z.has(G.id)).concat(_e.extraNodes)).map(G=>{const de=G.data.taskReferenceName,P=w[de];return{...G,selected:h?.taskReferenceName===de,data:{...G.data,isError:d==="edit"&&Q.has(de),hasWarning:d==="edit"&&Y.has(de),isHighlighted:t?(G.data.label||"").toLowerCase().includes(ne)||(G.data.taskReferenceName||"").toLowerCase().includes(ne):!1,simRunning:P==="running",simDone:P==="done"}}})},[o,k,t,h,_e,z,w,d,A]),edges:A?.edges??[...ye,...et],onNodesChange:l,onEdgesChange:c,onConnect:u,nodeTypes:D1,edgeTypes:A1,onNodeClick:(Q,Y)=>{if(Y.type==="plusNode"){ie({sourceId:Y.data.parentRef,edgeData:Y.data.edgeData||{}}),H(!0);return}if(Y.type==="loopNode"){const fe=Y.data.task||null;f(fe),e&&e(fe);return}const ne=Y.data.task||null;f(ne),e&&e(ne)},onPaneClick:()=>{f(null),d!=="run"&&S(!1)},fitView:!0,nodesDraggable:!x,nodesConnectable:!x,elementsSelectable:!0,minZoom:.2,maxZoom:2,children:[a.jsx(q.Background,{color:"var(--border-primary)",gap:20}),a.jsx(q.Panel,{position:"bottom-left",style:{marginBottom:"20px",marginLeft:"20px",zIndex:1e3},children:a.jsx(Vv,{})}),st>=5&&!_&&!ge&&a.jsx(q.MiniMap,{position:"bottom-right",pannable:!0,zoomable:!0,style:{marginBottom:20,marginRight:20,width:160,height:110,backgroundColor:"var(--glass-surface)"},maskColor:g==="light"?"rgba(241, 245, 249, 0.7)":"rgba(15, 23, 42, 0.7)",nodeColor:Q=>{if(Q.type==="plusNode")return"transparent";if(d==="run"&&v){const Y=Q.data?.taskReferenceName,ne=v[Y]?.status;return ne==="COMPLETED"?"#10b981":ne==="FAILED"||ne==="FAILED_WITH_TERMINAL_ERROR"?"#ef4444":ne==="IN_PROGRESS"||ne==="SCHEDULED"?"#3b82f6":ne==="TIMED_OUT"||ne==="COMPLETED_WITH_ERRORS"?"#f59e0b":"#64748b"}return Q.type==="decisionNode"?"#f59e0b":Q.type==="forkNode"||Q.type==="joinNode"?"#10b981":Q.type==="loopNode"?"#8b5cf6":"#3b82f6"}}),d==="run"&&a.jsx(q.Panel,{position:"bottom-center",children:a.jsx(Uv,{})}),a.jsx(Jv,{isOpen:ge,onClose:()=>Se(!1),theme:g,onTaskSelect:Q=>{m(Q,!0)}}),I&&a.jsx(q.Panel,{position:"top-left",style:{marginTop:"14px",marginLeft:"16px",zIndex:1500},children:a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"8px 16px",borderRadius:"999px",background:"rgba(15, 23, 42, 0.94)",backdropFilter:"blur(16px)",border:"1px solid rgba(99, 102, 241, 0.45)",boxShadow:"0 12px 32px rgba(0, 0, 0, 0.4)",color:"#f8fafc",fontSize:"12px"},children:[a.jsx("span",{style:{fontWeight:700,color:"#a5b4fc"},children:"👻 Shadow Graph 架构变更预览"}),a.jsxs("div",{style:{display:"flex",gap:"8px",fontFamily:"monospace",fontSize:"11px"},children:[I.diff.added.length>0&&a.jsxs("span",{style:{color:"#34d399",fontWeight:700},children:["+",I.diff.added.length," 新增"]}),I.diff.modified.length>0&&a.jsxs("span",{style:{color:"#fbbf24",fontWeight:700},children:["~",I.diff.modified.length," 修改"]}),I.diff.removed.length>0&&a.jsxs("span",{style:{color:"#f87171",fontWeight:700},children:["-",I.diff.removed.length," 移除"]})]}),a.jsxs("div",{style:{display:"flex",gap:"6px"},children:[a.jsx("button",{type:"button",onClick:()=>{j&&Z(j),R(I.proposedDef),O(),F()},style:{padding:"4px 12px",borderRadius:"999px",border:"none",background:"#10b981",color:"#fff",fontSize:"11px",fontWeight:700,cursor:"pointer"},children:"✓ 采纳上屏"}),a.jsx("button",{type:"button",onClick:()=>{J(),F()},style:{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(248, 113, 113, 0.4)",background:"rgba(239, 68, 68, 0.14)",color:"#f87171",fontSize:"11px",fontWeight:600,cursor:"pointer"},children:"✕ 拒绝"})]})]})}),a.jsx("div",{style:{position:"absolute",top:14,right:16,zIndex:1e3},children:a.jsx(Yv,{onShowHealthCheck:()=>Se(!ge),showHealthCheck:ge,onShowSettings:()=>$(!0),executionActions:s})})]}),a.jsx(w1,{}),a.jsx(O1,{}),!j&&!I&&a.jsx(e1,{onRequestImport:n}),j&&o.length===0&&d==="edit"&&a.jsx("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:10,display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:a.jsxs("button",{className:"empty-state-btn primary",style:{padding:"12px 24px",borderRadius:"8px",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",fontSize:"16px",fontWeight:500,boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1)"},onClick:()=>{ie({sourceId:"start",targetId:"end",edgeId:"new",edgeData:{}}),H(!0)},children:[a.jsx("span",{style:{fontSize:"20px",lineHeight:1},children:"+"}),"添加第一个任务"]})}),U&&a.jsx(Hv,{theme:g,onSelect:Fe,onCancel:()=>H(!1)}),a.jsx(Zv,{isOpen:we,onClose:()=>$(!1)}),te&&a.jsx(kr,{message:te.message,onConfirm:se,onCancel:re}),a.jsx(r1,{messages:ve,onDismiss:pe})]})},M1=(e,t)=>{const r=t?`当前工作流(JSON):
|
|
86
86
|
${JSON.stringify({name:t.name,tasks:t.tasks.map(n=>({ref:n.taskReferenceName,type:n.type,name:n.name}))},null,2)}`:"当前工作流:尚未定义。";return`
|
|
87
87
|
用户请求:${e}
|
|
88
88
|
|
|
@@ -113,7 +113,7 @@ ${r}
|
|
|
113
113
|
|
|
114
114
|
如果是全量生成新工作流,使用 kind="replace" 并在 diff-json 中加入 "payload": {...完整工作流JSON...}。
|
|
115
115
|
如果不涉及工作流变更(仅解释/回答),则不需要输出 diff-json 块。
|
|
116
|
-
`},
|
|
116
|
+
`},q1=(e,t)=>`
|
|
117
117
|
Context: I am configuring a Conductor task in a workflow.
|
|
118
118
|
Task Reference Name: ${e.taskReferenceName}
|
|
119
119
|
Task Type: ${e.type}
|
|
@@ -123,7 +123,10 @@ ${JSON.stringify(t,null,2)}
|
|
|
123
123
|
|
|
124
124
|
Requirement: Suggest 3 meaningful 'inputParameters' or JSONPath expressions for this task based on the workflow context.
|
|
125
125
|
Return the suggestions as a JSON array of objects with { label, value, description }.
|
|
126
|
-
`,
|
|
127
|
-
`).length," 行"]}),o.jsxs("span",{children:[c.length," 字符"]}),c!==t&&o.jsx("span",{style:{color:"#f59e0b",fontWeight:600},children:"● 未保存"})]})]}),document.body)},f1=[{label:"工作流输入",value:"${workflow.input.fieldName}",desc:"引用工作流启动时传入的参数"},{label:"上游任务输出",value:"${taskRef.output.result}",desc:"引用上游任务的输出字段"},{label:"工作流变量",value:"${workflow.variables.varName}",desc:"引用 SET_VARIABLE 设置的变量"},{label:"工作流 ID",value:"${workflow.workflowId}",desc:"当前工作流实例 ID"},{label:"关联 ID",value:"${workflow.correlationId}",desc:"工作流关联 ID"},{label:"工作流状态",value:"${workflow.status}",desc:"当前工作流状态"}],p1=({task:e,isOpen:t=!0,onClose:r,aiConfig:n})=>{const{mode:s,updateTask:a,checkTaskRefUniqueness:i,workflowDef:l,executionData:c,workflowInstance:d,lastRefactorNotice:u,clearRefactorNotice:f}=oe(),[h,p]=I.useState(e),[m,g]=I.useState(e?.taskReferenceName??null),[x,v]=I.useState(null),[y,b]=I.useState(!1),[k,_]=I.useState(null),[w,T]=I.useState(()=>e?.type==="WAIT"&&e.inputParameters?.until?"until":"duration"),[O,D]=I.useState(()=>e?.type==="DO_WHILE"&&e.inputParameters?.items?"items":"condition"),[N,S]=I.useState(()=>!e||e.type!=="FORK_JOIN_DYNAMIC"?"classic":e.forkTaskWorkflow?"workflow":e.forkTaskType?"task":"classic"),[R,j]=I.useState(!1),[E,q]=I.useState(),[$,J]=I.useState([]),[V,A]=I.useState(()=>()=>{}),B=e?.taskReferenceName||h?.taskReferenceName||"",P=I.useMemo(()=>!l||!B?[]:rm(l,B,c,d?.input),[l,B,c,d?.input]),[U,se]=I.useState(null),[L,F]=I.useState(!1),[z,H]=I.useState(null),Y=(C,K,ae,re)=>{se({title:C,value:K,language:ae,onSave:re})},ie=[{label:"引用工作流输入",value:"${workflow.input.data}",description:"引用工作流启动时传入的原始数据"},{label:"引用前序任务输出",value:"${previous_task.output.result}",description:"引用上一个节点的计算结果"},{label:"环境变量",value:"${workflow.variables.api_key}",description:"引用工作流定义的全局变量"}],fe=async()=>{const C=n?.apiKey||localStorage.getItem("AI_API_KEY")||"";if(!C){alert("请先在设置中配置 AI API Key");return}if(be){F(!0);try{const{workflowDef:K,taskMap:ae}=oe.getState(),re=At(K?.inputParameters).map(pe=>pe.name),Z=Object.values(ae).filter(pe=>pe.taskReferenceName!==be.taskReferenceName).map(pe=>({ref:pe.taskReferenceName,type:pe.type,name:pe.name})).slice(0,10),ye={apiKey:C};n?.baseUrl&&(ye.baseUrl=n.baseUrl),n?.model&&(ye.model=n.model);const xe=await e1(be.type,be.taskReferenceName,re,Z,be.inputParameters??{},ye);H({generated:xe,original:be.inputParameters??{}})}catch(K){alert(`AI 生成失败:${K?.message||"未知错误"}`)}finally{F(!1)}}},ve=async(C,K)=>{const ae=C.currentTarget.getBoundingClientRect();if(q(ae),A(()=>K),j(!0),P.length>0)return;J([]);const re=n?.apiKey||localStorage.getItem("AI_API_KEY")||"";if(!re){J(ie);return}try{const Z=n?.baseUrl||localStorage.getItem("AI_BASE_URL")||"",ye=n?.model||localStorage.getItem("AI_MODEL")||"",xe={apiKey:re};Z&&(xe.baseUrl=Z),ye&&(xe.model=ye);const{workflowDef:pe}=oe.getState(),ue=l1(be,pe),Pe=(await xl([{role:"system",content:"You are a Conductor workflow expert. Return only valid JSON."},{role:"user",content:ue}],xe)).match(/\[[\s\S]*\]/);if(Pe){const Re=JSON.parse(Pe[0]);J(Re)}else J(ie)}catch{J(ie)}};if(I.useEffect(()=>{e&&(p(e),g(e.taskReferenceName),v(null),e.type==="WAIT"&&T(e.inputParameters?.until?"until":"duration"),e.type==="DO_WHILE"&&D(e.inputParameters?.items?"items":"condition"),e.type==="FORK_JOIN_DYNAMIC"&&(e.forkTaskWorkflow?S("workflow"):e.forkTaskType?S("task"):S("classic")))},[e]),!e&&!h)return null;const be=e||h,W=h&&e&&m===e.taskReferenceName?h:be,ke=t&&e?"panel-enter-active":"panel-exit",ee=s==="edit",me="var(--text-primary)",ne="var(--glass-border)",_e="var(--bg-tertiary)",ce="var(--text-secondary)",he=(C,K)=>{const ae={...W,[C]:K};p(ae),a(W.taskReferenceName,{[C]:K})},Fe=(C,K,ae)=>{const Z={...W[C]||{},[K]:ae},ye={...W,[C]:Z};p(ye),a(W.taskReferenceName,{[C]:Z})},Se=(C,K)=>{const ae=W.inputParameters||{},Z={...ae.http_request||W.httpRequest||{},[C]:K},xe={inputParameters:{...ae,http_request:Z}};W.httpRequest&&(xe.httpRequest=Z);const pe={...W,...xe};p(pe),a(W.taskReferenceName,xe)},ge=(C,K)=>{const re={inputParameters:{...W.inputParameters,[C]:K}},Z={...W,...re};p(Z),a(W.taskReferenceName,re)},Qe=C=>{if(!k)return;const K=k.selectionStart??0,ae=k.selectionEnd??0,re=k.value,Z=re.substring(0,K)+C+re.substring(ae),ye=k.getAttribute("data-field");ye&&he(ye,Z),b(!1)},Ee=(C,K,ae,re)=>o.jsxs("div",{style:{marginBottom:"24px",padding:"16px",borderRadius:"12px",background:`${ae}10`,border:`1px solid ${ae}30`,boxShadow:"0 4px 12px rgba(0,0,0,0.05)"},children:[o.jsxs("div",{style:{fontSize:"12px",fontWeight:"bold",marginBottom:"16px",color:ae,display:"flex",alignItems:"center",gap:"8px"},children:[o.jsx("span",{children:K})," ",C]}),re]}),rt=(C,K,ae="text",re)=>{const Z=K==="taskReferenceName",ye=Z&&x!==null?x:W[K]??"",xe=Z&&!i(ye,W.taskReferenceName);return o.jsxs("div",{style:{marginBottom:"16px"},children:[o.jsxs("label",{style:{display:"block",fontSize:"11px",color:ce,marginBottom:"6px",fontWeight:"600",textTransform:"uppercase"},children:[C,Z&&xe&&o.jsx("span",{style:{color:"#ef4444",marginLeft:"8px",textTransform:"none"},children:"⚠️ 已存在相同引用名"})]}),o.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center"},children:[o.jsx("input",{type:ae,value:ye,placeholder:re,onChange:pe=>{const ue=pe.target.value;if(Z)v(ue);else{he(K,ae==="number"?ue===""?void 0:Number(ue):ue);const Te=pe.target.selectionStart??0;if(ae==="text"&&Te>=2&&ue.slice(Te-2,Te)==="${"){const Pe=pe.target.getBoundingClientRect();q(Pe),A(()=>Re=>{const Be=ue.slice(0,Te-2),vl=ue.slice(Te);he(K,Be+Re+vl)}),j(!0)}}},onFocus:Z?()=>{x===null&&v(W.taskReferenceName??"")}:void 0,onBlur:Z?pe=>{const ue=pe.target.value.trim();v(null),ue&&ue!==W.taskReferenceName&&he("taskReferenceName",ue)}:void 0,onKeyDown:Z?pe=>{pe.key==="Enter"&&pe.currentTarget.blur(),pe.stopPropagation()}:void 0,disabled:!ee,style:{width:"100%",padding:`8px ${ee&&!Z?"32px":"12px"} 8px 12px`,borderRadius:"6px",border:`1px solid ${xe?"#ef4444":ne}`,background:_e,color:me,fontSize:"13px",outline:"none",opacity:ee?1:.8,fontFamily:Z?"monospace":"inherit"}}),ee&&!Z&&o.jsx("button",{className:"ai-hint-trigger",onClick:pe=>ve(pe,ue=>he(K,ue)),title:"AI 智能提示",style:{position:"absolute",right:"8px",background:"none",border:"none",cursor:"pointer",fontSize:"14px",padding:"4px",opacity:.6,display:"flex",alignItems:"center",justifyContent:"center"},children:"✨"})]})]})},Q=(C,K,ae,re={})=>{const{rows:Z=5,language:ye="text",style:xe,placeholder:pe,"data-field":ue}=re,Te={width:"100%",padding:"12px",borderRadius:"8px",border:`1px solid ${ne}`,background:_e,color:me,fontSize:"12px",fontFamily:"monospace",lineHeight:"1.5",resize:"vertical",...xe};return o.jsxs("div",{style:{marginBottom:"8px"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"4px"},children:[o.jsx("label",{style:{fontSize:"10px",color:ce},children:C}),ee&&o.jsx("button",{onClick:()=>Y(C,K,ye,Pe=>{ae(Pe),se(null)}),title:"全屏编辑",style:{background:"none",border:"none",cursor:"pointer",fontSize:"14px",padding:"2px 4px",color:"var(--text-secondary)",opacity:.7,lineHeight:1},children:"⛶"})]}),o.jsx("textarea",{value:K,placeholder:pe,onChange:Pe=>{const Re=Pe.target.value;ae(Re);const Be=Pe.target.selectionStart??0;if(Be>=2&&Re.slice(Be-2,Be)==="${"){const vl=Pe.target.getBoundingClientRect();q(vl),A(()=>A1=>{const L1=Re.slice(0,Be-2),D1=Re.slice(Be);ae(L1+A1+D1)}),j(!0)}},disabled:!ee,rows:Z,"data-field":ue,onFocus:Pe=>_(Pe.currentTarget),style:Te})]})},X=(C,K,ae,re="text",Z)=>o.jsxs("div",{style:{marginBottom:"12px"},children:[o.jsx("label",{style:{display:"block",fontSize:"10px",color:ce,marginBottom:"4px"},children:C}),o.jsx("input",{type:re,value:K??"",placeholder:Z,onChange:ye=>{const xe=ye.target.value;ae(re==="number"?xe===""?void 0:Number(xe):xe);const pe=ye.target.selectionStart??0;if(re==="text"&&pe>=2&&xe.slice(pe-2,pe)==="${"){const ue=ye.target.getBoundingClientRect();q(ue),A(()=>Te=>{const Pe=xe.slice(0,pe-2),Re=xe.slice(pe);ae(Pe+Te+Re)}),j(!0)}},disabled:!ee,style:{width:"100%",padding:"8px 10px",borderRadius:"6px",border:`1px solid ${ne}`,background:_e,color:me,fontSize:"12px",outline:"none"}})]}),te=(C,K,ae,re)=>o.jsxs("div",{style:{marginBottom:"12px"},children:[o.jsx("label",{style:{display:"block",fontSize:"10px",color:ce,marginBottom:"4px"},children:C}),o.jsx("select",{value:ae,onChange:Z=>re(Z.target.value),disabled:!ee,style:{width:"100%",padding:"8px 10px",borderRadius:"6px",border:`1px solid ${ne}`,background:_e,color:me,fontSize:"12px",outline:"none",cursor:"pointer"},children:K.map(Z=>o.jsx("option",{value:Z,children:Z},Z))})]}),de=(C,K,ae)=>o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},children:[o.jsx("span",{style:{fontSize:"11px",color:ce},children:C}),o.jsx("button",{onClick:()=>ae(!K),disabled:!ee,style:{width:"36px",height:"20px",borderRadius:"10px",border:"none",cursor:"pointer",background:K?"var(--color-accent)":ne,position:"relative",transition:"background 0.2s"},children:o.jsx("span",{style:{position:"absolute",top:"2px",left:K?"18px":"2px",width:"16px",height:"16px",borderRadius:"50%",background:"#fff",transition:"left 0.2s"}})})]}),G=(C,K,ae)=>o.jsx("div",{style:{display:"flex",gap:"6px",marginBottom:"12px"},children:C.map(re=>o.jsx("button",{onClick:()=>ae(re.key),disabled:!ee,style:{flex:1,padding:"6px",borderRadius:"6px",border:`1px solid ${ne}`,cursor:"pointer",fontSize:"11px",fontWeight:K===re.key?"bold":"normal",background:K===re.key?"var(--color-accent)":_e,color:K===re.key?"#fff":me},children:re.label},re.key))}),le=W.inputParameters?.http_request||W.httpRequest||{};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:`detail-panel-container ${ke}`,style:{position:"absolute",right:0,top:0,bottom:0,width:"450px",zIndex:1200,display:"flex",flexDirection:"column",background:"var(--bg-primary)",borderLeft:`1px solid ${ne}`,boxShadow:"-10px 0 30px rgba(0, 0, 0, 0.2)",overflowY:"hidden"},children:[o.jsxs("div",{style:{padding:"24px",borderBottom:`1px solid ${ne}`,background:"var(--bg-secondary)",flexShrink:0},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[o.jsx("div",{style:{background:"var(--color-accent)",color:"#fff",padding:"2px 8px",borderRadius:"4px",fontSize:"10px",fontWeight:"bold",letterSpacing:"1px"},children:W.type||"TASK"}),o.jsx("button",{onClick:r,style:{background:"none",border:"none",color:me,cursor:"pointer",fontSize:"20px"},children:"✕"})]}),ee?o.jsx("input",{value:W.name||"",onChange:C=>he("name",C.target.value),placeholder:"任务名称",style:{display:"block",width:"100%",fontSize:"22px",fontWeight:"bold",background:"transparent",border:"none",color:me,outline:"none",borderBottom:"2px dashed var(--color-accent)"}}):o.jsx("div",{style:{fontSize:"22px",fontWeight:"bold"},children:W.name}),o.jsxs("div",{style:{fontSize:"12px",color:ce,marginTop:"8px",fontFamily:"monospace",opacity:.8},children:["REF: ",W.taskReferenceName]})]}),o.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"24px",background:"var(--bg-primary)"},children:[W.type==="HTTP"&&Ee("HTTP 请求配置","🌐","var(--color-accent)",o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{display:"flex",gap:"8px",marginBottom:"12px"},children:[o.jsx("select",{value:le.method||"GET",onChange:C=>Se("method",C.target.value),disabled:!ee,style:{width:"90px",padding:"10px",borderRadius:"8px",background:_e,color:me,border:`1px solid ${ne}`,cursor:"pointer"},children:["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"].map(C=>o.jsx("option",{value:C,children:C},C))}),o.jsx("input",{placeholder:"URI (支持 ${workflow.input.uri})",value:le.uri||"",onChange:C=>Se("uri",C.target.value),disabled:!ee,style:{flex:1,padding:"10px",borderRadius:"8px",background:_e,color:me,border:`1px solid ${ne}`}})]}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px",marginBottom:"12px"},children:[o.jsxs("div",{children:[o.jsx("label",{style:{display:"block",fontSize:"10px",color:ce,marginBottom:"4px"},children:"CONTENT-TYPE"}),o.jsx("input",{placeholder:"application/json",value:le.contentType||"",onChange:C=>Se("contentType",C.target.value),disabled:!ee,style:{width:"100%",padding:"8px",borderRadius:"6px",background:_e,color:me,border:`1px solid ${ne}`,fontSize:"12px"}})]}),o.jsxs("div",{children:[o.jsx("label",{style:{display:"block",fontSize:"10px",color:ce,marginBottom:"4px"},children:"ACCEPT"}),o.jsx("input",{placeholder:"application/json",value:le.accept||"",onChange:C=>Se("accept",C.target.value),disabled:!ee,style:{width:"100%",padding:"8px",borderRadius:"6px",background:_e,color:me,border:`1px solid ${ne}`,fontSize:"12px"}})]})]}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px",marginBottom:"12px"},children:[o.jsxs("div",{children:[o.jsx("label",{style:{display:"block",fontSize:"10px",color:ce,marginBottom:"4px"},children:"连接超时 (ms)"}),o.jsx("input",{type:"number",placeholder:"3000",value:le.connectionTimeOut??"",onChange:C=>Se("connectionTimeOut",C.target.value===""?void 0:Number(C.target.value)),disabled:!ee,style:{width:"100%",padding:"8px",borderRadius:"6px",background:_e,color:me,border:`1px solid ${ne}`,fontSize:"12px"}})]}),o.jsxs("div",{children:[o.jsx("label",{style:{display:"block",fontSize:"10px",color:ce,marginBottom:"4px"},children:"读取超时 (ms)"}),o.jsx("input",{type:"number",placeholder:"3000",value:le.readTimeOut??"",onChange:C=>Se("readTimeOut",C.target.value===""?void 0:Number(C.target.value)),disabled:!ee,style:{width:"100%",padding:"8px",borderRadius:"6px",background:_e,color:me,border:`1px solid ${ne}`,fontSize:"12px"}})]})]}),o.jsxs("div",{style:{marginBottom:"12px"},children:[o.jsx("label",{style:{display:"block",fontSize:"10px",color:ce,marginBottom:"4px"},children:"HEADERS (JSON)"}),o.jsx("textarea",{value:typeof le.headers=="object"?JSON.stringify(le.headers,null,2):"{}",onChange:C=>{try{Se("headers",JSON.parse(C.target.value))}catch{}},disabled:!ee,rows:3,style:{width:"100%",padding:"8px",borderRadius:"8px",background:_e,color:me,border:`1px solid ${ne}`,fontSize:"11px",fontFamily:"monospace"}})]}),o.jsx("label",{style:{display:"block",fontSize:"10px",color:ce,marginBottom:"4px"},children:"BODY (RAW/JSON)"}),o.jsx("textarea",{value:typeof le.body=="object"?JSON.stringify(le.body,null,2):le.body||"",onChange:C=>{let K=C.target.value;try{K=JSON.parse(C.target.value)}catch{}Se("body",K)},disabled:!ee,rows:4,style:{width:"100%",padding:"8px",borderRadius:"8px",background:_e,color:me,border:`1px solid ${ne}`,fontSize:"11px",fontFamily:"monospace"}})]})),(W.type==="INLINE"||W.type==="LAMBDA")&&Ee("内联脚本配置 (Inline)","📜","var(--color-accent)",o.jsxs(o.Fragment,{children:[te("脚本引擎",["graaljs","javascript","value-param","python"],W.evaluatorType||"graaljs",C=>he("evaluatorType",C)),Q(`EXPRESSION ${W.evaluatorType==="value-param"?"(值引用)":"(脚本)"}`,W.inputParameters?.expression||W.inputParameters?.scriptExpression||"",C=>{const K=W.inputParameters?.scriptExpression!==void 0?"scriptExpression":"expression";ge(K,C)},{rows:10,language:W.evaluatorType||"javascript",style:{background:"#000",color:"var(--color-accent)",border:"1px solid var(--color-accent)"}}),o.jsx("div",{style:{marginTop:"8px",fontSize:"10px",color:ce,fontStyle:"italic"},children:"提示: 使用 $.input.key 访问输入参数,返回值作为任务输出。"})]})),W.type==="JSON_JQ_TRANSFORM"&&Ee("JQ 数据转换","🔍","var(--color-accent)",o.jsxs(o.Fragment,{children:[Q("JQ QUERY EXPRESSION",W.inputParameters?.queryExpression||"",C=>ge("queryExpression",C),{rows:6,language:"jq",style:{color:"var(--color-accent)"}}),o.jsx("div",{style:{marginTop:"8px",fontSize:"10px",color:ce},children:"输出字段: result(首个结果)、resultList(完整列表)"})]})),W.type==="SUB_WORKFLOW"&&Ee("子工作流配置","🏗️","var(--color-accent)",o.jsxs(o.Fragment,{children:[X("WORKFLOW NAME *",W.subWorkflowParam?.name||"",C=>Fe("subWorkflowParam","name",C),"text","e.g. my_workflow"),X("VERSION",W.subWorkflowParam?.version??"",C=>Fe("subWorkflowParam","version",C?parseInt(C):void 0),"number","1"),Q("INPUT PARAMETERS MAPPING (JSON)",typeof W.inputParameters=="object"&&W.inputParameters!==null?JSON.stringify(W.inputParameters,null,2):"{}",C=>{try{he("inputParameters",JSON.parse(C))}catch{}},{rows:5,language:"json"}),o.jsxs("div",{style:{fontSize:"10px",color:ce,marginTop:"4px"},children:["传递给子工作流的参数,支持 ","${workflow.input.xxx}"," 表达式"]})]})),W.type==="START_WORKFLOW"&&Ee("启动工作流配置","▶️","var(--color-accent)",o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{fontSize:"11px",color:ce,marginBottom:"12px",padding:"8px",borderRadius:"6px",background:"rgba(255,165,0,0.1)",border:"1px solid rgba(255,165,0,0.3)"},children:["⚡ 注意:此任务启动目标工作流后立即继续,",o.jsx("b",{children:"不等待"}),"目标工作流完成。"]}),X("WORKFLOW NAME *",W.inputParameters?.startWorkflow?.name||"",C=>{const K={...W.inputParameters?.startWorkflow||{},name:C};ge("startWorkflow",K)},"text","e.g. target_workflow"),X("VERSION",W.inputParameters?.startWorkflow?.version??"",C=>{const K={...W.inputParameters?.startWorkflow||{},version:C?parseInt(C):void 0};ge("startWorkflow",K)},"number","1"),X("CORRELATION ID",W.inputParameters?.startWorkflow?.correlationId||"",C=>{const K={...W.inputParameters?.startWorkflow||{},correlationId:C};ge("startWorkflow",K)},"text","${workflow.correlationId}"),Q("WORKFLOW INPUT (JSON)",typeof W.inputParameters?.startWorkflow?.input=="object"?JSON.stringify(W.inputParameters.startWorkflow.input,null,2):"{}",C=>{try{const K={...W.inputParameters?.startWorkflow||{},input:JSON.parse(C)};ge("startWorkflow",K)}catch{}},{rows:4,language:"json"})]})),W.type==="TERMINATE"&&Ee("终止状态配置","⏹️","var(--color-accent)",o.jsxs(o.Fragment,{children:[o.jsx("label",{style:{display:"block",fontSize:"10px",color:ce,marginBottom:"4px"},children:"TERMINATION STATUS"}),o.jsx("div",{style:{display:"flex",gap:"8px",marginBottom:"16px"},children:["COMPLETED","FAILED"].map(C=>o.jsx("button",{onClick:()=>ge("terminationStatus",C),disabled:!ee,style:{flex:1,padding:"8px",borderRadius:"6px",cursor:"pointer",background:(W.inputParameters?.terminationStatus||"COMPLETED")===C?"var(--color-accent)":_e,color:(W.inputParameters?.terminationStatus||"COMPLETED")===C?"#fff":me,border:`1px solid ${ne}`,fontWeight:"bold",fontSize:"11px"},children:C},C))}),X("TERMINATION REASON",W.inputParameters?.terminationReason||"",C=>ge("terminationReason",C),"text","终止原因..."),Q("WORKFLOW OUTPUT (JSON)",typeof W.inputParameters?.workflowOutput=="object"?JSON.stringify(W.inputParameters.workflowOutput,null,2):"{}",C=>{try{ge("workflowOutput",JSON.parse(C))}catch{}},{rows:3,language:"json"})]})),W.type==="EVENT"&&Ee("事件发送配置","✉️","var(--color-accent)",o.jsxs(o.Fragment,{children:[X("EVENT SINK *",W.sink||"",C=>he("sink",C),"text","e.g. sqs:queue_name 或 conductor"),o.jsx("div",{style:{fontSize:"10px",color:ce,marginTop:"4px",marginBottom:"8px"},children:"支持前缀: conductor | sqs | kafka | amqp | nats"}),de("异步完成 (asyncComplete)",!!W.asyncComplete,C=>he("asyncComplete",C))]})),W.type==="WAIT"&&Ee("等待状态配置","⏳","var(--color-accent)",o.jsxs(o.Fragment,{children:[G([{key:"duration",label:"等待时长"},{key:"until",label:"等待到指定时间"}],w,C=>T(C)),w==="duration"?X("DURATION",W.inputParameters?.duration||"",C=>ge("duration",C),"text","e.g. 30s, 10m, 2 hours"):X("UNTIL (时间点)",W.inputParameters?.until||"",C=>ge("until",C),"text","e.g. 2025-06-15 09:00 GMT+00:00"),o.jsxs("div",{style:{fontSize:"11px",color:ce,lineHeight:"1.6",marginTop:"8px"},children:["此任务会使工作流进入 ",o.jsx("b",{children:"IN_PROGRESS"})," 状态,直到时间满足或外部 API 触发完成。"]})]})),(W.type==="DECISION"||W.type==="SWITCH")&&Ee("条件分支配置","⚖️","var(--color-accent)",o.jsxs(o.Fragment,{children:[te("评估模式 (evaluatorType)",["value-param","javascript"],W.evaluatorType||"value-param",C=>he("evaluatorType",C)),(W.evaluatorType||"value-param")==="value-param"?X("CASE VALUE PARAM (参数名)",W.caseValueParam||"",C=>he("caseValueParam",C),"text","e.g. status"):o.jsx(o.Fragment,{children:Q("CASE EXPRESSION (JS)",W.caseExpression||"",C=>he("caseExpression",C),{rows:4,language:"javascript",style:{color:"var(--color-accent)"}})}),o.jsx("div",{style:{fontSize:"10px",color:ce,marginTop:"8px"},children:'分支可在图中通过右键节点→"添加分支"进行管理'})]})),W.type==="DO_WHILE"&&Ee("循环逻辑配置","🔄","var(--color-accent)",o.jsxs(o.Fragment,{children:[G([{key:"condition",label:"条件循环"},{key:"items",label:"列表迭代"}],O,C=>D(C)),O==="condition"?o.jsxs(o.Fragment,{children:[Q("LOOP CONDITION (JS) *",W.loopCondition||"",C=>he("loopCondition",C),{rows:4,language:"javascript",style:{color:"var(--color-accent)"}}),o.jsx("div",{style:{fontSize:"10px",color:ce,marginTop:"4px"},children:"条件为 true 时继续循环,false 时退出"})]}):o.jsxs(o.Fragment,{children:[o.jsx("label",{style:{display:"block",fontSize:"10px",color:ce,marginBottom:"4px"},children:"ITEMS (列表表达式)"}),o.jsx("input",{value:W.inputParameters?.items||"",onChange:C=>ge("items",C.target.value),disabled:!ee,placeholder:"${workflow.input.myList}",style:{width:"100%",padding:"8px",borderRadius:"6px",border:`1px solid ${ne}`,background:_e,color:me,fontSize:"12px",outline:"none"}}),o.jsx("div",{style:{fontSize:"10px",color:ce,marginTop:"4px"},children:"引用一个数组,对每个元素执行一次循环体"})]}),o.jsx("div",{style:{marginTop:"12px"},children:X("KEEP LAST N 次迭代",W.keepLastN??"",C=>he("keepLastN",C?parseInt(C):void 0),"number","0 = 保留全部")})]})),W.type==="FORK_JOIN_DYNAMIC"&&Ee("动态并行配置","⚡","var(--color-accent)",o.jsxs(o.Fragment,{children:[G([{key:"classic",label:"经典模式"},{key:"task",label:"任务简化"},{key:"workflow",label:"工作流简化"}],N,C=>S(C)),N==="classic"&&o.jsxs(o.Fragment,{children:[X("DYNAMIC_FORK_TASKS_PARAM",W.dynamicForkTasksParam||"",C=>he("dynamicForkTasksParam",C),"text","e.g. dynamic_tasks"),X("DYNAMIC_FORK_TASKS_INPUT_PARAM",W.dynamicForkTasksInputParamName||"",C=>he("dynamicForkTasksInputParamName",C),"text","e.g. input"),o.jsx("div",{style:{fontSize:"10px",color:ce},children:"经典模式:通过 inputParameters 传入 dynamicTasks 数组和 dynamicTasksInput 映射"})]}),N==="task"&&o.jsxs(o.Fragment,{children:[X("FORK TASK TYPE *",W.forkTaskType||"",C=>he("forkTaskType",C),"text","e.g. HTTP"),X("FORK TASK NAME (仅 SIMPLE 任务)",W.forkTaskName||"",C=>he("forkTaskName",C),"text","e.g. my_task"),X("FORK TASK INPUTS PARAM",W.forkTaskInputs||"",C=>he("forkTaskInputs",C),"text","e.g. inputs"),o.jsx("div",{style:{fontSize:"10px",color:ce},children:"所有分支执行相同任务类型,每个元素作为一个分支输入"})]}),N==="workflow"&&o.jsxs(o.Fragment,{children:[X("FORK WORKFLOW NAME *",W.forkTaskWorkflow||"",C=>he("forkTaskWorkflow",C),"text","e.g. sub_workflow"),X("WORKFLOW VERSION",W.forkTaskWorkflowVersion||"",C=>he("forkTaskWorkflowVersion",C),"text","1"),X("FORK TASK INPUTS PARAM",W.forkTaskInputs||"",C=>he("forkTaskInputs",C),"text","e.g. inputs"),o.jsx("div",{style:{fontSize:"10px",color:ce},children:"所有分支执行相同子工作流,每个元素作为一个子工作流输入"})]})]})),W.type==="DYNAMIC"&&Ee("动态任务配置","🎯","var(--color-accent)",o.jsxs(o.Fragment,{children:[X("DYNAMIC TASK NAME PARAM *",W.dynamicTaskNameParam||"",C=>he("dynamicTaskNameParam",C),"text","e.g. taskToExecute"),o.jsx("div",{style:{fontSize:"10px",color:ce,marginTop:"4px"},children:'运行时从 inputParameters 的指定键中读取实际任务类型名(如 "HTTP"、"SIMPLE")'})]})),W.type==="HUMAN"&&Ee("人工审批配置","👤","var(--color-accent)",o.jsxs(o.Fragment,{children:[X("表单模板名 (userFormTemplate)",W.humanTaskDef?.userFormTemplate||"",C=>Fe("humanTaskDef","userFormTemplate",C),"text","e.g. approval_form"),te("分配策略 (assignmentCompletionStrategy)",["LEAVE_OPEN","TERMINATE"],W.humanTaskDef?.assignmentCompletionStrategy||"LEAVE_OPEN",C=>Fe("humanTaskDef","assignmentCompletionStrategy",C)),X("显示名称 (displayName)",W.humanTaskDef?.displayName||"",C=>Fe("humanTaskDef","displayName",C),"text","审批任务")]})),W.type==="KAFKA_PUBLISH"&&Ee("Kafka 推送配置","📨","var(--color-accent)",o.jsxs(o.Fragment,{children:[X("BOOTSTRAP SERVERS *",W.inputParameters?.bootStrapServers||"",C=>ge("bootStrapServers",C),"text","localhost:9092"),X("TOPIC *",W.inputParameters?.topic||"",C=>ge("topic",C),"text","my_topic"),X("KEY (消息分区键)",W.inputParameters?.key||"",C=>ge("key",C),"text",""),Q("VALUE (消息内容)",typeof W.inputParameters?.value=="object"?JSON.stringify(W.inputParameters.value,null,2):W.inputParameters?.value||"",C=>{let K=C;try{K=JSON.parse(C)}catch{}ge("value",K)},{rows:4,language:"json"}),Q("HEADERS (JSON)",typeof W.inputParameters?.headers=="object"?JSON.stringify(W.inputParameters.headers,null,2):"{}",C=>{try{ge("headers",JSON.parse(C))}catch{}},{rows:3,language:"json"})]})),W.type==="SET_VARIABLE"&&Ee("变量配置","📦","var(--color-accent)",o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{fontSize:"11px",color:ce,marginBottom:"12px"},children:["在 inputParameters 中定义要设置的变量名和值,后续任务通过 ","${workflow.variables.varName}"," 访问。"]}),Q("VARIABLES (JSON)",typeof W.inputParameters=="object"&&W.inputParameters!==null?JSON.stringify(W.inputParameters,null,2):"{}",C=>{try{he("inputParameters",JSON.parse(C))}catch{}},{rows:6,language:"json"})]})),o.jsxs("div",{style:{marginTop:"32px",borderTop:`1px solid ${ne}`,paddingTop:"24px"},children:[o.jsx("div",{style:{fontSize:"11px",fontWeight:"bold",marginBottom:"16px",opacity:.6,textTransform:"uppercase",letterSpacing:"1px"},children:"通用参数与属性"}),rt("任务唯一引用名 (Reference Name)","taskReferenceName"),u&&u.newRef===W.taskReferenceName&&o.jsxs("div",{style:{marginBottom:"16px",padding:"10px 12px",borderRadius:"8px",background:"rgba(16, 185, 129, 0.12)",border:"1px solid rgba(16, 185, 129, 0.35)",display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px"},children:[o.jsxs("div",{style:{fontSize:"11px",color:"#34d399",lineHeight:1.5},children:[o.jsx("b",{children:"🔗 W-LSP 全图级联重构已生效"}),o.jsx("br",{}),"引用名 ",o.jsx("code",{children:u.oldRef})," → ",o.jsx("code",{children:u.newRef}),",已自动同步 ",o.jsx("b",{children:u.replacedCount})," 处下游表达式(涉及节点:",u.affectedTasks.join(", "),")"]}),o.jsx("button",{onClick:f,style:{background:"none",border:"none",color:"#34d399",cursor:"pointer",fontSize:"12px",padding:"2px"},children:"✕"})]}),rt("任务描述","description"),o.jsxs("div",{style:{marginBottom:"16px"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px",gap:"6px"},children:[o.jsxs("label",{style:{fontSize:"11px",color:ce,fontWeight:"600",textTransform:"uppercase",flex:1},children:["输入参数 (inputParameters) ",o.jsxs("span",{style:{opacity:.5,fontWeight:"normal"},children:["(JSON / 输入 $","{"," 自动补全)"]})]}),ee&&o.jsxs("div",{style:{display:"flex",gap:"6px"},children:[o.jsx("button",{onClick:C=>{const K=C.currentTarget.getBoundingClientRect();q(K),A(()=>ae=>{if(k)Qe(ae);else{const re=typeof W.inputParameters=="object"&&W.inputParameters!==null?{...W.inputParameters}:{};re[`param_${Object.keys(re).length+1}`]=ae,he("inputParameters",re)}}),j(!0)},title:"打开 W-LSP 上游变量与 Schema 零延迟补全器",style:{fontSize:"11px",background:"rgba(56, 189, 248, 0.14)",border:"1px solid rgba(56, 189, 248, 0.35)",borderRadius:"4px",padding:"2px 8px",cursor:"pointer",color:"#38bdf8",fontWeight:600,display:"flex",alignItems:"center",gap:"4px"},children:"⚡ 变量补全"}),o.jsxs("button",{onClick:fe,disabled:L,title:"AI 根据上下文自动生成 inputParameters",style:{fontSize:"11px",background:"linear-gradient(135deg, #6366f1, #8b5cf6)",border:"none",borderRadius:"4px",padding:"2px 8px",cursor:L?"not-allowed":"pointer",color:"#fff",fontWeight:600,display:"flex",alignItems:"center",gap:"4px",opacity:L?.7:1},children:[L?"⏳":"✨"," AI 填充"]}),o.jsxs("button",{onClick:()=>b(!y),title:"快捷表达式",style:{fontSize:"11px",background:y?"var(--color-accent)":"none",border:`1px solid ${ne}`,borderRadius:"4px",padding:"2px 6px",cursor:"pointer",color:y?"#fff":ce},children:["{}"," 片段"]})]})]}),y&&o.jsx("div",{style:{marginBottom:"8px",padding:"8px",borderRadius:"6px",border:`1px solid ${ne}`,background:"var(--bg-secondary)",display:"flex",flexWrap:"wrap",gap:"6px"},children:f1.map(C=>o.jsx("button",{onClick:()=>Qe(C.value),title:C.desc,style:{fontSize:"10px",padding:"3px 8px",borderRadius:"4px",border:`1px solid ${ne}`,background:_e,color:me,cursor:"pointer",fontFamily:"monospace"},children:C.label},C.value))}),z&&o.jsxs("div",{style:{marginBottom:"8px",borderRadius:"8px",border:"1px solid #6366f130",background:"#6366f108",overflow:"hidden"},children:[o.jsxs("div",{style:{padding:"8px 12px",background:"#6366f118",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsx("span",{style:{fontSize:"11px",fontWeight:700,color:"#6366f1"},children:"✨ AI 建议的 inputParameters"}),o.jsxs("div",{style:{display:"flex",gap:"6px"},children:[o.jsx("button",{onClick:()=>{he("inputParameters",z.generated),H(null)},style:{fontSize:"11px",background:"#6366f1",color:"#fff",border:"none",borderRadius:"4px",padding:"3px 10px",cursor:"pointer",fontWeight:600,fontFamily:"inherit"},children:"应用"}),o.jsx("button",{onClick:()=>H(null),style:{fontSize:"11px",background:"none",color:ce,border:`1px solid ${ne}`,borderRadius:"4px",padding:"3px 8px",cursor:"pointer",fontFamily:"inherit"},children:"取消"})]})]}),o.jsx("pre",{style:{margin:0,padding:"10px 12px",fontSize:"12px",fontFamily:"var(--font-mono)",overflowX:"auto",color:me,maxHeight:"180px",overflowY:"auto"},children:JSON.stringify(z.generated,null,2)})]}),Q("",typeof W.inputParameters=="object"&&W.inputParameters!==null?JSON.stringify(W.inputParameters,null,2):W.inputParameters??"",C=>{try{he("inputParameters",JSON.parse(C))}catch{p(K=>({...K,inputParameters:C}))}},{rows:5,language:"json","data-field":"inputParameters",style:{outline:"none"}})]}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[rt("重试次数","retryCount","number"),rt("超时限制 (秒)","timeoutSeconds","number")]}),o.jsxs("details",{style:{marginTop:"16px"},children:[o.jsx("summary",{style:{fontSize:"11px",cursor:"pointer",color:ce,userSelect:"none",fontWeight:"600"},children:"▸ 执行控制(高级)"}),o.jsxs("div",{style:{marginTop:"12px"},children:[te("重试策略 (retryLogic)",["FIXED","EXPONENTIAL_BACKOFF","LINEAR_BACKOFF"],W.retryLogic||"FIXED",C=>he("retryLogic",C)),X("重试延迟 (秒)",W.retryDelaySeconds??"",C=>he("retryDelaySeconds",C?parseInt(C):void 0),"number","0"),te("超时策略 (timeoutPolicy)",["TIME_OUT_WF","ALERT_ONLY","RETRY","FAIL_WORKFLOW"],W.timeoutPolicy||"TIME_OUT_WF",C=>he("timeoutPolicy",C)),X("启动延迟 (秒)",W.startDelay??"",C=>he("startDelay",C?parseInt(C):void 0),"number","0"),de("可选任务 (optional) — 失败不影响工作流",!!W.optional,C=>he("optional",C)),de("异步完成 (asyncComplete)",!!W.asyncComplete,C=>he("asyncComplete",C))]})]})]}),o.jsx("div",{style:{marginTop:"48px",opacity:.6},children:o.jsxs("details",{children:[o.jsx("summary",{style:{fontSize:"11px",cursor:"pointer",marginBottom:"8px"},children:"查看完整 JSON (只读)"}),o.jsx("pre",{style:{background:"rgba(0,0,0,0.2)",padding:"16px",borderRadius:"8px",fontSize:"10px",overflow:"auto",border:`1px solid ${ne}`,color:ce},children:JSON.stringify(W,null,2)})]})})]}),ee&&o.jsxs("div",{style:{padding:"24px",borderTop:`1px solid ${ne}`,background:"var(--bg-secondary)",display:"flex",gap:"12px",flexShrink:0},children:[o.jsx("div",{style:{flex:1,fontSize:"11px",color:ce,display:"flex",alignItems:"center"},children:"✅ 所有修改已实时同步"}),o.jsx("button",{onClick:r,style:{padding:"10px 24px",background:"var(--color-accent)",color:"#fff",border:"none",borderRadius:"8px",fontWeight:"bold",cursor:"pointer",boxShadow:"0 4px 12px var(--color-accent-bg)"},children:"完成退出"})]}),o.jsx(d1,{isOpen:R,onClose:()=>j(!1),onSelect:V,suggestions:$,wlspItems:P,anchorRect:E})]}),U&&o.jsx(u1,{title:U.title,value:U.value,language:U.language,onSave:U.onSave,onClose:()=>se(null)})]})},h1=I.memo(p1),Om=({keyName:e,value:t,path:r,depth:n,defaultExpanded:s,forceExpandAll:a,searchQuery:i,onCopyExpr:l,copiedPath:c,buildExpr:d})=>{const u=t!==null&&typeof t=="object",f=Array.isArray(t),[h,p]=I.useState(s),m=a!==null?a:h,g=d(r);if(!I.useMemo(()=>{if(!i.trim())return!0;const _=i.toLowerCase();if(e!==void 0&&String(e).toLowerCase().includes(_))return!0;try{return JSON.stringify(t).toLowerCase().includes(_)}catch{return!1}},[e,t,i]))return null;if(!u){let _="#e2e8f0",w=String(t);return typeof t=="string"?(_="#34d399",w=`"${t}"`):typeof t=="number"?_="#fbbf24":typeof t=="boolean"?_="#f472b6":t==null&&(_="#94a3b8",w="null"),o.jsxs("div",{className:"sjson-row",style:{paddingLeft:`${n*14}px`,display:"flex",alignItems:"center",justifyContent:"space-between",gap:"6px",paddingTop:"2px",paddingBottom:"2px",borderRadius:"4px",fontSize:"12px",fontFamily:"'JetBrains Mono', 'Fira Code', monospace"},children:[o.jsxs("div",{style:{wordBreak:"break-all",lineHeight:1.45},children:[e!==void 0&&o.jsxs("span",{style:{color:"#93c5fd"},children:[typeof e=="number"?`[${e}]`:`"${e}"`,o.jsx("span",{style:{color:"#64748b"},children:": "})]}),o.jsx("span",{style:{color:_},children:w})]}),g&&o.jsx("button",{type:"button",onClick:T=>{T.stopPropagation(),l(g)},title:`复制表达式 ${g}`,style:{flexShrink:0,fontSize:"10px",padding:"1px 6px",borderRadius:"4px",border:"1px solid rgba(56, 189, 248, 0.3)",background:c===g?"rgba(16, 185, 129, 0.2)":"rgba(56, 189, 248, 0.08)",color:c===g?"#34d399":"#38bdf8",cursor:"pointer",opacity:.85,fontFamily:"inherit"},children:c===g?"✓ 已复制":"${} 引用"})]})}const v=f?t.map((_,w)=>[w,_]):Object.entries(t),y=f?"[":"{",b=f?"]":"}",k=f?`${v.length} items`:`${v.length} keys`;return o.jsxs("div",{children:[o.jsxs("div",{onClick:()=>p(!m),style:{paddingLeft:`${n*14}px`,display:"flex",alignItems:"center",justifyContent:"space-between",gap:"6px",paddingTop:"2px",paddingBottom:"2px",cursor:"pointer",userSelect:"none",fontSize:"12px",fontFamily:"'JetBrains Mono', 'Fira Code', monospace"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[o.jsx("span",{style:{fontSize:"9px",color:"#64748b",width:"10px",display:"inline-block"},children:m?"▼":"▶"}),e!==void 0&&o.jsxs("span",{style:{color:"#93c5fd"},children:[typeof e=="number"?`[${e}]`:`"${e}"`,o.jsx("span",{style:{color:"#64748b"},children:": "})]}),o.jsxs("span",{style:{color:"#94a3b8"},children:[y,!m&&o.jsx("span",{style:{fontSize:"10px",color:"#64748b",margin:"0 4px"},children:k}),!m&&b]})]}),g&&r&&o.jsx("button",{type:"button",onClick:_=>{_.stopPropagation(),l(g)},title:`复制对象引用 ${g}`,style:{flexShrink:0,fontSize:"10px",padding:"1px 6px",borderRadius:"4px",border:"1px solid rgba(56, 189, 248, 0.25)",background:c===g?"rgba(16, 185, 129, 0.2)":"rgba(56, 189, 248, 0.06)",color:c===g?"#34d399":"#38bdf8",cursor:"pointer",opacity:.75,fontFamily:"inherit"},children:c===g?"✓ 已复制":"${} 引用"})]}),m&&o.jsxs("div",{children:[v.map(([_,w])=>{const T=typeof _=="number"?`${r}[${_}]`:r?`${r}.${_}`:String(_);return o.jsx(Om,{keyName:_,value:w,path:T,depth:n+1,defaultExpanded:n<1,forceExpandAll:a,searchQuery:i,onCopyExpr:l,copiedPath:c,buildExpr:d},String(_))}),o.jsx("div",{style:{paddingLeft:`${n*14+14}px`,color:"#94a3b8",fontSize:"12px",fontFamily:"'JetBrains Mono', 'Fira Code', monospace"},children:b})]})]})},Pm=({data:e,taskReferenceName:t,expressionScope:r="output",maxHeight:n="420px"})=>{const[s,a]=I.useState(""),[i,l]=I.useState(null),[c,d]=I.useState(null),[u,f]=I.useState(!1),h=g=>g?r==="workflow.input"?`\${workflow.input.${g}}`:t?`\${${t}.${r}.${g}}`:null:null,p=g=>{navigator.clipboard.writeText(g),d(g),setTimeout(()=>d(null),1600)};return e==null||typeof e=="object"&&Object.keys(e).length===0?o.jsx("div",{style:{padding:"20px",textAlign:"center",color:"var(--text-secondary)",fontSize:"12px",background:"rgba(15, 23, 42, 0.35)",borderRadius:"8px",border:"1px solid var(--border-primary)"},children:"暂无数据 (Empty Payload)"}):o.jsxs("div",{style:{borderRadius:"8px",border:"1px solid var(--border-primary)",background:"rgba(15, 23, 42, 0.55)",overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",padding:"6px 10px",borderBottom:"1px solid rgba(148, 163, 184, 0.14)",background:"rgba(15, 23, 42, 0.4)"},children:[o.jsx("input",{type:"text",value:s,onChange:g=>a(g.target.value),placeholder:"🔍 检索字段名或值...",style:{flex:1,padding:"4px 8px",borderRadius:"5px",border:"1px solid rgba(148, 163, 184, 0.2)",background:"rgba(2, 6, 23, 0.5)",color:"#f8fafc",fontSize:"11px",outline:"none"}}),o.jsx("button",{type:"button",onClick:()=>l(!0),style:{fontSize:"10px",padding:"3px 7px",borderRadius:"4px",border:"1px solid rgba(148, 163, 184, 0.2)",background:"transparent",color:"#cbd5e1",cursor:"pointer"},children:"全部展开"}),o.jsx("button",{type:"button",onClick:()=>l(!1),style:{fontSize:"10px",padding:"3px 7px",borderRadius:"4px",border:"1px solid rgba(148, 163, 184, 0.2)",background:"transparent",color:"#cbd5e1",cursor:"pointer"},children:"折叠"}),o.jsx("button",{type:"button",onClick:()=>f(!u),style:{fontSize:"10px",padding:"3px 7px",borderRadius:"4px",border:"1px solid rgba(148, 163, 184, 0.2)",background:u?"rgba(56, 189, 248, 0.18)":"transparent",color:u?"#38bdf8":"#cbd5e1",cursor:"pointer"},children:u?"树形视图":"RAW"})]}),o.jsx("div",{style:{padding:"10px 12px",maxHeight:n,overflowY:"auto",overflowX:"auto"},children:u?o.jsx("pre",{style:{margin:0,fontSize:"11px",fontFamily:"'JetBrains Mono', 'Fira Code', monospace",color:"#e2e8f0",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:JSON.stringify(e,null,2)}):o.jsx(Om,{value:e,path:"",depth:0,defaultExpanded:!0,forceExpandAll:i,searchQuery:s,onCopyExpr:p,copiedPath:c,buildExpr:h})})]})},m1={COMPLETED:"var(--status-completed)",FAILED:"var(--status-failed)",FAILED_WITH_TERMINAL_ERROR:"var(--status-failed-terminal)",IN_PROGRESS:"var(--status-in-progress)",SCHEDULED:"var(--status-scheduled)",TIMED_OUT:"var(--status-timed-out)",CANCELED:"var(--status-canceled)",SKIPPED:"var(--status-skipped)"},$t=e=>m1[e??""]??"var(--text-secondary)",g1=(e,t)=>{if(!e)return"-";const r=(t??Date.now())-e;return r<1e3?`${r}ms`:`${(r/1e3).toFixed(2)}s`},Am=e=>e?new Date(e).toLocaleTimeString():"-",y1=({executionActions:e})=>{const{selectedTask:t,selectedTaskInstance:r,setSelectedTask:n,setSelectedTaskInstance:s,executionData:a,workflowInstance:i}=oe(),[l,c]=I.useState("summary"),d=I.useRef(null);I.useEffect(()=>{d.current?.scrollTo({top:0})},[l,t?.taskReferenceName]),I.useEffect(()=>{c("summary")},[t?.taskReferenceName]);const u=t?.taskReferenceName==="__workflow_global__",f=t?a?.[t.taskReferenceName]:null;if(!t||!f&&!u)return null;const h=f?.attempts??[],p=r??h[h.length-1],m=i?.workflowId??"",g=i?.status,x=f?.status,v=u?g:p?.status??x,y=u?i?.startTime:p?.startTime,b=u?i?.endTime:p?.endTime,k=u?i?.reasonForIncompletion:p?.reasonForIncompletion,_=u?i?.workflowId:p?.taskId,w=u?i?.input:p?.inputData,T=u?i?.output:p?.outputData,O=!u&&e?.onSkipTask&&(x==="SCHEDULED"||x==="IN_PROGRESS")&&(g==="RUNNING"||g==="PAUSED"),D=!u&&e?.onRerunFromTask&&(g==="FAILED"||g==="TERMINATED"||g==="COMPLETED"||g==="TIMED_OUT"),N=O||D,S=e?.allowOperations!==!1,R=()=>{n(null),s(null)},j="var(--glass-border)",E="var(--text-secondary)",q="var(--bg-tertiary)";return o.jsxs("div",{className:"detail-panel-container panel-enter-active",style:{position:"absolute",right:0,top:0,bottom:0,width:450,zIndex:1200,display:"flex",flexDirection:"column",background:"var(--bg-primary)",borderLeft:`1px solid ${j}`,boxShadow:"-10px 0 30px rgba(0,0,0,0.2)",overflow:"hidden"},children:[o.jsxs("div",{style:{padding:"20px 24px",borderBottom:`1px solid ${j}`,background:"var(--bg-secondary)",flexShrink:0},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[o.jsx("div",{style:{background:"var(--color-accent)",color:"#fff",padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:"bold",letterSpacing:"1px",flexShrink:0},children:u?"WORKFLOW":t.type||"TASK"}),v&&o.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:5,padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:700,background:`${$t(v)}18`,color:$t(v),letterSpacing:"0.5px",flexShrink:0},children:["● ",v]}),o.jsx("div",{style:{flex:1}}),o.jsx("button",{onClick:R,style:{background:"none",border:"none",color:E,cursor:"pointer",fontSize:20,lineHeight:1,padding:4},children:"✕"})]}),o.jsx("div",{style:{fontSize:20,fontWeight:700,color:"var(--text-primary)",lineHeight:1.3},children:u?"工作流全局数据":t.name}),o.jsxs("div",{style:{fontSize:12,color:E,marginTop:6,fontFamily:"monospace",opacity:.8},children:["REF: ",t.taskReferenceName]})]}),h.length>1&&o.jsxs("div",{style:{padding:"12px 24px",borderBottom:`1px solid ${j}`,background:"var(--bg-secondary)",flexShrink:0},children:[o.jsxs("div",{style:{fontSize:11,fontWeight:600,color:E,marginBottom:8,textTransform:"uppercase",letterSpacing:"0.5px"},children:["执行记录(",h.length," 次",h.some($=>$.iteration)?" / 迭代":"尝试",")"]}),o.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:h.map(($,J)=>{const V=p?.taskId===$.taskId;return o.jsx("button",{onClick:()=>s($),style:{padding:"4px 12px",borderRadius:20,fontSize:12,cursor:"pointer",border:`1px solid ${V?"var(--color-accent)":j}`,background:V?"var(--color-accent)":"var(--bg-tertiary)",color:V?"#fff":"var(--text-primary)",fontFamily:"inherit",transition:"all 0.15s"},children:$.iteration?`迭代 ${$.iteration}`:`尝试 ${J+1}`},$.taskId)})})]}),o.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${j}`,background:"var(--bg-secondary)",flexShrink:0},children:["summary","input","output"].map($=>{const J={summary:"概览",input:"输入 JSON",output:"输出 JSON"},V=l===$;return o.jsx("button",{onClick:()=>c($),style:{padding:"10px 20px",background:"none",border:"none",borderBottom:`2px solid ${V?"var(--color-accent)":"transparent"}`,color:V?"var(--color-accent)":E,cursor:"pointer",fontSize:13,fontWeight:V?600:400,fontFamily:"inherit",transition:"all 0.15s"},children:J[$]},$)})}),o.jsxs("div",{ref:d,style:{flex:1,overflowY:"auto",padding:24,background:"var(--bg-primary)"},children:[l==="summary"&&o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,marginBottom:24},children:[{label:"总耗时",value:g1(y,b)},{label:"开始时间",value:Am(y)},{label:"结束时间",value:Am(b)},{label:u?"Workflow ID":"Task ID",value:o.jsx("span",{style:{fontSize:10,fontFamily:"monospace",opacity:.7,wordBreak:"break-all"},children:_??"-"})}].map(({label:$,value:J})=>o.jsxs("div",{style:{padding:"12px 14px",background:q,borderRadius:10,border:`1px solid ${j}`},children:[o.jsx("div",{style:{fontSize:10,color:E,textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:6,fontWeight:600},children:$}),o.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",fontSize:13},children:J})]},$))}),h.length>1&&o.jsxs("div",{style:{marginBottom:20,padding:"10px 14px",background:`${$t(x)}10`,border:`1px solid ${$t(x)}30`,borderRadius:8,fontSize:12,color:$t(x),display:"flex",alignItems:"center",gap:8},children:[o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[o.jsx("path",{d:"M13 2v4h-4"}),o.jsx("path",{d:"M13 6A7 7 0 1 1 9.5 2.5"})]}),"已重试 ",h.length-1," 次,共 ",h.length," 次尝试"]}),!u&&p?.workerId&&o.jsxs("div",{style:{marginBottom:20},children:[o.jsx("div",{style:{fontSize:10,color:E,textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:4,fontWeight:600},children:"Worker"}),o.jsx("div",{style:{fontSize:12,fontFamily:"monospace",color:"var(--text-primary)",opacity:.8},children:p.workerId})]}),k&&o.jsxs("div",{style:{padding:14,background:"rgba(239,68,68,0.08)",borderLeft:"3px solid var(--status-failed)",borderRadius:"0 8px 8px 0",fontSize:12,color:"var(--status-failed)",lineHeight:1.6},children:[o.jsx("strong",{children:"异常信息"}),o.jsx("div",{style:{marginTop:6,opacity:.9},children:k})]}),N&&o.jsxs("div",{style:{marginTop:24,paddingTop:20,borderTop:`1px solid ${j}`},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[o.jsx("div",{style:{fontSize:11,fontWeight:600,color:E,textTransform:"uppercase",letterSpacing:"0.5px"},children:"任务操作"}),!S&&o.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 7px",borderRadius:4,background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.25)",color:"var(--status-failed)",fontSize:10,fontWeight:600},children:[o.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[o.jsx("circle",{cx:"8",cy:"8",r:"6"}),o.jsx("path",{d:"M8 5v3M8 11v.5"})]}),"操作权限受限"]})]}),o.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[D&&o.jsxs("button",{disabled:!S,onClick:()=>S&&e.onRerunFromTask(m,t.taskReferenceName,p?.taskId),title:S?`从任务 ${t.taskReferenceName} 处重新运行工作流`:"操作权限受限",style:S?ct:Lm,onMouseEnter:$=>!S||Object.assign($.currentTarget.style,x1),onMouseLeave:$=>!S||Object.assign($.currentTarget.style,ct),children:[o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[o.jsx("path",{d:"M3 14v-4h4"}),o.jsx("path",{d:"M3 10A7 7 0 1 1 6.5 13.5"})]}),"从此处重新运行"]}),O&&o.jsxs("button",{disabled:!S,onClick:()=>S&&e.onSkipTask(m,t.taskReferenceName,p?.taskId),title:S?`跳过任务 ${t.taskReferenceName}`:"操作权限受限",style:S?ct:Lm,onMouseEnter:$=>!S||Object.assign($.currentTarget.style,v1),onMouseLeave:$=>!S||Object.assign($.currentTarget.style,ct),children:[o.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:o.jsx("path",{d:"M4 4l8 8M12 4l-8 8"})}),"跳过此任务"]})]})]})]}),l==="input"&&o.jsx(Pm,{data:w,taskReferenceName:u?void 0:t.taskReferenceName,expressionScope:u?"workflow.input":"input",maxHeight:"calc(100vh - 280px)"}),l==="output"&&o.jsx(Pm,{data:T,taskReferenceName:u?void 0:t.taskReferenceName,expressionScope:"output",maxHeight:"calc(100vh - 280px)"})]})]})},ct={display:"inline-flex",alignItems:"center",gap:6,padding:"7px 14px",borderRadius:8,fontSize:12,fontWeight:500,cursor:"pointer",border:"1px solid var(--border-primary)",background:"var(--bg-secondary)",color:"var(--text-primary)",fontFamily:"inherit",transition:"all 0.15s"},x1={...ct,borderColor:"var(--color-accent)",color:"var(--color-accent)",background:"var(--bg-primary)"},v1={...ct,borderColor:"var(--status-failed)",color:"var(--status-failed)",background:"rgba(239,68,68,0.08)"},Lm={...ct,opacity:.45,cursor:"not-allowed",border:"1px solid var(--border-primary)",background:"var(--bg-secondary)",color:"var(--text-secondary)"},b1={add:"新增",mod:"修改",del:"删除",replace:"替换"},k1={add:"+",mod:"~",del:"−"};function S1({diff:e,applied:t,onApply:r,onUndo:n}){const s=e.kind==="replace"?"add":e.kind;return o.jsxs("div",{className:"diff-card",children:[o.jsxs("div",{className:"diff-head",children:[o.jsx("span",{className:`diff-badge ${s}`,children:b1[e.kind]??e.kind}),o.jsx("span",{className:"diff-summary",children:e.summary})]}),e.rows&&e.rows.length>0&&o.jsx("div",{className:"diff-list",children:e.rows.map((a,i)=>o.jsxs("div",{className:`diff-row ${a.kind}`,children:[o.jsx("div",{className:"diff-marker",children:k1[a.kind]??"·"}),o.jsx("div",{className:"diff-desc",children:a.desc})]},i))}),o.jsx("div",{className:"diff-actions",children:t?o.jsxs(o.Fragment,{children:[o.jsxs("button",{className:"diff-btn applied",disabled:!0,children:[o.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:o.jsx("path",{d:"M3 8l3.5 3.5L13 5",strokeLinecap:"round",strokeLinejoin:"round"})}),"已应用"]}),o.jsxs("button",{className:"diff-btn undo",onClick:n,children:[o.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("path",{d:"M3.5 8a4.5 4.5 0 1 1 1.4 3.3",strokeLinecap:"round"}),o.jsx("path",{d:"M3 4.5L4.5 8L7 6.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),"撤销"]})]}):o.jsxs("button",{className:"diff-btn apply",onClick:r,children:[o.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:o.jsx("path",{d:"M3 8l3.5 3.5L13 5",strokeLinecap:"round",strokeLinejoin:"round"})}),"应用更改"]})})]})}function Dm(e,t){const r=JSON.parse(JSON.stringify(e));if(t.kind==="replace"&&t.payload)return{next:JSON.parse(JSON.stringify(t.payload)),inverse:{kind:"replace",summary:"撤销替换",rows:[],payload:e}};if(t.kind==="add"&&t.payload)return{next:JSON.parse(JSON.stringify(t.payload)),inverse:{kind:"replace",summary:"撤销生成",rows:[],payload:e}};if(!t.patch)return{next:r,inverse:{kind:t.kind,summary:"(无变更)",rows:[]}};const n=[],s=[];for(const a of t.patch)if(a.op==="patchTask"){const i=r.tasks.find(c=>c.taskReferenceName===a.ref);if(!i)continue;const l={};for(const c of Object.keys(a.set))l[c]=i[c];Object.assign(i,a.set),n.push({op:"patchTask",ref:a.ref,set:l}),s.push({kind:"mod",desc:`还原 ${a.ref} 属性`})}else if(a.op==="addEdge")r.edges=r.edges??[],r.edges.push({from:a.from,to:a.to,label:a.label}),n.push({op:"removeEdge",from:a.from,to:a.to}),s.push({kind:"del",desc:`移除边 ${a.from} → ${a.to}`});else if(a.op==="removeEdge")r.edges=(r.edges??[]).filter(i=>!(i.from===a.from&&i.to===a.to)),n.push({op:"addEdge",from:a.from,to:a.to}),s.push({kind:"add",desc:`恢复边 ${a.from} → ${a.to}`});else if(a.op==="addTask")r.tasks.push(a.task),r.edges=r.edges??[],a.removeEdges&&a.removeEdges.forEach(i=>{r.edges=r.edges.filter(l=>!(l.from===i.from&&l.to===i.to))}),a.extraEdges&&a.extraEdges.forEach(i=>r.edges.push(i)),n.push({op:"removeTask",ref:a.task.taskReferenceName}),s.push({kind:"del",desc:`移除 ${a.task.taskReferenceName}`});else if(a.op==="removeTask"){const i=r.tasks.findIndex(d=>d.taskReferenceName===a.ref);if(i<0)continue;const[l]=r.tasks.splice(i,1),c=(r.edges??[]).filter(d=>d.from===a.ref||d.to===a.ref);r.edges=(r.edges??[]).filter(d=>d.from!==a.ref&&d.to!==a.ref),n.push({op:"addTask",task:l,extraEdges:c}),s.push({kind:"add",desc:`恢复 ${a.ref}`})}else if(a.op==="insertAfter"){r.tasks.push(a.task),r.edges=r.edges??[];const i=r.edges.findIndex(l=>l.from===a.after&&l.to===a.edgeTo);i>=0&&r.edges.splice(i,1),r.edges.push({from:a.after,to:a.task.taskReferenceName}),r.edges.push({from:a.task.taskReferenceName,to:a.edgeTo}),n.push({op:"removeTask",ref:a.task.taskReferenceName}),s.push({kind:"del",desc:`移除 ${a.task.taskReferenceName}(恢复直连边)`})}else if(a.op==="insertBefore"){r.tasks.push(a.task),r.edges=r.edges??[];const i=r.edges.filter(l=>l.to===a.before);r.edges=r.edges.filter(l=>l.to!==a.before),i.forEach(l=>r.edges.push({from:l.from,to:a.task.taskReferenceName,label:l.label})),r.edges.push({from:a.task.taskReferenceName,to:a.before}),n.push({op:"removeTask",ref:a.task.taskReferenceName}),s.push({kind:"del",desc:`移除 ${a.task.taskReferenceName}(恢复原有入边)`})}return{next:r,inverse:{kind:t.kind,summary:`撤销:${t.summary}`,rows:s,patch:n.reverse()}}}function _1(e){const t=e.match(/```diff-json\n([\s\S]*?)\n```/);if(!t)return null;try{const r=JSON.parse(t[1]);return!r.kind||!r.summary?null:r}catch{return null}}const Mm={id:"1",role:"ai",content:"你好!我是您的流程助手。我可以帮你生成工作流框架、优化逻辑或提供参数配置建议。你想实现什么样的流程?"},qm=e=>e.split(/(```[\s\S]*?```)/).map((r,n)=>{if(r.startsWith("```")&&r.endsWith("```")){const s=r.slice(3,-3),a=s.indexOf(`
|
|
128
|
-
`),i=
|
|
129
|
-
`&&t.push(o.jsx("br",{},s.index)),n=s.index+a.length}return n<e.length&&t.push(e.slice(n)),t},T1=({aiConfig:e})=>{const{workflowDef:t,setWorkflow:r,mode:n}=oe(),[s,a]=I.useState(!1),[i,l]=I.useState(""),[c,d]=I.useState(!1),[u,f]=I.useState([Mm]),[h,p]=I.useState(""),[m,g]=I.useState(null),x=I.useRef(null),v=I.useRef(null),y=I.useRef(null),b=I.useCallback(E=>{if(!E.diff||E.applied||!t)return;const{next:q,inverse:$}=Dm(t,E.diff);r(q),f(J=>J.map(V=>V.id===E.id?{...V,applied:!0,inverse:$}:V))},[t,r]),k=I.useCallback(E=>{if(!E.inverse||!E.applied||!t)return;const{next:q}=Dm(t,E.inverse);r(q),f($=>$.map(J=>J.id===E.id?{...J,applied:!1,inverse:void 0}:J))},[t,r]),_=()=>{const E=v.current;E&&(E.style.height="auto",E.style.height=Math.min(E.scrollHeight,120)+"px")},w=()=>{const E=v.current;E&&(E.style.height="auto")};I.useEffect(()=>()=>{y.current?.abort()},[]),I.useEffect(()=>{const E=()=>a(!0);return window.addEventListener("open-ai-chat",E),()=>window.removeEventListener("open-ai-chat",E)},[]);const T=()=>{x.current?.scrollIntoView({behavior:"smooth"})};I.useEffect(()=>{s&&T()},[u,s,h]);const O=I.useCallback(E=>{const q=[{role:"system",content:t1}];for(const J of u)J.role==="user"&&J.content?q.push({role:"user",content:J.content}):J.role==="ai"&&J.content&&!J.thinking&&q.push({role:"assistant",content:J.content});const $=i1(E,t);return q.push({role:"user",content:$}),q},[u,t]),D=async E=>{const q=i.trim();if(!q||c)return;y.current?.abort();const $=new AbortController;y.current=$;const J={id:Date.now().toString(),role:"user",content:q};f(V=>[...V,J]),l(""),w(),d(!0),p("");try{const V=e?.apiKey||localStorage.getItem("AI_API_KEY")||"",A=e?.baseUrl||localStorage.getItem("AI_BASE_URL")||"",B=e?.model||localStorage.getItem("AI_MODEL")||"";if(!V){setTimeout(()=>{if($.signal.aborted)return;const H={name:"demo_approval_workflow",description:"演示审批流程",tasks:[{name:"submit_request",taskReferenceName:"submit_request",type:"SIMPLE",inputParameters:{}},{name:"human_approval",taskReferenceName:"human_approval",type:"HUMAN",inputParameters:{}},{name:"process_result",taskReferenceName:"process_result",type:"SIMPLE",inputParameters:{}}]},Y={id:(Date.now()+1).toString(),role:"ai",content:"**演示模式**:未检测到 API Key,以下是一个示例审批流程供体验。请在标题栏 🤖 按钮中配置真实 API Key 以启用 AI 功能。",diff:{kind:"replace",summary:"生成三步审批流程(演示)",rows:[{kind:"add",desc:"submit_request — 提交申请任务"},{kind:"add",desc:"human_approval — 人工审批任务"},{kind:"add",desc:"process_result — 处理审批结果"}],payload:H}};f(ie=>[...ie,Y]),d(!1)},800);return}const P={apiKey:V};A&&(P.baseUrl=A),B&&(P.model=B);const U=O(q),se=await Qb(U,P,H=>{p(Y=>Y+H)},()=>{},$.signal);let F=_1(se);if(!F){const H=se.match(/```json\n([\s\S]*?)\n```/);if(H)try{const Y=JSON.parse(H[1]);F={kind:"replace",summary:"应用 AI 生成的工作流",rows:[{kind:"add",desc:"全量替换为 AI 生成的工作流定义"}],payload:Y}}catch{}}const z={id:(Date.now()+1).toString(),role:"ai",content:se,diff:F??void 0,applied:!1};f(H=>[...H,z]),p("")}catch(V){if(V.name==="AbortError")p(A=>{if(A){const B={id:(Date.now()+1).toString(),role:"ai",content:A};f(P=>[...P,B])}return""});else{const A={id:Date.now().toString(),role:"ai",content:`抱歉,目前无法连接到 AI 服务: ${V.message}`};f(B=>[...B,A]),p("")}}finally{d(!1)}},N=()=>{y.current?.abort()},S=()=>{y.current?.abort(),f([Mm]),p(""),d(!1)},R=E=>{navigator.clipboard.writeText(E.content??""),g(E.id),setTimeout(()=>g(null),1500)},j=E=>{E.nativeEvent.isComposing||E.keyCode===229||E.key==="Enter"&&!E.shiftKey&&(E.preventDefault(),D())};return n!=="edit"?null:s?o.jsxs("div",{className:"ai-chat-panel",children:[o.jsxs("div",{className:"ai-header",children:[o.jsxs("div",{className:"ai-title",children:[o.jsx("span",{className:"ai-sparkles",children:"✨"}),"AI 助手"]}),o.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[o.jsx("button",{className:"ai-close",onClick:S,title:"清空对话",children:"🗑"}),o.jsx("button",{className:"ai-close",onClick:()=>a(!1),children:"×"})]})]}),o.jsxs("div",{className:"ai-messages",children:[u.map(E=>o.jsxs("div",{className:`message ${E.role}`,children:[o.jsx("div",{className:"message-content",children:E.thinking?o.jsxs("div",{className:"thinking-skeleton",children:[o.jsx("div",{className:"skeleton-line",style:{width:"80%"}}),o.jsx("div",{className:"skeleton-line",style:{width:"60%"}})]}):E.role==="ai"?qm(E.content??""):E.content}),E.diff&&!E.thinking&&o.jsx(S1,{diff:E.diff,applied:E.applied??!1,onApply:()=>b(E),onUndo:()=>k(E)}),E.role==="ai"&&E.content&&o.jsx("button",{className:"copy-btn",onClick:()=>R(E),title:"复制",children:m===E.id?"✓":"📋"})]},E.id)),c&&h&&o.jsxs("div",{className:"message ai",style:{opacity:.9},children:[o.jsx("div",{className:"message-content",children:qm(h)}),o.jsx("span",{className:"streaming-cursor",children:"▊"})]}),c&&!h&&o.jsxs("div",{className:"message ai thinking-skeleton",children:[o.jsx("div",{className:"skeleton-line",style:{width:"80%"}}),o.jsx("div",{className:"skeleton-line",style:{width:"60%"}}),o.jsx("div",{className:"skeleton-line",style:{width:"70%"}})]}),o.jsx("div",{ref:x})]}),o.jsx("div",{className:"ai-input-area",children:o.jsxs("div",{className:"ai-input-container",children:[o.jsx("textarea",{ref:v,className:"ai-input",placeholder:c?"AI 正在响应...":"描述您的需求…(Shift+Enter 换行)",value:i,onChange:E=>l(E.target.value),onInput:_,onKeyDown:j,disabled:c,rows:2}),c?o.jsx("button",{className:"ai-send stop",onClick:N,title:"停止生成",children:"⏹"}):o.jsx("button",{className:"ai-send",onClick:()=>D(),title:"发送",children:"🚀"})]})})]}):o.jsx("div",{className:"ai-chat-panel collapsed",onClick:()=>a(!0),children:o.jsx("div",{className:"ai-header",style:{borderBottom:"none"},children:o.jsxs("div",{className:"ai-title",children:[o.jsx("span",{className:"ai-sparkles",children:"✨"}),"AI 助手"]})})})},E1=new Set(["COMPLETED","FAILED","TIMED_OUT","TERMINATED"]),N1=({onTriggerExecution:e,onPollExecution:t,executionPollInterval:r=3e3})=>{const{workflowDef:n,showRunPanel:s,setShowRunPanel:a,setRunState:i,importExecutionJSON:l,setMode:c}=oe(),[d,u]=I.useState("form"),[f,h]=I.useState({}),[p,m]=I.useState("{}"),[g,x]=I.useState(""),[v,y]=I.useState(!1),[b,k]=I.useState(""),_=At(n?.inputParameters);I.useEffect(()=>{s&&(h({}),m("{}"),x(""),k(""),y(!1))},[s]);const w=I.useCallback(()=>{try{const S={};_.forEach(R=>{const j=f[R.name];if(j!==void 0&&j!=="")if(R.type==="number")S[R.name]=Number(j);else if(R.type==="boolean")S[R.name]=j==="true";else if(R.type==="object"||R.type==="array")try{S[R.name]=JSON.parse(j)}catch{S[R.name]=j}else S[R.name]=j;else R.defaultValue!==void 0&&(S[R.name]=R.defaultValue)}),m(JSON.stringify(S,null,2))}catch{}u("json")},[f,_]),T=I.useCallback(()=>{try{const S=JSON.parse(p),R={};_.forEach(j=>{const E=S[j.name];E!==void 0&&(R[j.name]=typeof E=="object"?JSON.stringify(E,null,2):String(E))}),h(R),x("")}catch{x("JSON 格式有误,无法切换为表单模式")}u("form")},[p,_]),O=I.useCallback(()=>{if(d==="json")try{return JSON.parse(p)}catch{return x("JSON 格式有误,请检查后重试"),null}const S={};return _.forEach(R=>{const j=f[R.name]??(R.defaultValue!==void 0?String(R.defaultValue):"");if(!(j===""&&!R.required))if(R.type==="number")S[R.name]=Number(j);else if(R.type==="boolean")S[R.name]=j==="true";else if(R.type==="object"||R.type==="array")try{S[R.name]=JSON.parse(j)}catch{S[R.name]=j}else S[R.name]=j}),S},[d,p,f,_]),D=I.useCallback(async()=>{if(!e||!n)return;const S=O();if(S===null)return;const R=_.filter(j=>j.required&&(S[j.name]===void 0||S[j.name]===""));if(R.length>0){k(`必填参数未填写:${R.map(j=>j.name).join(", ")}`);return}y(!0),k(""),i("triggering");try{const{workflowId:j}=await e(n.name,n.version??1,S);if(i("polling",j),a(!1),c("run"),!t)return;let E=r;const q=15e3;let $;const J=async()=>{try{const V=await t(j);if(V&&(l(V),E1.has(V.status))){i("done",j);return}}catch{}E=Math.min(E*1.5,q),$=setTimeout(J,E)};$=setTimeout(J,E),oe.getState().__pollTimer=$}catch(j){const E=j?.message||"执行触发失败,请检查配置后重试";i("error",null,E),k(E),y(!1)}},[e,t,n,O,_,i,a,l,c,r]);if(!s||!n)return null;const N=_.length>0;return o.jsx("div",{className:"wrp-overlay",onClick:()=>a(!1),children:o.jsxs("div",{className:"wrp-panel",onClick:S=>S.stopPropagation(),children:[o.jsxs("div",{className:"wrp-header",children:[o.jsxs("div",{className:"wrp-header-title",children:[o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",style:{color:"var(--status-completed)"},children:o.jsx("path",{d:"M4 3l9 5-9 5z"})}),"执行验证"]}),o.jsxs("div",{className:"wrp-workflow-name",children:[n.name," ",o.jsxs("span",{className:"wrp-version",children:["v",n.version??1]})]}),o.jsx("button",{className:"wrp-close",onClick:()=>a(!1),children:"✕"})]}),o.jsxs("div",{className:"wrp-content",children:[o.jsxs("div",{className:"wrp-section-label",children:["工作流输入参数",N&&o.jsxs("div",{className:"wrp-mode-toggle",children:[o.jsx("button",{className:d==="form"?"active":"",onClick:d==="json"?T:void 0,children:"表单模式"}),o.jsx("button",{className:d==="json"?"active":"",onClick:d==="form"?w:void 0,children:"JSON 编辑器"})]})]}),!N&&d==="form"&&o.jsxs("p",{className:"wrp-hint",children:["该工作流未声明输入参数。你可以在 ",o.jsx("strong",{children:"工作流设置 → 参数配置"})," 中添加,也可以直接在 JSON 编辑器中手动填写。"]}),d==="form"?o.jsxs("div",{className:"wrp-form",children:[_.map(S=>o.jsxs("div",{className:"wrp-field",children:[o.jsxs("label",{className:"wrp-field-label",children:[S.name,S.required&&o.jsx("span",{className:"wrp-required",children:"*"}),S.type&&o.jsx("span",{className:"wrp-type",children:S.type})]}),S.description&&o.jsx("p",{className:"wrp-field-desc",children:S.description}),S.type==="object"||S.type==="array"?o.jsx("textarea",{className:"wrp-input",rows:3,placeholder:S.example?JSON.stringify(S.example,null,2):"{}",value:f[S.name]??"",onChange:R=>h(j=>({...j,[S.name]:R.target.value}))}):S.type==="boolean"?o.jsxs("select",{className:"wrp-input",value:f[S.name]??(S.defaultValue!==void 0?String(S.defaultValue):""),onChange:R=>h(j=>({...j,[S.name]:R.target.value})),children:[o.jsx("option",{value:"",children:"请选择"}),o.jsx("option",{value:"true",children:"true"}),o.jsx("option",{value:"false",children:"false"})]}):o.jsx("input",{className:"wrp-input",type:S.type==="number"?"number":"text",placeholder:S.example!==void 0?String(S.example):S.defaultValue!==void 0?String(S.defaultValue):"",value:f[S.name]??"",onChange:R=>h(j=>({...j,[S.name]:R.target.value}))})]},S.name)),!N&&o.jsx("button",{className:"wrp-switch-json",onClick:w,children:"切换为 JSON 编辑器手动填写"})]}):o.jsxs("div",{className:"wrp-json-editor",children:[o.jsx("textarea",{className:"wrp-input wrp-json",rows:12,value:p,onChange:S=>{m(S.target.value),x("")},spellCheck:!1,placeholder:'{\\n "key": "value"\\n}'}),g&&o.jsx("p",{className:"wrp-error",children:g})]}),b&&o.jsx("p",{className:"wrp-error wrp-submit-error",children:b})]}),o.jsxs("div",{className:"wrp-footer",children:[o.jsx("button",{className:"wrp-btn wrp-btn-cancel",onClick:()=>a(!1),children:"取消"}),e?o.jsx("button",{className:"wrp-btn wrp-btn-execute",onClick:D,disabled:v,children:v?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"wrp-spinner"}),"执行中..."]}):o.jsxs(o.Fragment,{children:[o.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:o.jsx("path",{d:"M4 3l9 5-9 5z"})}),"发起执行"]})}):o.jsx("span",{className:"wrp-hint-inline",children:"未配置 onTriggerExecution 回调"})]})]})})},j1=[{pattern:/NullPointerException|null.*inputData|inputData.*null/i,category:"parameter",title:"参数引用为空",explanation:"某个 inputParameters 字段引用的上游任务输出为 null。请检查 JSONPath 表达式,确认前序任务确实返回了对应字段。",suggestEditParam:"inputParameters"},{pattern:/PathNotFoundException|No results for path|path not found/i,category:"parameter",title:"JSONPath 路径不存在",explanation:"参数中的 JSONPath 表达式(如 ${task.output.field})在实际执行数据中找不到对应路径。请核查前序任务的实际输出结构。",suggestEditParam:"inputParameters"},{pattern:/ClassCastException|cannot cast|type mismatch/i,category:"parameter",title:"参数类型不匹配",explanation:"输入参数的数据类型与任务期望不符(如将字符串传给了数字类型参数)。请检查参数值的类型。",suggestEditParam:"inputParameters"},{pattern:/Connection refused|connect.*timeout|SocketException/i,category:"network",title:"网络连接失败",explanation:"无法连接到目标服务器。请检查 HTTP 任务的 uri 是否正确,以及目标服务是否可访问。",suggestEditParam:"uri"},{pattern:/HTTP.*4\d\d|status.*4\d\d|4\d\d.*status/i,category:"network",title:"HTTP 客户端错误",explanation:"HTTP 请求返回 4xx 错误,通常由请求参数、认证或权限问题引起。请检查 uri、headers、body 配置。",suggestEditParam:"inputParameters"},{pattern:/HTTP.*5\d\d|status.*5\d\d|5\d\d.*status/i,category:"network",title:"HTTP 服务端错误",explanation:"目标服务返回 5xx 错误,服务端发生异常。可尝试重试,或检查传入的请求体是否符合服务端期望。",suggestEditParam:"inputParameters"},{pattern:/Unauthorized|401|authentication|auth.*failed/i,category:"auth",title:"认证失败",explanation:"请求被拒绝,认证信息无效或缺失。请检查 headers 中的 Authorization 或 token 参数配置。",suggestEditParam:"inputParameters"},{pattern:/timeout|timed.?out|TIMED_OUT/i,category:"timeout",title:"任务超时",explanation:"任务执行时间超过配置的超时阈值。可考虑增大 timeoutSeconds,或优化被调用服务的响应速度。",suggestEditParam:"timeoutSeconds"},{pattern:/loopCondition|loop.*condition|condition.*false/i,category:"logic",title:"循环条件配置问题",explanation:"DO_WHILE 的 loopCondition 表达式可能无法正常求值。请检查条件表达式引用的变量是否正确。",suggestEditParam:"loopCondition"},{pattern:/expression.*error|script.*error|evaluator.*failed/i,category:"logic",title:"脚本表达式错误",explanation:"INLINE/LAMBDA 任务的脚本表达式执行时出错。请检查 expression 或 scriptExpression 的语法和逻辑。",suggestEditParam:"inputParameters"}];function C1(e,t){const r=t[e];if(!r)return[];const n=r.reasonForIncompletion||"";if(!n)return[];const s=[];for(const a of j1)a.pattern.test(n)&&s.push({category:a.category,title:a.title,explanation:a.explanation,suggestEditParam:a.suggestEditParam});return s.length===0&&n.length>0&&s.push({category:"logic",title:"执行异常",explanation:`任务执行失败,原因:${n.slice(0,200)}${n.length>200?"...":""}`}),s}function I1(e,t){const r=Object.values(e).map(p=>{const m=p.startTime&&p.endTime?p.endTime-p.startTime:void 0,g=Math.max(0,(p.attempts?.length??1)-1);return{taskRef:p.taskReferenceName,status:p.status,startTime:p.startTime,endTime:p.endTime,durationMs:m,retryCount:g,reasonForIncompletion:p.reasonForIncompletion,diagnostics:C1(p.taskReferenceName,e)}}).sort((p,m)=>(p.startTime??0)-(m.startTime??0)),n=["FAILED","FAILED_WITH_TERMINAL_ERROR","TIMED_OUT"],s=r.filter(p=>p.status==="COMPLETED"||p.status==="COMPLETED_WITH_ERRORS").length,a=r.filter(p=>n.includes(p.status)).length,i=r.filter(p=>p.status==="SKIPPED").length,l=r.flatMap(p=>[p.startTime,p.endTime]).filter(p=>!!p),c=l.length?Math.min(...l):0,u=(l.length?Math.max(...l):0)-c,f=t?.status,h=f==="FAILED"||f==="TIMED_OUT"||f==="TERMINATED"||a>0;return{totalTasks:r.length,completedTasks:s,failedTasks:a,skippedTasks:i,totalDurationMs:u,steps:r,hasFailed:h}}function $m(e){return e===void 0||e<0?"-":e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m ${Math.round(e%6e4/1e3)}s`}function R1(e){return{parameter:"⚙️",timeout:"⏱️",auth:"🔐",network:"🌐",logic:"🔧"}[e]??"⚠️"}function O1(e){return{parameter:"#f59e0b",timeout:"#8b5cf6",auth:"#ef4444",network:"#3b82f6",logic:"#10b981"}[e]??"#6b7280"}const Wm={COMPLETED:"完成",COMPLETED_WITH_ERRORS:"完成(含错误)",FAILED:"失败",FAILED_WITH_TERMINAL_ERROR:"终态失败",IN_PROGRESS:"执行中",SCHEDULED:"等待中",TIMED_OUT:"超时",SKIPPED:"跳过",CANCELED:"已取消"},Fm={COMPLETED:"var(--status-completed)",COMPLETED_WITH_ERRORS:"var(--status-completed)",FAILED:"var(--status-failed)",FAILED_WITH_TERMINAL_ERROR:"var(--status-failed)",IN_PROGRESS:"var(--status-running)",SCHEDULED:"var(--status-scheduled)",TIMED_OUT:"var(--status-failed)",SKIPPED:"var(--status-skipped, #6b7280)",CANCELED:"var(--status-failed)"},P1=()=>{const{executionData:e,workflowInstance:t,showAnalysisPanel:r,setShowAnalysisPanel:n,switchToEditAndFocusParam:s,selectTaskAction:a,taskMap:i}=oe(),l=I.useMemo(()=>e?I1(e,t??null):null,[e,t]);if(!r||!l)return null;const{totalTasks:c,completedTasks:d,failedTasks:u,skippedTasks:f,totalDurationMs:h,steps:p}=l,m=c>0?Math.round(d/c*100):0,g=t?.status,x=g?Fm[g]??"var(--text-secondary)":"var(--text-secondary)";return o.jsxs("div",{className:"esp-panel glass-panel",children:[o.jsxs("div",{className:"esp-header",children:[o.jsxs("div",{className:"esp-title",children:[o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[o.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"2"}),o.jsx("path",{d:"M5 8h6M5 5h3M5 11h4"})]}),"执行分析"]}),g&&o.jsx("span",{className:"esp-wf-status",style:{color:x},children:Wm[g]??g}),o.jsx("button",{className:"esp-close",onClick:()=>n(!1),children:"✕"})]}),o.jsxs("div",{className:"esp-content",children:[o.jsxs("div",{className:"esp-overview",children:[o.jsxs("div",{className:"esp-card",children:[o.jsx("span",{className:"esp-card-value",children:c}),o.jsx("span",{className:"esp-card-label",children:"总任务数"})]}),o.jsxs("div",{className:"esp-card esp-card-success",children:[o.jsx("span",{className:"esp-card-value",style:{color:"var(--status-completed)"},children:d}),o.jsx("span",{className:"esp-card-label",children:"已完成"})]}),o.jsxs("div",{className:"esp-card esp-card-failed",children:[o.jsx("span",{className:"esp-card-value",style:{color:u>0?"var(--status-failed)":"var(--text-secondary)"},children:u}),o.jsx("span",{className:"esp-card-label",children:"失败"})]}),o.jsxs("div",{className:"esp-card",children:[o.jsx("span",{className:"esp-card-value",children:$m(h)}),o.jsx("span",{className:"esp-card-label",children:"总耗时"})]})]}),o.jsx("div",{className:"esp-progress-bar",children:o.jsx("div",{className:"esp-progress-fill",style:{width:`${m}%`,background:u>0?"var(--status-failed)":"var(--status-completed)"},title:`成功率 ${m}%`})}),o.jsxs("div",{className:"esp-progress-label",children:[m,"% 成功率",f>0?`,${f} 个任务已跳过`:""]}),p.filter(v=>v.diagnostics.length>0).map(v=>o.jsxs("div",{className:"esp-diagnostic-card",children:[o.jsxs("div",{className:"esp-diag-task-ref",children:[o.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",style:{color:"var(--status-failed)",flexShrink:0},children:o.jsx("path",{d:"M8 1a7 7 0 100 14A7 7 0 008 1zm-.75 4a.75.75 0 011.5 0v3.5a.75.75 0 01-1.5 0V5zm.75 7a1 1 0 110-2 1 1 0 010 2z"})}),v.taskRef]}),v.diagnostics.map((y,b)=>o.jsxs("div",{className:"esp-diag-item",style:{borderLeftColor:O1(y.category)},children:[o.jsxs("div",{className:"esp-diag-title",children:[o.jsx("span",{children:R1(y.category)}),y.title]}),o.jsx("p",{className:"esp-diag-explanation",children:y.explanation}),o.jsxs("button",{className:"esp-fix-btn",onClick:()=>s(v.taskRef,y.suggestEditParam),children:["去修复",o.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:o.jsx("path",{d:"M5 8h6M9 5l3 3-3 3"})})]})]},b))]},v.taskRef)),o.jsx("div",{className:"esp-section-label",children:"步骤执行时序"}),o.jsxs("div",{className:"esp-steps-table",children:[o.jsxs("div",{className:"esp-steps-header",children:[o.jsx("span",{children:"#"}),o.jsx("span",{children:"任务引用名"}),o.jsx("span",{children:"状态"}),o.jsx("span",{children:"耗时"}),o.jsx("span",{children:"重试"})]}),p.map((v,y)=>{const b=Fm[v.status]??"var(--text-secondary)",k=i[v.taskRef];return o.jsxs("button",{className:"esp-step-row",onClick:()=>k&&a(k,!0),title:v.reasonForIncompletion||v.taskRef,children:[o.jsx("span",{className:"esp-step-idx",children:y+1}),o.jsx("span",{className:"esp-step-ref",children:v.taskRef}),o.jsxs("span",{className:"esp-step-status",style:{color:b},children:[o.jsx("span",{className:"esp-status-dot",style:{background:b}}),Wm[v.status]??v.status]}),o.jsx("span",{className:"esp-step-duration",children:$m(v.durationMs)}),o.jsx("span",{className:"esp-step-retry",style:{color:v.retryCount>0?"var(--status-failed)":"var(--text-secondary)"},children:v.retryCount>0?`${v.retryCount}次`:"-"})]},v.taskRef)})]})]})]})},Bm=I.forwardRef(({workflowDef:e,readOnly:t=!1,theme:r="dark",themeColor:n="blue",layoutDirection:s="LR",searchQuery:a="",workflowExecution:i,onRequestImport:l,executionActions:c,aiConfig:d,viewMode:u="developer",onSave:f,onWorkflowChange:h,height:p="100%",onTriggerExecution:m,onPollExecution:g,executionPollInterval:x=3e3},v)=>{const{setWorkflow:y,setTheme:b,setThemeColor:k,setLayoutDirection:_,setNodesLocked:w,selectedTask:T,setSelectedTask:O,edgeType:D,importExecutionJSON:N,setMode:S,setViewMode:R,isDetailPanelOpen:j,setIsDetailPanelOpen:E,selectTaskAction:q,workflowDef:$,isSimRunning:J,startSimulation:V,stopSimulation:A,mode:B,setShowRunPanel:P,showAnalysisPanel:U,setShowAnalysisPanel:se,executionData:L}=oe(),F=I.useCallback(()=>{if(!$)return;const Y=new Blob([JSON.stringify($,null,2)],{type:"application/json"}),ie=URL.createObjectURL(Y),fe=document.createElement("a");fe.href=ie,fe.download=`${$.name||"workflow"}.json`,fe.click(),URL.revokeObjectURL(ie)},[$]),z=I.useCallback(()=>{$&&navigator.clipboard.writeText(JSON.stringify($,null,2))},[$]);I.useEffect(()=>{b(r),k(n),_(s),w(t||!!i)},[r,n,s,t,i,b,k,_,w]),I.useEffect(()=>{R(i?"developer":u)},[u,i,R]),I.useEffect(()=>{e&&(y(e,s),oe.temporal.getState().clear())},[e,y,s]),I.useEffect(()=>{i?N(i):S(t?"view":"edit")},[i,N,S,t]),I.useImperativeHandle(v,()=>({getWorkflowDef:()=>oe.getState().workflowDef,getValidationResults:()=>oe.getState().validationResults,save:()=>{const Y=oe.getState().workflowDef;Y&&f&&f(Y)},createBlankWorkflow:Y=>{oe.getState().createBlankWorkflow(Y),oe.temporal.getState().clear()}}),[f]),I.useEffect(()=>{if(!h)return;let Y=!0,ie=oe.getState().workflowDef;return oe.subscribe(ve=>{const be=ve.workflowDef;if(be!==ie){if(ie=be,Y){Y=!1;return}be&&h(be)}})},[h]);const H=Y=>{B!=="run"&&!i?q(Y,!0):O(Y)};return o.jsxs("div",{className:`workflow-ide ${r==="light"?"light-theme":""}`,"data-mode":r,"data-brand":n,style:{width:"100%",height:p,display:"flex",flexDirection:"column",position:"relative",overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 12px",borderBottom:"1px solid var(--border)",background:"var(--bg-primary)",flexShrink:0,flexWrap:"wrap"},children:[o.jsx("div",{style:{flex:1}}),B==="edit"&&$&&o.jsxs("button",{onClick:()=>P(!0),style:{height:28,padding:"0 10px",background:"color-mix(in srgb, var(--color-accent) 15%, transparent)",color:"var(--color-accent)",border:"1px solid color-mix(in srgb, var(--color-accent) 40%, transparent)",borderRadius:6,cursor:"pointer",fontSize:12,fontWeight:600,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"填写工作流入参并触发真实执行",children:[o.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"currentColor",children:o.jsx("path",{d:"M4 3l9 5-9 5z"})}),"执行验证"]}),B==="run"&&L&&o.jsxs("button",{onClick:()=>se(!U),style:{height:28,padding:"0 10px",background:U?"color-mix(in srgb, var(--color-accent) 20%, transparent)":"transparent",color:U?"var(--color-accent)":"var(--text-secondary)",border:`1px solid ${U?"color-mix(in srgb, var(--color-accent) 40%, transparent)":"var(--border-strong)"}`,borderRadius:6,cursor:"pointer",fontSize:12,fontWeight:500,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"查看执行概览与异常分析",children:[o.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[o.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"2"}),o.jsx("path",{d:"M5 8h6M5 5h3M5 11h4"})]}),"分析"]}),B!=="run"&&$&&(J?o.jsxs("button",{onClick:A,style:{height:28,padding:"0 10px",background:"color-mix(in srgb, var(--status-failed) 15%, transparent)",color:"var(--status-failed)",border:"1px solid color-mix(in srgb, var(--status-failed) 30%, transparent)",borderRadius:6,cursor:"pointer",fontSize:12,fontWeight:500,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"停止模拟",children:[o.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"currentColor",children:o.jsx("rect",{x:"4",y:"4",width:"8",height:"8",rx:"1"})}),"停止"]}):o.jsxs("button",{onClick:V,style:{height:28,padding:"0 10px",background:"color-mix(in srgb, var(--status-completed) 15%, transparent)",color:"var(--status-completed)",border:"1px solid color-mix(in srgb, var(--status-completed) 30%, transparent)",borderRadius:6,cursor:"pointer",fontSize:12,fontWeight:500,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"模拟执行工作流",children:[o.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"currentColor",children:o.jsx("path",{d:"M4 3l9 5-9 5z"})}),"模拟运行"]})),$&&o.jsxs(o.Fragment,{children:[o.jsxs("button",{onClick:F,style:{height:28,padding:"0 10px",background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-secondary)",borderRadius:6,cursor:"pointer",fontSize:12,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"导出工作流 JSON 文件",children:[o.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:o.jsx("path",{d:"M3 10v2.5a.5.5 0 0 0 .5.5h9a.5.5 0 0 0 .5-.5V10M5 7l3 3 3-3M8 2v8",strokeLinecap:"round",strokeLinejoin:"round"})}),"导出 JSON"]}),o.jsxs("button",{onClick:z,style:{height:28,padding:"0 10px",background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-secondary)",borderRadius:6,cursor:"pointer",fontSize:12,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"复制 Conductor DSL 到剪贴板",children:[o.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[o.jsx("rect",{x:"4",y:"4",width:"9",height:"10",rx:"1"}),o.jsx("path",{d:"M2 10V3a1 1 0 0 1 1-1h7",strokeLinecap:"round"})]}),"复制 DSL"]})]})]}),o.jsx("div",{className:"workflow-viewer",style:{flex:1,position:"relative",overflow:"hidden"},children:o.jsx(M.ReactFlowProvider,{children:o.jsx(o1,{onNodeClick:H,edgeType:D,theme:r,nodesLocked:t||B==="run"||!!i,searchQuery:a,onSave:f,onRequestImport:l,executionActions:c})})}),o.jsx(h1,{task:T,isOpen:j&&B!=="run",onClose:()=>E(!1),theme:r,aiConfig:d}),(i||B==="run")&&o.jsx(y1,{executionActions:c}),o.jsx(T1,{aiConfig:d}),o.jsx(N1,{onTriggerExecution:m,onPollExecution:g,executionPollInterval:x}),B==="run"&&o.jsx(P1,{})]})});Bm.displayName="WorkflowIDE",Ce.WorkflowIDE=Bm,Ce.buildDataFlowGraph=nm,Ce.buildDefaultWorkflowMockInput=Lt,Ce.executeLocalSandboxDryRun=im,Ce.generateDefaultTaskOutputPreview=ur,Ce.getCompletionItems=rm,Ce.getUpstreamAncestors=cl,Ce.inferTaskOutputSchema=tm,Ce.parseWorkflowInputParams=At,Ce.refactorTaskReferenceName=sm,Object.defineProperty(Ce,Symbol.toStringTag,{value:"Module"})}));
|
|
126
|
+
`,z1={string:"#38bdf8",number:"#a78bfa",boolean:"#f472b6",object:"#fbbf24",array:"#34d399",any:"#94a3b8"},$1=({isOpen:e,onClose:t,onSelect:r,suggestions:n,wlspItems:s=[],anchorRect:o,onRequestAiHint:i,aiLoading:l=!1})=>{const c=le(C=>C.theme),[u,d]=N.useState("all"),[p,h]=N.useState(""),[f,m]=N.useState(0),g=N.useRef(null);N.useEffect(()=>{e&&(h(""),m(0),setTimeout(()=>g.current?.focus(),30))},[e]);const y=N.useMemo(()=>{const C=s.map(W=>({label:W.label,value:W.value,description:W.description,category:W.category,valueType:W.valueType,sourceLabel:W.sourceLabel,sampleValue:W.sampleValue,isConditional:W.isConditional})),z=new Set(C.map(W=>W.value));for(const W of n)z.has(W.value)||(z.add(W.value),C.push({...W,category:W.category||"ai"}));return C},[s,n]),b=N.useMemo(()=>y.filter(C=>{if(u!=="all"&&C.category!==u&&C.category!=="ai")return!1;if(!p.trim())return!0;const z=p.toLowerCase();return C.label.toLowerCase().includes(z)||C.value.toLowerCase().includes(z)||C.description.toLowerCase().includes(z)||C.sourceLabel&&C.sourceLabel.toLowerCase().includes(z)}),[y,u,p]);if(N.useEffect(()=>{m(0)},[u,p]),!e||!o||typeof document>"u")return null;const x=typeof window<"u"?window.innerHeight:800,v=typeof window<"u"?window.innerWidth:1280,k=Math.min(380,v-32),_=o.width>=160?o.left:o.right-k,S=Math.min(Math.max(16,_),v-k-16),j=x-o.bottom-16,R=o.top-16,L=j<260&&R>j,T=L?Math.min(400,Math.max(200,R)):Math.min(400,Math.max(200,j)),w=c==="light",D={position:"fixed",...L?{bottom:`${x-o.top+6}px`}:{top:`${o.bottom+6}px`},left:`${S}px`,width:`${k}px`,maxHeight:`${T}px`,zIndex:9999,background:w?"rgba(255, 255, 255, 0.98)":"rgba(15, 23, 42, 0.96)",color:w?"#0f172a":"#f8fafc",borderColor:w?"rgba(148, 163, 184, 0.35)":"rgba(56, 189, 248, 0.28)"},E=C=>{C.key==="ArrowDown"?(C.preventDefault(),m(z=>b.length>0?(z+1)%b.length:0)):C.key==="ArrowUp"?(C.preventDefault(),m(z=>b.length>0?(z-1+b.length)%b.length:0)):C.key==="Enter"&&b[f]?(C.preventDefault(),r(b[f].value),t()):C.key==="Escape"&&(C.preventDefault(),t())};return Ye.createPortal(a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"suggester-overlay",onClick:t}),a.jsxs("div",{className:`parameter-suggester-popover glass-panel ${w?"theme-light":"theme-dark"}`,style:D,onKeyDown:E,children:[a.jsxs("div",{className:"suggester-header",children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[a.jsx("span",{className:"sparkle-icon",children:"⚡"}),a.jsx("span",{children:"W-LSP 上下文变量补全"}),a.jsxs("span",{style:{fontSize:10,opacity:.65,fontWeight:500},children:["(",b.length,")"]})]}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[i&&a.jsx("button",{type:"button",className:"suggester-ai-btn",onClick:i,disabled:l,title:"调用 AI 推理更多上下文表达式",children:l?"AI 思考中...":"✨ AI 推荐"}),a.jsx("button",{type:"button",onClick:t,title:"关闭 (Esc)",style:{background:"none",border:"none",color:"inherit",opacity:.55,cursor:"pointer",padding:"2px 4px",fontSize:12,lineHeight:1},children:"✕"})]})]}),a.jsx("div",{className:"suggester-search-bar",children:a.jsx("input",{ref:g,type:"text",className:"suggester-search-input",placeholder:"搜索上游任务、输出字段或输入参数 (↑↓选择, Enter插入)...",value:p,onChange:C=>h(C.target.value)})}),a.jsx("div",{className:"suggester-tabs",children:[{id:"all",label:"全部"},{id:"upstream",label:"🔗 上游输出"},{id:"workflow_input",label:"📥 工作流输入"},{id:"variable",label:"📦 全局变量"},{id:"system",label:"⚙️ 系统"}].map(C=>a.jsx("button",{type:"button",className:`suggester-tab ${u===C.id?"active":""}`,onClick:()=>d(C.id),children:C.label},C.id))}),a.jsx("div",{className:"suggester-list",children:b.length===0?a.jsx("div",{className:"suggester-empty",children:"没有匹配的上下文变量"}):b.map((C,z)=>{const W=z1[C.valueType||"any"]||"#94a3b8";return a.jsxs("div",{className:`suggestion-item ${z===f?"active":""}`,onMouseEnter:()=>m(z),onClick:()=>{r(C.value),t()},children:[a.jsxs("div",{className:"suggestion-top-row",children:[a.jsx("span",{className:"suggestion-label",children:C.label}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[C.isConditional&&a.jsx("span",{className:"suggestion-cond-badge",title:"来自条件分支,可能未执行",children:"条件分支"}),C.valueType&&a.jsx("span",{className:"suggestion-type-badge",style:{color:W,borderColor:`${W}44`,background:`${W}15`},children:C.valueType})]})]}),a.jsxs("div",{className:"suggestion-value-row",children:[a.jsx("code",{className:"suggestion-value",children:C.value}),C.sampleValue!==void 0&&a.jsxs("span",{className:"suggestion-sample",title:`真实样本值: ${C.sampleValue}`,children:["= ",C.sampleValue]})]}),a.jsxs("div",{className:"suggestion-desc",children:[C.sourceLabel?`[${C.sourceLabel}] `:"",C.description]})]},`${C.value}-${z}`)})})]})]}),document.body)},W1=({title:e,value:t,language:r="text",placeholder:n="",onSave:s,onClose:o})=>{const{theme:i,themeColor:l}=le(),[c,u]=N.useState(t),d=N.useRef(null);N.useEffect(()=>{d.current?.focus();const f=m=>{m.key==="Escape"&&(m.stopPropagation(),o()),(m.ctrlKey||m.metaKey)&&m.key==="s"&&(m.preventDefault(),m.stopPropagation(),s(c))};return window.addEventListener("keydown",f,!0),()=>window.removeEventListener("keydown",f,!0)},[c,s,o]);const h={javascript:"#f7df1e",js:"#f7df1e",json:"#89b4fa",jq:"#a6e3a1",groovy:"#4ec994",python:"#3572A5",text:"var(--text-secondary)"}[r.toLowerCase()]??"var(--text-secondary)";return Ye.createPortal(a.jsxs("div",{"data-mode":i,"data-brand":l,style:{position:"fixed",inset:0,zIndex:3e3,display:"flex",flexDirection:"column",background:"var(--bg-primary)"},onClick:f=>f.stopPropagation(),children:[a.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:[a.jsx("span",{style:{fontSize:"11px",fontWeight:700,color:h,background:`${h}18`,border:`1px solid ${h}44`,padding:"2px 8px",borderRadius:"4px",fontFamily:"monospace",letterSpacing:"0.5px",textTransform:"uppercase",flexShrink:0},children:r}),a.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:"var(--text-primary)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e}),a.jsx("span",{style:{fontSize:"11px",color:"var(--text-secondary)",flexShrink:0},children:"Ctrl+S 保存 · Esc 取消"}),a.jsx("button",{onClick:o,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:"取消"}),a.jsx("button",{onClick:()=>s(c),style:{padding:"6px 16px",background:"var(--color-accent)",border:"none",borderRadius:"6px",color:"#fff",cursor:"pointer",fontSize:"12px",fontWeight:600,flexShrink:0},children:"应用"})]}),a.jsx("textarea",{ref:d,value:c,placeholder:n,onChange:f=>u(f.target.value),onKeyDown:f=>f.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)"}}),a.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:[a.jsxs("span",{children:[c.split(`
|
|
127
|
+
`).length," 行"]}),a.jsxs("span",{children:[c.length," 字符"]}),c!==t&&a.jsx("span",{style:{color:"#f59e0b",fontWeight:600},children:"● 未保存"})]})]}),document.body)},F1=[{label:"工作流输入",value:"${workflow.input.fieldName}",desc:"引用工作流启动时传入的参数"},{label:"上游任务输出",value:"${taskRef.output.result}",desc:"引用上游任务的输出字段"},{label:"工作流变量",value:"${workflow.variables.varName}",desc:"引用 SET_VARIABLE 设置的变量"},{label:"工作流 ID",value:"${workflow.workflowId}",desc:"当前工作流实例 ID"},{label:"关联 ID",value:"${workflow.correlationId}",desc:"工作流关联 ID"},{label:"工作流状态",value:"${workflow.status}",desc:"当前工作流状态"}],B1=({task:e,isOpen:t=!0,onClose:r,aiConfig:n})=>{const{mode:s,updateTask:o,checkTaskRefUniqueness:i,workflowDef:l,executionData:c,workflowInstance:u,lastRefactorNotice:d,clearRefactorNotice:p}=le(),[h,f]=N.useState(e),[m,g]=N.useState(e?.taskReferenceName??null),[y,b]=N.useState(null),[x,v]=N.useState(!1),[k,_]=N.useState(null),[S,j]=N.useState(()=>e?.type==="WAIT"&&e.inputParameters?.until?"until":"duration"),[R,L]=N.useState(()=>e?.type==="DO_WHILE"&&e.inputParameters?.items?"items":"condition"),[T,w]=N.useState(()=>!e||e.type!=="FORK_JOIN_DYNAMIC"?"classic":e.forkTaskWorkflow?"workflow":e.forkTaskType?"task":"classic"),[D,E]=N.useState(!1),[C,z]=N.useState(),[W,K]=N.useState([]),[M,I]=N.useState(()=>()=>{}),F=e?.taskReferenceName||h?.taskReferenceName||"",O=N.useMemo(()=>!l||!F?[]:fm(l,F,c,u?.input),[l,F,c,u?.input]),[J,Z]=N.useState(null),[A,B]=N.useState(!1),[U,H]=N.useState(null),X=(P,V,oe,ae)=>{Z({title:P,value:V,language:oe,onSave:ae})},ie=[{label:"引用工作流输入",value:"${workflow.input.data}",description:"引用工作流启动时传入的原始数据"},{label:"引用前序任务输出",value:"${previous_task.output.result}",description:"引用上一个节点的计算结果"},{label:"环境变量",value:"${workflow.variables.api_key}",description:"引用工作流定义的全局变量"}],ge=async()=>{const P=n?.apiKey||localStorage.getItem("AI_API_KEY")||"";if(!P){alert("请先在设置中配置 AI API Key");return}if(we){B(!0);try{const{workflowDef:V,taskMap:oe}=le.getState(),ae=qt(V?.inputParameters).map(me=>me.name),ee=Object.values(oe).filter(me=>me.taskReferenceName!==we.taskReferenceName).map(me=>({ref:me.taskReferenceName,type:me.type,name:me.name})).slice(0,10),xe={apiKey:P};n?.baseUrl&&(xe.baseUrl=n.baseUrl),n?.model&&(xe.model=n.model);const be=await R1(we.type,we.taskReferenceName,ae,ee,we.inputParameters??{},xe);H({generated:be,original:we.inputParameters??{}})}catch(V){alert(`AI 生成失败:${V?.message||"未知错误"}`)}finally{B(!1)}}},Se=async(P,V)=>{const oe=P.currentTarget.getBoundingClientRect();if(z(oe),I(()=>V),E(!0),O.length>0)return;K([]);const ae=n?.apiKey||localStorage.getItem("AI_API_KEY")||"";if(!ae){K(ie);return}try{const ee=n?.baseUrl||localStorage.getItem("AI_BASE_URL")||"",xe=n?.model||localStorage.getItem("AI_MODEL")||"",be={apiKey:ae};ee&&(be.baseUrl=ee),xe&&(be.model=xe);const{workflowDef:me}=le.getState(),he=q1(we,me),Oe=(await Il([{role:"system",content:"You are a Conductor workflow expert. Return only valid JSON."},{role:"user",content:he}],be)).match(/\[[\s\S]*\]/);if(Oe){const Ee=JSON.parse(Oe[0]);K(Ee)}else K(ie)}catch{K(ie)}};if(N.useEffect(()=>{e&&(f(e),g(e.taskReferenceName),b(null),e.type==="WAIT"&&j(e.inputParameters?.until?"until":"duration"),e.type==="DO_WHILE"&&L(e.inputParameters?.items?"items":"condition"),e.type==="FORK_JOIN_DYNAMIC"&&(e.forkTaskWorkflow?w("workflow"):e.forkTaskType?w("task"):w("classic")))},[e]),!e&&!h)return null;const we=e||h,$=h&&e&&m===e.taskReferenceName?h:we,ke=t&&e?"panel-enter-active":"panel-exit",te=s==="edit",se="var(--text-primary)",re="var(--glass-border)",ve="var(--bg-tertiary)",ue="var(--text-secondary)",pe=(P,V)=>{const oe={...$,[P]:V};f(oe),o($.taskReferenceName,{[P]:V})},Fe=(P,V,oe)=>{const ee={...$[P]||{},[V]:oe},xe={...$,[P]:ee};f(xe),o($.taskReferenceName,{[P]:ee})},_e=(P,V)=>{const oe=$.inputParameters||{},ee={...oe.http_request||$.httpRequest||{},[P]:V},be={inputParameters:{...oe,http_request:ee}};$.httpRequest&&(be.httpRequest=ee);const me={...$,...be};f(me),o($.taskReferenceName,be)},ye=(P,V)=>{const ae={inputParameters:{...$.inputParameters,[P]:V}},ee={...$,...ae};f(ee),o($.taskReferenceName,ae)},et=P=>{if(!k)return;const V=k.selectionStart??0,oe=k.selectionEnd??0,ae=k.value,ee=ae.substring(0,V)+P+ae.substring(oe),xe=k.getAttribute("data-field");xe&&pe(xe,ee),v(!1)},Te=(P,V,oe,ae)=>a.jsxs("div",{style:{marginBottom:"24px",padding:"16px",borderRadius:"12px",background:`${oe}10`,border:`1px solid ${oe}30`,boxShadow:"0 4px 12px rgba(0,0,0,0.05)"},children:[a.jsxs("div",{style:{fontSize:"12px",fontWeight:"bold",marginBottom:"16px",color:oe,display:"flex",alignItems:"center",gap:"8px"},children:[a.jsx("span",{children:V})," ",P]}),ae]}),st=(P,V,oe="text",ae)=>{const ee=V==="taskReferenceName",xe=ee&&y!==null?y:$[V]??"",be=ee&&!i(xe,$.taskReferenceName);return a.jsxs("div",{style:{marginBottom:"16px"},children:[a.jsxs("label",{style:{display:"block",fontSize:"11px",color:ue,marginBottom:"6px",fontWeight:"600",textTransform:"uppercase"},children:[P,ee&&be&&a.jsx("span",{style:{color:"#ef4444",marginLeft:"8px",textTransform:"none"},children:"⚠️ 已存在相同引用名"})]}),a.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center"},children:[a.jsx("input",{type:oe,value:xe,placeholder:ae,onChange:me=>{const he=me.target.value;if(ee)b(he);else{pe(V,oe==="number"?he===""?void 0:Number(he):he);const Ie=me.target.selectionStart??0;if(oe==="text"&&Ie>=2&&he.slice(Ie-2,Ie)==="${"){const Oe=me.target.getBoundingClientRect();z(Oe),I(()=>Ee=>{const Be=he.slice(0,Ie-2),Rl=he.slice(Ie);pe(V,Be+Ee+Rl)}),E(!0)}}},onFocus:ee?()=>{y===null&&b($.taskReferenceName??"")}:void 0,onBlur:ee?me=>{const he=me.target.value.trim();b(null),he&&he!==$.taskReferenceName&&pe("taskReferenceName",he)}:void 0,onKeyDown:ee?me=>{me.key==="Enter"&&me.currentTarget.blur(),me.stopPropagation()}:void 0,disabled:!te,style:{width:"100%",padding:`8px ${te&&!ee?"32px":"12px"} 8px 12px`,borderRadius:"6px",border:`1px solid ${be?"#ef4444":re}`,background:ve,color:se,fontSize:"13px",outline:"none",opacity:te?1:.8,fontFamily:ee?"monospace":"inherit"}}),te&&!ee&&a.jsx("button",{className:"ai-hint-trigger",onClick:me=>Se(me,he=>pe(V,he)),title:"AI 智能提示",style:{position:"absolute",right:"8px",background:"none",border:"none",cursor:"pointer",fontSize:"14px",padding:"4px",opacity:.6,display:"flex",alignItems:"center",justifyContent:"center"},children:"✨"})]})]})},Q=(P,V,oe,ae={})=>{const{rows:ee=5,language:xe="text",style:be,placeholder:me,"data-field":he}=ae,Ie={width:"100%",padding:"12px",borderRadius:"8px",border:`1px solid ${re}`,background:ve,color:se,fontSize:"12px",fontFamily:"monospace",lineHeight:"1.5",resize:"vertical",...be};return a.jsxs("div",{style:{marginBottom:"8px"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"4px"},children:[a.jsx("label",{style:{fontSize:"10px",color:ue},children:P}),te&&a.jsx("button",{onClick:()=>X(P,V,xe,Oe=>{oe(Oe),Z(null)}),title:"全屏编辑",style:{background:"none",border:"none",cursor:"pointer",fontSize:"14px",padding:"2px 4px",color:"var(--text-secondary)",opacity:.7,lineHeight:1},children:"⛶"})]}),a.jsx("textarea",{value:V,placeholder:me,onChange:Oe=>{const Ee=Oe.target.value;oe(Ee);const Be=Oe.target.selectionStart??0;if(Be>=2&&Ee.slice(Be-2,Be)==="${"){const Rl=Oe.target.getBoundingClientRect();z(Rl),I(()=>f0=>{const h0=Ee.slice(0,Be-2),m0=Ee.slice(Be);oe(h0+f0+m0)}),E(!0)}},disabled:!te,rows:ee,"data-field":he,onFocus:Oe=>_(Oe.currentTarget),style:Ie})]})},Y=(P,V,oe,ae="text",ee)=>a.jsxs("div",{style:{marginBottom:"12px"},children:[a.jsx("label",{style:{display:"block",fontSize:"10px",color:ue,marginBottom:"4px"},children:P}),a.jsx("input",{type:ae,value:V??"",placeholder:ee,onChange:xe=>{const be=xe.target.value;oe(ae==="number"?be===""?void 0:Number(be):be);const me=xe.target.selectionStart??0;if(ae==="text"&&me>=2&&be.slice(me-2,me)==="${"){const he=xe.target.getBoundingClientRect();z(he),I(()=>Ie=>{const Oe=be.slice(0,me-2),Ee=be.slice(me);oe(Oe+Ie+Ee)}),E(!0)}},disabled:!te,style:{width:"100%",padding:"8px 10px",borderRadius:"6px",border:`1px solid ${re}`,background:ve,color:se,fontSize:"12px",outline:"none"}})]}),ne=(P,V,oe,ae)=>a.jsxs("div",{style:{marginBottom:"12px"},children:[a.jsx("label",{style:{display:"block",fontSize:"10px",color:ue,marginBottom:"4px"},children:P}),a.jsx("select",{value:oe,onChange:ee=>ae(ee.target.value),disabled:!te,style:{width:"100%",padding:"8px 10px",borderRadius:"6px",border:`1px solid ${re}`,background:ve,color:se,fontSize:"12px",outline:"none",cursor:"pointer"},children:V.map(ee=>a.jsx("option",{value:ee,children:ee},ee))})]}),fe=(P,V,oe)=>a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},children:[a.jsx("span",{style:{fontSize:"11px",color:ue},children:P}),a.jsx("button",{onClick:()=>oe(!V),disabled:!te,style:{width:"36px",height:"20px",borderRadius:"10px",border:"none",cursor:"pointer",background:V?"var(--color-accent)":re,position:"relative",transition:"background 0.2s"},children:a.jsx("span",{style:{position:"absolute",top:"2px",left:V?"18px":"2px",width:"16px",height:"16px",borderRadius:"50%",background:"#fff",transition:"left 0.2s"}})})]}),G=(P,V,oe)=>a.jsx("div",{style:{display:"flex",gap:"6px",marginBottom:"12px"},children:P.map(ae=>a.jsx("button",{onClick:()=>oe(ae.key),disabled:!te,style:{flex:1,padding:"6px",borderRadius:"6px",border:`1px solid ${re}`,cursor:"pointer",fontSize:"11px",fontWeight:V===ae.key?"bold":"normal",background:V===ae.key?"var(--color-accent)":ve,color:V===ae.key?"#fff":se},children:ae.label},ae.key))}),de=$.inputParameters?.http_request||$.httpRequest||{};return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:`detail-panel-container ${ke}`,style:{position:"absolute",right:0,top:0,bottom:0,width:"450px",zIndex:1200,display:"flex",flexDirection:"column",background:"var(--bg-primary)",borderLeft:`1px solid ${re}`,boxShadow:"-10px 0 30px rgba(0, 0, 0, 0.2)",overflowY:"hidden"},children:[a.jsxs("div",{style:{padding:"24px",borderBottom:`1px solid ${re}`,background:"var(--bg-secondary)",flexShrink:0},children:[a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[a.jsx("div",{style:{background:"var(--color-accent)",color:"#fff",padding:"2px 8px",borderRadius:"4px",fontSize:"10px",fontWeight:"bold",letterSpacing:"1px"},children:$.type||"TASK"}),a.jsx("button",{onClick:r,style:{background:"none",border:"none",color:se,cursor:"pointer",fontSize:"20px"},children:"✕"})]}),te?a.jsx("input",{value:$.name||"",onChange:P=>pe("name",P.target.value),placeholder:"任务名称",style:{display:"block",width:"100%",fontSize:"22px",fontWeight:"bold",background:"transparent",border:"none",color:se,outline:"none",borderBottom:"2px dashed var(--color-accent)"}}):a.jsx("div",{style:{fontSize:"22px",fontWeight:"bold"},children:$.name}),a.jsxs("div",{style:{fontSize:"12px",color:ue,marginTop:"8px",fontFamily:"monospace",opacity:.8},children:["REF: ",$.taskReferenceName]})]}),a.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"24px",background:"var(--bg-primary)"},children:[$.type==="HTTP"&&Te("HTTP 请求配置","🌐","var(--color-accent)",a.jsxs(a.Fragment,{children:[a.jsxs("div",{style:{display:"flex",gap:"8px",marginBottom:"12px"},children:[a.jsx("select",{value:de.method||"GET",onChange:P=>_e("method",P.target.value),disabled:!te,style:{width:"90px",padding:"10px",borderRadius:"8px",background:ve,color:se,border:`1px solid ${re}`,cursor:"pointer"},children:["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"].map(P=>a.jsx("option",{value:P,children:P},P))}),a.jsx("input",{placeholder:"URI (支持 ${workflow.input.uri})",value:de.uri||"",onChange:P=>_e("uri",P.target.value),disabled:!te,style:{flex:1,padding:"10px",borderRadius:"8px",background:ve,color:se,border:`1px solid ${re}`}})]}),a.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px",marginBottom:"12px"},children:[a.jsxs("div",{children:[a.jsx("label",{style:{display:"block",fontSize:"10px",color:ue,marginBottom:"4px"},children:"CONTENT-TYPE"}),a.jsx("input",{placeholder:"application/json",value:de.contentType||"",onChange:P=>_e("contentType",P.target.value),disabled:!te,style:{width:"100%",padding:"8px",borderRadius:"6px",background:ve,color:se,border:`1px solid ${re}`,fontSize:"12px"}})]}),a.jsxs("div",{children:[a.jsx("label",{style:{display:"block",fontSize:"10px",color:ue,marginBottom:"4px"},children:"ACCEPT"}),a.jsx("input",{placeholder:"application/json",value:de.accept||"",onChange:P=>_e("accept",P.target.value),disabled:!te,style:{width:"100%",padding:"8px",borderRadius:"6px",background:ve,color:se,border:`1px solid ${re}`,fontSize:"12px"}})]})]}),a.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px",marginBottom:"12px"},children:[a.jsxs("div",{children:[a.jsx("label",{style:{display:"block",fontSize:"10px",color:ue,marginBottom:"4px"},children:"连接超时 (ms)"}),a.jsx("input",{type:"number",placeholder:"3000",value:de.connectionTimeOut??"",onChange:P=>_e("connectionTimeOut",P.target.value===""?void 0:Number(P.target.value)),disabled:!te,style:{width:"100%",padding:"8px",borderRadius:"6px",background:ve,color:se,border:`1px solid ${re}`,fontSize:"12px"}})]}),a.jsxs("div",{children:[a.jsx("label",{style:{display:"block",fontSize:"10px",color:ue,marginBottom:"4px"},children:"读取超时 (ms)"}),a.jsx("input",{type:"number",placeholder:"3000",value:de.readTimeOut??"",onChange:P=>_e("readTimeOut",P.target.value===""?void 0:Number(P.target.value)),disabled:!te,style:{width:"100%",padding:"8px",borderRadius:"6px",background:ve,color:se,border:`1px solid ${re}`,fontSize:"12px"}})]})]}),a.jsxs("div",{style:{marginBottom:"12px"},children:[a.jsx("label",{style:{display:"block",fontSize:"10px",color:ue,marginBottom:"4px"},children:"HEADERS (JSON)"}),a.jsx("textarea",{value:typeof de.headers=="object"?JSON.stringify(de.headers,null,2):"{}",onChange:P=>{try{_e("headers",JSON.parse(P.target.value))}catch{}},disabled:!te,rows:3,style:{width:"100%",padding:"8px",borderRadius:"8px",background:ve,color:se,border:`1px solid ${re}`,fontSize:"11px",fontFamily:"monospace"}})]}),a.jsx("label",{style:{display:"block",fontSize:"10px",color:ue,marginBottom:"4px"},children:"BODY (RAW/JSON)"}),a.jsx("textarea",{value:typeof de.body=="object"?JSON.stringify(de.body,null,2):de.body||"",onChange:P=>{let V=P.target.value;try{V=JSON.parse(P.target.value)}catch{}_e("body",V)},disabled:!te,rows:4,style:{width:"100%",padding:"8px",borderRadius:"8px",background:ve,color:se,border:`1px solid ${re}`,fontSize:"11px",fontFamily:"monospace"}})]})),($.type==="INLINE"||$.type==="LAMBDA")&&Te("内联脚本配置 (Inline)","📜","var(--color-accent)",a.jsxs(a.Fragment,{children:[ne("脚本引擎",["graaljs","javascript","value-param","python"],$.evaluatorType||"graaljs",P=>pe("evaluatorType",P)),Q(`EXPRESSION ${$.evaluatorType==="value-param"?"(值引用)":"(脚本)"}`,$.inputParameters?.expression||$.inputParameters?.scriptExpression||"",P=>{const V=$.inputParameters?.scriptExpression!==void 0?"scriptExpression":"expression";ye(V,P)},{rows:10,language:$.evaluatorType||"javascript",style:{background:"#000",color:"var(--color-accent)",border:"1px solid var(--color-accent)"}}),a.jsx("div",{style:{marginTop:"8px",fontSize:"10px",color:ue,fontStyle:"italic"},children:"提示: 使用 $.input.key 访问输入参数,返回值作为任务输出。"})]})),$.type==="JSON_JQ_TRANSFORM"&&Te("JQ 数据转换","🔍","var(--color-accent)",a.jsxs(a.Fragment,{children:[Q("JQ QUERY EXPRESSION",$.inputParameters?.queryExpression||"",P=>ye("queryExpression",P),{rows:6,language:"jq",style:{color:"var(--color-accent)"}}),a.jsx("div",{style:{marginTop:"8px",fontSize:"10px",color:ue},children:"输出字段: result(首个结果)、resultList(完整列表)"})]})),$.type==="SUB_WORKFLOW"&&Te("子工作流配置","🏗️","var(--color-accent)",a.jsxs(a.Fragment,{children:[Y("WORKFLOW NAME *",$.subWorkflowParam?.name||"",P=>Fe("subWorkflowParam","name",P),"text","e.g. my_workflow"),Y("VERSION",$.subWorkflowParam?.version??"",P=>Fe("subWorkflowParam","version",P?parseInt(P):void 0),"number","1"),Q("INPUT PARAMETERS MAPPING (JSON)",typeof $.inputParameters=="object"&&$.inputParameters!==null?JSON.stringify($.inputParameters,null,2):"{}",P=>{try{pe("inputParameters",JSON.parse(P))}catch{}},{rows:5,language:"json"}),a.jsxs("div",{style:{fontSize:"10px",color:ue,marginTop:"4px"},children:["传递给子工作流的参数,支持 ","${workflow.input.xxx}"," 表达式"]})]})),$.type==="START_WORKFLOW"&&Te("启动工作流配置","▶️","var(--color-accent)",a.jsxs(a.Fragment,{children:[a.jsxs("div",{style:{fontSize:"11px",color:ue,marginBottom:"12px",padding:"8px",borderRadius:"6px",background:"rgba(255,165,0,0.1)",border:"1px solid rgba(255,165,0,0.3)"},children:["⚡ 注意:此任务启动目标工作流后立即继续,",a.jsx("b",{children:"不等待"}),"目标工作流完成。"]}),Y("WORKFLOW NAME *",$.inputParameters?.startWorkflow?.name||"",P=>{const V={...$.inputParameters?.startWorkflow||{},name:P};ye("startWorkflow",V)},"text","e.g. target_workflow"),Y("VERSION",$.inputParameters?.startWorkflow?.version??"",P=>{const V={...$.inputParameters?.startWorkflow||{},version:P?parseInt(P):void 0};ye("startWorkflow",V)},"number","1"),Y("CORRELATION ID",$.inputParameters?.startWorkflow?.correlationId||"",P=>{const V={...$.inputParameters?.startWorkflow||{},correlationId:P};ye("startWorkflow",V)},"text","${workflow.correlationId}"),Q("WORKFLOW INPUT (JSON)",typeof $.inputParameters?.startWorkflow?.input=="object"?JSON.stringify($.inputParameters.startWorkflow.input,null,2):"{}",P=>{try{const V={...$.inputParameters?.startWorkflow||{},input:JSON.parse(P)};ye("startWorkflow",V)}catch{}},{rows:4,language:"json"})]})),$.type==="TERMINATE"&&Te("终止状态配置","⏹️","var(--color-accent)",a.jsxs(a.Fragment,{children:[a.jsx("label",{style:{display:"block",fontSize:"10px",color:ue,marginBottom:"4px"},children:"TERMINATION STATUS"}),a.jsx("div",{style:{display:"flex",gap:"8px",marginBottom:"16px"},children:["COMPLETED","FAILED"].map(P=>a.jsx("button",{onClick:()=>ye("terminationStatus",P),disabled:!te,style:{flex:1,padding:"8px",borderRadius:"6px",cursor:"pointer",background:($.inputParameters?.terminationStatus||"COMPLETED")===P?"var(--color-accent)":ve,color:($.inputParameters?.terminationStatus||"COMPLETED")===P?"#fff":se,border:`1px solid ${re}`,fontWeight:"bold",fontSize:"11px"},children:P},P))}),Y("TERMINATION REASON",$.inputParameters?.terminationReason||"",P=>ye("terminationReason",P),"text","终止原因..."),Q("WORKFLOW OUTPUT (JSON)",typeof $.inputParameters?.workflowOutput=="object"?JSON.stringify($.inputParameters.workflowOutput,null,2):"{}",P=>{try{ye("workflowOutput",JSON.parse(P))}catch{}},{rows:3,language:"json"})]})),$.type==="EVENT"&&Te("事件发送配置","✉️","var(--color-accent)",a.jsxs(a.Fragment,{children:[Y("EVENT SINK *",$.sink||"",P=>pe("sink",P),"text","e.g. sqs:queue_name 或 conductor"),a.jsx("div",{style:{fontSize:"10px",color:ue,marginTop:"4px",marginBottom:"8px"},children:"支持前缀: conductor | sqs | kafka | amqp | nats"}),fe("异步完成 (asyncComplete)",!!$.asyncComplete,P=>pe("asyncComplete",P))]})),$.type==="WAIT"&&Te("等待状态配置","⏳","var(--color-accent)",a.jsxs(a.Fragment,{children:[G([{key:"duration",label:"等待时长"},{key:"until",label:"等待到指定时间"}],S,P=>j(P)),S==="duration"?Y("DURATION",$.inputParameters?.duration||"",P=>ye("duration",P),"text","e.g. 30s, 10m, 2 hours"):Y("UNTIL (时间点)",$.inputParameters?.until||"",P=>ye("until",P),"text","e.g. 2025-06-15 09:00 GMT+00:00"),a.jsxs("div",{style:{fontSize:"11px",color:ue,lineHeight:"1.6",marginTop:"8px"},children:["此任务会使工作流进入 ",a.jsx("b",{children:"IN_PROGRESS"})," 状态,直到时间满足或外部 API 触发完成。"]})]})),($.type==="DECISION"||$.type==="SWITCH")&&Te("条件分支配置","⚖️","var(--color-accent)",a.jsxs(a.Fragment,{children:[ne("评估模式 (evaluatorType)",["value-param","javascript"],$.evaluatorType||"value-param",P=>pe("evaluatorType",P)),($.evaluatorType||"value-param")==="value-param"?Y("CASE VALUE PARAM (参数名)",$.caseValueParam||"",P=>pe("caseValueParam",P),"text","e.g. status"):a.jsx(a.Fragment,{children:Q("CASE EXPRESSION (JS)",$.caseExpression||"",P=>pe("caseExpression",P),{rows:4,language:"javascript",style:{color:"var(--color-accent)"}})}),a.jsx("div",{style:{fontSize:"10px",color:ue,marginTop:"8px"},children:'分支可在图中通过右键节点→"添加分支"进行管理'})]})),$.type==="DO_WHILE"&&Te("循环逻辑配置","🔄","var(--color-accent)",a.jsxs(a.Fragment,{children:[G([{key:"condition",label:"条件循环"},{key:"items",label:"列表迭代"}],R,P=>L(P)),R==="condition"?a.jsxs(a.Fragment,{children:[Q("LOOP CONDITION (JS) *",$.loopCondition||"",P=>pe("loopCondition",P),{rows:4,language:"javascript",style:{color:"var(--color-accent)"}}),a.jsx("div",{style:{fontSize:"10px",color:ue,marginTop:"4px"},children:"条件为 true 时继续循环,false 时退出"})]}):a.jsxs(a.Fragment,{children:[a.jsx("label",{style:{display:"block",fontSize:"10px",color:ue,marginBottom:"4px"},children:"ITEMS (列表表达式)"}),a.jsx("input",{value:$.inputParameters?.items||"",onChange:P=>ye("items",P.target.value),disabled:!te,placeholder:"${workflow.input.myList}",style:{width:"100%",padding:"8px",borderRadius:"6px",border:`1px solid ${re}`,background:ve,color:se,fontSize:"12px",outline:"none"}}),a.jsx("div",{style:{fontSize:"10px",color:ue,marginTop:"4px"},children:"引用一个数组,对每个元素执行一次循环体"})]}),a.jsx("div",{style:{marginTop:"12px"},children:Y("KEEP LAST N 次迭代",$.keepLastN??"",P=>pe("keepLastN",P?parseInt(P):void 0),"number","0 = 保留全部")})]})),$.type==="FORK_JOIN_DYNAMIC"&&Te("动态并行配置","⚡","var(--color-accent)",a.jsxs(a.Fragment,{children:[G([{key:"classic",label:"经典模式"},{key:"task",label:"任务简化"},{key:"workflow",label:"工作流简化"}],T,P=>w(P)),T==="classic"&&a.jsxs(a.Fragment,{children:[Y("DYNAMIC_FORK_TASKS_PARAM",$.dynamicForkTasksParam||"",P=>pe("dynamicForkTasksParam",P),"text","e.g. dynamic_tasks"),Y("DYNAMIC_FORK_TASKS_INPUT_PARAM",$.dynamicForkTasksInputParamName||"",P=>pe("dynamicForkTasksInputParamName",P),"text","e.g. input"),a.jsx("div",{style:{fontSize:"10px",color:ue},children:"经典模式:通过 inputParameters 传入 dynamicTasks 数组和 dynamicTasksInput 映射"})]}),T==="task"&&a.jsxs(a.Fragment,{children:[Y("FORK TASK TYPE *",$.forkTaskType||"",P=>pe("forkTaskType",P),"text","e.g. HTTP"),Y("FORK TASK NAME (仅 SIMPLE 任务)",$.forkTaskName||"",P=>pe("forkTaskName",P),"text","e.g. my_task"),Y("FORK TASK INPUTS PARAM",$.forkTaskInputs||"",P=>pe("forkTaskInputs",P),"text","e.g. inputs"),a.jsx("div",{style:{fontSize:"10px",color:ue},children:"所有分支执行相同任务类型,每个元素作为一个分支输入"})]}),T==="workflow"&&a.jsxs(a.Fragment,{children:[Y("FORK WORKFLOW NAME *",$.forkTaskWorkflow||"",P=>pe("forkTaskWorkflow",P),"text","e.g. sub_workflow"),Y("WORKFLOW VERSION",$.forkTaskWorkflowVersion||"",P=>pe("forkTaskWorkflowVersion",P),"text","1"),Y("FORK TASK INPUTS PARAM",$.forkTaskInputs||"",P=>pe("forkTaskInputs",P),"text","e.g. inputs"),a.jsx("div",{style:{fontSize:"10px",color:ue},children:"所有分支执行相同子工作流,每个元素作为一个子工作流输入"})]})]})),$.type==="DYNAMIC"&&Te("动态任务配置","🎯","var(--color-accent)",a.jsxs(a.Fragment,{children:[Y("DYNAMIC TASK NAME PARAM *",$.dynamicTaskNameParam||"",P=>pe("dynamicTaskNameParam",P),"text","e.g. taskToExecute"),a.jsx("div",{style:{fontSize:"10px",color:ue,marginTop:"4px"},children:'运行时从 inputParameters 的指定键中读取实际任务类型名(如 "HTTP"、"SIMPLE")'})]})),$.type==="HUMAN"&&Te("人工审批配置","👤","var(--color-accent)",a.jsxs(a.Fragment,{children:[Y("表单模板名 (userFormTemplate)",$.humanTaskDef?.userFormTemplate||"",P=>Fe("humanTaskDef","userFormTemplate",P),"text","e.g. approval_form"),ne("分配策略 (assignmentCompletionStrategy)",["LEAVE_OPEN","TERMINATE"],$.humanTaskDef?.assignmentCompletionStrategy||"LEAVE_OPEN",P=>Fe("humanTaskDef","assignmentCompletionStrategy",P)),Y("显示名称 (displayName)",$.humanTaskDef?.displayName||"",P=>Fe("humanTaskDef","displayName",P),"text","审批任务")]})),$.type==="KAFKA_PUBLISH"&&Te("Kafka 推送配置","📨","var(--color-accent)",a.jsxs(a.Fragment,{children:[Y("BOOTSTRAP SERVERS *",$.inputParameters?.bootStrapServers||"",P=>ye("bootStrapServers",P),"text","localhost:9092"),Y("TOPIC *",$.inputParameters?.topic||"",P=>ye("topic",P),"text","my_topic"),Y("KEY (消息分区键)",$.inputParameters?.key||"",P=>ye("key",P),"text",""),Q("VALUE (消息内容)",typeof $.inputParameters?.value=="object"?JSON.stringify($.inputParameters.value,null,2):$.inputParameters?.value||"",P=>{let V=P;try{V=JSON.parse(P)}catch{}ye("value",V)},{rows:4,language:"json"}),Q("HEADERS (JSON)",typeof $.inputParameters?.headers=="object"?JSON.stringify($.inputParameters.headers,null,2):"{}",P=>{try{ye("headers",JSON.parse(P))}catch{}},{rows:3,language:"json"})]})),$.type==="SET_VARIABLE"&&Te("变量配置","📦","var(--color-accent)",a.jsxs(a.Fragment,{children:[a.jsxs("div",{style:{fontSize:"11px",color:ue,marginBottom:"12px"},children:["在 inputParameters 中定义要设置的变量名和值,后续任务通过 ","${workflow.variables.varName}"," 访问。"]}),Q("VARIABLES (JSON)",typeof $.inputParameters=="object"&&$.inputParameters!==null?JSON.stringify($.inputParameters,null,2):"{}",P=>{try{pe("inputParameters",JSON.parse(P))}catch{}},{rows:6,language:"json"})]})),a.jsxs("div",{style:{marginTop:"32px",borderTop:`1px solid ${re}`,paddingTop:"24px"},children:[a.jsx("div",{style:{fontSize:"11px",fontWeight:"bold",marginBottom:"16px",opacity:.6,textTransform:"uppercase",letterSpacing:"1px"},children:"通用参数与属性"}),st("任务唯一引用名 (Reference Name)","taskReferenceName"),d&&d.newRef===$.taskReferenceName&&a.jsxs("div",{style:{marginBottom:"16px",padding:"10px 12px",borderRadius:"8px",background:"rgba(16, 185, 129, 0.12)",border:"1px solid rgba(16, 185, 129, 0.35)",display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px"},children:[a.jsxs("div",{style:{fontSize:"11px",color:"#34d399",lineHeight:1.5},children:[a.jsx("b",{children:"🔗 W-LSP 全图级联重构已生效"}),a.jsx("br",{}),"引用名 ",a.jsx("code",{children:d.oldRef})," → ",a.jsx("code",{children:d.newRef}),",已自动同步 ",a.jsx("b",{children:d.replacedCount})," 处下游表达式(涉及节点:",d.affectedTasks.join(", "),")"]}),a.jsx("button",{onClick:p,style:{background:"none",border:"none",color:"#34d399",cursor:"pointer",fontSize:"12px",padding:"2px"},children:"✕"})]}),st("任务描述","description"),a.jsxs("div",{style:{marginBottom:"16px"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px",gap:"6px"},children:[a.jsxs("label",{style:{fontSize:"11px",color:ue,fontWeight:"600",textTransform:"uppercase",flex:1},children:["输入参数 (inputParameters) ",a.jsxs("span",{style:{opacity:.5,fontWeight:"normal"},children:["(JSON / 输入 $","{"," 自动补全)"]})]}),te&&a.jsxs("div",{style:{display:"flex",gap:"6px"},children:[a.jsx("button",{onClick:P=>{const V=P.currentTarget.getBoundingClientRect();z(V),I(()=>oe=>{if(k)et(oe);else{const ae=typeof $.inputParameters=="object"&&$.inputParameters!==null?{...$.inputParameters}:{};ae[`param_${Object.keys(ae).length+1}`]=oe,pe("inputParameters",ae)}}),E(!0)},title:"打开 W-LSP 上游变量与 Schema 零延迟补全器",style:{fontSize:"11px",background:"rgba(56, 189, 248, 0.14)",border:"1px solid rgba(56, 189, 248, 0.35)",borderRadius:"4px",padding:"2px 8px",cursor:"pointer",color:"#38bdf8",fontWeight:600,display:"flex",alignItems:"center",gap:"4px"},children:"⚡ 变量补全"}),a.jsxs("button",{onClick:ge,disabled:A,title:"AI 根据上下文自动生成 inputParameters",style:{fontSize:"11px",background:"linear-gradient(135deg, #6366f1, #8b5cf6)",border:"none",borderRadius:"4px",padding:"2px 8px",cursor:A?"not-allowed":"pointer",color:"#fff",fontWeight:600,display:"flex",alignItems:"center",gap:"4px",opacity:A?.7:1},children:[A?"⏳":"✨"," AI 填充"]}),a.jsxs("button",{onClick:()=>v(!x),title:"快捷表达式",style:{fontSize:"11px",background:x?"var(--color-accent)":"none",border:`1px solid ${re}`,borderRadius:"4px",padding:"2px 6px",cursor:"pointer",color:x?"#fff":ue},children:["{}"," 片段"]})]})]}),x&&a.jsx("div",{style:{marginBottom:"8px",padding:"8px",borderRadius:"6px",border:`1px solid ${re}`,background:"var(--bg-secondary)",display:"flex",flexWrap:"wrap",gap:"6px"},children:F1.map(P=>a.jsx("button",{onClick:()=>et(P.value),title:P.desc,style:{fontSize:"10px",padding:"3px 8px",borderRadius:"4px",border:`1px solid ${re}`,background:ve,color:se,cursor:"pointer",fontFamily:"monospace"},children:P.label},P.value))}),U&&a.jsxs("div",{style:{marginBottom:"8px",borderRadius:"8px",border:"1px solid #6366f130",background:"#6366f108",overflow:"hidden"},children:[a.jsxs("div",{style:{padding:"8px 12px",background:"#6366f118",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[a.jsx("span",{style:{fontSize:"11px",fontWeight:700,color:"#6366f1"},children:"✨ AI 建议的 inputParameters"}),a.jsxs("div",{style:{display:"flex",gap:"6px"},children:[a.jsx("button",{onClick:()=>{pe("inputParameters",U.generated),H(null)},style:{fontSize:"11px",background:"#6366f1",color:"#fff",border:"none",borderRadius:"4px",padding:"3px 10px",cursor:"pointer",fontWeight:600,fontFamily:"inherit"},children:"应用"}),a.jsx("button",{onClick:()=>H(null),style:{fontSize:"11px",background:"none",color:ue,border:`1px solid ${re}`,borderRadius:"4px",padding:"3px 8px",cursor:"pointer",fontFamily:"inherit"},children:"取消"})]})]}),a.jsx("pre",{style:{margin:0,padding:"10px 12px",fontSize:"12px",fontFamily:"var(--font-mono)",overflowX:"auto",color:se,maxHeight:"180px",overflowY:"auto"},children:JSON.stringify(U.generated,null,2)})]}),Q("",typeof $.inputParameters=="object"&&$.inputParameters!==null?JSON.stringify($.inputParameters,null,2):$.inputParameters??"",P=>{try{pe("inputParameters",JSON.parse(P))}catch{f(V=>({...V,inputParameters:P}))}},{rows:5,language:"json","data-field":"inputParameters",style:{outline:"none"}})]}),a.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[st("重试次数","retryCount","number"),st("超时限制 (秒)","timeoutSeconds","number")]}),a.jsxs("details",{style:{marginTop:"16px"},children:[a.jsx("summary",{style:{fontSize:"11px",cursor:"pointer",color:ue,userSelect:"none",fontWeight:"600"},children:"▸ 执行控制(高级)"}),a.jsxs("div",{style:{marginTop:"12px"},children:[ne("重试策略 (retryLogic)",["FIXED","EXPONENTIAL_BACKOFF","LINEAR_BACKOFF"],$.retryLogic||"FIXED",P=>pe("retryLogic",P)),Y("重试延迟 (秒)",$.retryDelaySeconds??"",P=>pe("retryDelaySeconds",P?parseInt(P):void 0),"number","0"),ne("超时策略 (timeoutPolicy)",["TIME_OUT_WF","ALERT_ONLY","RETRY","FAIL_WORKFLOW"],$.timeoutPolicy||"TIME_OUT_WF",P=>pe("timeoutPolicy",P)),Y("启动延迟 (秒)",$.startDelay??"",P=>pe("startDelay",P?parseInt(P):void 0),"number","0"),fe("可选任务 (optional) — 失败不影响工作流",!!$.optional,P=>pe("optional",P)),fe("异步完成 (asyncComplete)",!!$.asyncComplete,P=>pe("asyncComplete",P))]})]})]}),a.jsx("div",{style:{marginTop:"48px",opacity:.6},children:a.jsxs("details",{children:[a.jsx("summary",{style:{fontSize:"11px",cursor:"pointer",marginBottom:"8px"},children:"查看完整 JSON (只读)"}),a.jsx("pre",{style:{background:"rgba(0,0,0,0.2)",padding:"16px",borderRadius:"8px",fontSize:"10px",overflow:"auto",border:`1px solid ${re}`,color:ue},children:JSON.stringify($,null,2)})]})})]}),te&&a.jsxs("div",{style:{padding:"24px",borderTop:`1px solid ${re}`,background:"var(--bg-secondary)",display:"flex",gap:"12px",flexShrink:0},children:[a.jsx("div",{style:{flex:1,fontSize:"11px",color:ue,display:"flex",alignItems:"center"},children:"✅ 所有修改已实时同步"}),a.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:"完成退出"})]}),a.jsx($1,{isOpen:D,onClose:()=>E(!1),onSelect:M,suggestions:W,wlspItems:O,anchorRect:C})]}),J&&a.jsx(W1,{title:J.title,value:J.value,language:J.language,onSave:J.onSave,onClose:()=>Z(null)})]})},H1=N.memo(B1),Wm=({keyName:e,value:t,path:r,depth:n,defaultExpanded:s,forceExpandAll:o,searchQuery:i,onCopyExpr:l,copiedPath:c,buildExpr:u})=>{const d=t!==null&&typeof t=="object",p=Array.isArray(t),[h,f]=N.useState(s),m=o!==null?o:h,g=u(r);if(!N.useMemo(()=>{if(!i.trim())return!0;const _=i.toLowerCase();if(e!==void 0&&String(e).toLowerCase().includes(_))return!0;try{return JSON.stringify(t).toLowerCase().includes(_)}catch{return!1}},[e,t,i]))return null;if(!d){let _="#e2e8f0",S=String(t);return typeof t=="string"?(_="#34d399",S=`"${t}"`):typeof t=="number"?_="#fbbf24":typeof t=="boolean"?_="#f472b6":t==null&&(_="#94a3b8",S="null"),a.jsxs("div",{className:"sjson-row",style:{paddingLeft:`${n*14}px`,display:"flex",alignItems:"center",justifyContent:"space-between",gap:"6px",paddingTop:"2px",paddingBottom:"2px",borderRadius:"4px",fontSize:"12px",fontFamily:"'JetBrains Mono', 'Fira Code', monospace"},children:[a.jsxs("div",{style:{wordBreak:"break-all",lineHeight:1.45},children:[e!==void 0&&a.jsxs("span",{style:{color:"#93c5fd"},children:[typeof e=="number"?`[${e}]`:`"${e}"`,a.jsx("span",{style:{color:"#64748b"},children:": "})]}),a.jsx("span",{style:{color:_},children:S})]}),g&&a.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),l(g)},title:`复制表达式 ${g}`,style:{flexShrink:0,fontSize:"10px",padding:"1px 6px",borderRadius:"4px",border:"1px solid rgba(56, 189, 248, 0.3)",background:c===g?"rgba(16, 185, 129, 0.2)":"rgba(56, 189, 248, 0.08)",color:c===g?"#34d399":"#38bdf8",cursor:"pointer",opacity:.85,fontFamily:"inherit"},children:c===g?"✓ 已复制":"${} 引用"})]})}const b=p?t.map((_,S)=>[S,_]):Object.entries(t),x=p?"[":"{",v=p?"]":"}",k=p?`${b.length} items`:`${b.length} keys`;return a.jsxs("div",{children:[a.jsxs("div",{onClick:()=>f(!m),style:{paddingLeft:`${n*14}px`,display:"flex",alignItems:"center",justifyContent:"space-between",gap:"6px",paddingTop:"2px",paddingBottom:"2px",cursor:"pointer",userSelect:"none",fontSize:"12px",fontFamily:"'JetBrains Mono', 'Fira Code', monospace"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[a.jsx("span",{style:{fontSize:"9px",color:"#64748b",width:"10px",display:"inline-block"},children:m?"▼":"▶"}),e!==void 0&&a.jsxs("span",{style:{color:"#93c5fd"},children:[typeof e=="number"?`[${e}]`:`"${e}"`,a.jsx("span",{style:{color:"#64748b"},children:": "})]}),a.jsxs("span",{style:{color:"#94a3b8"},children:[x,!m&&a.jsx("span",{style:{fontSize:"10px",color:"#64748b",margin:"0 4px"},children:k}),!m&&v]})]}),g&&r&&a.jsx("button",{type:"button",onClick:_=>{_.stopPropagation(),l(g)},title:`复制对象引用 ${g}`,style:{flexShrink:0,fontSize:"10px",padding:"1px 6px",borderRadius:"4px",border:"1px solid rgba(56, 189, 248, 0.25)",background:c===g?"rgba(16, 185, 129, 0.2)":"rgba(56, 189, 248, 0.06)",color:c===g?"#34d399":"#38bdf8",cursor:"pointer",opacity:.75,fontFamily:"inherit"},children:c===g?"✓ 已复制":"${} 引用"})]}),m&&a.jsxs("div",{children:[b.map(([_,S])=>{const j=typeof _=="number"?`${r}[${_}]`:r?`${r}.${_}`:String(_);return a.jsx(Wm,{keyName:_,value:S,path:j,depth:n+1,defaultExpanded:n<1,forceExpandAll:o,searchQuery:i,onCopyExpr:l,copiedPath:c,buildExpr:u},String(_))}),a.jsx("div",{style:{paddingLeft:`${n*14+14}px`,color:"#94a3b8",fontSize:"12px",fontFamily:"'JetBrains Mono', 'Fira Code', monospace"},children:v})]})]})},Fm=({data:e,taskReferenceName:t,expressionScope:r="output",maxHeight:n="420px"})=>{const[s,o]=N.useState(""),[i,l]=N.useState(null),[c,u]=N.useState(null),[d,p]=N.useState(!1),h=g=>g?r==="workflow.input"?`\${workflow.input.${g}}`:t?`\${${t}.${r}.${g}}`:null:null,f=g=>{navigator.clipboard.writeText(g),u(g),setTimeout(()=>u(null),1600)};return e==null||typeof e=="object"&&Object.keys(e).length===0?a.jsx("div",{style:{padding:"20px",textAlign:"center",color:"var(--text-secondary)",fontSize:"12px",background:"rgba(15, 23, 42, 0.35)",borderRadius:"8px",border:"1px solid var(--border-primary)"},children:"暂无数据 (Empty Payload)"}):a.jsxs("div",{style:{borderRadius:"8px",border:"1px solid var(--border-primary)",background:"rgba(15, 23, 42, 0.55)",overflow:"hidden"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",padding:"6px 10px",borderBottom:"1px solid rgba(148, 163, 184, 0.14)",background:"rgba(15, 23, 42, 0.4)"},children:[a.jsx("input",{type:"text",value:s,onChange:g=>o(g.target.value),placeholder:"🔍 检索字段名或值...",style:{flex:1,padding:"4px 8px",borderRadius:"5px",border:"1px solid rgba(148, 163, 184, 0.2)",background:"rgba(2, 6, 23, 0.5)",color:"#f8fafc",fontSize:"11px",outline:"none"}}),a.jsx("button",{type:"button",onClick:()=>l(!0),style:{fontSize:"10px",padding:"3px 7px",borderRadius:"4px",border:"1px solid rgba(148, 163, 184, 0.2)",background:"transparent",color:"#cbd5e1",cursor:"pointer"},children:"全部展开"}),a.jsx("button",{type:"button",onClick:()=>l(!1),style:{fontSize:"10px",padding:"3px 7px",borderRadius:"4px",border:"1px solid rgba(148, 163, 184, 0.2)",background:"transparent",color:"#cbd5e1",cursor:"pointer"},children:"折叠"}),a.jsx("button",{type:"button",onClick:()=>p(!d),style:{fontSize:"10px",padding:"3px 7px",borderRadius:"4px",border:"1px solid rgba(148, 163, 184, 0.2)",background:d?"rgba(56, 189, 248, 0.18)":"transparent",color:d?"#38bdf8":"#cbd5e1",cursor:"pointer"},children:d?"树形视图":"RAW"})]}),a.jsx("div",{style:{padding:"10px 12px",maxHeight:n,overflowY:"auto",overflowX:"auto"},children:d?a.jsx("pre",{style:{margin:0,fontSize:"11px",fontFamily:"'JetBrains Mono', 'Fira Code', monospace",color:"#e2e8f0",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:JSON.stringify(e,null,2)}):a.jsx(Wm,{value:e,path:"",depth:0,defaultExpanded:!0,forceExpandAll:i,searchQuery:s,onCopyExpr:f,copiedPath:c,buildExpr:h})})]})},U1={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)"},Ht=e=>U1[e??""]??"var(--text-secondary)",J1=(e,t)=>{if(!e)return"-";const r=(t??Date.now())-e;return r<1e3?`${r}ms`:`${(r/1e3).toFixed(2)}s`},Bm=e=>e?new Date(e).toLocaleTimeString():"-",K1=({executionActions:e})=>{const{selectedTask:t,selectedTaskInstance:r,setSelectedTask:n,setSelectedTaskInstance:s,executionData:o,workflowInstance:i}=le(),[l,c]=N.useState("summary"),u=N.useRef(null);N.useEffect(()=>{u.current?.scrollTo({top:0})},[l,t?.taskReferenceName]),N.useEffect(()=>{c("summary")},[t?.taskReferenceName]);const d=t?.taskReferenceName==="__workflow_global__",p=t?o?.[t.taskReferenceName]:null;if(!t||!p&&!d)return null;const h=p?.attempts??[],f=r??h[h.length-1],m=i?.workflowId??"",g=i?.status,y=p?.status,b=d?g:f?.status??y,x=d?i?.startTime:f?.startTime,v=d?i?.endTime:f?.endTime,k=d?i?.reasonForIncompletion:f?.reasonForIncompletion,_=d?i?.workflowId:f?.taskId,S=d?i?.input:f?.inputData,j=d?i?.output:f?.outputData,R=!d&&e?.onSkipTask&&(y==="SCHEDULED"||y==="IN_PROGRESS")&&(g==="RUNNING"||g==="PAUSED"),L=!d&&e?.onRerunFromTask&&(g==="FAILED"||g==="TERMINATED"||g==="COMPLETED"||g==="TIMED_OUT"),T=R||L,w=e?.allowOperations!==!1,D=()=>{n(null),s(null)},E="var(--glass-border)",C="var(--text-secondary)",z="var(--bg-tertiary)";return a.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 ${E}`,boxShadow:"-10px 0 30px rgba(0,0,0,0.2)",overflow:"hidden"},children:[a.jsxs("div",{style:{padding:"20px 24px",borderBottom:`1px solid ${E}`,background:"var(--bg-secondary)",flexShrink:0},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[a.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":t.type||"TASK"}),b&&a.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:5,padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:700,background:`${Ht(b)}18`,color:Ht(b),letterSpacing:"0.5px",flexShrink:0},children:["● ",b]}),a.jsx("div",{style:{flex:1}}),a.jsx("button",{onClick:D,style:{background:"none",border:"none",color:C,cursor:"pointer",fontSize:20,lineHeight:1,padding:4},children:"✕"})]}),a.jsx("div",{style:{fontSize:20,fontWeight:700,color:"var(--text-primary)",lineHeight:1.3},children:d?"工作流全局数据":t.name}),a.jsxs("div",{style:{fontSize:12,color:C,marginTop:6,fontFamily:"monospace",opacity:.8},children:["REF: ",t.taskReferenceName]})]}),h.length>1&&a.jsxs("div",{style:{padding:"12px 24px",borderBottom:`1px solid ${E}`,background:"var(--bg-secondary)",flexShrink:0},children:[a.jsxs("div",{style:{fontSize:11,fontWeight:600,color:C,marginBottom:8,textTransform:"uppercase",letterSpacing:"0.5px"},children:["执行记录(",h.length," 次",h.some(W=>W.iteration)?" / 迭代":"尝试",")"]}),a.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:h.map((W,K)=>{const M=f?.taskId===W.taskId;return a.jsx("button",{onClick:()=>s(W),style:{padding:"4px 12px",borderRadius:20,fontSize:12,cursor:"pointer",border:`1px solid ${M?"var(--color-accent)":E}`,background:M?"var(--color-accent)":"var(--bg-tertiary)",color:M?"#fff":"var(--text-primary)",fontFamily:"inherit",transition:"all 0.15s"},children:W.iteration?`迭代 ${W.iteration}`:`尝试 ${K+1}`},W.taskId)})})]}),a.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${E}`,background:"var(--bg-secondary)",flexShrink:0},children:["summary","input","output"].map(W=>{const K={summary:"概览",input:"输入 JSON",output:"输出 JSON"},M=l===W;return a.jsx("button",{onClick:()=>c(W),style:{padding:"10px 20px",background:"none",border:"none",borderBottom:`2px solid ${M?"var(--color-accent)":"transparent"}`,color:M?"var(--color-accent)":C,cursor:"pointer",fontSize:13,fontWeight:M?600:400,fontFamily:"inherit",transition:"all 0.15s"},children:K[W]},W)})}),a.jsxs("div",{ref:u,style:{flex:1,overflowY:"auto",padding:24,background:"var(--bg-primary)"},children:[l==="summary"&&a.jsxs(a.Fragment,{children:[a.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,marginBottom:24},children:[{label:"总耗时",value:J1(x,v)},{label:"开始时间",value:Bm(x)},{label:"结束时间",value:Bm(v)},{label:d?"Workflow ID":"Task ID",value:a.jsx("span",{style:{fontSize:10,fontFamily:"monospace",opacity:.7,wordBreak:"break-all"},children:_??"-"})}].map(({label:W,value:K})=>a.jsxs("div",{style:{padding:"12px 14px",background:z,borderRadius:10,border:`1px solid ${E}`},children:[a.jsx("div",{style:{fontSize:10,color:C,textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:6,fontWeight:600},children:W}),a.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",fontSize:13},children:K})]},W))}),h.length>1&&a.jsxs("div",{style:{marginBottom:20,padding:"10px 14px",background:`${Ht(y)}10`,border:`1px solid ${Ht(y)}30`,borderRadius:8,fontSize:12,color:Ht(y),display:"flex",alignItems:"center",gap:8},children:[a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[a.jsx("path",{d:"M13 2v4h-4"}),a.jsx("path",{d:"M13 6A7 7 0 1 1 9.5 2.5"})]}),"已重试 ",h.length-1," 次,共 ",h.length," 次尝试"]}),!d&&f?.workerId&&a.jsxs("div",{style:{marginBottom:20},children:[a.jsx("div",{style:{fontSize:10,color:C,textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:4,fontWeight:600},children:"Worker"}),a.jsx("div",{style:{fontSize:12,fontFamily:"monospace",color:"var(--text-primary)",opacity:.8},children:f.workerId})]}),k&&a.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:[a.jsx("strong",{children:"异常信息"}),a.jsx("div",{style:{marginTop:6,opacity:.9},children:k})]}),T&&a.jsxs("div",{style:{marginTop:24,paddingTop:20,borderTop:`1px solid ${E}`},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[a.jsx("div",{style:{fontSize:11,fontWeight:600,color:C,textTransform:"uppercase",letterSpacing:"0.5px"},children:"任务操作"}),!w&&a.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:[a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[a.jsx("circle",{cx:"8",cy:"8",r:"6"}),a.jsx("path",{d:"M8 5v3M8 11v.5"})]}),"操作权限受限"]})]}),a.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[L&&a.jsxs("button",{disabled:!w,onClick:()=>w&&e.onRerunFromTask(m,t.taskReferenceName,f?.taskId),title:w?`从任务 ${t.taskReferenceName} 处重新运行工作流`:"操作权限受限",style:w?pt:Hm,onMouseEnter:W=>!w||Object.assign(W.currentTarget.style,V1),onMouseLeave:W=>!w||Object.assign(W.currentTarget.style,pt),children:[a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[a.jsx("path",{d:"M3 14v-4h4"}),a.jsx("path",{d:"M3 10A7 7 0 1 1 6.5 13.5"})]}),"从此处重新运行"]}),R&&a.jsxs("button",{disabled:!w,onClick:()=>w&&e.onSkipTask(m,t.taskReferenceName,f?.taskId),title:w?`跳过任务 ${t.taskReferenceName}`:"操作权限受限",style:w?pt:Hm,onMouseEnter:W=>!w||Object.assign(W.currentTarget.style,G1),onMouseLeave:W=>!w||Object.assign(W.currentTarget.style,pt),children:[a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:a.jsx("path",{d:"M4 4l8 8M12 4l-8 8"})}),"跳过此任务"]})]})]})]}),l==="input"&&a.jsx(Fm,{data:S,taskReferenceName:d?void 0:t.taskReferenceName,expressionScope:d?"workflow.input":"input",maxHeight:"calc(100vh - 280px)"}),l==="output"&&a.jsx(Fm,{data:j,taskReferenceName:d?void 0:t.taskReferenceName,expressionScope:"output",maxHeight:"calc(100vh - 280px)"})]})]})},pt={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"},V1={...pt,borderColor:"var(--color-accent)",color:"var(--color-accent)",background:"var(--bg-primary)"},G1={...pt,borderColor:"var(--status-failed)",color:"var(--status-failed)",background:"rgba(239,68,68,0.08)"},Hm={...pt,opacity:.45,cursor:"not-allowed",border:"1px solid var(--border-primary)",background:"var(--bg-secondary)",color:"var(--text-secondary)"},Y1={add:"新增",mod:"修改",del:"删除",replace:"替换"},X1={add:"+",mod:"~",del:"−"};function Z1({diff:e,applied:t,onApply:r,onUndo:n}){const s=e.kind==="replace"?"add":e.kind;return a.jsxs("div",{className:"diff-card",children:[a.jsxs("div",{className:"diff-head",children:[a.jsx("span",{className:`diff-badge ${s}`,children:Y1[e.kind]??e.kind}),a.jsx("span",{className:"diff-summary",children:e.summary})]}),e.rows&&e.rows.length>0&&a.jsx("div",{className:"diff-list",children:e.rows.map((o,i)=>a.jsxs("div",{className:`diff-row ${o.kind}`,children:[a.jsx("div",{className:"diff-marker",children:X1[o.kind]??"·"}),a.jsx("div",{className:"diff-desc",children:o.desc})]},i))}),a.jsx("div",{className:"diff-actions",children:t?a.jsxs(a.Fragment,{children:[a.jsxs("button",{className:"diff-btn applied",disabled:!0,children:[a.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("path",{d:"M3 8l3.5 3.5L13 5",strokeLinecap:"round",strokeLinejoin:"round"})}),"已应用"]}),a.jsxs("button",{className:"diff-btn undo",onClick:n,children:[a.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("path",{d:"M3.5 8a4.5 4.5 0 1 1 1.4 3.3",strokeLinecap:"round"}),a.jsx("path",{d:"M3 4.5L4.5 8L7 6.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),"撤销"]})]}):a.jsxs("button",{className:"diff-btn apply",onClick:r,children:[a.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("path",{d:"M3 8l3.5 3.5L13 5",strokeLinecap:"round",strokeLinejoin:"round"})}),"应用更改"]})})]})}function Um(e,t){const r=JSON.parse(JSON.stringify(e));if(t.kind==="replace"&&t.payload)return{next:JSON.parse(JSON.stringify(t.payload)),inverse:{kind:"replace",summary:"撤销替换",rows:[],payload:e}};if(t.kind==="add"&&t.payload)return{next:JSON.parse(JSON.stringify(t.payload)),inverse:{kind:"replace",summary:"撤销生成",rows:[],payload:e}};if(!t.patch)return{next:r,inverse:{kind:t.kind,summary:"(无变更)",rows:[]}};const n=[],s=[];for(const o of t.patch)if(o.op==="patchTask"){const i=r.tasks.find(c=>c.taskReferenceName===o.ref);if(!i)continue;const l={};for(const c of Object.keys(o.set))l[c]=i[c];Object.assign(i,o.set),n.push({op:"patchTask",ref:o.ref,set:l}),s.push({kind:"mod",desc:`还原 ${o.ref} 属性`})}else if(o.op==="addEdge")r.edges=r.edges??[],r.edges.push({from:o.from,to:o.to,label:o.label}),n.push({op:"removeEdge",from:o.from,to:o.to}),s.push({kind:"del",desc:`移除边 ${o.from} → ${o.to}`});else if(o.op==="removeEdge")r.edges=(r.edges??[]).filter(i=>!(i.from===o.from&&i.to===o.to)),n.push({op:"addEdge",from:o.from,to:o.to}),s.push({kind:"add",desc:`恢复边 ${o.from} → ${o.to}`});else if(o.op==="addTask")r.tasks.push(o.task),r.edges=r.edges??[],o.removeEdges&&o.removeEdges.forEach(i=>{r.edges=r.edges.filter(l=>!(l.from===i.from&&l.to===i.to))}),o.extraEdges&&o.extraEdges.forEach(i=>r.edges.push(i)),n.push({op:"removeTask",ref:o.task.taskReferenceName}),s.push({kind:"del",desc:`移除 ${o.task.taskReferenceName}`});else if(o.op==="removeTask"){const i=r.tasks.findIndex(u=>u.taskReferenceName===o.ref);if(i<0)continue;const[l]=r.tasks.splice(i,1),c=(r.edges??[]).filter(u=>u.from===o.ref||u.to===o.ref);r.edges=(r.edges??[]).filter(u=>u.from!==o.ref&&u.to!==o.ref),n.push({op:"addTask",task:l,extraEdges:c}),s.push({kind:"add",desc:`恢复 ${o.ref}`})}else if(o.op==="insertAfter"){r.tasks.push(o.task),r.edges=r.edges??[];const i=r.edges.findIndex(l=>l.from===o.after&&l.to===o.edgeTo);i>=0&&r.edges.splice(i,1),r.edges.push({from:o.after,to:o.task.taskReferenceName}),r.edges.push({from:o.task.taskReferenceName,to:o.edgeTo}),n.push({op:"removeTask",ref:o.task.taskReferenceName}),s.push({kind:"del",desc:`移除 ${o.task.taskReferenceName}(恢复直连边)`})}else if(o.op==="insertBefore"){r.tasks.push(o.task),r.edges=r.edges??[];const i=r.edges.filter(l=>l.to===o.before);r.edges=r.edges.filter(l=>l.to!==o.before),i.forEach(l=>r.edges.push({from:l.from,to:o.task.taskReferenceName,label:l.label})),r.edges.push({from:o.task.taskReferenceName,to:o.before}),n.push({op:"removeTask",ref:o.task.taskReferenceName}),s.push({kind:"del",desc:`移除 ${o.task.taskReferenceName}(恢复原有入边)`})}return{next:r,inverse:{kind:t.kind,summary:`撤销:${t.summary}`,rows:s,patch:n.reverse()}}}function Q1(e){const t=e.match(/```diff-json\n([\s\S]*?)\n```/);if(!t)return null;try{const r=JSON.parse(t[1]);return!r.kind||!r.summary?null:r}catch{return null}}const Jm={id:"1",role:"ai",content:"你好!我是您的流程助手。我可以帮你生成工作流框架、优化逻辑或提供参数配置建议。你想实现什么样的流程?"},Km=e=>e.split(/(```[\s\S]*?```)/).map((r,n)=>{if(r.startsWith("```")&&r.endsWith("```")){const s=r.slice(3,-3),o=s.indexOf(`
|
|
128
|
+
`),i=o>=0?s.slice(o+1):s;return a.jsx("pre",{children:a.jsx("code",{children:i})},n)}return a.jsx("span",{children:e0(r)},n)}),e0=e=>{const t=[],r=/(\*\*[^*]+\*\*|`[^`]+`|\n)/g;let n=0,s;for(;(s=r.exec(e))!==null;){s.index>n&&t.push(e.slice(n,s.index));const o=s[0];o.startsWith("**")&&o.endsWith("**")?t.push(a.jsx("strong",{children:o.slice(2,-2)},s.index)):o.startsWith("`")&&o.endsWith("`")?t.push(a.jsx("code",{children:o.slice(1,-1)},s.index)):o===`
|
|
129
|
+
`&&t.push(a.jsx("br",{},s.index)),n=s.index+o.length}return n<e.length&&t.push(e.slice(n)),t},t0=({aiConfig:e})=>{const{workflowDef:t,setWorkflow:r,mode:n}=le(),[s,o]=N.useState(!1),[i,l]=N.useState(""),[c,u]=N.useState(!1),[d,p]=N.useState([Jm]),[h,f]=N.useState(""),[m,g]=N.useState(null),y=N.useRef(null),b=N.useRef(null),x=N.useRef(null),v=N.useCallback(C=>{if(!C.diff||C.applied||!t)return;const{next:z,inverse:W}=Um(t,C.diff);r(z),p(K=>K.map(M=>M.id===C.id?{...M,applied:!0,inverse:W}:M))},[t,r]),k=N.useCallback(C=>{if(!C.inverse||!C.applied||!t)return;const{next:z}=Um(t,C.inverse);r(z),p(W=>W.map(K=>K.id===C.id?{...K,applied:!1,inverse:void 0}:K))},[t,r]),_=()=>{const C=b.current;C&&(C.style.height="auto",C.style.height=Math.min(C.scrollHeight,120)+"px")},S=()=>{const C=b.current;C&&(C.style.height="auto")};N.useEffect(()=>()=>{x.current?.abort()},[]),N.useEffect(()=>{const C=()=>o(!0);return window.addEventListener("open-ai-chat",C),()=>window.removeEventListener("open-ai-chat",C)},[]);const j=()=>{y.current?.scrollIntoView({behavior:"smooth"})};N.useEffect(()=>{s&&j()},[d,s,h]);const R=N.useCallback(C=>{const z=[{role:"system",content:E1}];for(const K of d)K.role==="user"&&K.content?z.push({role:"user",content:K.content}):K.role==="ai"&&K.content&&!K.thinking&&z.push({role:"assistant",content:K.content});const W=M1(C,t);return z.push({role:"user",content:W}),z},[d,t]),L=async C=>{const z=i.trim();if(!z||c)return;x.current?.abort();const W=new AbortController;x.current=W;const K={id:Date.now().toString(),role:"user",content:z};p(M=>[...M,K]),l(""),S(),u(!0),f("");try{const M=e?.apiKey||localStorage.getItem("AI_API_KEY")||"",I=e?.baseUrl||localStorage.getItem("AI_BASE_URL")||"",F=e?.model||localStorage.getItem("AI_MODEL")||"";if(!M){setTimeout(()=>{if(W.signal.aborted)return;const H={name:"demo_approval_workflow",description:"演示审批流程",tasks:[{name:"submit_request",taskReferenceName:"submit_request",type:"SIMPLE",inputParameters:{}},{name:"human_approval",taskReferenceName:"human_approval",type:"HUMAN",inputParameters:{}},{name:"process_result",taskReferenceName:"process_result",type:"SIMPLE",inputParameters:{}}]},X={id:(Date.now()+1).toString(),role:"ai",content:"**演示模式**:未检测到 API Key,以下是一个示例审批流程供体验。请在标题栏 🤖 按钮中配置真实 API Key 以启用 AI 功能。",diff:{kind:"replace",summary:"生成三步审批流程(演示)",rows:[{kind:"add",desc:"submit_request — 提交申请任务"},{kind:"add",desc:"human_approval — 人工审批任务"},{kind:"add",desc:"process_result — 处理审批结果"}],payload:H}};p(ie=>[...ie,X]),u(!1)},800);return}const O={apiKey:M};I&&(O.baseUrl=I),F&&(O.model=F);const J=R(z),Z=await C1(J,O,H=>{f(X=>X+H)},()=>{},W.signal);let B=Q1(Z);if(!B){const H=Z.match(/```json\n([\s\S]*?)\n```/);if(H)try{const X=JSON.parse(H[1]);B={kind:"replace",summary:"应用 AI 生成的工作流",rows:[{kind:"add",desc:"全量替换为 AI 生成的工作流定义"}],payload:X}}catch{}}const U={id:(Date.now()+1).toString(),role:"ai",content:Z,diff:B??void 0,applied:!1};p(H=>[...H,U]),f("")}catch(M){if(M.name==="AbortError")f(I=>{if(I){const F={id:(Date.now()+1).toString(),role:"ai",content:I};p(O=>[...O,F])}return""});else{const I={id:Date.now().toString(),role:"ai",content:`抱歉,目前无法连接到 AI 服务: ${M.message}`};p(F=>[...F,I]),f("")}}finally{u(!1)}},T=()=>{x.current?.abort()},w=()=>{x.current?.abort(),p([Jm]),f(""),u(!1)},D=C=>{navigator.clipboard.writeText(C.content??""),g(C.id),setTimeout(()=>g(null),1500)},E=C=>{C.nativeEvent.isComposing||C.keyCode===229||C.key==="Enter"&&!C.shiftKey&&(C.preventDefault(),L())};return n!=="edit"?null:s?a.jsxs("div",{className:"ai-chat-panel",children:[a.jsxs("div",{className:"ai-header",children:[a.jsxs("div",{className:"ai-title",children:[a.jsx("span",{className:"ai-sparkles",children:"✨"}),"AI 助手"]}),a.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[a.jsx("button",{className:"ai-close",onClick:w,title:"清空对话",children:"🗑"}),a.jsx("button",{className:"ai-close",onClick:()=>o(!1),children:"×"})]})]}),a.jsxs("div",{className:"ai-messages",children:[d.map(C=>a.jsxs("div",{className:`message ${C.role}`,children:[a.jsx("div",{className:"message-content",children:C.thinking?a.jsxs("div",{className:"thinking-skeleton",children:[a.jsx("div",{className:"skeleton-line",style:{width:"80%"}}),a.jsx("div",{className:"skeleton-line",style:{width:"60%"}})]}):C.role==="ai"?Km(C.content??""):C.content}),C.diff&&!C.thinking&&a.jsx(Z1,{diff:C.diff,applied:C.applied??!1,onApply:()=>v(C),onUndo:()=>k(C)}),C.role==="ai"&&C.content&&a.jsx("button",{className:"copy-btn",onClick:()=>D(C),title:"复制",children:m===C.id?"✓":"📋"})]},C.id)),c&&h&&a.jsxs("div",{className:"message ai",style:{opacity:.9},children:[a.jsx("div",{className:"message-content",children:Km(h)}),a.jsx("span",{className:"streaming-cursor",children:"▊"})]}),c&&!h&&a.jsxs("div",{className:"message ai thinking-skeleton",children:[a.jsx("div",{className:"skeleton-line",style:{width:"80%"}}),a.jsx("div",{className:"skeleton-line",style:{width:"60%"}}),a.jsx("div",{className:"skeleton-line",style:{width:"70%"}})]}),a.jsx("div",{ref:y})]}),a.jsx("div",{className:"ai-input-area",children:a.jsxs("div",{className:"ai-input-container",children:[a.jsx("textarea",{ref:b,className:"ai-input",placeholder:c?"AI 正在响应...":"描述您的需求…(Shift+Enter 换行)",value:i,onChange:C=>l(C.target.value),onInput:_,onKeyDown:E,disabled:c,rows:2}),c?a.jsx("button",{className:"ai-send stop",onClick:T,title:"停止生成",children:"⏹"}):a.jsx("button",{className:"ai-send",onClick:()=>L(),title:"发送",children:"🚀"})]})})]}):a.jsx("div",{className:"ai-chat-panel collapsed",onClick:()=>o(!0),children:a.jsx("div",{className:"ai-header",style:{borderBottom:"none"},children:a.jsxs("div",{className:"ai-title",children:[a.jsx("span",{className:"ai-sparkles",children:"✨"}),"AI 助手"]})})})},r0=new Set(["COMPLETED","FAILED","TIMED_OUT","TERMINATED"]),n0=({onTriggerExecution:e,onPollExecution:t,executionPollInterval:r=3e3})=>{const{workflowDef:n,showRunPanel:s,setShowRunPanel:o,setRunState:i,importExecutionJSON:l,setMode:c}=le(),[u,d]=N.useState("form"),[p,h]=N.useState({}),[f,m]=N.useState("{}"),[g,y]=N.useState(""),[b,x]=N.useState(!1),[v,k]=N.useState(""),_=qt(n?.inputParameters);N.useEffect(()=>{s&&(h({}),m("{}"),y(""),k(""),x(!1))},[s]);const S=N.useCallback(()=>{try{const w={};_.forEach(D=>{const E=p[D.name];if(E!==void 0&&E!=="")if(D.type==="number")w[D.name]=Number(E);else if(D.type==="boolean")w[D.name]=E==="true";else if(D.type==="object"||D.type==="array")try{w[D.name]=JSON.parse(E)}catch{w[D.name]=E}else w[D.name]=E;else D.defaultValue!==void 0&&(w[D.name]=D.defaultValue)}),m(JSON.stringify(w,null,2))}catch{}d("json")},[p,_]),j=N.useCallback(()=>{try{const w=JSON.parse(f),D={};_.forEach(E=>{const C=w[E.name];C!==void 0&&(D[E.name]=typeof C=="object"?JSON.stringify(C,null,2):String(C))}),h(D),y("")}catch{y("JSON 格式有误,无法切换为表单模式")}d("form")},[f,_]),R=N.useCallback(()=>{if(u==="json")try{return JSON.parse(f)}catch{return y("JSON 格式有误,请检查后重试"),null}const w={};return _.forEach(D=>{const E=p[D.name]??(D.defaultValue!==void 0?String(D.defaultValue):"");if(!(E===""&&!D.required))if(D.type==="number")w[D.name]=Number(E);else if(D.type==="boolean")w[D.name]=E==="true";else if(D.type==="object"||D.type==="array")try{w[D.name]=JSON.parse(E)}catch{w[D.name]=E}else w[D.name]=E}),w},[u,f,p,_]),L=N.useCallback(async()=>{if(!e||!n)return;const w=R();if(w===null)return;const D=_.filter(E=>E.required&&(w[E.name]===void 0||w[E.name]===""));if(D.length>0){k(`必填参数未填写:${D.map(E=>E.name).join(", ")}`);return}x(!0),k(""),i("triggering");try{const{workflowId:E}=await e(n.name,n.version??1,w);if(i("polling",E),o(!1),c("run"),!t)return;let C=r;const z=15e3;let W;const K=async()=>{try{const M=await t(E);if(M&&(l(M),r0.has(M.status))){i("done",E);return}}catch{}C=Math.min(C*1.5,z),W=setTimeout(K,C)};W=setTimeout(K,C),le.getState().__pollTimer=W}catch(E){const C=E?.message||"执行触发失败,请检查配置后重试";i("error",null,C),k(C),x(!1)}},[e,t,n,R,_,i,o,l,c,r]);if(!s||!n)return null;const T=_.length>0;return a.jsx("div",{className:"wrp-overlay",onClick:()=>o(!1),children:a.jsxs("div",{className:"wrp-panel",onClick:w=>w.stopPropagation(),children:[a.jsxs("div",{className:"wrp-header",children:[a.jsxs("div",{className:"wrp-header-title",children:[a.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",style:{color:"var(--status-completed)"},children:a.jsx("path",{d:"M4 3l9 5-9 5z"})}),"执行验证"]}),a.jsxs("div",{className:"wrp-workflow-name",children:[n.name," ",a.jsxs("span",{className:"wrp-version",children:["v",n.version??1]})]}),a.jsx("button",{className:"wrp-close",onClick:()=>o(!1),children:"✕"})]}),a.jsxs("div",{className:"wrp-content",children:[a.jsxs("div",{className:"wrp-section-label",children:["工作流输入参数",T&&a.jsxs("div",{className:"wrp-mode-toggle",children:[a.jsx("button",{className:u==="form"?"active":"",onClick:u==="json"?j:void 0,children:"表单模式"}),a.jsx("button",{className:u==="json"?"active":"",onClick:u==="form"?S:void 0,children:"JSON 编辑器"})]})]}),!T&&u==="form"&&a.jsxs("p",{className:"wrp-hint",children:["该工作流未声明输入参数。你可以在 ",a.jsx("strong",{children:"工作流设置 → 参数配置"})," 中添加,也可以直接在 JSON 编辑器中手动填写。"]}),u==="form"?a.jsxs("div",{className:"wrp-form",children:[_.map(w=>a.jsxs("div",{className:"wrp-field",children:[a.jsxs("label",{className:"wrp-field-label",children:[w.name,w.required&&a.jsx("span",{className:"wrp-required",children:"*"}),w.type&&a.jsx("span",{className:"wrp-type",children:w.type})]}),w.description&&a.jsx("p",{className:"wrp-field-desc",children:w.description}),w.type==="object"||w.type==="array"?a.jsx("textarea",{className:"wrp-input",rows:3,placeholder:w.example?JSON.stringify(w.example,null,2):"{}",value:p[w.name]??"",onChange:D=>h(E=>({...E,[w.name]:D.target.value}))}):w.type==="boolean"?a.jsxs("select",{className:"wrp-input",value:p[w.name]??(w.defaultValue!==void 0?String(w.defaultValue):""),onChange:D=>h(E=>({...E,[w.name]:D.target.value})),children:[a.jsx("option",{value:"",children:"请选择"}),a.jsx("option",{value:"true",children:"true"}),a.jsx("option",{value:"false",children:"false"})]}):a.jsx("input",{className:"wrp-input",type:w.type==="number"?"number":"text",placeholder:w.example!==void 0?String(w.example):w.defaultValue!==void 0?String(w.defaultValue):"",value:p[w.name]??"",onChange:D=>h(E=>({...E,[w.name]:D.target.value}))})]},w.name)),!T&&a.jsx("button",{className:"wrp-switch-json",onClick:S,children:"切换为 JSON 编辑器手动填写"})]}):a.jsxs("div",{className:"wrp-json-editor",children:[a.jsx("textarea",{className:"wrp-input wrp-json",rows:12,value:f,onChange:w=>{m(w.target.value),y("")},spellCheck:!1,placeholder:'{\\n "key": "value"\\n}'}),g&&a.jsx("p",{className:"wrp-error",children:g})]}),v&&a.jsx("p",{className:"wrp-error wrp-submit-error",children:v})]}),a.jsxs("div",{className:"wrp-footer",children:[a.jsx("button",{className:"wrp-btn wrp-btn-cancel",onClick:()=>o(!1),children:"取消"}),e?a.jsx("button",{className:"wrp-btn wrp-btn-execute",onClick:L,disabled:b,children:b?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"wrp-spinner"}),"执行中..."]}):a.jsxs(a.Fragment,{children:[a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:a.jsx("path",{d:"M4 3l9 5-9 5z"})}),"发起执行"]})}):a.jsx("span",{className:"wrp-hint-inline",children:"未配置 onTriggerExecution 回调"})]})]})})},a0=[{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 s0(e,t){const r=t[e];if(!r)return[];const n=r.reasonForIncompletion||"";if(!n)return[];const s=[];for(const o of a0)o.pattern.test(n)&&s.push({category:o.category,title:o.title,explanation:o.explanation,suggestEditParam:o.suggestEditParam});return s.length===0&&n.length>0&&s.push({category:"logic",title:"执行异常",explanation:`任务执行失败,原因:${n.slice(0,200)}${n.length>200?"...":""}`}),s}function o0(e,t){const r=Object.values(e).map(f=>{const m=f.startTime&&f.endTime?f.endTime-f.startTime:void 0,g=Math.max(0,(f.attempts?.length??1)-1);return{taskRef:f.taskReferenceName,status:f.status,startTime:f.startTime,endTime:f.endTime,durationMs:m,retryCount:g,reasonForIncompletion:f.reasonForIncompletion,diagnostics:s0(f.taskReferenceName,e)}}).sort((f,m)=>(f.startTime??0)-(m.startTime??0)),n=["FAILED","FAILED_WITH_TERMINAL_ERROR","TIMED_OUT"],s=r.filter(f=>f.status==="COMPLETED"||f.status==="COMPLETED_WITH_ERRORS").length,o=r.filter(f=>n.includes(f.status)).length,i=r.filter(f=>f.status==="SKIPPED").length,l=r.flatMap(f=>[f.startTime,f.endTime]).filter(f=>!!f),c=l.length?Math.min(...l):0,d=(l.length?Math.max(...l):0)-c,p=t?.status,h=p==="FAILED"||p==="TIMED_OUT"||p==="TERMINATED"||o>0;return{totalTasks:r.length,completedTasks:s,failedTasks:o,skippedTasks:i,totalDurationMs:d,steps:r,hasFailed:h}}function Vm(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 i0(e){return{parameter:"⚙️",timeout:"⏱️",auth:"🔐",network:"🌐",logic:"🔧"}[e]??"⚠️"}function l0(e){return{parameter:"#f59e0b",timeout:"#8b5cf6",auth:"#ef4444",network:"#3b82f6",logic:"#10b981"}[e]??"#6b7280"}const at={CREDENTIAL_KEY:/(token|secret|password|passwd|authorization|apikey|api_key|webhook|access_key|private_key|auth)/i,PRIVATE_IP:/\b(10\.\d{1,3}\.\d{1,3}\.\d{1,3}|172\.(1[6-9]|2\d|3[01])\.\d{1,3}\.\d{1,3}|192\.168\.\d{1,3}\.\d{1,3})\b/,PHONE:/\b1[3-9]\d{9}\b/,EMAIL:/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/,CLOUD_RESOURCE_ID:/\b(i|d|s|vpc|vsw|sg|disk|snap)-[a-z0-9]{8,24}\b/i};function _r(e,t,r,n=[]){if(!e||typeof e!="object")return n;for(const[s,o]of Object.entries(e)){if(s==="_actionId"||s==="actionName")continue;const i=`${r}.${s}`;if(o!=null)if(typeof o=="string"){if(at.CREDENTIAL_KEY.test(s)&&o.length>5){n.push({id:`finding_${n.length+1}`,kind:"credential",path:i,taskRef:t,keyName:s,rawValue:o,maskedValue:"",suggestedVarName:`${s}_凭证密钥`,action:"variable"});continue}if(at.PRIVATE_IP.test(o)){n.push({id:`finding_${n.length+1}`,kind:"network",path:i,taskRef:t,keyName:s,rawValue:o,maskedValue:o.replace(at.PRIVATE_IP,"172.16.0.42"),suggestedVarName:`${s}_内网IP`,action:"mask"});continue}if(at.PHONE.test(o)){n.push({id:`finding_${n.length+1}`,kind:"pii",path:i,taskRef:t,keyName:s,rawValue:o,maskedValue:o.replace(at.PHONE,"13800138000"),suggestedVarName:"通知联系手机",action:"mask"});continue}if(at.EMAIL.test(o)){n.push({id:`finding_${n.length+1}`,kind:"pii",path:i,taskRef:t,keyName:s,rawValue:o,maskedValue:o.replace(at.EMAIL,"ops-notify@example.com"),suggestedVarName:"接收人邮箱",action:"mask"});continue}if(at.CLOUD_RESOURCE_ID.test(o)&&!o.includes("${")){n.push({id:`finding_${n.length+1}`,kind:"resourceId",path:i,taskRef:t,keyName:s,rawValue:o,maskedValue:"i-bp18a9z3j42m09a",suggestedVarName:`${s}_云资源ID`,action:"variable"});continue}}else typeof o=="object"&&_r(o,t,i,n)}return n}function Gm(e){const t=[];return(e.tasks||[]).forEach((r,n)=>{const s=`tasks[${n}].inputParameters`;r.inputParameters&&_r(r.inputParameters,r.taskReferenceName,s,t),r.httpRequest&&_r(r.httpRequest,r.taskReferenceName,`tasks[${n}].httpRequest`,t)}),t}const Ym=/(debug|fallback|compensate|retry|temporary|temp|log_dump|tracer)/i;function Xm(e,t){const r=[],n=e.tasks||[];for(const s of n){if(Ym.test(s.name)||Ym.test(s.taskReferenceName)){r.push({taskReferenceName:s.taskReferenceName,taskName:s.name,taskType:s.type,reason:"检测到任务名称含调试/单次补偿/临时特征,建议从公共通用模板中剔除。",selected:!0});continue}if(t){const o=t.tasks.find(i=>i.referenceTaskName===s.taskReferenceName);o&&o.status==="SKIPPED"&&r.push({taskReferenceName:s.taskReferenceName,taskName:s.name,taskType:s.type,reason:"该任务在生产历史执行中被判定跳过 (SKIPPED),通常属于特殊条件下的低频补偿分支。",selected:!1})}}return r}function Zm(e,t){const r=structuredClone(e);return r.tasks=(r.tasks||[]).filter(n=>!t.has(n.taskReferenceName)),r}function jr(e){if(!e||typeof e!="object")return e;if(Array.isArray(e))return e.map(jr);const t={};for(const[r,n]of Object.entries(e))typeof n=="string"?/(token|secret|password|authorization|apikey)/i.test(r)&&n.length>5?t[r]="":/\b1[3-9]\d{9}\b/.test(n)?t[r]=n.replace(/\b1[3-9]\d{9}\b/,"13800138000"):/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/.test(n)?t[r]=n.replace(/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/,"ops-notify@example.com"):/\b(10\.\d{1,3}\.\d{1,3}\.\d{1,3}|172\.(1[6-9]|2\d|3[01])\.\d{1,3}\.\d{1,3}|192\.168\.\d{1,3}\.\d{1,3})\b/.test(n)?t[r]=n.replace(/\b(10\.\d{1,3}\.\d{1,3}\.\d{1,3}|172\.(1[6-9]|2\d|3[01])\.\d{1,3}\.\d{1,3}|192\.168\.\d{1,3}\.\d{1,3})\b/,"172.16.0.42"):t[r]=n:typeof n=="object"&&n!==null?t[r]=jr(n):t[r]=n;return t}function Qm(e){const{instance:t,title:r,category:n,valueProposition:s,author:o}=e,i=t.workflowDefinition?structuredClone(t.workflowDefinition):{name:t.workflowName||"extracted_workflow",tasks:t.tasks.map(k=>k.workflowTask||{name:k.taskDefName||k.referenceTaskName,taskReferenceName:k.referenceTaskName,type:k.taskType||"SIMPLE",inputParameters:k.inputData})},l=Gm(i),c=Xm(i,t),u=new Set(c.filter(k=>k.selected).map(k=>k.taskReferenceName)),d=Zm(i,u),p=[],h=structuredClone(d);for(const k of l)if(k.action==="variable"){const _=`var_${k.keyName}_${Date.now().toString(36).slice(-3)}`;p.push({key:_,label:k.suggestedVarName||k.keyName,type:typeof k.rawValue=="number"?"number":"text",defaultValue:k.maskedValue||k.rawValue,required:!0,bindings:[k.path]})}const f={};for(const k of t.tasks)k.outputData&&!u.has(k.referenceTaskName)&&(f[k.referenceTaskName]=jr(k.outputData));const m={name:"生产真实运行数据脱敏样本",description:`基于实例 ${t.workflowId} 真实执行产物自动生成的高保真无害化数据集`,workflowInput:jr(t.input||{}),taskOutputs:f},g=`tpl_extracted_${Date.now().toString(36)}`,y=r||`${i.name||"业务流"} (实战萃取模板)`,b=n||"ops",x=s||`源于真实执行实例 ${t.workflowId},已完成自动化脱敏与参数提取。`;return{template:{id:g,version:"1.0.0",title:y,category:b,icon:"💎",valueProposition:x,description:i.description||"由管理员从高频成功的生产运行记录中提炼而成的标准化黄金模板。",connectors:["cloud_host","dingtalk"],roi:{minutesSavedPerRun:25,typicalRunsPerWeek:10,popularityCount:1},difficulty:"intermediate",variables:p,definition:h,mockDataset:{scenarios:[m]},provenance:{source:"extracted",author:o||"Platform Admin",publishedAt:new Date().toISOString(),extractedFromWorkflowId:t.workflowId}},findings:l,prunedTasks:c,report:{extractedAt:new Date().toISOString(),totalTasksScanned:i.tasks?.length??0,sensitiveItemsCount:l.length,credentialsRedactedCount:l.filter(k=>k.kind==="credential").length,variablesCreatedCount:p.length}}}const eg=[{id:"tpl_ecs_auto_provision",version:"1.0.0",title:"云主机自动化交付与环境配置",category:"compute",icon:"🚀",valueProposition:"一键完成主机创建、运行时环境自动化部署、基线快照与交付群通知,单次节省 35 分钟手工操作。",description:"面向新业务系统上线场景,自动根据指定规格在云平台创建云主机,通过远程免密脚本自动安装 Docker 与运行时依赖,并在验证就绪后自动归档基线快照向运维协同群发送交付卡片。",connectors:["cloud_host","dingtalk"],roi:{minutesSavedPerRun:35,typicalRunsPerWeek:12,popularityCount:1420},difficulty:"starter",variables:[{key:"instanceName",label:"新主机名称",type:"text",defaultValue:"app-service-prod",required:!0,placeholder:"例如: app-service-prod",bindings:["tasks[0].inputParameters.instanceName"]},{key:"regionId",label:"目标地域",type:"select",defaultValue:"cn-hangzhou",required:!0,options:[{label:"华东 1 (杭州)",value:"cn-hangzhou"},{label:"华北 2 (北京)",value:"cn-beijing"},{label:"华南 1 (深圳)",value:"cn-shenzhen"}],bindings:["tasks[0].inputParameters.regionId"]},{key:"notifyChannel",label:"交付通知渠道",type:"select",defaultValue:"webhook_dingtalk",required:!0,options:[{label:"钉钉运维机器人 (DingTalk)",value:"webhook_dingtalk"},{label:"企业微信机器人 (WeCom)",value:"webhook_wecom"},{label:"飞书群机器人 (Feishu/Lark)",value:"webhook_feishu"}],bindings:["tasks[4].inputParameters.channel"]}],definition:{name:"ecs_auto_provision_flow",description:"云主机全自动交付与运行时环境部署",version:1,tasks:[{name:"ecs_create_instance",taskReferenceName:"create_node",type:"HTTP",description:"创建计算型云主机",inputParameters:{_actionId:"ecs.create_instance",instanceName:"app-service-prod",regionId:"cn-hangzhou",instanceType:"ecs.c7.xlarge",imageId:"image-alilinux-3",systemDiskSize:120}},{name:"wait_for_network",taskReferenceName:"wait_network_ready",type:"WAIT",description:"等待网络与底层系统完成自检",inputParameters:{_actionId:"control.wait",duration:"10s"}},{name:"ecs_run_command",taskReferenceName:"install_runtime",type:"HTTP",description:"免密下发初始化命令: 安装 Docker 与守护进程",inputParameters:{_actionId:"ecs.run_command",instanceId:"${create_node.output.instanceId}",commandContent:"yum update -y && systemctl start docker && docker info",commandType:"RunShellScript",timeoutSeconds:60}},{name:"ecs_create_snapshot",taskReferenceName:"create_baseline_snap",type:"HTTP",description:"创建系统盘基线快照",inputParameters:{_actionId:"ecs.create_snapshot",instanceId:"${create_node.output.instanceId}",snapshotName:"baseline-init-snapshot",retentionDays:30}},{name:"send_operation_notification",taskReferenceName:"notify_devops",type:"EVENT",description:"向运维协同群发送交付卡片",inputParameters:{_actionId:"notify.send_message",channel:"webhook_dingtalk",title:"【交付就绪】新云主机已部署完成",content:"云主机 ${create_node.output.instanceId} 已创建并完成 Docker 运行时初始化与安全基线快照,内网IP: ${create_node.output.privateIp}。"}}]},mockDataset:{scenarios:[{name:"标准交付场景",description:"模拟一次完整的 4C8G 主机自动交付与脚本安装过程",workflowInput:{},taskOutputs:{create_node:{instanceId:"i-bp18a9z3j42m09a",instanceName:"app-service-prod",privateIp:"172.16.0.42",status:"RUNNING",createdAt:"2026-10-20T14:00:00Z"},wait_network_ready:{waited:!0,duration:"10s"},install_runtime:{exitCode:0,status:"SUCCESS",output:"Docker version 24.0.5 installed and running"},create_baseline_snap:{snapshotId:"s-bp199042",status:"ACCOMPLISHED"},notify_devops:{messageId:"msg-9921",sentStatus:"DELIVERED"}}}]}},{id:"tpl_ecs_daily_snapshot_backup",version:"1.0.0",title:"核心云主机每日定时快照备份",category:"security",icon:"💾",valueProposition:"每日自动化创建增量快照并自动清理超期备份,防勒索防误删,单次节省 15 分钟人工检查。",description:"自动对生产数据库或核心应用所在的云主机创建带时间戳的增量快照,保留 14 天自动循环轮转,并在完成备份后发送健康汇报。",connectors:["cloud_host","dingtalk"],roi:{minutesSavedPerRun:15,typicalRunsPerWeek:7,popularityCount:2310},difficulty:"starter",variables:[{key:"instanceId",label:"目标云主机 ID",type:"text",defaultValue:"i-bp18a9z3j42m09a",required:!0,placeholder:"例如: i-bp18a9z3j42m09a",bindings:["tasks[0].inputParameters.instanceId","tasks[1].inputParameters.instanceId"]},{key:"retentionDays",label:"快照保留天数",type:"number",defaultValue:14,required:!0,bindings:["tasks[1].inputParameters.retentionDays"]}],definition:{name:"ecs_daily_snapshot_backup_flow",description:"核心云主机每日定时增量备份",version:1,tasks:[{name:"ecs_query_instance",taskReferenceName:"check_host",type:"HTTP",description:"检查主机运行健康状态",inputParameters:{_actionId:"ecs.query_instance",instanceId:"i-bp18a9z3j42m09a"}},{name:"ecs_create_snapshot",taskReferenceName:"create_daily_snap",type:"HTTP",description:"执行云盘增量备份快照",inputParameters:{_actionId:"ecs.create_snapshot",instanceId:"i-bp18a9z3j42m09a",snapshotName:"auto-daily-backup",retentionDays:14}},{name:"send_operation_notification",taskReferenceName:"notify_result",type:"EVENT",description:"发送备份执行简报",inputParameters:{_actionId:"notify.send_message",channel:"webhook_dingtalk",title:"【快照备份成功】每日例行备份完成",content:"云主机 ${check_host.output.instanceId} (${check_host.output.status}) 增量快照已生成,快照ID: ${create_daily_snap.output.snapshotId}。"}}]},mockDataset:{scenarios:[{name:"定时备份成功场景",workflowInput:{},taskOutputs:{check_host:{instanceId:"i-bp18a9z3j42m09a",status:"RUNNING",osName:"Alibaba Cloud Linux 3"},create_daily_snap:{snapshotId:"s-bp188201",snapshotName:"auto-daily-backup",status:"ACCOMPLISHED"},notify_result:{sentStatus:"DELIVERED"}}}]}},{id:"tpl_ecs_high_load_autoscale",version:"1.0.0",title:"主机高负载告警与在线自动升配",category:"ops",icon:"⚡",valueProposition:"检测到 CPU 利用率超标时自动发起升配流程,内置人工审批安全网,秒级在线完成 4C8G -> 8C16G 弹性扩容。",description:"自动轮询主机性能指标,一旦触发瓶颈阈值,系统即刻生成规格变更提案并向架构师推送一键审批卡片,审批后自动在线变配,保障大促不卡顿。",connectors:["cloud_host","dingtalk","approval"],roi:{minutesSavedPerRun:40,typicalRunsPerWeek:5,popularityCount:980},difficulty:"intermediate",variables:[{key:"instanceId",label:"监控主机 ID",type:"text",defaultValue:"i-bp18a9z3j42m09a",required:!0,bindings:["tasks[0].inputParameters.instanceId","tasks[2].inputParameters.instanceId"]},{key:"targetSpec",label:"目标扩容规格",type:"select",defaultValue:"ecs.c7.2xlarge",required:!0,options:[{label:"提升至 计算型 8C16G (ecs.c7.2xlarge)",value:"ecs.c7.2xlarge"},{label:"提升至 内存型 8C32G (ecs.r7.2xlarge)",value:"ecs.r7.2xlarge"}],bindings:["tasks[2].inputParameters.targetSpec"]}],definition:{name:"ecs_high_load_autoscale_flow",description:"云主机高负载自动熔断与在线变配",version:1,tasks:[{name:"ecs_get_monitor_metrics",taskReferenceName:"fetch_metrics",type:"HTTP",description:"采集 CPU 与内存利用率",inputParameters:{_actionId:"ecs.get_monitor_metrics",instanceId:"i-bp18a9z3j42m09a",periodSeconds:60}},{name:"human_operation_approval",taskReferenceName:"approve_spec_upgrade",type:"HUMAN",description:"高危硬件配置变更审批",inputParameters:{_actionId:"human.approval",assigneeRole:"architect",promptMessage:"云主机 ${fetch_metrics.output.instanceId} 当前 CPU 利用率达到 ${fetch_metrics.output.cpuUsagePercent}%,申请在线升配。",timeoutMinutes:30}},{name:"ecs_modify_spec",taskReferenceName:"apply_spec_change",type:"HTTP",description:"执行在线规格扩容变更",inputParameters:{_actionId:"ecs.modify_spec",instanceId:"i-bp18a9z3j42m09a",targetSpec:"ecs.c7.2xlarge"}},{name:"send_operation_notification",taskReferenceName:"notify_upgrade_done",type:"EVENT",description:"发送变配完成汇报",inputParameters:{_actionId:"notify.send_message",channel:"webhook_dingtalk",title:"【升配成功】云主机硬件规格已在线提升",content:"云主机 ${fetch_metrics.output.instanceId} 已成功从 ${apply_spec_change.output.oldSpec} 变更为 ${apply_spec_change.output.newSpec}。"}}]},mockDataset:{scenarios:[{name:"高负载升配成功场景",workflowInput:{},taskOutputs:{fetch_metrics:{instanceId:"i-bp18a9z3j42m09a",cpuUsagePercent:88.5,isOverloaded:!0},approve_spec_upgrade:{approved:!0,reviewer:"architect@internal.cloud"},apply_spec_change:{oldSpec:"ecs.c7.xlarge",newSpec:"ecs.c7.2xlarge",status:"SUCCESS"},notify_upgrade_done:{sentStatus:"DELIVERED"}}}]}},{id:"tpl_ecs_vulnerability_patch",version:"1.0.0",title:"生产主机一键漏洞巡检与修复",category:"security",icon:"🛡️",valueProposition:"修补前自动创建保护快照,免密下发 OS 补丁脚本,带审批确认软重启,消除系统 CVE 高危隐患。",description:"解决企业 Linux 主机补丁升级流程繁琐、缺少回滚预案的问题。流程自动先对磁盘建立防护快照,执行补丁更新后通知责任人确认软重启。",connectors:["cloud_host","dingtalk","approval"],roi:{minutesSavedPerRun:45,typicalRunsPerWeek:4,popularityCount:760},difficulty:"intermediate",variables:[{key:"instanceId",label:"目标主机 ID",type:"text",defaultValue:"i-bp18a9z3j42m09a",required:!0,bindings:["tasks[0].inputParameters.instanceId","tasks[1].inputParameters.instanceId","tasks[3].inputParameters.instanceId"]}],definition:{name:"ecs_vulnerability_patch_flow",description:"带快照防护的操作系统漏洞巡检与修复流程",version:1,tasks:[{name:"ecs_create_snapshot",taskReferenceName:"patch_safeguard_snap",type:"HTTP",description:"建立补丁前安全还原快照",inputParameters:{_actionId:"ecs.create_snapshot",instanceId:"i-bp18a9z3j42m09a",snapshotName:"pre-patch-safeguard",retentionDays:7}},{name:"ecs_run_command",taskReferenceName:"apply_cve_patches",type:"HTTP",description:"下发漏洞热补丁脚本",inputParameters:{_actionId:"ecs.run_command",instanceId:"i-bp18a9z3j42m09a",commandContent:"yum update-minimal --security -y",commandType:"RunShellScript",timeoutSeconds:120}},{name:"human_operation_approval",taskReferenceName:"confirm_soft_reboot",type:"HUMAN",description:"责任人确认重启",inputParameters:{_actionId:"human.approval",assigneeRole:"devops_lead",promptMessage:"补丁更新已完成,请确认是否即刻安排主机软重启以使内核生效。",timeoutMinutes:60}},{name:"ecs_restart_instance",taskReferenceName:"reboot_host",type:"HTTP",description:"软重启生效补丁",inputParameters:{_actionId:"ecs.restart_instance",instanceId:"i-bp18a9z3j42m09a",forceRestart:!1}},{name:"send_operation_notification",taskReferenceName:"report_patch_result",type:"EVENT",description:"发送合规汇报",inputParameters:{_actionId:"notify.send_message",channel:"webhook_dingtalk",title:"【补丁更新成功】系统漏洞修复完成",content:"云主机 ${patch_safeguard_snap.output.instanceId} 补丁更新完成,主机已完成重启并恢复在线。"}}]},mockDataset:{scenarios:[{name:"补丁升级全流程演示",workflowInput:{},taskOutputs:{patch_safeguard_snap:{snapshotId:"s-bp1904",status:"ACCOMPLISHED"},apply_cve_patches:{exitCode:0,output:"3 security packages updated",status:"SUCCESS"},confirm_soft_reboot:{approved:!0,reviewer:"devops_lead@internal.cloud"},reboot_host:{status:"RUNNING"},report_patch_result:{sentStatus:"DELIVERED"}}}]}},{id:"tpl_ecs_night_idle_shutdown",version:"1.0.0",title:"非生产环境夜间定时关机降本",category:"cost",icon:"🌙",valueProposition:"工作日 21:00 自动停止闲置研发测试主机,次日晨自动开机,降低约 65% 计算资源账单。",description:"自动在夜间巡检开发测试集群,若无活跃计算任务,则下发优雅安全关机指令,并在协同群汇报当晚关机台数与预计节约的算力金额。",connectors:["cloud_host","dingtalk"],roi:{minutesSavedPerRun:20,typicalRunsPerWeek:5,popularityCount:3100},difficulty:"starter",variables:[{key:"instanceId",label:"测试环境主机 ID",type:"text",defaultValue:"i-bp18a9z3j42m09a",required:!0,bindings:["tasks[0].inputParameters.instanceId","tasks[1].inputParameters.instanceId"]},{key:"forceStop",label:"超时是否强制关机",type:"boolean",defaultValue:!1,bindings:["tasks[1].inputParameters.forceStop"]}],definition:{name:"ecs_night_idle_shutdown_flow",description:"测试环境夜间自动关机降本",version:1,tasks:[{name:"ecs_get_monitor_metrics",taskReferenceName:"check_idle_state",type:"HTTP",description:"核实主机是否处于闲置低负载",inputParameters:{_actionId:"ecs.get_monitor_metrics",instanceId:"i-bp18a9z3j42m09a",periodSeconds:300}},{name:"ecs_stop_instance",taskReferenceName:"shutdown_host",type:"HTTP",description:"执行优雅关机",inputParameters:{_actionId:"ecs.stop_instance",instanceId:"i-bp18a9z3j42m09a",forceStop:!1}},{name:"send_operation_notification",taskReferenceName:"notify_cost_saving",type:"EVENT",description:"发送夜间节能降本简报",inputParameters:{_actionId:"notify.send_message",channel:"webhook_dingtalk",title:"【夜间节能】测试主机已自动进入休眠",content:"测试主机 ${check_idle_state.output.instanceId} (CPU ${check_idle_state.output.cpuUsagePercent}%) 已于 21:00 完成关机,预计今夜节约 11 小时按量费用。"}}]},mockDataset:{scenarios:[{name:"闲置关机场景",workflowInput:{},taskOutputs:{check_idle_state:{instanceId:"i-bp18a9z3j42m09a",cpuUsagePercent:2.1,isOverloaded:!1},shutdown_host:{status:"STOPPED"},notify_cost_saving:{sentStatus:"DELIVERED"}}}]}},{id:"tpl_ecs_morning_boot",version:"1.0.0",title:"测试环境工作日早晨定时自动开机",category:"cost",icon:"🌅",valueProposition:"工作日 08:30 自动唤醒测试主机,自检网络并广播就绪通知,研发开工即可联调无需等待。",description:"与夜间关机模板形成完整的节能闭环,在工作日上班前 30 分钟定时批量启动主机,校验网络联通性后发送早报。",connectors:["cloud_host","dingtalk"],roi:{minutesSavedPerRun:15,typicalRunsPerWeek:5,popularityCount:2890},difficulty:"starter",variables:[{key:"instanceId",label:"测试环境主机 ID",type:"text",defaultValue:"i-bp18a9z3j42m09a",required:!0,bindings:["tasks[0].inputParameters.instanceId","tasks[2].inputParameters.instanceId"]}],definition:{name:"ecs_morning_boot_flow",description:"测试环境早间自动唤醒开机",version:1,tasks:[{name:"ecs_start_instance",taskReferenceName:"boot_host",type:"HTTP",description:"执行主机开机启动",inputParameters:{_actionId:"ecs.start_instance",instanceId:"i-bp18a9z3j42m09a"}},{name:"wait_boot_ready",taskReferenceName:"wait_boot",type:"WAIT",description:"等待操作系统内核引导就绪",inputParameters:{_actionId:"control.wait",duration:"10s"}},{name:"ecs_query_instance",taskReferenceName:"verify_network",type:"HTTP",description:"核实网络与运行状态",inputParameters:{_actionId:"ecs.query_instance",instanceId:"i-bp18a9z3j42m09a"}},{name:"send_operation_notification",taskReferenceName:"notify_team_ready",type:"EVENT",description:"向研发测试群发送环境就绪广播",inputParameters:{_actionId:"notify.send_message",channel:"webhook_dingtalk",title:"【环境就绪】测试云主机已唤醒开机",content:"测试主机 ${verify_network.output.instanceId} 已启动 (${verify_network.output.status}),内网IP: ${verify_network.output.privateIp},开发人员可正常开始联调。"}}]},mockDataset:{scenarios:[{name:"晨间开机唤醒演示",workflowInput:{},taskOutputs:{boot_host:{instanceId:"i-bp18a9z3j42m09a",currentStatus:"STARTING"},wait_boot:{waited:!0},verify_network:{instanceId:"i-bp18a9z3j42m09a",status:"RUNNING",privateIp:"172.16.0.42"},notify_team_ready:{sentStatus:"DELIVERED"}}}]}},{id:"tpl_ecs_disk_expansion",version:"1.0.0",title:"磁盘容量告警与在线自动扩容",category:"ops",icon:"💽",valueProposition:"磁盘利用率超 85% 自动快照并在线扩充云盘容量,免停机扩展文件系统,杜绝业务写爆宕机。",description:"自动对磁盘快满的主机执行保护性快照,随后免停机远程下发 growpart 与 resize2fs 脚本刷新空间,最后在运维群反馈扩容结果。",connectors:["cloud_host","dingtalk"],roi:{minutesSavedPerRun:30,typicalRunsPerWeek:6,popularityCount:1650},difficulty:"intermediate",variables:[{key:"instanceId",label:"目标主机 ID",type:"text",defaultValue:"i-bp18a9z3j42m09a",required:!0,bindings:["tasks[0].inputParameters.instanceId","tasks[1].inputParameters.instanceId","tasks[2].inputParameters.instanceId"]}],definition:{name:"ecs_disk_expansion_flow",description:"云主机磁盘在线自动扩容与自愈",version:1,tasks:[{name:"ecs_get_monitor_metrics",taskReferenceName:"check_disk_usage",type:"HTTP",description:"检测磁盘利用率",inputParameters:{_actionId:"ecs.get_monitor_metrics",instanceId:"i-bp18a9z3j42m09a",periodSeconds:60}},{name:"ecs_create_snapshot",taskReferenceName:"pre_expand_snap",type:"HTTP",description:"扩容前创建磁盘保护快照",inputParameters:{_actionId:"ecs.create_snapshot",instanceId:"i-bp18a9z3j42m09a",snapshotName:"pre-disk-expansion",retentionDays:7}},{name:"ecs_run_command",taskReferenceName:"grow_filesystem",type:"HTTP",description:"在线扩展分区与文件系统",inputParameters:{_actionId:"ecs.run_command",instanceId:"i-bp18a9z3j42m09a",commandContent:"growpart /dev/vda 1 && resize2fs /dev/vda1 && df -h",commandType:"RunShellScript",timeoutSeconds:60}},{name:"send_operation_notification",taskReferenceName:"notify_expand_done",type:"EVENT",description:"发送扩容完成通知",inputParameters:{_actionId:"notify.send_message",channel:"webhook_dingtalk",title:"【自愈成功】云盘空间已在线扩容",content:"云主机 ${check_disk_usage.output.instanceId} 磁盘扩容完毕,当前文件系统状态正常。"}}]},mockDataset:{scenarios:[{name:"磁盘扩容自愈演示",workflowInput:{},taskOutputs:{check_disk_usage:{instanceId:"i-bp18a9z3j42m09a",diskUsagePercent:89.2},pre_expand_snap:{snapshotId:"s-bp1449",status:"ACCOMPLISHED"},grow_filesystem:{exitCode:0,output:"CHANGED: partition=1, size expanded to 200GB"},notify_expand_done:{sentStatus:"DELIVERED"}}}]}},{id:"tpl_ecs_emergency_isolation",version:"1.0.0",title:"突发入侵应急响应与快照取证",category:"security",icon:"🚨",valueProposition:"发生高危网络入侵威胁时,秒级冻结证据快照并强制关机隔离,将安全暴露面降至最低。",description:"面对勒索病毒、WebShell 或异常爆破入侵时,自动对受害主机创建取证快照保存现场内存与日志,随后强制关机切断危害,并向 SecOps 安全小组发送紧急红色通知。",connectors:["cloud_host","dingtalk"],roi:{minutesSavedPerRun:60,typicalRunsPerWeek:1,popularityCount:890},difficulty:"advanced",variables:[{key:"instanceId",label:"受害云主机 ID",type:"text",defaultValue:"i-bp18a9z3j42m09a",required:!0,bindings:["tasks[0].inputParameters.instanceId","tasks[1].inputParameters.instanceId"]}],definition:{name:"ecs_emergency_isolation_flow",description:"安全事件突发应急取证与快速隔离",version:1,tasks:[{name:"ecs_create_snapshot",taskReferenceName:"forensics_snapshot",type:"HTTP",description:"紧急创建现场取证快照",inputParameters:{_actionId:"ecs.create_snapshot",instanceId:"i-bp18a9z3j42m09a",snapshotName:"security-forensics-evidence",retentionDays:90}},{name:"ecs_stop_instance",taskReferenceName:"isolate_victim_node",type:"HTTP",description:"强制切断关机隔离",inputParameters:{_actionId:"ecs.stop_instance",instanceId:"i-bp18a9z3j42m09a",forceStop:!0}},{name:"send_operation_notification",taskReferenceName:"alert_secops_incident",type:"EVENT",description:"发送安全应急处置最高级别预警",inputParameters:{_actionId:"notify.send_message",channel:"webhook_dingtalk",title:"🚨【紧急安全通报】入侵主机已隔离取证",content:"受害主机 ${forensics_snapshot.output.instanceId} 已完成现场留证快照 (${forensics_snapshot.output.snapshotId}) 并被强制关机隔离,请 SecOps 立即启动应急调查。"}}]},mockDataset:{scenarios:[{name:"应急阻断演示",workflowInput:{},taskOutputs:{forensics_snapshot:{snapshotId:"s-forensics-911",status:"ACCOMPLISHED"},isolate_victim_node:{status:"STOPPED",forceStop:!0},alert_secops_incident:{sentStatus:"DELIVERED"}}}]}}];class tg{templates=new Map;constructor(t=[]){this.registerAll(t)}register(t){this.templates.set(t.id,t)}registerAll(t){for(const r of t)this.register(r)}getAllTemplates(){return Array.from(this.templates.values())}getTemplateById(t){return this.templates.get(t)}search(t,r="all"){let n=this.getAllTemplates();if(r&&r!=="all"&&(n=n.filter(s=>s.category===r)),t&&t.trim()){const s=t.toLowerCase().trim();n=n.filter(o=>o.title.toLowerCase().includes(s)||o.valueProposition.toLowerCase().includes(s)||o.description.toLowerCase().includes(s))}return n}}const Tl=new tg(eg),rg=({isOpen:e,instance:t,onClose:r,onPublished:n})=>{const s=N.useMemo(()=>Qm({instance:t,title:`${t.workflowName||"云平台工作流"} (实战提炼)`,category:"ops",valueProposition:`基于实例 ${t.workflowId} 的成功运行萃取,已通过自动化脱敏与参数提取。`,author:"系统管理员"}),[t]),[o,i]=N.useState(s.template.title),[l,c]=N.useState(s.template.category),[u,d]=N.useState(s.template.valueProposition),[p,h]=N.useState(s.template.roi.minutesSavedPerRun),[f,m]=N.useState(()=>{const S={};for(const j of s.prunedTasks)S[j.taskReferenceName]=j.selected;return S}),[g,y]=N.useState(!1),[b,x]=N.useState(!1);if(!e||typeof document>"u")return null;const v=S=>{m(j=>({...j,[S]:!j[S]}))},k=()=>{y(!0);try{const S={...s.template,title:o,category:l,valueProposition:u,roi:{...s.template.roi,minutesSavedPerRun:p}};Tl.register(S),n&&n(S),x(!0),setTimeout(()=>{r()},1500)}catch(S){alert(`发布模板出错: ${S.message}`)}finally{y(!1)}},_=s.findings;return Ye.createPortal(a.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0, 0, 0, 0.72)",backdropFilter:"blur(6px)",zIndex:2e3,display:"flex",alignItems:"center",justifyContent:"center",padding:24,fontFamily:"inherit"},onClick:r,children:a.jsxs("div",{onClick:S=>S.stopPropagation(),style:{width:980,maxWidth:"calc(100vw - 48px)",height:720,maxHeight:"calc(100vh - 48px)",background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",borderRadius:14,boxShadow:"0 28px 72px rgba(0, 0, 0, 0.5)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[a.jsxs("div",{style:{padding:"14px 20px",borderBottom:"1px solid var(--border-primary, rgba(255, 255, 255, 0.1))",display:"flex",alignItems:"center",justifyContent:"space-between",background:"var(--bg-primary, #0f172a)"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[a.jsx("span",{style:{fontSize:22},children:"🛠️"}),a.jsxs("div",{children:[a.jsx("div",{style:{fontWeight:600,fontSize:15,color:"var(--text-primary, #f8fafc)"},children:"生产工作流一键提炼与脱敏工作台 (管理员)"}),a.jsxs("div",{style:{fontSize:11,color:"var(--text-muted, #94a3b8)"},children:["基于执行实例 #",t.workflowId," 自动识别敏感信息并生成高保真模板"]})]})]}),a.jsx("button",{onClick:r,style:{background:"none",border:"none",color:"var(--text-muted, #94a3b8)",cursor:"pointer",fontSize:16},children:"✕"})]}),a.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"18px 20px",display:"grid",gridTemplateColumns:"1fr 1.2fr 1fr",gap:16},children:[a.jsxs("div",{style:{background:"var(--bg-primary, #0f172a)",borderRadius:10,border:"1px solid var(--border-primary, rgba(255,255,255,0.1))",padding:14,display:"flex",flexDirection:"column",gap:10},children:[a.jsx("div",{style:{fontWeight:600,fontSize:13,color:"var(--text-primary, #f8fafc)"},children:"1. 骨架拓扑剪枝建议"}),a.jsx("div",{style:{fontSize:11,color:"var(--text-muted, #94a3b8)"},children:"自动识别并建议剔除特定的临时调试、重试与低频孤立分支:"}),a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8,marginTop:4},children:s.template.definition.tasks?.map((S,j)=>{const R=!!f[S.taskReferenceName];return a.jsxs("div",{style:{padding:"8px 10px",borderRadius:6,background:R?"rgba(239, 68, 68, 0.08)":"rgba(255,255,255,0.03)",border:`1px solid ${R?"rgba(239, 68, 68, 0.25)":"rgba(255,255,255,0.08)"}`,display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:12,opacity:R?.6:1},children:[a.jsxs("div",{children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[a.jsxs("span",{style:{color:"var(--color-accent, #3b82f6)",fontWeight:600},children:["#",j+1]}),a.jsx("span",{style:{color:R?"#fca5a5":"var(--text-primary, #f8fafc)"},children:S.description||S.name})]}),a.jsx("div",{style:{fontSize:10,color:"var(--text-muted, #94a3b8)",fontFamily:"monospace"},children:S.taskReferenceName})]}),a.jsx("button",{onClick:()=>v(S.taskReferenceName),style:{padding:"2px 6px",borderRadius:4,background:R?"rgba(239, 68, 68, 0.2)":"rgba(255,255,255,0.08)",border:"none",color:R?"#f87171":"var(--text-muted, #94a3b8)",fontSize:11,cursor:"pointer"},children:R?"已剪枝剔除":"保留"})]},S.taskReferenceName)})})]}),a.jsxs("div",{style:{background:"var(--bg-primary, #0f172a)",borderRadius:10,border:"1px solid var(--border-primary, rgba(255,255,255,0.1))",padding:14,display:"flex",flexDirection:"column",gap:10},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[a.jsx("div",{style:{fontWeight:600,fontSize:13,color:"var(--text-primary, #f8fafc)"},children:"2. 敏感项扫描与变量提取"}),a.jsxs("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:4,background:"rgba(16, 185, 129, 0.15)",color:"#34d399",fontWeight:600},children:["已扫描 ",_.length," 项"]})]}),a.jsx("div",{style:{fontSize:11,color:"var(--text-muted, #94a3b8)"},children:"命中规则的生产密钥已强制置空,真实 IP/ID 推荐转为填空变量:"}),a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8,marginTop:4},children:_.length===0?a.jsx("div",{style:{padding:"24px 12px",textAlign:"center",color:"var(--text-muted, #94a3b8)",fontSize:12},children:"✓ 未发现任何硬编码的高危凭据或敏感信息"}):_.map(S=>a.jsxs("div",{style:{padding:"8px 10px",borderRadius:6,background:"rgba(255,255,255,0.03)",border:"1px solid var(--border-primary, rgba(255,255,255,0.08))",display:"flex",flexDirection:"column",gap:4,fontSize:11},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[a.jsx("span",{style:{padding:"1px 5px",borderRadius:3,fontSize:10,fontWeight:600,background:S.kind==="credential"?"rgba(239, 68, 68, 0.2)":S.kind==="network"?"rgba(59, 130, 246, 0.2)":"rgba(245, 158, 11, 0.2)",color:S.kind==="credential"?"#f87171":S.kind==="network"?"#60a5fa":"#fbbf24"},children:S.kind==="credential"?"🔑 密钥凭据":S.kind==="network"?"🌐 内网地址":S.kind==="pii"?"📱 个人隐私":"🖥️ 云资源ID"}),a.jsxs("span",{style:{color:"var(--text-muted, #94a3b8)"},children:["建议处理: ",S.action==="variable"?"提取为向导变量":"自动掩码脱敏"]})]}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,marginTop:2},children:[a.jsx("span",{style:{color:"var(--text-secondary, #b0bec5)"},children:"字段:"}),a.jsx("span",{style:{color:"var(--text-primary, #f8fafc)",fontFamily:"monospace"},children:S.keyName})]}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[a.jsx("span",{style:{color:"var(--text-secondary, #b0bec5)"},children:"脱敏后:"}),a.jsx("span",{style:{color:"#34d399",fontFamily:"monospace"},children:S.maskedValue?String(S.maskedValue):"(强制置空并由用户填入)"})]})]},S.id))})]}),a.jsxs("div",{style:{background:"var(--bg-primary, #0f172a)",borderRadius:10,border:"1px solid var(--border-primary, rgba(255,255,255,0.1))",padding:14,display:"flex",flexDirection:"column",gap:12},children:[a.jsx("div",{style:{fontWeight:600,fontSize:13,color:"var(--text-primary, #f8fafc)"},children:"3. 模板货架信息配置"}),a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[a.jsx("label",{style:{fontSize:12,color:"var(--text-secondary, #b0bec5)"},children:"模板中文标题"}),a.jsx("input",{type:"text",value:o,onChange:S=>i(S.target.value),style:{padding:"6px 10px",borderRadius:6,background:"var(--bg-secondary, #1e293b)",border:"1px solid var(--border-secondary, rgba(255,255,255,0.2))",color:"var(--text-primary, #f8fafc)",fontSize:12,outline:"none"}})]}),a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[a.jsx("label",{style:{fontSize:12,color:"var(--text-secondary, #b0bec5)"},children:"业务分类"}),a.jsxs("select",{value:l,onChange:S=>c(S.target.value),style:{padding:"6px 10px",borderRadius:6,background:"var(--bg-secondary, #1e293b)",border:"1px solid var(--border-secondary, rgba(255,255,255,0.2))",color:"var(--text-primary, #f8fafc)",fontSize:12,outline:"none"},children:[a.jsx("option",{value:"compute",children:"🖥️ 交付与计算"}),a.jsx("option",{value:"security",children:"💾 安全与容灾"}),a.jsx("option",{value:"ops",children:"⚡ 运维与自愈"}),a.jsx("option",{value:"cost",children:"🌙 节能与降本"})]})]}),a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[a.jsx("label",{style:{fontSize:12,color:"var(--text-secondary, #b0bec5)"},children:"一句话业务价值"}),a.jsx("textarea",{rows:2,value:u,onChange:S=>d(S.target.value),style:{padding:"6px 10px",borderRadius:6,background:"var(--bg-secondary, #1e293b)",border:"1px solid var(--border-secondary, rgba(255,255,255,0.2))",color:"var(--text-primary, #f8fafc)",fontSize:12,outline:"none",resize:"none"}})]}),a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[a.jsx("label",{style:{fontSize:12,color:"var(--text-secondary, #b0bec5)"},children:"单次预估节省 (分钟)"}),a.jsx("input",{type:"number",value:p,onChange:S=>h(Number(S.target.value)),style:{padding:"6px 10px",borderRadius:6,background:"var(--bg-secondary, #1e293b)",border:"1px solid var(--border-secondary, rgba(255,255,255,0.2))",color:"var(--text-primary, #f8fafc)",fontSize:12,outline:"none"}})]}),a.jsx("div",{style:{marginTop:6,padding:"8px 10px",borderRadius:6,background:"rgba(16, 185, 129, 0.08)",border:"1px solid rgba(16, 185, 129, 0.2)",fontSize:11,color:"#34d399"},children:"✓ 已自动从该运行实例生成无害化保真沙盒数据集,上架后支持其他用户零授权一键试跑。"})]})]}),a.jsxs("div",{style:{padding:"12px 20px",borderTop:"1px solid var(--border-primary, rgba(255, 255, 255, 0.1))",background:"var(--bg-primary, #0f172a)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[a.jsxs("div",{style:{fontSize:12,color:"var(--text-muted, #94a3b8)"},children:["审计报告: 扫描 ",s.report.totalTasksScanned," 个任务 · 脱敏凭证"," ",s.report.credentialsRedactedCount," 项 · 生成模板变量"," ",s.report.variablesCreatedCount," 项"]}),a.jsxs("div",{style:{display:"flex",gap:10,alignItems:"center"},children:[b&&a.jsx("span",{style:{fontSize:12,color:"#34d399",fontWeight:600},children:"✓ 已成功上架到模板中心!"}),a.jsx("button",{onClick:r,style:{padding:"6px 14px",borderRadius:6,background:"transparent",border:"1px solid var(--border-secondary, rgba(255,255,255,0.2))",color:"var(--text-secondary, #b0bec5)",fontSize:12,cursor:"pointer"},children:"取消"}),a.jsxs("button",{onClick:k,disabled:g||b,style:{padding:"6px 18px",borderRadius:6,background:"var(--color-accent, #3b82f6)",color:"#fff",border:"none",fontSize:12,fontWeight:600,cursor:g||b?"not-allowed":"pointer",display:"inline-flex",alignItems:"center",gap:6},children:[a.jsx("span",{children:"🚀"}),a.jsx("span",{children:g?"发布中...":"注册并发布到模板中心"})]})]})]})]})}),document.body)},ng={COMPLETED:"完成",COMPLETED_WITH_ERRORS:"完成(含错误)",FAILED:"失败",FAILED_WITH_TERMINAL_ERROR:"终态失败",IN_PROGRESS:"执行中",SCHEDULED:"等待中",TIMED_OUT:"超时",SKIPPED:"跳过",CANCELED:"已取消"},ag={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)"},c0=()=>{const[e,t]=N.useState(!1),{executionData:r,workflowInstance:n,showAnalysisPanel:s,setShowAnalysisPanel:o,switchToEditAndFocusParam:i,selectTaskAction:l,taskMap:c}=le(),u=N.useMemo(()=>r?o0(r,n??null):null,[r,n]);if(!s||!u)return null;const{totalTasks:d,completedTasks:p,failedTasks:h,skippedTasks:f,totalDurationMs:m,steps:g}=u,y=d>0?Math.round(p/d*100):0,b=n?.status,x=b?ag[b]??"var(--text-secondary)":"var(--text-secondary)";return a.jsxs("div",{className:"esp-panel glass-panel",children:[a.jsxs("div",{className:"esp-header",children:[a.jsxs("div",{className:"esp-title",children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[a.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"2"}),a.jsx("path",{d:"M5 8h6M5 5h3M5 11h4"})]}),"执行分析"]}),b&&a.jsx("span",{className:"esp-wf-status",style:{color:x},children:ng[b]??b}),n&&a.jsxs("button",{onClick:()=>t(!0),style:{padding:"3px 8px",borderRadius:5,background:"color-mix(in srgb, var(--color-brand-blue) 18%, transparent)",border:"1px solid color-mix(in srgb, var(--color-brand-blue) 40%, transparent)",color:"var(--color-brand-blue)",fontSize:11,cursor:"pointer",fontWeight:600,display:"inline-flex",alignItems:"center",gap:4,marginLeft:"auto",marginRight:6},title:"将本次执行实例脱敏并提炼为公共标准化模板",children:[a.jsx("span",{children:"🛠️"}),a.jsx("span",{children:"提取为模板"})]}),a.jsx("button",{className:"esp-close",onClick:()=>o(!1),children:"✕"})]}),a.jsxs("div",{className:"esp-content",children:[a.jsxs("div",{className:"esp-overview",children:[a.jsxs("div",{className:"esp-card",children:[a.jsx("span",{className:"esp-card-value",children:d}),a.jsx("span",{className:"esp-card-label",children:"总任务数"})]}),a.jsxs("div",{className:"esp-card esp-card-success",children:[a.jsx("span",{className:"esp-card-value",style:{color:"var(--status-completed)"},children:p}),a.jsx("span",{className:"esp-card-label",children:"已完成"})]}),a.jsxs("div",{className:"esp-card esp-card-failed",children:[a.jsx("span",{className:"esp-card-value",style:{color:h>0?"var(--status-failed)":"var(--text-secondary)"},children:h}),a.jsx("span",{className:"esp-card-label",children:"失败"})]}),a.jsxs("div",{className:"esp-card",children:[a.jsx("span",{className:"esp-card-value",children:Vm(m)}),a.jsx("span",{className:"esp-card-label",children:"总耗时"})]})]}),a.jsx("div",{className:"esp-progress-bar",children:a.jsx("div",{className:"esp-progress-fill",style:{width:`${y}%`,background:h>0?"var(--status-failed)":"var(--status-completed)"},title:`成功率 ${y}%`})}),a.jsxs("div",{className:"esp-progress-label",children:[y,"% 成功率",f>0?`,${f} 个任务已跳过`:""]}),g.filter(v=>v.diagnostics.length>0).map(v=>a.jsxs("div",{className:"esp-diagnostic-card",children:[a.jsxs("div",{className:"esp-diag-task-ref",children:[a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",style:{color:"var(--status-failed)",flexShrink:0},children:a.jsx("path",{d:"M8 1a7 7 0 100 14A7 7 0 008 1zm-.75 4a.75.75 0 011.5 0v3.5a.75.75 0 01-1.5 0V5zm.75 7a1 1 0 110-2 1 1 0 010 2z"})}),v.taskRef]}),v.diagnostics.map((k,_)=>a.jsxs("div",{className:"esp-diag-item",style:{borderLeftColor:l0(k.category)},children:[a.jsxs("div",{className:"esp-diag-title",children:[a.jsx("span",{children:i0(k.category)}),k.title]}),a.jsx("p",{className:"esp-diag-explanation",children:k.explanation}),a.jsxs("button",{className:"esp-fix-btn",onClick:()=>i(v.taskRef,k.suggestEditParam),children:["去修复",a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:a.jsx("path",{d:"M5 8h6M9 5l3 3-3 3"})})]})]},_))]},v.taskRef)),a.jsx("div",{className:"esp-section-label",children:"步骤执行时序"}),a.jsxs("div",{className:"esp-steps-table",children:[a.jsxs("div",{className:"esp-steps-header",children:[a.jsx("span",{children:"#"}),a.jsx("span",{children:"任务引用名"}),a.jsx("span",{children:"状态"}),a.jsx("span",{children:"耗时"}),a.jsx("span",{children:"重试"})]}),g.map((v,k)=>{const _=ag[v.status]??"var(--text-secondary)",S=c[v.taskRef];return a.jsxs("button",{className:"esp-step-row",onClick:()=>S&&l(S,!0),title:v.reasonForIncompletion||v.taskRef,children:[a.jsx("span",{className:"esp-step-idx",children:k+1}),a.jsx("span",{className:"esp-step-ref",children:v.taskRef}),a.jsxs("span",{className:"esp-step-status",style:{color:_},children:[a.jsx("span",{className:"esp-status-dot",style:{background:_}}),ng[v.status]??v.status]}),a.jsx("span",{className:"esp-step-duration",children:Vm(v.durationMs)}),a.jsx("span",{className:"esp-step-retry",style:{color:v.retryCount>0?"var(--status-failed)":"var(--text-secondary)"},children:v.retryCount>0?`${v.retryCount}次`:"-"})]},v.taskRef)})]})]}),e&&n&&a.jsx(rg,{isOpen:e,instance:n,onClose:()=>t(!1),onPublished:()=>{console.log("[ExecutionSummaryPanel] 模板已成功发布到场景中心")}})]})},sg=[{id:"ecs.create_instance",name:"创建云主机",category:"compute",icon:"🖥️",description:"在指定可用区根据镜像与规格创建并初始化一台新的云主机实例",connector:"cloud_host",riskLevel:"safe",fields:[{key:"regionId",label:"所属地域",type:"select",required:!0,defaultValue:"cn-hangzhou",options:[{label:"华东 1 (杭州)",value:"cn-hangzhou"},{label:"华北 2 (北京)",value:"cn-beijing"},{label:"华南 1 (深圳)",value:"cn-shenzhen"},{label:"亚太东南 1 (新加坡)",value:"ap-southeast-1"}],acceptsPills:!0},{key:"instanceType",label:"计算规格",type:"select",required:!0,defaultValue:"ecs.c7.xlarge",options:[{label:"通用型 2C4G (ecs.g7.large)",value:"ecs.g7.large"},{label:"计算型 4C8G (ecs.c7.xlarge)",value:"ecs.c7.xlarge"},{label:"内存型 4C16G (ecs.r7.xlarge)",value:"ecs.r7.xlarge"},{label:"高性能 8C32G (ecs.c7.2xlarge)",value:"ecs.c7.2xlarge"}],acceptsPills:!0},{key:"imageId",label:"操作系统镜像",type:"select",required:!0,defaultValue:"image-alilinux-3",options:[{label:"Alibaba Cloud Linux 3.2104 LTS 64位",value:"image-alilinux-3"},{label:"Ubuntu 22.04 LTS 64位",value:"image-ubuntu-22"},{label:"CentOS 7.9 64位",value:"image-centos-7"},{label:"Debian 12 64位",value:"image-debian-12"}],acceptsPills:!0},{key:"instanceName",label:"主机名称",type:"text",placeholder:"例如: web-prod-01",required:!0,defaultValue:"app-server-node",acceptsPills:!0},{key:"systemDiskSize",label:"系统盘容量 (GB)",type:"number",defaultValue:100,required:!0,acceptsPills:!0}],outputs:[{key:"instanceId",label:"实例ID",type:"string",example:"i-bp18a9z3j42m09a"},{key:"instanceName",label:"主机名称",type:"string",example:"app-server-node"},{key:"privateIp",label:"内网IP",type:"string",example:"172.16.0.42"},{key:"status",label:"实例状态",type:"string",example:"RUNNING"},{key:"createdAt",label:"创建时间",type:"string",example:"2026-10-20T14:00:00Z"}],compile:(e,t)=>({name:"ecs_create_instance",taskReferenceName:t.taskReferenceName,type:"HTTP",description:`创建云主机: ${e.instanceName||t.taskReferenceName}`,inputParameters:{_actionId:"ecs.create_instance",actionName:"创建云主机",regionId:e.regionId??"cn-hangzhou",instanceType:e.instanceType??"ecs.c7.xlarge",imageId:e.imageId??"image-alilinux-3",instanceName:e.instanceName??"app-node",systemDiskSize:Number(e.systemDiskSize??100),http_request:{uri:"https://ecs.internal.cloud/api/v2/instances",method:"POST",body:{regionId:e.regionId,instanceType:e.instanceType,imageId:e.imageId,instanceName:e.instanceName,systemDiskSize:e.systemDiskSize}}}}),decompile:e=>{if(e.inputParameters?._actionId==="ecs.create_instance"){const t=e.inputParameters;return{regionId:t.regionId??"cn-hangzhou",instanceType:t.instanceType??"ecs.c7.xlarge",imageId:t.imageId??"image-alilinux-3",instanceName:t.instanceName??e.taskReferenceName,systemDiskSize:t.systemDiskSize??100}}return null},mockOutput:e=>({instanceId:`i-bp1${Math.random().toString(36).substring(2,9)}`,instanceName:e.instanceName||"app-server-node",privateIp:"172.16.0."+Math.floor(10+Math.random()*200),status:"RUNNING",regionId:e.regionId||"cn-hangzhou",instanceType:e.instanceType||"ecs.c7.xlarge",createdAt:new Date().toISOString()})},{id:"ecs.query_instance",name:"查询云主机详情",category:"compute",icon:"🔍",description:"根据主机实例 ID 查询其实时运行状态、配置规格与网络 IP",connector:"cloud_host",riskLevel:"safe",fields:[{key:"instanceId",label:"云主机实例 ID",type:"text",placeholder:"例如: i-bp18a9z3j42m09a 或绑定上游胶囊",required:!0,acceptsPills:!0}],outputs:[{key:"instanceId",label:"实例ID",type:"string",example:"i-bp18a9z3j42m09a"},{key:"status",label:"运行状态",type:"string",example:"RUNNING"},{key:"cpu",label:"CPU核心数",type:"number",example:4},{key:"memoryGb",label:"内存(GB)",type:"number",example:8},{key:"privateIp",label:"内网IP",type:"string",example:"172.16.0.42"},{key:"publicIp",label:"公网IP",type:"string",example:"47.98.112.23"},{key:"osName",label:"操作系统",type:"string",example:"Alibaba Cloud Linux 3"}],compile:(e,t)=>({name:"ecs_query_instance",taskReferenceName:t.taskReferenceName,type:"HTTP",description:`查询云主机状态: ${e.instanceId||""}`,inputParameters:{_actionId:"ecs.query_instance",actionName:"查询云主机详情",instanceId:e.instanceId,http_request:{uri:`https://ecs.internal.cloud/api/v2/instances/${e.instanceId||""}`,method:"GET"}}}),decompile:e=>e.inputParameters?._actionId==="ecs.query_instance"?{instanceId:e.inputParameters.instanceId??""}:null,mockOutput:e=>({instanceId:e.instanceId||"i-bp18a9z3j42m09a",status:"RUNNING",cpu:4,memoryGb:8,privateIp:"172.16.0.42",publicIp:"47.98.112.23",osName:"Alibaba Cloud Linux 3.2104",uptimeHours:360})},{id:"ecs.start_instance",name:"启动云主机",category:"compute",icon:"▶️",description:"将处于关机/停止状态的云主机实例开机启动",connector:"cloud_host",riskLevel:"safe",fields:[{key:"instanceId",label:"云主机实例 ID",type:"text",placeholder:"选择或填入要开机的主机 ID",required:!0,acceptsPills:!0}],outputs:[{key:"instanceId",label:"实例ID",type:"string",example:"i-bp18a9z3j42m09a"},{key:"previousStatus",label:"变更前状态",type:"string",example:"STOPPED"},{key:"currentStatus",label:"当前状态",type:"string",example:"STARTING"},{key:"startedAt",label:"开机时间",type:"string",example:"2026-10-20T14:15:00Z"}],compile:(e,t)=>({name:"ecs_start_instance",taskReferenceName:t.taskReferenceName,type:"HTTP",description:`开机启动云主机: ${e.instanceId||""}`,inputParameters:{_actionId:"ecs.start_instance",actionName:"启动云主机",instanceId:e.instanceId,http_request:{uri:`https://ecs.internal.cloud/api/v2/instances/${e.instanceId||""}/start`,method:"POST"}}}),decompile:e=>e.inputParameters?._actionId==="ecs.start_instance"?{instanceId:e.inputParameters.instanceId??""}:null,mockOutput:e=>({instanceId:e.instanceId||"i-bp18a9z3j42m09a",previousStatus:"STOPPED",currentStatus:"RUNNING",startedAt:new Date().toISOString()})},{id:"ecs.stop_instance",name:"停止云主机",category:"compute",icon:"⏹️",description:"安全关机或强制关机运行中的云主机实例",connector:"cloud_host",riskLevel:"sensitive",fields:[{key:"instanceId",label:"云主机实例 ID",type:"text",placeholder:"选择或填入要关机的主机 ID",required:!0,acceptsPills:!0},{key:"forceStop",label:"是否强制关机",type:"boolean",defaultValue:!1,help:"默认安全优雅关机,开启后若超时将直接切断电源"}],outputs:[{key:"instanceId",label:"实例ID",type:"string",example:"i-bp18a9z3j42m09a"},{key:"status",label:"当前状态",type:"string",example:"STOPPED"},{key:"stoppedAt",label:"关机完成时间",type:"string",example:"2026-10-20T14:20:00Z"}],compile:(e,t)=>({name:"ecs_stop_instance",taskReferenceName:t.taskReferenceName,type:"HTTP",description:`停止云主机: ${e.instanceId||""}`,inputParameters:{_actionId:"ecs.stop_instance",actionName:"停止云主机",instanceId:e.instanceId,forceStop:!!e.forceStop,http_request:{uri:`https://ecs.internal.cloud/api/v2/instances/${e.instanceId||""}/stop`,method:"POST",body:{forceStop:e.forceStop}}}}),decompile:e=>e.inputParameters?._actionId==="ecs.stop_instance"?{instanceId:e.inputParameters.instanceId??"",forceStop:!!e.inputParameters.forceStop}:null,mockOutput:e=>({instanceId:e.instanceId||"i-bp18a9z3j42m09a",status:"STOPPED",forceStop:!!e.forceStop,stoppedAt:new Date().toISOString()})},{id:"ecs.restart_instance",name:"重启云主机",category:"compute",icon:"🔄",description:"重新启动运行中的云主机(支持软重启与强制硬重启)",connector:"cloud_host",riskLevel:"sensitive",fields:[{key:"instanceId",label:"云主机实例 ID",type:"text",placeholder:"例如: i-bp18a9z3j42m09a",required:!0,acceptsPills:!0},{key:"forceRestart",label:"强制重启 (硬重启)",type:"boolean",defaultValue:!1}],outputs:[{key:"instanceId",label:"实例ID",type:"string",example:"i-bp18a9z3j42m09a"},{key:"status",label:"状态",type:"string",example:"REBOOTING"},{key:"restartedAt",label:"重启时间",type:"string",example:"2026-10-20T14:22:00Z"}],compile:(e,t)=>({name:"ecs_restart_instance",taskReferenceName:t.taskReferenceName,type:"HTTP",description:`重启云主机: ${e.instanceId||""}`,inputParameters:{_actionId:"ecs.restart_instance",actionName:"重启云主机",instanceId:e.instanceId,forceRestart:!!e.forceRestart}}),decompile:e=>e.inputParameters?._actionId==="ecs.restart_instance"?{instanceId:e.inputParameters.instanceId??"",forceRestart:!!e.inputParameters.forceRestart}:null,mockOutput:e=>({instanceId:e.instanceId||"i-bp18a9z3j42m09a",status:"RUNNING",restartedAt:new Date().toISOString()})},{id:"ecs.modify_spec",name:"变更实例规格 (升降配)",category:"compute",icon:"⚡",description:"在线或离线升级/降低云主机 CPU 与内存硬件配置",connector:"cloud_host",riskLevel:"sensitive",fields:[{key:"instanceId",label:"云主机实例 ID",type:"text",required:!0,acceptsPills:!0},{key:"targetSpec",label:"目标规格配置",type:"select",required:!0,defaultValue:"ecs.c7.2xlarge",options:[{label:"提升至 计算型 8C16G (ecs.c7.2xlarge)",value:"ecs.c7.2xlarge"},{label:"提升至 内存型 8C32G (ecs.r7.2xlarge)",value:"ecs.r7.2xlarge"},{label:"降低至 通用型 2C4G (ecs.g7.large)",value:"ecs.g7.large"}],acceptsPills:!0}],outputs:[{key:"instanceId",label:"实例ID",type:"string",example:"i-bp18a9z3j42m09a"},{key:"oldSpec",label:"变更前规格",type:"string",example:"ecs.c7.xlarge"},{key:"newSpec",label:"新规格",type:"string",example:"ecs.c7.2xlarge"},{key:"status",label:"变配状态",type:"string",example:"SUCCESS"}],compile:(e,t)=>({name:"ecs_modify_spec",taskReferenceName:t.taskReferenceName,type:"HTTP",description:`云主机变配为 ${e.targetSpec||""}`,inputParameters:{_actionId:"ecs.modify_spec",actionName:"变更实例规格",instanceId:e.instanceId,targetSpec:e.targetSpec}}),decompile:e=>e.inputParameters?._actionId==="ecs.modify_spec"?{instanceId:e.inputParameters.instanceId??"",targetSpec:e.inputParameters.targetSpec??"ecs.c7.2xlarge"}:null,mockOutput:e=>({instanceId:e.instanceId||"i-bp18a9z3j42m09a",oldSpec:"ecs.c7.xlarge",newSpec:e.targetSpec||"ecs.c7.2xlarge",status:"SUCCESS",effectiveImmediately:!0})},{id:"ecs.create_snapshot",name:"创建云盘快照",category:"storage",icon:"💾",description:"为云主机的系统盘或数据盘创建实时快照,用于容灾备份或回滚",connector:"cloud_host",riskLevel:"safe",fields:[{key:"instanceId",label:"云主机实例 ID",type:"text",required:!0,acceptsPills:!0},{key:"snapshotName",label:"快照名称/备注",type:"text",defaultValue:"backup-auto-snapshot",acceptsPills:!0},{key:"retentionDays",label:"自动保留天数",type:"number",defaultValue:7,help:"过期后自动清理释放,0 为永久保留"}],outputs:[{key:"snapshotId",label:"快照ID",type:"string",example:"s-bp14209938"},{key:"snapshotName",label:"快照名称",type:"string",example:"backup-auto-snapshot"},{key:"progress",label:"创建进度",type:"string",example:"100%"},{key:"status",label:"状态",type:"string",example:"ACCOMPLISHED"}],compile:(e,t)=>({name:"ecs_create_snapshot",taskReferenceName:t.taskReferenceName,type:"HTTP",description:`创建快照: ${e.snapshotName||t.taskReferenceName}`,inputParameters:{_actionId:"ecs.create_snapshot",actionName:"创建云盘快照",instanceId:e.instanceId,snapshotName:e.snapshotName,retentionDays:Number(e.retentionDays??7)}}),decompile:e=>e.inputParameters?._actionId==="ecs.create_snapshot"?{instanceId:e.inputParameters.instanceId??"",snapshotName:e.inputParameters.snapshotName??"backup-auto-snapshot",retentionDays:e.inputParameters.retentionDays??7}:null,mockOutput:e=>({snapshotId:`s-bp1${Math.random().toString(36).substring(2,8)}`,snapshotName:e.snapshotName||"backup-auto-snapshot",progress:"100%",status:"ACCOMPLISHED",sizeGb:100})},{id:"ecs.run_command",name:"执行远程运维脚本",category:"compute",icon:"💻",description:"免登录直接在云主机内部运行 Shell/Python 脚本并捕获返回日志",connector:"cloud_host",riskLevel:"sensitive",fields:[{key:"instanceId",label:"云主机实例 ID",type:"text",required:!0,acceptsPills:!0},{key:"commandType",label:"脚本语言",type:"select",defaultValue:"RunShellScript",options:[{label:"Shell 脚本 (Linux)",value:"RunShellScript"},{label:"Python 脚本",value:"RunPythonScript"}]},{key:"commandContent",label:"执行脚本命令",type:"textarea",placeholder:"例如: df -h && free -m && systemctl status nginx",defaultValue:"uptime && free -m",required:!0,acceptsPills:!0},{key:"timeoutSeconds",label:"超时时间 (秒)",type:"number",defaultValue:60}],outputs:[{key:"commandId",label:"调用批次ID",type:"string",example:"cmd-0992384"},{key:"exitCode",label:"进程退出码",type:"number",example:0},{key:"output",label:"标准输出日志",type:"string",example:"Linux 5.10.134-13.al8.x86_64"},{key:"status",label:"执行状态",type:"string",example:"SUCCESS"}],compile:(e,t)=>({name:"ecs_run_command",taskReferenceName:t.taskReferenceName,type:"HTTP",description:`主机下发命令: ${t.taskReferenceName}`,inputParameters:{_actionId:"ecs.run_command",actionName:"执行远程运维脚本",instanceId:e.instanceId,commandType:e.commandType??"RunShellScript",commandContent:e.commandContent,timeoutSeconds:Number(e.timeoutSeconds??60)}}),decompile:e=>e.inputParameters?._actionId==="ecs.run_command"?{instanceId:e.inputParameters.instanceId??"",commandType:e.inputParameters.commandType??"RunShellScript",commandContent:e.inputParameters.commandContent??"",timeoutSeconds:e.inputParameters.timeoutSeconds??60}:null,mockOutput:e=>({commandId:`cmd-${Date.now().toString(36)}`,exitCode:0,output:`[2026-10-20 22:30:00 UTC] Command executed on ${e.instanceId||"i-bp18a9z3j42m09a"}
|
|
130
|
+
Total Memory: 8192 MB, Free: 5410 MB
|
|
131
|
+
Load Average: 0.12, 0.08, 0.05
|
|
132
|
+
Result: OK`,status:"SUCCESS"})},{id:"ecs.get_monitor_metrics",name:"获取运行监控指标",category:"monitor",icon:"📊",description:"采集云主机的实时 CPU 利用率、内存消耗与磁盘使用率",connector:"cloud_host",riskLevel:"safe",fields:[{key:"instanceId",label:"云主机实例 ID",type:"text",required:!0,acceptsPills:!0},{key:"periodSeconds",label:"聚合统计周期",type:"select",defaultValue:60,options:[{label:"最近 1 分钟平均",value:60},{label:"最近 5 分钟平均",value:300},{label:"最近 15 分钟平均",value:900}]}],outputs:[{key:"instanceId",label:"实例ID",type:"string",example:"i-bp18a9z3j42m09a"},{key:"cpuUsagePercent",label:"CPU使用率(%)",type:"number",example:45.2},{key:"memoryUsagePercent",label:"内存使用率(%)",type:"number",example:62.8},{key:"diskUsagePercent",label:"磁盘使用率(%)",type:"number",example:38.5},{key:"isOverloaded",label:"是否高负载告警",type:"boolean",example:!1}],compile:(e,t)=>({name:"ecs_get_monitor_metrics",taskReferenceName:t.taskReferenceName,type:"HTTP",description:`采集监控指标: ${e.instanceId||t.taskReferenceName}`,inputParameters:{_actionId:"ecs.get_monitor_metrics",actionName:"获取运行监控指标",instanceId:e.instanceId,periodSeconds:Number(e.periodSeconds??60)}}),decompile:e=>e.inputParameters?._actionId==="ecs.get_monitor_metrics"?{instanceId:e.inputParameters.instanceId??"",periodSeconds:e.inputParameters.periodSeconds??60}:null,mockOutput:e=>{const t=32.4+Math.round(Math.random()*40*10)/10;return{instanceId:e.instanceId||"i-bp18a9z3j42m09a",cpuUsagePercent:t,memoryUsagePercent:58.6,diskUsagePercent:42.1,isOverloaded:t>80,collectedAt:new Date().toISOString()}}},{id:"ecs.release_instance",name:"释放下线云主机",category:"compute",icon:"🗑️",description:"彻底销毁并下线按量付费云主机,不可恢复",connector:"cloud_host",riskLevel:"sensitive",fields:[{key:"instanceId",label:"云主机实例 ID",type:"text",required:!0,acceptsPills:!0},{key:"forceRelease",label:"是否强制释放 (即刻关机并清理)",type:"boolean",defaultValue:!1}],outputs:[{key:"instanceId",label:"实例ID",type:"string",example:"i-bp18a9z3j42m09a"},{key:"status",label:"最终状态",type:"string",example:"RELEASED"},{key:"releasedAt",label:"释放时间",type:"string",example:"2026-10-20T14:30:00Z"}],compile:(e,t)=>({name:"ecs_release_instance",taskReferenceName:t.taskReferenceName,type:"HTTP",description:`释放云主机: ${e.instanceId||""}`,inputParameters:{_actionId:"ecs.release_instance",actionName:"释放下线云主机",instanceId:e.instanceId,forceRelease:!!e.forceRelease}}),decompile:e=>e.inputParameters?._actionId==="ecs.release_instance"?{instanceId:e.inputParameters.instanceId??"",forceRelease:!!e.inputParameters.forceRelease}:null,mockOutput:e=>({instanceId:e.instanceId||"i-bp18a9z3j42m09a",status:"RELEASED",releasedAt:new Date().toISOString()})}],og=[{id:"notify.send_message",name:"发送运维通知",category:"notify",icon:"📢",description:"向指定运维协同群(钉钉/企微/飞书)或负责人发送通知卡片",riskLevel:"safe",fields:[{key:"channel",label:"通知渠道",type:"select",required:!0,defaultValue:"webhook_dingtalk",options:[{label:"钉钉运维机器人 (DingTalk)",value:"webhook_dingtalk"},{label:"企业微信机器人 (WeCom)",value:"webhook_wecom"},{label:"飞书群机器人 (Lark/Feishu)",value:"webhook_feishu"},{label:"运维邮件 (Email)",value:"email"}]},{key:"title",label:"通知标题",type:"text",placeholder:"例如: 【生产告警】云主机 CPU 负载过高",defaultValue:"【云平台通知】运维自动化工作流执行汇报",required:!0,acceptsPills:!0},{key:"content",label:"消息正文内容",type:"textarea",placeholder:"支持输入文字,或键入 @ 插入上游实例 ID / IP 等数据胶囊",defaultValue:"主机实例已成功处理完成,请相关人员知悉。",required:!0,acceptsPills:!0}],outputs:[{key:"messageId",label:"消息追踪ID",type:"string",example:"msg_994200"},{key:"sentStatus",label:"发送状态",type:"string",example:"DELIVERED"},{key:"sentAt",label:"送达时间",type:"string",example:"2026-10-20T14:35:00Z"}],compile:(e,t)=>({name:"send_operation_notification",taskReferenceName:t.taskReferenceName,type:"EVENT",description:`发送通知: ${e.title||t.taskReferenceName}`,inputParameters:{_actionId:"notify.send_message",actionName:"发送运维通知",channel:e.channel??"webhook_dingtalk",title:e.title,content:e.content}}),decompile:e=>e.inputParameters?._actionId==="notify.send_message"?{channel:e.inputParameters.channel??"webhook_dingtalk",title:e.inputParameters.title??"",content:e.inputParameters.content??""}:null,mockOutput:e=>({messageId:`msg-${Date.now().toString(36)}`,channel:e.channel,sentStatus:"DELIVERED",sentAt:new Date().toISOString()})},{id:"human.approval",name:"人工确认 / 审批",category:"human",icon:"👤",description:"在执行高危变动或财务扣费前,暂停流程并等待指定责任人点击确认",riskLevel:"safe",fields:[{key:"assigneeRole",label:"审批责任角色",type:"select",required:!0,defaultValue:"devops_lead",options:[{label:"运维负责人 (DevOps Lead)",value:"devops_lead"},{label:"架构师 (Architect)",value:"architect"},{label:"安全管理员 (SecOps)",value:"secops"},{label:"项目经理 (PM)",value:"pm"}]},{key:"promptMessage",label:"审批确认说明",type:"textarea",placeholder:"请输入需要审批人重点核对的信息(支持 @ 插入参数)",defaultValue:"请核实即将执行的高危变更操作,确认无误后点击批准。",required:!0,acceptsPills:!0},{key:"timeoutMinutes",label:"超时自动处理",type:"select",defaultValue:60,options:[{label:"30 分钟无响应自动拒绝",value:30},{label:"60 分钟无响应自动拒绝",value:60},{label:"24 小时等待",value:1440}]}],outputs:[{key:"approved",label:"审批结果",type:"boolean",example:!0},{key:"reviewer",label:"审批人",type:"string",example:"zhangsan@cloud.com"},{key:"comment",label:"审批意见",type:"string",example:"已核实变更方案,同意执行"},{key:"decisionTime",label:"审批时间",type:"string",example:"2026-10-20T14:40:00Z"}],compile:(e,t)=>({name:"human_operation_approval",taskReferenceName:t.taskReferenceName,type:"HUMAN",description:`人工审批: ${e.promptMessage||t.taskReferenceName}`,inputParameters:{_actionId:"human.approval",actionName:"人工确认 / 审批",assigneeRole:e.assigneeRole??"devops_lead",promptMessage:e.promptMessage,timeoutMinutes:Number(e.timeoutMinutes??60)}}),decompile:e=>e.inputParameters?._actionId==="human.approval"?{assigneeRole:e.inputParameters.assigneeRole??"devops_lead",promptMessage:e.inputParameters.promptMessage??"",timeoutMinutes:e.inputParameters.timeoutMinutes??60}:null,mockOutput:e=>({approved:!0,reviewer:"devops_lead@internal.cloud",comment:"沙盒模拟快速通过",decisionTime:new Date().toISOString()})},{id:"control.wait",name:"等待缓冲",category:"logic",icon:"⏳",description:"在两个步骤之间暂停等待一段时间(等待系统自检、镜像就绪等)",riskLevel:"safe",fields:[{key:"duration",label:"等待时长",type:"select",required:!0,defaultValue:"10s",options:[{label:"等待 5 秒 (5s)",value:"5s"},{label:"等待 10 秒 (10s)",value:"10s"},{label:"等待 30 秒 (30s)",value:"30s"},{label:"等待 1 分钟 (1m)",value:"1m"},{label:"等待 5 分钟 (5m)",value:"5m"}]}],outputs:[{key:"waited",label:"是否已就绪",type:"boolean",example:!0},{key:"duration",label:"实际等待时长",type:"string",example:"10s"}],compile:(e,t)=>({name:"wait_step",taskReferenceName:t.taskReferenceName,type:"WAIT",description:`等待 ${e.duration||"10s"}`,inputParameters:{_actionId:"control.wait",actionName:"等待缓冲",duration:e.duration??"10s"}}),decompile:e=>e.inputParameters?._actionId==="control.wait"?{duration:e.inputParameters.duration??"10s"}:e.type==="WAIT"?{duration:e.inputParameters?.duration??"10s"}:null,mockOutput:e=>({waited:!0,duration:e.duration||"10s"})},{id:"control.decision",name:"条件分支",category:"logic",icon:"🔀",description:"根据输入参数或上下文表达式,精准分流执行不同业务分支",riskLevel:"safe",fields:[{key:"caseParam",label:"分支判断参数",type:"text",required:!0,defaultValue:"status",placeholder:"例如 status 或 userType",acceptsPills:!0}],outputs:[{key:"selectedCase",label:"命中的分支名称",type:"string",example:"premium"}],compile:(e,t)=>({name:"decision_router",taskReferenceName:t.taskReferenceName,type:"DECISION",caseValueParam:e.caseParam||"status",decisionCases:{},defaultCase:[],inputParameters:{_actionId:"control.decision",actionName:"条件分支",[e.caseParam||"status"]:e[e.caseParam||"status"]??"${workflow.input.status}"}}),decompile:e=>e.type==="DECISION"||e.type==="SWITCH"?{caseParam:e.caseValueParam||"status"}:null,mockOutput:()=>({selectedCase:"SUCCESS"})},{id:"control.fork",name:"并行并发组",category:"logic",icon:"⚡",description:"同时并发执行多条独立业务泳道,并在全部完成后汇聚向下流转",riskLevel:"safe",fields:[],outputs:[{key:"lanesCompleted",label:"已完成泳道数",type:"number",example:2}],compile:(e,t)=>({name:"fork_parallel",taskReferenceName:t.taskReferenceName,type:"FORK_JOIN",forkTasks:[],inputParameters:{_actionId:"control.fork",actionName:"并行并发组"}}),decompile:e=>e.type==="FORK_JOIN"||e.type==="FORK_JOIN_DYNAMIC"?{}:null,mockOutput:()=>({lanesCompleted:2})},{id:"control.loop",name:"循环迭代",category:"logic",icon:"🔁",description:"重复循环执行内部步骤,直到满足退出条件或达到最大轮次",riskLevel:"safe",fields:[{key:"loopCondition",label:"循环继续条件表达式",type:"text",required:!0,defaultValue:'$.status == "PENDING"',placeholder:'例如 $.status == "PENDING"',acceptsPills:!0}],outputs:[{key:"iterationCount",label:"实际迭代轮次",type:"number",example:3}],compile:(e,t)=>({name:"do_while_loop",taskReferenceName:t.taskReferenceName,type:"DO_WHILE",loopCondition:e.loopCondition||"false",loopOver:[],inputParameters:{_actionId:"control.loop",actionName:"循环迭代",loopCondition:e.loopCondition||"false"}}),decompile:e=>e.type==="DO_WHILE"?{loopCondition:e.loopCondition||""}:null,mockOutput:()=>({iterationCount:3})}];class Cl{actions=new Map;constructor(t=[]){this.registerAll(t)}register(t){this.actions.set(t.id,t)}registerAll(t){for(const r of t)this.register(r)}getAction(t){return this.actions.get(t)}getAllActions(){return Array.from(this.actions.values())}getActionsByCategory(t){const r=this.getAllActions();return t?r.filter(n=>n.category===t):r}findActionForTask(t){const r=t.inputParameters?._actionId;if(r&&typeof r=="string"){const n=this.getAction(r);if(n&&n.decompile){const s=n.decompile(t);if(s)return{action:n,values:s}}}for(const n of this.actions.values())if(n.decompile){const s=n.decompile(t);if(s)return{action:n,values:s}}return null}}const Le=new Cl([...sg,...og]);function It(e,t,r,n=Le){if(e.controlType==="decision"){const o=e.rawTaskDef?structuredClone(e.rawTaskDef):{},i={};let l;for(const c of e.branches||[])c.caseKey==="__default__"?l=c.steps.map((u,d)=>It(u,d,r,n)):i[c.caseKey]=c.steps.map((u,d)=>It(u,d,r,n));return{...o,name:e.name||o.name||e.taskReferenceName,taskReferenceName:e.taskReferenceName,type:o.type==="SWITCH"?"SWITCH":"DECISION",description:e.description??o.description,caseValueParam:e.caseParam||o.caseValueParam,caseExpression:e.caseExpression||o.caseExpression,decisionCases:i,defaultCase:l||o.defaultCase||[],inputParameters:{...o.inputParameters||{},...e.values||{}}}}if(e.controlType==="fork"){const o=e.rawTaskDef?structuredClone(e.rawTaskDef):{},i=(e.forkLanes||[]).map(l=>l.steps.map((c,u)=>It(c,u,r,n)));return{...o,name:e.name||o.name||e.taskReferenceName,taskReferenceName:e.taskReferenceName,type:o.type==="FORK_JOIN_DYNAMIC"?"FORK_JOIN_DYNAMIC":"FORK_JOIN",description:e.description??o.description,forkTasks:i,inputParameters:{...o.inputParameters||{},...e.values||{}}}}if(e.controlType==="loop"){const o=e.rawTaskDef?structuredClone(e.rawTaskDef):{},i=(e.loopSteps||[]).map((l,c)=>It(l,c,r,n));return{...o,name:e.name||o.name||e.taskReferenceName,taskReferenceName:e.taskReferenceName,type:"DO_WHILE",description:e.description??o.description,loopCondition:e.loopCondition||o.loopCondition||"false",loopOver:i,inputParameters:{...o.inputParameters||{},...e.values||{}}}}if(e.isProFallback&&e.rawTaskDef)return{...e.rawTaskDef,taskReferenceName:e.taskReferenceName||e.rawTaskDef.taskReferenceName,name:e.name||e.rawTaskDef.name,description:e.description??e.rawTaskDef.description};const s=n.getAction(e.actionId);return s?s.compile(e.values,{taskReferenceName:e.taskReferenceName,stepIndex:t,workflowName:r}):{name:e.name||e.taskReferenceName,taskReferenceName:e.taskReferenceName,type:"SIMPLE",description:e.description,inputParameters:{_actionId:e.actionId,...e.values}}}function ig(e,t=Le){const r=e.rawWorkflowDef?structuredClone(e.rawWorkflowDef):{},n=[];for(let s=0;s<e.steps.length;s++){const o=e.steps[s],i=It(o,s,e.name,t);if(n.push(i),o.controlType==="fork"){const l=o.pairedJoinTaskRef||`join_${o.taskReferenceName}`,c=[];if(i.forkTasks)for(const u of i.forkTasks)u&&u.length>0&&c.push(u[u.length-1].taskReferenceName);n.push({name:`${o.taskReferenceName}_join`,taskReferenceName:l,type:"JOIN",description:`Join task for ${o.taskReferenceName}`,joinOn:c.length>0?c:void 0})}}return{...r,name:e.name||"cloud_host_automation",description:e.description||"云平台自动化工作流",version:e.version??1,schemaVersion:2,tasks:n,inputParameters:e.inputParameters||r.inputParameters}}function Tt(e,t,r=Le){const n=`step_${e.taskReferenceName||t}_${Date.now().toString(36)}`;if(e.type==="DECISION"||e.type==="SWITCH"){const o=[];if(e.decisionCases)for(const[i,l]of Object.entries(e.decisionCases))o.push({caseKey:i,caseLabel:`分支: ${i}`,steps:(l||[]).map((c,u)=>Tt(c,u,r))});return e.defaultCase&&e.defaultCase.length>0&&o.push({caseKey:"__default__",caseLabel:"默认分支 (Default)",steps:e.defaultCase.map((i,l)=>Tt(i,l,r))}),{id:n,actionId:"control_decision",taskReferenceName:e.taskReferenceName,name:e.description||e.name||"条件分支路由 (Decision / Switch)",description:e.description||`根据 ${e.caseValueParam||e.caseExpression||"条件"} 进行分支路由`,values:e.inputParameters||{},isProFallback:!1,rawTaskDef:structuredClone(e),controlType:"decision",caseParam:e.caseValueParam,caseExpression:e.caseExpression,branches:o}}if(e.type==="FORK_JOIN"||e.type==="FORK_JOIN_DYNAMIC"){const o=(e.forkTasks||[]).map((i,l)=>({laneId:`lane_${l}`,laneLabel:`并发泳道 #${l+1}`,steps:(i||[]).map((c,u)=>Tt(c,u,r))}));return{id:n,actionId:"control_fork",taskReferenceName:e.taskReferenceName,name:e.description||e.name||"并行并发任务组 (Fork / Join)",description:e.description||`同时并发执行 ${o.length} 条独立业务泳道`,values:e.inputParameters||{},isProFallback:!1,rawTaskDef:structuredClone(e),controlType:"fork",forkLanes:o}}if(e.type==="DO_WHILE"){const o=(e.loopOver||[]).map((i,l)=>Tt(i,l,r));return{id:n,actionId:"control_loop",taskReferenceName:e.taskReferenceName,name:e.description||e.name||"循环迭代处理 (Do-While Loop)",description:e.description||`循环执行内部步骤,跳出条件: ${e.loopCondition||""}`,values:e.inputParameters||{},isProFallback:!1,rawTaskDef:structuredClone(e),controlType:"loop",loopCondition:e.loopCondition,loopSteps:o}}const s=r.findActionForTask(e);return s?{id:n,actionId:s.action.id,taskReferenceName:e.taskReferenceName,name:s.action.name,description:e.description,values:s.values,isProFallback:!1}:{id:n,actionId:"pro_custom_task",taskReferenceName:e.taskReferenceName,name:e.name||e.taskReferenceName,description:e.description||`底层 ${e.type} 技术任务`,values:e.inputParameters||{},isProFallback:!0,rawTaskDef:structuredClone(e)}}function lg(e,t=Le){if(!e)return{name:"new_cloud_automation",description:"新建云平台运维自动化流程",version:1,steps:[]};const r=e.tasks||[],n=new Set;for(let o=0;o<r.length;o++)if(r[o].type==="FORK_JOIN"){for(let l=o+1;l<r.length;l++)if(r[l].type==="JOIN"){n.add(r[l].taskReferenceName);break}}const s=[];for(let o=0;o<r.length;o++){const i=r[o];if(i.type==="JOIN"&&n.has(i.taskReferenceName))continue;const l=Tt(i,o,t);if(l.controlType==="fork"){for(let c=o+1;c<r.length;c++)if(r[c].type==="JOIN"){l.pairedJoinTaskRef=r[c].taskReferenceName;break}}s.push(l)}return{name:e.name||"unnamed_workflow",description:e.description||"",version:e.version||1,steps:s,inputParameters:e.inputParameters,rawWorkflowDef:structuredClone(e)}}const d0=({upstreamSteps:e,onSelect:t,onClose:r,registry:n=Le,workflowInputParams:s})=>{const[o,i]=N.useState(""),l=N.useMemo(()=>{const u=[];s&&s.length>0&&u.push({stepTitle:"工作流全局入参",stepIcon:"🌐",stepRef:"workflow.input",items:s.map(d=>{const p=typeof d=="string"?d:d.name;return{rawRef:`workflow.input.${p}`,label:typeof d=="object"&&d.description?d.description:p,type:typeof d=="object"&&d.type?d.type:"string",example:typeof d=="object"?d.example??d.defaultValue:void 0,stepLabel:"全局入参"}})});for(let d=0;d<e.length;d++){const p=e[d],h=n.getAction(p.actionId),f=`#${d+1} ${p.name||h?.name||p.taskReferenceName}`,m=h?.icon||"⚙️",g=[];if(h&&h.outputs.length>0)for(const y of h.outputs)g.push({rawRef:`${p.taskReferenceName}.output.${y.key}`,label:y.label,type:y.type,example:y.example,stepLabel:p.name||h.name});else g.push({rawRef:`${p.taskReferenceName}.output`,label:"完整输出对象",type:"object",example:"{ ... }",stepLabel:p.name});u.push({stepTitle:f,stepIcon:m,stepRef:p.taskReferenceName,items:g})}return u},[e,n,s]),c=N.useMemo(()=>{if(!o.trim())return l;const u=o.toLowerCase();return l.map(d=>({...d,items:d.items.filter(p=>p.label.toLowerCase().includes(u)||p.rawRef.toLowerCase().includes(u))})).filter(d=>d.items.length>0)},[l,o]);return a.jsxs("div",{style:{position:"absolute",top:"100%",left:0,zIndex:1100,width:340,maxHeight:380,background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",borderRadius:8,boxShadow:"0 12px 32px rgba(0,0,0,0.35)",display:"flex",flexDirection:"column",overflow:"hidden",marginTop:4,fontFamily:"inherit"},children:[a.jsxs("div",{style:{padding:"8px 10px",borderBottom:"1px solid var(--border-primary)",display:"flex",alignItems:"center",gap:8,background:"var(--bg-tertiary)"},children:[a.jsx("span",{style:{fontSize:13},children:"🏷️"}),a.jsx("input",{autoFocus:!0,type:"text",placeholder:"搜索上游输出字段...",value:o,onChange:u=>i(u.target.value),style:{flex:1,background:"transparent",border:"none",outline:"none",color:"var(--text-primary)",fontSize:12}}),a.jsx("button",{onClick:r,style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:14,padding:"2px 4px"},title:"关闭",children:"✕"})]}),a.jsx("div",{style:{flex:1,overflowY:"auto",padding:"6px 4px"},children:c.length===0?a.jsx("div",{style:{padding:"24px 12px",textAlign:"center",color:"var(--text-muted, #94a3b8)",fontSize:12},children:e.length===0?"当前步骤是第 1 步,前面暂无可引用的上游步骤输出":"未找到匹配的字段"}):c.map(u=>a.jsxs("div",{style:{marginBottom:8},children:[a.jsxs("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted, #94a3b8)",padding:"4px 8px",display:"flex",alignItems:"center",gap:6},children:[a.jsx("span",{children:u.stepIcon}),a.jsx("span",{children:u.stepTitle})]}),a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:2},children:u.items.map(d=>a.jsxs("div",{onClick:()=>{t({rawRef:d.rawRef,label:d.label,stepLabel:d.stepLabel}),r()},style:{padding:"6px 10px",borderRadius:6,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"space-between",transition:"background 0.15s ease",fontSize:12},onMouseEnter:p=>{p.currentTarget.style.background="var(--bg-highlight)"},onMouseLeave:p=>{p.currentTarget.style.background="transparent"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,overflow:"hidden"},children:[a.jsx("span",{style:{fontWeight:500,color:"var(--text-primary)",whiteSpace:"nowrap"},children:d.label}),a.jsx("span",{style:{fontSize:10,color:"var(--text-muted)",fontFamily:"monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d.rawRef})]}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[d.example!==void 0&&a.jsx("span",{style:{fontSize:10,padding:"1px 5px",borderRadius:4,background:"var(--color-accent-bg, rgba(59, 130, 246, 0.12))",color:"var(--color-accent-text, #1e40af)",fontFamily:"monospace",maxWidth:90,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:`样例值: ${String(d.example)}`,children:String(d.example)}),a.jsx("span",{style:{fontSize:10,padding:"1px 4px",borderRadius:3,background:"var(--bg-tertiary)",color:"var(--text-muted)"},children:d.type})]})]},d.rawRef))})]},u.stepRef))}),a.jsx("div",{style:{padding:"4px 8px",background:"var(--bg-tertiary)",borderTop:"1px solid var(--border-primary)",fontSize:10,color:"var(--text-muted)",textAlign:"right"},children:"点击将变量以数据胶囊形式插入"})]})},cg=({value:e,onChange:t,placeholder:r,multiline:n=!1,upstreamSteps:s,registry:o=Le,workflowInputParams:i,disabled:l=!1})=>{const[c,u]=N.useState(!1),d=N.useRef(null),p=N.useRef(null),h=e!=null?String(e):"",f=N.useMemo(()=>{const y=h.matchAll(/\$\{([^}]+)\}/g),b=[];for(const x of y){const v=x[0],k=x[1].trim();let _=k;for(const S of s)if(k.startsWith(`${S.taskReferenceName}.output`)){const j=o.getAction(S.actionId),R=k.replace(`${S.taskReferenceName}.output.`,""),L=j?.outputs.find(T=>T.key===R);L?_=`${S.name||j?.name||S.taskReferenceName} · ${L.label}`:_=`${S.name||S.taskReferenceName} 输出`;break}k.startsWith("workflow.input.")&&(_=`全局入参 · ${k.slice(15)}`),b.push({raw:v,ref:k,label:_})}return b},[h,s,o]),m=y=>{const b=`\${${y.rawRef}}`,x=p.current;if(x){const v=x.selectionStart??h.length,k=x.selectionEnd??h.length,_=h.substring(0,v)+b+h.substring(k);t(_),setTimeout(()=>{x.focus(),x.setSelectionRange(v+b.length,v+b.length)},0)}else t(h?`${h} ${b}`:b)},g=y=>{y.key==="@"&&u(!0)};return a.jsxs("div",{ref:d,style:{position:"relative",display:"flex",flexDirection:"column",gap:4,width:"100%"},children:[a.jsxs("div",{style:{display:"flex",alignItems:n?"flex-start":"center",gap:6,background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",borderRadius:6,padding:"4px 8px",transition:"border-color 0.15s ease"},children:[n?a.jsx("textarea",{ref:p,disabled:l,value:h,placeholder:r||"输入内容,或按 @ 插入上游数据胶囊...",rows:3,onChange:y=>t(y.target.value),onKeyDown:g,style:{flex:1,background:"transparent",border:"none",outline:"none",color:"var(--text-primary)",fontSize:13,fontFamily:"inherit",resize:"vertical",lineHeight:1.5}}):a.jsx("input",{ref:p,type:"text",disabled:l,value:h,placeholder:r||"输入内容,或按 @ 插入数据胶囊...",onChange:y=>t(y.target.value),onKeyDown:g,style:{flex:1,background:"transparent",border:"none",outline:"none",color:"var(--text-primary)",fontSize:13,fontFamily:"inherit"}}),a.jsxs("button",{type:"button",disabled:l,onClick:()=>u(!c),title:"点击选择并插入上游数据胶囊 (@)",style:{background:c?"var(--color-accent-bg, rgba(59, 130, 246, 0.15))":"var(--bg-tertiary)",color:c?"var(--color-accent, #3b82f6)":"var(--text-secondary)",border:`1px solid ${c?"var(--color-accent, #3b82f6)":"var(--border-primary)"}`,borderRadius:4,padding:"2px 8px",fontSize:11,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4,flexShrink:0,transition:"all 0.15s ease"},children:[a.jsx("span",{children:"🏷️"}),a.jsx("span",{children:"插入数据"})]})]}),f.length>0&&a.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:4,alignItems:"center",padding:"2px 2px"},children:[a.jsx("span",{style:{fontSize:10,color:"var(--text-muted)"},children:"已引用胶囊:"}),f.map((y,b)=>a.jsxs("span",{style:{fontSize:11,padding:"2px 8px",borderRadius:12,background:"var(--color-accent-bg, rgba(59, 130, 246, 0.12))",color:"var(--color-accent-text, #1e40af)",border:"1px solid color-mix(in srgb, var(--color-accent, #3b82f6) 35%, transparent)",display:"inline-flex",alignItems:"center",gap:4,fontWeight:500},title:`原始引用表达式: ${y.raw}`,children:[a.jsx("span",{children:"🔗"}),a.jsx("span",{children:y.label})]},`${y.ref}_${b}`))]}),c&&a.jsx(d0,{upstreamSteps:s,workflowInputParams:i,registry:o,onSelect:m,onClose:()=>u(!1)})]})},Ut=({step:e,upstreamSteps:t,workflowInputParams:r,registry:n=Le,onChange:s,disabled:o=!1})=>{const i=n.getAction(e.actionId);if(e.isProFallback||!i)return a.jsxs("div",{style:{padding:16,background:"rgba(255, 255, 255, 0.03)",borderRadius:8,border:"1px dashed var(--border-secondary, rgba(255, 255, 255, 0.2))",display:"flex",flexDirection:"column",gap:12},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[a.jsx("span",{style:{fontSize:20},children:"🔧"}),a.jsxs("div",{children:[a.jsxs("div",{style:{fontWeight:600,color:"var(--text-primary)",fontSize:14},children:[e.name||e.taskReferenceName," (底层技术步骤)"]}),a.jsxs("div",{style:{fontSize:12,color:"var(--text-muted)"},children:["任务类型: ",e.rawTaskDef?.type||"CUSTOM"]})]})]}),a.jsx("p",{style:{fontSize:12,color:"var(--text-secondary)",lineHeight:1.6,margin:0},children:"该步骤属于底层控制流或未映射的 Conductor 任务。在业务模式下已为您无损保留其参数与依赖关系。如需深度修改其底层 JQ 脚本或 JSON Schema,请切换至右上方「全景画布模式」。"})]});const l=(c,u)=>{const d={...e.values,[c]:u};s({...e,values:d})};return a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[a.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10,padding:"10px 12px",background:"var(--bg-primary)",borderRadius:8,border:"1px solid var(--border-primary)"},children:[a.jsx("span",{style:{fontSize:24},children:i.icon}),a.jsxs("div",{style:{flex:1},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[a.jsx("span",{style:{fontWeight:600,fontSize:14,color:"var(--text-primary)"},children:i.name}),i.riskLevel==="sensitive"&&a.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:4,background:"color-mix(in srgb, var(--status-failed, #ef4444) 15%, transparent)",color:"var(--status-failed, #ef4444)",border:"1px solid color-mix(in srgb, var(--status-failed, #ef4444) 30%, transparent)",fontWeight:600},children:"⚠️ 敏感变更"})]}),a.jsx("div",{style:{fontSize:12,color:"var(--text-muted)",marginTop:2},children:i.description})]})]}),i.riskLevel==="sensitive"&&a.jsxs("div",{style:{padding:"8px 12px",borderRadius:6,background:"color-mix(in srgb, var(--status-failed, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--status-failed, #ef4444) 25%, transparent)",fontSize:12,color:"var(--status-failed, #ef4444)",lineHeight:1.5},children:["💡 ",a.jsx("strong",{children:"操作安全网"}),":此步骤会直接影响真实云主机的运行状态(关机、重启、变配或下线)。建议在流程设计中,于本步骤之前放置一个「人工确认/审批」步骤,确保生产稳定性。"]}),a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:14},children:i.fields.map(c=>{const u=e.values[c.key]??c.defaultValue;return a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[a.jsxs("label",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)",display:"flex",alignItems:"center",gap:4},children:[c.label,c.required&&a.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),c.help&&a.jsx("span",{style:{fontSize:11,color:"var(--text-muted)"},children:c.help})]}),c.type==="select"?a.jsx("select",{disabled:o,value:u??"",onChange:d=>l(c.key,d.target.value),style:{padding:"7px 10px",borderRadius:6,background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",color:"var(--text-primary)",fontSize:13,outline:"none",cursor:"pointer"},children:c.options?.map(d=>a.jsx("option",{value:d.value,children:d.label},d.value))}):c.type==="boolean"?a.jsxs("label",{style:{display:"inline-flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13,color:"var(--text-secondary)"},children:[a.jsx("input",{type:"checkbox",disabled:o,checked:!!u,onChange:d=>l(c.key,d.target.checked),style:{width:16,height:16,cursor:"pointer"}}),a.jsx("span",{children:"开启 / 启用"})]}):c.acceptsPills?a.jsx(cg,{disabled:o,value:u,placeholder:c.placeholder,multiline:c.type==="textarea",upstreamSteps:t,workflowInputParams:r,registry:n,onChange:d=>l(c.key,d)}):c.type==="textarea"?a.jsx("textarea",{disabled:o,rows:3,value:u??"",placeholder:c.placeholder,onChange:d=>l(c.key,d.target.value),style:{padding:"6px 10px",borderRadius:6,background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",color:"var(--text-primary)",fontSize:13,outline:"none",fontFamily:"inherit"}}):a.jsx("input",{disabled:o,type:c.type==="number"?"number":"text",value:u??"",placeholder:c.placeholder,onChange:d=>l(c.key,c.type==="number"?Number(d.target.value):d.target.value),style:{padding:"6px 10px",borderRadius:6,background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",color:"var(--text-primary)",fontSize:13,outline:"none",fontFamily:"inherit"}})]},c.key)})}),i.outputs.length>0&&a.jsxs("div",{style:{marginTop:8,padding:"10px 12px",background:"var(--bg-tertiary)",borderRadius:6,border:"1px solid var(--border-primary)"},children:[a.jsx("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)",marginBottom:6},children:"📋 本步骤产生的数据(可被后续步骤引用):"}),a.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:i.outputs.map(c=>a.jsxs("span",{style:{fontSize:11,padding:"2px 8px",borderRadius:4,background:"var(--bg-secondary)",color:"var(--text-secondary)",border:"1px solid var(--border-primary)",display:"inline-flex",alignItems:"center",gap:4},children:[a.jsx("span",{children:"🏷️"}),a.jsx("span",{children:c.label}),a.jsxs("span",{style:{fontSize:10,color:"var(--text-muted)",fontFamily:"monospace"},children:["(",c.key,")"]})]},c.key))})]})]})},dg=({step:e,upstreamSteps:t,registry:r=Le,disabled:n=!1,onChange:s,onOpenInsertModal:o})=>{const i=e.branches||[],[l,c]=N.useState(i[0]?.caseKey||"__default__"),[u,d]=N.useState(null),[p,h]=N.useState(""),[f,m]=N.useState(!1),g=i.find(_=>_.caseKey===l)||i[0],y=(_,S)=>{const j=i.map(R=>R.caseKey===_?{...R,steps:S}:R);s({...e,branches:j})},b=()=>{const _=p.trim();if(!_)return;if(i.some(j=>j.caseKey===_)){alert(`分支 "${_}" 已存在`);return}const S=[...i,{caseKey:_,caseLabel:`分支: ${_}`,steps:[]}];s({...e,branches:S}),c(_),h(""),m(!1)},x=(_,S)=>{if(S.stopPropagation(),_==="__default__"){if(!confirm("确定要删除默认分支吗?"))return}else if(!confirm(`确定要删除分支 "${_}" 及其内部所有步骤吗?`))return;const j=i.filter(R=>R.caseKey!==_);s({...e,branches:j}),l===_&&c(j[0]?.caseKey||"")},v=()=>{g&&o(_=>{const S={id:`step_${_.id}_${Date.now().toString(36)}`,actionId:_.id,taskReferenceName:`${_.id.replace(/\./g,"_")}_${Date.now().toString(36).slice(-4)}`,name:_.name,description:_.description,values:{},isProFallback:!1};y(g.caseKey,[...g.steps,S])})},k=i.reduce((_,S)=>_+(S.steps?.length||0),0);return a.jsxs("div",{style:{borderRadius:12,background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",boxShadow:"0 4px 16px rgba(0, 0, 0, 0.08)",overflow:"hidden",transition:"all 0.2s ease"},children:[a.jsxs("div",{style:{padding:"12px 16px",background:"var(--bg-tertiary)",borderBottom:"1px solid var(--border-primary)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[a.jsx("div",{style:{width:32,height:32,borderRadius:8,background:"rgba(139, 92, 246, 0.15)",color:"color-mix(in srgb, #8b5cf6 85%, var(--text-primary))",display:"flex",alignItems:"center",justifyContent:"center",fontSize:16,fontWeight:700},children:"🔀"}),a.jsxs("div",{children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[a.jsx("span",{style:{fontWeight:600,fontSize:14,color:"var(--text-primary)"},children:e.name||"条件分支路由"}),a.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:4,background:"rgba(139, 92, 246, 0.12)",color:"color-mix(in srgb, #8b5cf6 85%, var(--text-primary))",fontWeight:600,border:"1px solid rgba(139, 92, 246, 0.3)"},children:"🔀 条件路由 (Decision / Switch)"})]}),a.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:2},children:["判断参数:"," ",a.jsx("code",{style:{color:"var(--color-accent-text, #1e40af)",background:"var(--bg-secondary)",padding:"1px 4px",borderRadius:4},children:e.caseParam||e.caseExpression||"未指定参数"})," ","· 共包含 ",i.length," 个分支,共 ",k," 个分支内业务步骤"]})]})]}),!n&&a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[a.jsx("span",{style:{fontSize:11,color:"var(--text-muted)"},children:"判断字段:"}),a.jsx("input",{type:"text",value:e.caseParam||e.caseExpression||"",placeholder:"如 userType 或 $.status",onChange:_=>s({...e,caseParam:_.target.value}),style:{width:140,padding:"4px 8px",borderRadius:4,background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",color:"var(--text-primary)",fontSize:11}})]})]}),a.jsx("div",{style:{padding:"8px 16px",background:"var(--bg-primary)",borderBottom:"1px solid var(--border-primary)",display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:8},children:a.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap",alignItems:"center"},children:[a.jsx("span",{style:{fontSize:11,color:"var(--text-muted)",marginRight:4},children:"分支列表:"}),i.map(_=>{const S=_.caseKey===l,j=_.caseKey==="__default__";return a.jsxs("div",{onClick:()=>c(_.caseKey),style:{padding:"4px 10px",borderRadius:6,cursor:"pointer",fontSize:12,fontWeight:S?600:400,background:S?"var(--color-accent-bg, rgba(59, 130, 246, 0.15))":"var(--bg-secondary)",color:S?"var(--color-accent-text, #1e40af)":"var(--text-secondary)",border:`1px solid ${S?"var(--color-accent, #3b82f6)":"var(--border-primary)"}`,display:"inline-flex",alignItems:"center",gap:6,transition:"all 0.15s ease"},children:[a.jsx("span",{children:j?"🍂":"🌿"}),a.jsx("span",{children:j?"默认分支 (Default)":_.caseKey}),a.jsx("span",{style:{fontSize:10,padding:"0 4px",borderRadius:8,background:S?"var(--color-accent, #3b82f6)":"var(--bg-tertiary)",color:S?"#fff":"var(--text-muted)"},children:_.steps?.length||0}),!n&&i.length>1&&a.jsx("span",{onClick:R=>x(_.caseKey,R),title:"删除此分支",style:{fontSize:11,color:"var(--text-muted)",marginLeft:2,cursor:"pointer"},children:"✕"})]},_.caseKey)}),!n&&!f&&a.jsx("button",{onClick:()=>m(!0),style:{padding:"4px 8px",borderRadius:6,background:"transparent",border:"1px dashed var(--border-secondary)",color:"var(--text-muted)",fontSize:11,cursor:"pointer"},children:"+ 新增分支"}),!n&&f&&a.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[a.jsx("input",{autoFocus:!0,type:"text",value:p,placeholder:"分支标识,如 VIP",onChange:_=>h(_.target.value),onKeyDown:_=>_.key==="Enter"&&b(),style:{padding:"3px 6px",borderRadius:4,border:"1px solid var(--color-accent, #3b82f6)",background:"var(--bg-secondary)",color:"var(--text-primary)",fontSize:11,width:110}}),a.jsx("button",{onClick:b,style:{padding:"3px 8px",borderRadius:4,background:"var(--color-accent, #3b82f6)",color:"#fff",border:"none",fontSize:11,cursor:"pointer"},children:"确认"}),a.jsx("button",{onClick:()=>{m(!1),h("")},style:{padding:"3px 6px",background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:11},children:"取消"})]})]})}),a.jsx("div",{style:{padding:"14px 16px",background:"var(--bg-primary)"},children:g?a.jsxs("div",{children:[a.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",marginBottom:10,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[a.jsxs("span",{children:["👉 当判断命中 ",a.jsx("strong",{children:g.caseKey})," 时,将依次串行执行以下步骤:"]}),!n&&a.jsxs("button",{onClick:v,style:{padding:"3px 8px",borderRadius:4,background:"var(--color-accent-bg, rgba(59, 130, 246, 0.12))",border:"1px solid var(--color-accent, #3b82f6)",color:"var(--color-accent-text, #1e40af)",fontSize:11,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4,fontWeight:500},children:[a.jsx("span",{children:"+"}),a.jsx("span",{children:"追加分支步骤"})]})]}),g.steps.length===0?a.jsx("div",{style:{padding:"24px 16px",borderRadius:8,border:"1px dashed var(--border-secondary)",textAlign:"center",color:"var(--text-muted)",fontSize:12,background:"var(--bg-secondary)"},children:"当前分支暂无步骤,点击右上方「+ 追加分支步骤」配置分支业务逻辑"}):a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:g.steps.map((_,S)=>{const j=r.getAction(_.actionId),R=u===_.id;return a.jsxs("div",{style:{borderRadius:8,background:"var(--bg-secondary)",border:R?"1px solid var(--color-accent, #3b82f6)":"1px solid var(--border-primary)",overflow:"hidden",transition:"all 0.15s ease"},children:[a.jsxs("div",{onClick:()=>d(R?null:_.id),style:{padding:"8px 12px",display:"flex",alignItems:"center",justifyContent:"space-between",cursor:"pointer"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[a.jsxs("span",{style:{fontSize:10,fontWeight:700,padding:"1px 5px",borderRadius:4,background:"var(--bg-tertiary)",color:"var(--color-accent-text, #1e40af)"},children:["#",S+1]}),a.jsx("span",{style:{fontSize:16},children:j?.icon||"⚙️"}),a.jsxs("div",{children:[a.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:_.name||j?.name||_.taskReferenceName}),a.jsx("div",{style:{fontSize:10,color:"var(--text-muted)",fontFamily:"monospace"},children:_.taskReferenceName})]})]}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},onClick:L=>L.stopPropagation(),children:[!n&&a.jsx("button",{onClick:()=>{const L=g.steps.filter((T,w)=>w!==S);y(g.caseKey,L)},title:"删除此步骤",style:{background:"none",border:"none",color:"#ef4444",cursor:"pointer",fontSize:12,padding:"2px 4px"},children:"🗑️"}),a.jsx("span",{style:{fontSize:10,color:"var(--text-muted)",transform:R?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.15s ease",cursor:"pointer"},onClick:()=>d(R?null:_.id),children:"▼"})]})]}),R&&a.jsx("div",{style:{padding:"12px 14px",borderTop:"1px solid var(--border-primary)",background:"var(--bg-primary)"},children:a.jsx(Ut,{step:_,upstreamSteps:[...t,...g.steps.slice(0,S)],registry:r,disabled:n,onChange:L=>{const T=[...g.steps];T[S]=L,y(g.caseKey,T)}})})]},_.id)})})]}):a.jsx("div",{style:{textAlign:"center",color:"var(--text-muted)",fontSize:12},children:"请选择或新增一个分支进行配置"})}),a.jsxs("div",{style:{padding:"6px 14px",background:"var(--bg-tertiary)",borderTop:"1px solid var(--border-primary)",fontSize:10,color:"var(--text-muted)",display:"flex",alignItems:"center",gap:4},children:[a.jsx("span",{children:"💡"}),a.jsx("span",{children:"分支执行逻辑:运行时仅会精准执行匹配的分支路径,未命中的分支步骤将安全跳过。"})]})]})},ug=({step:e,upstreamSteps:t,registry:r=Le,disabled:n=!1,onChange:s,onOpenInsertModal:o})=>{const i=e.forkLanes||[],[l,c]=N.useState(i[0]?.laneId||"lane_0"),[u,d]=N.useState(null),p=(y,b)=>{const x=i.map(v=>v.laneId===y?{...v,steps:b}:v);s({...e,forkLanes:x})},h=()=>{const y=i.length,b={laneId:`lane_${y}_${Date.now().toString(36).slice(-4)}`,laneLabel:`并发泳道 #${y+1}`,steps:[]},x=[...i,b];s({...e,forkLanes:x}),c(b.laneId)},f=(y,b)=>{if(b.stopPropagation(),i.length<=1){alert("至少需要保留一条并行泳道");return}if(!confirm("确定要删除此条并行泳道及其内部步骤吗?"))return;const x=i.filter(v=>v.laneId!==y);s({...e,forkLanes:x}),l===y&&c(x[0]?.laneId||"")},m=y=>{const b=i.find(x=>x.laneId===y);b&&o(x=>{const v={id:`step_${x.id}_${Date.now().toString(36)}`,actionId:x.id,taskReferenceName:`${x.id.replace(/\./g,"_")}_${Date.now().toString(36).slice(-4)}`,name:x.name,description:x.description,values:{},isProFallback:!1};p(y,[...b.steps,v])})},g=i.reduce((y,b)=>y+(b.steps?.length||0),0);return a.jsxs("div",{style:{borderRadius:12,background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",boxShadow:"0 4px 16px rgba(0, 0, 0, 0.08)",overflow:"hidden",transition:"all 0.2s ease"},children:[a.jsxs("div",{style:{padding:"12px 16px",background:"var(--bg-tertiary)",borderBottom:"1px solid var(--border-primary)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[a.jsx("div",{style:{width:32,height:32,borderRadius:8,background:"rgba(59, 130, 246, 0.15)",color:"var(--color-accent, #3b82f6)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:16,fontWeight:700},children:"⚡"}),a.jsxs("div",{children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[a.jsx("span",{style:{fontWeight:600,fontSize:14,color:"var(--text-primary)"},children:e.name||"并行并发任务组"}),a.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:4,background:"var(--color-accent-bg, rgba(59, 130, 246, 0.12))",color:"var(--color-accent-text, #1e40af)",fontWeight:600,border:"1px solid color-mix(in srgb, var(--color-accent, #3b82f6) 30%, transparent)"},children:"⚡ 并行并发 (Fork / Join)"})]}),a.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:2},children:["同时并发执行 ",i.length," 条独立业务泳道 · 涵盖 ",g," 个并发步骤"]})]})]}),!n&&a.jsxs("button",{onClick:h,style:{padding:"4px 10px",borderRadius:6,background:"var(--bg-secondary)",border:"1px dashed var(--border-secondary)",color:"var(--text-primary)",fontSize:11,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4},children:[a.jsx("span",{children:"+"}),a.jsx("span",{children:"新增并发泳道"})]})]}),a.jsx("div",{style:{padding:"14px 16px",background:"var(--bg-primary)",display:"grid",gridTemplateColumns:i.length>1?`repeat(${Math.min(i.length,3)}, minmax(240px, 1fr))`:"1fr",gap:12,overflowX:"auto"},children:i.map((y,b)=>a.jsxs("div",{style:{borderRadius:8,background:"var(--bg-secondary)",border:"1px solid var(--border-primary)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[a.jsxs("div",{style:{padding:"8px 12px",background:"var(--bg-tertiary)",borderBottom:"1px solid var(--border-primary)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[a.jsx("span",{style:{fontSize:13},children:"🏊"}),a.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:y.laneLabel||`泳道 #${b+1}`}),a.jsxs("span",{style:{fontSize:10,padding:"0 5px",borderRadius:8,background:"var(--bg-secondary)",color:"var(--text-muted)"},children:[y.steps.length," 步"]})]}),!n&&i.length>1&&a.jsx("button",{onClick:x=>f(y.laneId,x),title:"删除此泳道",style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:11,padding:"2px 4px"},children:"✕"})]}),a.jsxs("div",{style:{padding:10,flex:1,display:"flex",flexDirection:"column",gap:8,minHeight:80},children:[y.steps.length===0?a.jsx("div",{style:{padding:"16px 8px",textAlign:"center",color:"var(--text-muted)",fontSize:11,border:"1px dashed var(--border-secondary)",borderRadius:6},children:"此泳道暂无步骤"}):y.steps.map((x,v)=>{const k=r.getAction(x.actionId),_=u===x.id;return a.jsxs("div",{style:{borderRadius:6,background:"var(--bg-primary)",border:_?"1px solid var(--color-accent, #3b82f6)":"1px solid var(--border-primary)",overflow:"hidden"},children:[a.jsxs("div",{onClick:()=>d(_?null:x.id),style:{padding:"6px 8px",display:"flex",alignItems:"center",justifyContent:"space-between",cursor:"pointer"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,overflow:"hidden"},children:[a.jsx("span",{style:{fontSize:14},children:k?.icon||"⚙️"}),a.jsx("span",{style:{fontSize:11,fontWeight:600,color:"var(--text-primary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:x.name||k?.name})]}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},onClick:S=>S.stopPropagation(),children:[!n&&a.jsx("button",{onClick:()=>{const S=y.steps.filter((j,R)=>R!==v);p(y.laneId,S)},title:"删除此步骤",style:{background:"none",border:"none",color:"#ef4444",cursor:"pointer",fontSize:11,padding:"1px 3px"},children:"🗑️"}),a.jsx("span",{style:{fontSize:10,color:"var(--text-muted)",transform:_?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.15s ease",cursor:"pointer"},onClick:()=>d(_?null:x.id),children:"▼"})]})]}),_&&a.jsx("div",{style:{padding:"10px 10px",borderTop:"1px solid var(--border-primary)",background:"var(--bg-secondary)"},children:a.jsx(Ut,{step:x,upstreamSteps:[...t,...y.steps.slice(0,v)],registry:r,disabled:n,onChange:S=>{const j=[...y.steps];j[v]=S,p(y.laneId,j)}})})]},x.id)}),!n&&a.jsx("button",{onClick:()=>m(y.laneId),style:{padding:"4px 8px",borderRadius:4,background:"transparent",border:"1px dashed var(--border-secondary)",color:"var(--text-muted)",fontSize:11,cursor:"pointer",marginTop:2},children:"+ 追加并发步骤"})]})]},y.laneId))}),a.jsxs("div",{style:{padding:"8px 16px",background:"var(--bg-tertiary)",borderTop:"1px solid var(--border-primary)",fontSize:11,color:"var(--text-secondary)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[a.jsx("span",{children:"🔗"}),a.jsxs("span",{children:[a.jsx("strong",{children:"汇聚同步点 (Join)"}),":所有 ",i.length," 条并行泳道内步骤全部执行完毕后,在同步节点汇聚并继续向下执行。"]})]}),e.pairedJoinTaskRef&&a.jsx("code",{style:{fontSize:10,color:"var(--text-muted)",background:"var(--bg-secondary)",padding:"1px 6px",borderRadius:4},children:e.pairedJoinTaskRef})]})]})},pg=({step:e,upstreamSteps:t,registry:r=Le,disabled:n=!1,onChange:s,onOpenInsertModal:o})=>{const i=e.loopSteps||[],[l,c]=N.useState(null),u=p=>{s({...e,loopSteps:p})},d=()=>{o(p=>{const h={id:`step_${p.id}_${Date.now().toString(36)}`,actionId:p.id,taskReferenceName:`${p.id.replace(/\./g,"_")}_${Date.now().toString(36).slice(-4)}`,name:p.name,description:p.description,values:{},isProFallback:!1};u([...i,h])})};return a.jsxs("div",{style:{borderRadius:12,background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",boxShadow:"0 4px 16px rgba(0, 0, 0, 0.08)",overflow:"hidden",transition:"all 0.2s ease"},children:[a.jsxs("div",{style:{padding:"12px 16px",background:"var(--bg-tertiary)",borderBottom:"1px solid var(--border-primary)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[a.jsx("div",{style:{width:32,height:32,borderRadius:8,background:"var(--color-accent-bg, rgba(59, 130, 246, 0.15))",color:"var(--color-accent, #3b82f6)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:16,fontWeight:700},children:"🔁"}),a.jsxs("div",{children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[a.jsx("span",{style:{fontWeight:600,fontSize:14,color:"var(--text-primary)"},children:e.name||"循环迭代处理"}),a.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:4,background:"var(--color-accent-bg, rgba(59, 130, 246, 0.12))",color:"var(--color-accent-text, #1e40af)",fontWeight:600,border:"1px solid color-mix(in srgb, var(--color-accent, #3b82f6) 30%, transparent)"},children:"🔁 循环迭代 (Do-While Loop)"})]}),a.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:2},children:["循环体包含 ",i.length," 个步骤 · 每次迭代执行完将重新评估跳出条件"]})]})]}),!n&&a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[a.jsx("span",{style:{fontSize:11,color:"var(--text-muted)"},children:"循环继续条件:"}),a.jsx("input",{type:"text",value:e.loopCondition||"",placeholder:"如 $.status == 'PENDING'",onChange:p=>s({...e,loopCondition:p.target.value}),style:{width:200,padding:"4px 8px",borderRadius:4,background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",color:"var(--text-primary)",fontSize:11,fontFamily:"monospace"}})]})]}),a.jsx("div",{style:{padding:"14px 16px",background:"var(--bg-primary)"},children:a.jsxs("div",{style:{borderRadius:8,border:"2px dashed color-mix(in srgb, var(--color-accent, #3b82f6) 45%, var(--border-secondary))",background:"var(--bg-secondary)",padding:12},children:[a.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",marginBottom:10,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[a.jsx("span",{children:"🔄"}),a.jsxs("span",{children:[a.jsx("strong",{children:"循环体内部任务序列"})," (每轮迭代将依次执行以下 ",i.length," 个步骤):"]})]}),!n&&a.jsxs("button",{onClick:d,style:{padding:"3px 8px",borderRadius:4,background:"var(--color-accent-bg, rgba(59, 130, 246, 0.1))",border:"1px solid color-mix(in srgb, var(--color-accent, #3b82f6) 40%, transparent)",color:"var(--color-accent-text, #1e40af)",fontSize:11,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4,fontWeight:500},children:[a.jsx("span",{children:"+"}),a.jsx("span",{children:"追加循环步骤"})]})]}),i.length===0?a.jsx("div",{style:{padding:"20px 12px",textAlign:"center",color:"var(--text-muted)",fontSize:11},children:"循环体内暂无任务,请点击右上角「+ 追加循环步骤」添加轮询或重复执行动作"}):a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:i.map((p,h)=>{const f=r.getAction(p.actionId),m=l===p.id;return a.jsxs("div",{style:{borderRadius:6,background:"var(--bg-primary)",border:m?"1px solid var(--color-accent, #3b82f6)":"1px solid var(--border-primary)",overflow:"hidden"},children:[a.jsxs("div",{onClick:()=>c(m?null:p.id),style:{padding:"8px 12px",display:"flex",alignItems:"center",justifyContent:"space-between",cursor:"pointer"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[a.jsxs("span",{style:{fontSize:10,fontWeight:700,padding:"1px 5px",borderRadius:4,background:"var(--color-accent-bg, rgba(59, 130, 246, 0.12))",color:"var(--color-accent-text, #1e40af)"},children:["轮内 #",h+1]}),a.jsx("span",{style:{fontSize:16},children:f?.icon||"⚙️"}),a.jsxs("div",{children:[a.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:p.name||f?.name||p.taskReferenceName}),a.jsx("div",{style:{fontSize:10,color:"var(--text-muted)",fontFamily:"monospace"},children:p.taskReferenceName})]})]}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},onClick:g=>g.stopPropagation(),children:[!n&&a.jsx("button",{onClick:()=>{const g=i.filter((y,b)=>b!==h);u(g)},title:"删除此步骤",style:{background:"none",border:"none",color:"#ef4444",cursor:"pointer",fontSize:12,padding:"2px 4px"},children:"🗑️"}),a.jsx("span",{style:{fontSize:10,color:"var(--text-muted)",transform:m?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.15s ease",cursor:"pointer"},onClick:()=>c(m?null:p.id),children:"▼"})]})]}),m&&a.jsx("div",{style:{padding:"12px 14px",borderTop:"1px solid var(--border-primary)",background:"var(--bg-secondary)"},children:a.jsx(Ut,{step:p,upstreamSteps:[...t,...i.slice(0,h)],registry:r,disabled:n,onChange:g=>{const y=[...i];y[h]=g,u(y)}})})]},p.id)})})]})}),a.jsxs("div",{style:{padding:"8px 16px",background:"var(--bg-tertiary)",borderTop:"1px solid var(--border-primary)",fontSize:11,color:"var(--text-secondary)",display:"flex",alignItems:"center",gap:6},children:[a.jsx("span",{children:"🛑"}),a.jsxs("span",{children:[a.jsx("strong",{children:"跳出与安全保护"}),":当条件表达式评估为 false 时自动跳出循环向下继续;引擎内置循环熔断保护,防止生产环境死循环。"]})]})]})};function fg(e,t,r){const n=(e||"").toLowerCase();return t===401||t===403||n.includes("401")||n.includes("403")||n.includes("unauthorized")||n.includes("forbidden")||n.includes("token expired")||n.includes("invalid api key")||n.includes("signature does not match")?{type:"auth",title:"云平台账号授权已失效或权限受限",explanation:`在调用【${r||"云服务"}】时未通过安全身份核验。通常是因为配置的账号密钥 (AccessKey/Token) 已过期失效,或该账号缺乏对应资源的操作授权。`,suggestion:"建议检查账号授权状态,重新填入有效密钥或联系企业管理员为该账号分配权限。",actionLabel:"重新授权密钥",actionKey:"reauth"}:t===504||n.includes("timeout")||n.includes("timed out")||n.includes("etimedout")||n.includes("deadline")||n.includes("connection refused")?{type:"timeout",title:"目标云主机响应超时",explanation:`向【${r||"主机"}】发送指令后,在约定的时间内未收到回应。可能是云主机刚开机系统服务尚未就绪,或所在子网的安全组策略拦截了通信端口。`,suggestion:"云服务正在进行底层引导,通常稍等片刻自动重试即可恢复。",actionLabel:"稍后自动重试",actionKey:"retry"}:n.includes("exit code")||n.includes("command failed")||n.includes("command not found")||n.includes("syntax error")?{type:"script_fail",title:"主机内部脚本执行异常退出",explanation:"下发到云主机内部的 Shell/Python 脚本在运行过程中遇到错误并提前中断。通常是因为目标环境中缺少前置依赖库,或指定的文件路径不存在。",suggestion:"可展开下方查看脚本的标准输出日志排查具体报错,修正脚本后重新执行。",actionLabel:"查看脚本输出日志",actionKey:"inspect_upstream"}:n.includes("nullpointer")||n.includes("cannot read property")||n.includes("undefined")||n.includes("field not found")||n.includes("parameter not found")||n.includes("missing required parameter")?{type:"missing_data",title:"缺少必要的上游输入数据",explanation:"本步骤引用的上游步骤没有返回预期的数据内容(例如没有获取到有效的「主机实例ID」或「内网IP」),导致后续步骤无法继续执行。",suggestion:"请点击检查上游步骤的输出结果,确认上游任务是否正常产生了所需的数据胶囊。",actionLabel:"查看上游步骤数据",actionKey:"inspect_upstream"}:n.includes("quota")||n.includes("limit exceeded")||n.includes("insufficient")||n.includes("out of stock")||n.includes("balance")?{type:"quota",title:"可用区资源库存不足或配额受限",explanation:"当前所选可用区该型号的云主机规格暂时售罄,或云平台租户的配额上限已满。",suggestion:"建议在流程中更换目标规格(如选择通用型或计算型同等配置),或申请提升账号配额。",actionLabel:"更换规格/可用区",actionKey:"change_spec"}:n.includes("network")||n.includes("dns")||n.includes("unreachable")||n.includes("failed to fetch")?{type:"network",title:"网络通信中断或无法解析",explanation:"调度服务与目标云服务之间的网络连接不稳定,或专有网络 VPC 路由未打通。",suggestion:"请检查网络连通性配置,或联系网络运维人员协助排查。",actionLabel:"重新尝试连接",actionKey:"retry"}:{type:"unknown",title:"步骤执行未达预期",explanation:e||"执行过程中底层服务报告了非成功状态,请查阅详细日志。",suggestion:"可点击重试此步骤,或将此诊断报告反馈给技术支持排查。",actionLabel:"重试此任务",actionKey:"retry"}}const hg=({rawError:e,statusCode:t,taskName:r,onActionClick:n})=>{const[s,o]=N.useState(!1),i=fg(e,t,r);return a.jsxs("div",{style:{borderRadius:10,background:"rgba(239, 68, 68, 0.08)",border:"1px solid rgba(239, 68, 68, 0.3)",padding:"14px 16px",display:"flex",flexDirection:"column",gap:10,fontFamily:"inherit"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[a.jsx("span",{style:{fontSize:18},children:i.type==="auth"?"🔑":i.type==="timeout"?"⏱️":i.type==="missing_data"?"⚠️":i.type==="quota"?"💳":"❌"}),a.jsx("span",{style:{fontWeight:600,fontSize:14,color:"var(--status-failed, #ef4444)"},children:i.title})]}),i.actionLabel&&a.jsxs("button",{onClick:()=>n?.(i.actionKey),style:{padding:"4px 10px",borderRadius:6,background:"color-mix(in srgb, var(--status-failed, #ef4444) 15%, transparent)",border:"1px solid color-mix(in srgb, var(--status-failed, #ef4444) 30%, transparent)",color:"var(--status-failed, #ef4444)",fontSize:11,fontWeight:600,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4},children:[a.jsx("span",{children:"⚡"}),a.jsx("span",{children:i.actionLabel})]})]}),a.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",lineHeight:1.6},children:i.explanation}),a.jsxs("div",{style:{padding:"8px 12px",borderRadius:6,background:"var(--bg-tertiary)",border:"1px solid var(--border-primary)",fontSize:11,color:"var(--color-warning, #d97706)",lineHeight:1.5},children:["💡 ",a.jsx("strong",{children:"建议做法"}),":",i.suggestion]}),e&&a.jsxs("div",{style:{marginTop:2},children:[a.jsx("button",{onClick:()=>o(!s),style:{background:"none",border:"none",color:"var(--text-muted, #94a3b8)",fontSize:10,cursor:"pointer",padding:0,display:"inline-flex",alignItems:"center",gap:4},children:a.jsx("span",{children:s?"▾ 折叠底层技术报错":"▸ 展开底层技术报错 (供研发/技术支持排查)"})}),s&&a.jsx("div",{style:{marginTop:6,padding:"8px 10px",borderRadius:4,background:"rgba(0, 0, 0, 0.35)",color:"var(--text-muted, #94a3b8)",fontFamily:"monospace",fontSize:10,lineHeight:1.4,maxHeight:120,overflowY:"auto",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:e})]})]})};function u0(e,t){const r=e.outputData||{},n=e.workflowTask?.inputParameters?._actionId,s=n?t.getAction(n):void 0;if(e.status==="FAILED"||e.status==="FAILED_WITH_TERMINAL_ERROR")return"执行中断于此步骤,已触发异常诊断自愈建议。";if(n==="ecs.create_instance"){const o=r.privateIp?` · 分配内网 IP: ${r.privateIp}`:"";return`成功在可用区初始化并启动云主机${r.instanceId?` · 实例 ID: ${r.instanceId}`:""}${o}。`}return n==="ecs.query_instance"?`已查询获取主机实时状态 (${r.status||"RUNNING"}),公网 IP: ${r.publicIp||"未绑定"}。`:n==="ecs.run_command"?`远程运维脚本已成功在主机内执行完毕,命令批次: ${r.commandId||"cmd-ok"}。`:n==="ecs.create_snapshot"?`系统盘安全增量快照已成功归档,快照 ID: ${r.snapshotId||"s-done"}。`:n==="ecs.stop_instance"?"云主机已安全关闭电源,当前状态: STOPPED。":n==="ecs.start_instance"?"云主机已开机并启动系统服务,当前状态: RUNNING。":n==="ecs.modify_spec"?`云主机硬件规格已在线变更生效 (${r.oldSpec||""} → ${r.newSpec||""})。`:n==="ecs.get_monitor_metrics"?`采集到实时负载:CPU 利用率 ${r.cpuUsagePercent??20}%,系统运行平稳。`:n==="notify.send_message"?"运维协同卡片已成功推送至指定协同通知群,状态: DELIVERED。":n==="control.wait"||e.taskType==="WAIT"?"系统安全缓冲等待完成,底层服务就绪。":n==="human.approval"||e.taskType==="HUMAN"?`责任人 (${r.reviewer||"devops_lead"}) 已完成审核批准。`:e.taskType==="DECISION"||e.taskType==="SWITCH"?`条件分支路由完成:评估参数命中分支 [${r.selectedCase||r.case||r.output||""||"主干分支"}],正向下分流执行。`:e.taskType==="FORK_JOIN"||e.taskType==="FORK_JOIN_DYNAMIC"?"并行并发已触发:多条独立业务泳道同时展开并发执行。":e.taskType==="JOIN"?"并行汇聚同步完成:所有并发泳道已全部成功执行完毕,工作流汇合向下推进。":e.taskType==="DO_WHILE"?`循环迭代处理完成:已执行 ${e.iteration||r.iteration||1} 轮循环,评估跳出条件已满足。`:`${s?.name||e.taskDefName||e.referenceTaskName} 执行完毕。`}const mg=({instance:e,registry:t=Le,onInspectStep:r})=>{const[n,s]=N.useState({}),o=d=>{s(p=>({...p,[d]:!p[d]}))},i=e.tasks||[],l=e.status==="FAILED"||e.status==="TIMED_OUT",u=((e.endTime&&e.startTime?e.endTime-e.startTime:0)/1e3).toFixed(1);return a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16,padding:"16px 20px",background:"var(--bg-primary)",height:"100%",overflowY:"auto",fontFamily:"inherit"},children:[a.jsxs("div",{style:{padding:"12px 18px",borderRadius:10,background:l?"rgba(239, 68, 68, 0.1)":"rgba(16, 185, 129, 0.1)",border:`1px solid ${l?"rgba(239, 68, 68, 0.3)":"rgba(16, 185, 129, 0.3)"}`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[a.jsx("span",{style:{fontSize:24},children:l?"❌":"🎉"}),a.jsxs("div",{children:[a.jsx("div",{style:{fontWeight:700,fontSize:14,color:l?"var(--status-failed, #ef4444)":"var(--status-completed, #10b981)"},children:l?"工作流执行中断":"工作流全部步骤顺利执行完毕"}),a.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:2},children:["执行 ID: ",e.workflowId," · 共执行 ",i.length," 个步骤 · 总耗时约 ",u," 秒"]})]})]}),a.jsx("span",{style:{fontSize:11,padding:"2px 8px",borderRadius:4,fontWeight:600,background:l?"rgba(239, 68, 68, 0.15)":"rgba(16, 185, 129, 0.15)",color:l?"var(--status-failed, #ef4444)":"var(--status-completed, #10b981)"},children:e.status})]}),a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:i.map((d,p)=>{const h=d.workflowTask?.inputParameters?._actionId,f=h?t.getAction(h):void 0,m=f?.icon||(d.taskType==="DECISION"||d.taskType==="SWITCH"?"🔀":d.taskType==="FORK_JOIN"||d.taskType==="FORK_JOIN_DYNAMIC"?"⚡":d.taskType==="JOIN"?"🔗":d.taskType==="DO_WHILE"?"🔁":d.taskType==="WAIT"?"⏳":d.taskType==="HUMAN"?"👤":"⚙️"),g=d.status==="FAILED"||d.status==="FAILED_WITH_TERMINAL_ERROR",y=!!n[d.referenceTaskName],b=u0(d,t),x=d.startTime?new Date(d.startTime).toLocaleTimeString():"--:--:--",v=d.endTime&&d.startTime?`${((d.endTime-d.startTime)/1e3).toFixed(2)}s`:"";return a.jsxs("div",{style:{borderRadius:10,background:"var(--bg-secondary)",border:g?"1px solid var(--status-failed, #ef4444)":"1px solid var(--border-primary)",boxShadow:g?"0 4px 16px rgba(239, 68, 68, 0.12)":"none",padding:"12px 16px",display:"flex",flexDirection:"column",gap:8},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[a.jsx("span",{style:{fontSize:18},children:g?"❌":m}),a.jsxs("div",{children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[a.jsxs("span",{style:{fontWeight:600,fontSize:13,color:"var(--text-primary)"},children:["步骤 #",p+1,": ",f?.name||d.taskDefName||d.referenceTaskName]}),a.jsx("span",{style:{fontSize:10,padding:"1px 5px",borderRadius:3,background:g?"rgba(239, 68, 68, 0.15)":"rgba(16, 185, 129, 0.15)",color:g?"var(--status-failed, #ef4444)":"var(--status-completed, #10b981)",fontWeight:600},children:g?"执行失败":"执行完成"})]}),a.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:2},children:[x," ",v&&`· 耗时 ${v}`]})]})]}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[r&&a.jsx("button",{onClick:()=>r(d.referenceTaskName),style:{padding:"2px 8px",borderRadius:4,background:"transparent",border:"1px solid var(--border-secondary)",color:"var(--text-secondary)",fontSize:11,cursor:"pointer"},children:"定位步骤"}),a.jsx("button",{onClick:()=>o(d.referenceTaskName),style:{background:"none",border:"none",color:"var(--text-muted)",fontSize:11,cursor:"pointer"},children:y?"收起数据 ▴":"查看数据 ▾"})]})]}),a.jsx("div",{style:{fontSize:12,color:g?"var(--status-failed, #ef4444)":"var(--text-secondary)",lineHeight:1.5,padding:"4px 0"},children:b}),g&&a.jsx("div",{style:{marginTop:4},children:a.jsx(hg,{rawError:d.reasonForIncompletion||"底层任务状态异常终止",taskName:f?.name||d.referenceTaskName})}),y&&d.outputData&&a.jsx("div",{style:{marginTop:8,padding:"10px 12px",borderRadius:8,background:"var(--bg-tertiary)",border:"1px solid var(--border-primary)",display:"flex",flexWrap:"wrap",gap:8},children:Object.entries(d.outputData).map(([k,_])=>typeof _=="object"&&_!==null?null:a.jsxs("span",{style:{fontSize:11,padding:"3px 8px",borderRadius:6,background:"var(--color-accent-bg, rgba(59, 130, 246, 0.12))",border:"1px solid color-mix(in srgb, var(--color-accent, #3b82f6) 30%, transparent)",display:"inline-flex",alignItems:"center",gap:6,fontFamily:"monospace"},children:[a.jsxs("span",{style:{color:"var(--text-muted)"},children:[k,":"]}),a.jsx("span",{style:{color:"var(--color-accent-text, #1e40af)",fontWeight:600},children:String(_)})]},k))})]},d.taskId||d.referenceTaskName||p)})})]})},gg=({workflowDef:e,onChange:t,registry:r=Le,readOnly:n=!1,workflowExecution:s})=>{const o=N.useMemo(()=>lg(e,r),[e,r]),[i,l]=N.useState(null),[c,u]=N.useState(null),[d,p]=N.useState(null),[h,f]=N.useState("all"),[m,g]=N.useState(""),[y,b]=N.useState(!1),[x,v]=N.useState(null),[k,_]=N.useState(s||null),[S,j]=N.useState(s?"story":"steps");N.useEffect(()=>{s&&(_(s),j("story"))},[s]);const R=o.steps,L=M=>{const I={...o,steps:M},F=ig(I,r);t(F)},T=(M,I)=>{const F=[...R];F[M]=I,L(F)},w=M=>{if(n)return;const I=R.filter((F,O)=>O!==M);i===R[M]?.id&&l(null),L(I)},D=(M,I)=>{if(n||I<0||I>=R.length)return;const F=[...R],[O]=F.splice(M,1);F.splice(I,0,O),L(F)},E=M=>{p(()=>M),u(0)},C=(M,I)=>{if(d){d(M),p(null),u(null);return}const F=`${M.id.replace(/\./g,"_")}_${Date.now().toString(36).slice(-4)}`;let O;if(M.id==="control.decision")O={id:`step_${F}`,actionId:"control_decision",taskReferenceName:F,name:"条件分支路由",description:"根据输入参数或上下文表达式分流执行",values:{caseParam:"status"},controlType:"decision",caseParam:"status",branches:[{caseKey:"SUCCESS",caseLabel:"分支: SUCCESS",steps:[]},{caseKey:"__default__",caseLabel:"默认分支 (Default)",steps:[]}],isProFallback:!1};else if(M.id==="control.fork")O={id:`step_${F}`,actionId:"control_fork",taskReferenceName:F,name:"并行并发组",description:"同时并发执行多条独立业务泳道",values:{},controlType:"fork",forkLanes:[{laneId:"lane_0",laneLabel:"并发泳道 #1",steps:[]},{laneId:"lane_1",laneLabel:"并发泳道 #2",steps:[]}],isProFallback:!1};else if(M.id==="control.loop")O={id:`step_${F}`,actionId:"control_loop",taskReferenceName:F,name:"循环迭代处理",description:"重复循环执行内部步骤,直到满足退出条件",values:{loopCondition:'$.status == "PENDING"'},controlType:"loop",loopCondition:'$.status == "PENDING"',loopSteps:[],isProFallback:!1};else{const Z={};for(const A of M.fields)A.defaultValue!==void 0&&(Z[A.key]=A.defaultValue);O={id:`step_${F}`,actionId:M.id,taskReferenceName:F,name:M.name,description:M.description,values:Z,isProFallback:!1}}const J=[...R];J.splice(I,0,O),u(null),l(O.id),L(J)},z=()=>{if(e){b(!0);try{const M={};for(const O of R){const J=r.getAction(O.actionId);J&&J.mockOutput&&(M[O.taskReferenceName]=J.mockOutput(O.values))}const I=$t(e,{taskMocks:M});_(I),j("story");const F={};for(const O of I.tasks)F[O.referenceTaskName]={status:O.status,output:O.outputData};v(F)}catch(M){console.error("[StepFlowEditor] Dry run error:",M)}finally{b(!1)}}},W=r.getAllActions(),K=N.useMemo(()=>W.filter(M=>{const I=h==="all"||M.category===h,F=!m||M.name.toLowerCase().includes(m.toLowerCase())||M.description.toLowerCase().includes(m.toLowerCase());return I&&F}),[W,h,m]);return a.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",background:"var(--bg-primary, #0f172a)",overflowY:"auto",fontFamily:"inherit"},children:[a.jsxs("div",{style:{padding:"12px 20px",borderBottom:"1px solid var(--border-primary, rgba(255,255,255,0.1))",display:"flex",alignItems:"center",justifyContent:"space-between",background:"var(--bg-secondary, #1e293b)",flexShrink:0},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[a.jsx("span",{style:{fontSize:18},children:"📋"}),a.jsxs("div",{children:[a.jsx("div",{style:{fontWeight:600,fontSize:14,color:"var(--text-primary, #f8fafc)"},children:o.name||"云平台业务流程"}),a.jsxs("div",{style:{fontSize:12,color:"var(--text-muted, #94a3b8)"},children:["共 ",R.length," 个业务执行步骤 · 普通用户零代码模式"]})]})]}),k&&a.jsxs("div",{style:{display:"inline-flex",background:"rgba(255, 255, 255, 0.06)",borderRadius:6,padding:2,border:"1px solid var(--border-secondary, rgba(255, 255, 255, 0.15))"},children:[a.jsx("button",{onClick:()=>j("steps"),style:{padding:"4px 10px",borderRadius:4,border:"none",background:S==="steps"?"var(--color-accent, #3b82f6)":"transparent",color:S==="steps"?"#fff":"var(--text-secondary, #b0bec5)",fontSize:11,fontWeight:600,cursor:"pointer"},children:"📋 步骤配置"}),a.jsxs("button",{onClick:()=>j("story"),style:{padding:"4px 10px",borderRadius:4,border:"none",background:S==="story"?"var(--color-accent, #3b82f6)":"transparent",color:S==="story"?"#fff":"var(--text-secondary, #b0bec5)",fontSize:11,fontWeight:600,cursor:"pointer"},children:["📖 运行故事线 (",k.tasks.length,"步)"]})]}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[x&&a.jsx("button",{onClick:()=>v(null),style:{padding:"5px 10px",borderRadius:6,background:"transparent",border:"1px solid var(--border-secondary, rgba(255,255,255,0.2))",color:"var(--text-muted, #94a3b8)",fontSize:12,cursor:"pointer"},children:"清除试跑结果"}),a.jsx("button",{onClick:z,disabled:y||R.length===0,style:{padding:"6px 14px",borderRadius:6,background:"color-mix(in srgb, var(--color-success, #10b981) 20%, transparent)",border:"1px solid color-mix(in srgb, var(--color-success, #10b981) 45%, transparent)",color:"var(--color-success, #10b981)",fontSize:12,fontWeight:600,cursor:y||R.length===0?"not-allowed":"pointer",display:"inline-flex",alignItems:"center",gap:6,transition:"all 0.15s ease"},children:a.jsx("span",{children:y?"⏳ 模拟中...":"▶ 浏览器本地试跑 (零风险)"})})]})]}),S==="story"&&k?a.jsx("div",{style:{flex:1,overflowY:"auto"},children:a.jsx(mg,{instance:k,registry:r,onInspectStep:M=>{j("steps");const I=R.find(F=>F.taskReferenceName===M);I&&l(I.id)}})}):a.jsxs("div",{style:{flex:1,maxWidth:820,width:"100%",margin:"0 auto",padding:"24px 20px",display:"flex",flexDirection:"column",gap:16},children:[R.length===0&&a.jsxs("div",{style:{textAlign:"center",padding:"60px 20px",background:"var(--bg-secondary, #1e293b)",borderRadius:12,border:"1px dashed var(--border-secondary, rgba(255,255,255,0.2))",display:"flex",flexDirection:"column",alignItems:"center",gap:14},children:[a.jsx("span",{style:{fontSize:42},children:"⚡"}),a.jsx("div",{style:{fontWeight:600,fontSize:16,color:"var(--text-primary, #f8fafc)"},children:"尚未添加任何业务动作"}),a.jsx("p",{style:{fontSize:13,color:"var(--text-secondary, #b0bec5)",maxWidth:420,margin:0},children:"无需编写代码或配置复杂的 JSON,点击下方按钮选择第一个云主机业务动作,即可开始自动化编排。"}),a.jsxs("button",{disabled:n,onClick:()=>u(0),style:{marginTop:8,padding:"8px 18px",borderRadius:8,background:"var(--color-accent, #3b82f6)",color:"#fff",border:"none",fontWeight:600,fontSize:13,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:6},children:[a.jsx("span",{children:"+"}),a.jsx("span",{children:"添加第一个业务动作"})]})]}),R.length>0&&!n&&a.jsx("div",{style:{display:"flex",justifyContent:"center"},children:a.jsxs("button",{onClick:()=>u(0),style:{padding:"4px 12px",borderRadius:20,background:"rgba(255,255,255,0.04)",border:"1px dashed var(--border-secondary, rgba(255,255,255,0.2))",color:"var(--text-muted, #94a3b8)",fontSize:11,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4},children:[a.jsx("span",{children:"+"}),a.jsx("span",{children:"在最前插入步骤"})]})}),R.map((M,I)=>{const F=r.getAction(M.actionId),O=i===M.id,J=R.slice(0,I),Z=x?.[M.taskReferenceName];return M.controlType==="decision"?a.jsxs(N.Fragment,{children:[a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 4px"},children:[a.jsxs("span",{style:{fontSize:12,fontWeight:700,color:"color-mix(in srgb, #8b5cf6 75%, var(--text-primary))"},children:["#",I+1," 控制流分支"]}),!n&&a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[a.jsx("button",{disabled:I===0,onClick:()=>D(I,I-1),title:"上移",style:{background:"none",border:"none",color:I===0?"rgba(255,255,255,0.2)":"var(--text-secondary)",cursor:I===0?"default":"pointer",fontSize:13,padding:"2px 4px"},children:"↑"}),a.jsx("button",{disabled:I===R.length-1,onClick:()=>D(I,I+1),title:"下移",style:{background:"none",border:"none",color:I===R.length-1?"rgba(255,255,255,0.2)":"var(--text-secondary)",cursor:I===R.length-1?"default":"pointer",fontSize:13,padding:"2px 4px"},children:"↓"}),a.jsx("button",{onClick:()=>w(I),title:"删除步骤",style:{background:"none",border:"none",color:"#ef4444",cursor:"pointer",fontSize:13,padding:"2px 4px"},children:"🗑️"})]})]}),a.jsx(dg,{step:M,upstreamSteps:J,registry:r,disabled:n,onChange:A=>T(I,A),onOpenInsertModal:E})]}),!n&&a.jsx("div",{style:{display:"flex",justifyContent:"center",margin:"-4px 0"},children:a.jsxs("button",{onClick:()=>u(I+1),style:{padding:"4px 12px",borderRadius:16,background:"var(--bg-tertiary)",border:"1px dashed var(--border-secondary)",color:"var(--text-muted)",fontSize:11,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4,transition:"all 0.15s ease"},onMouseEnter:A=>{A.currentTarget.style.borderColor="var(--color-accent, #3b82f6)",A.currentTarget.style.color="var(--color-accent, #3b82f6)"},onMouseLeave:A=>{A.currentTarget.style.borderColor="var(--border-secondary)",A.currentTarget.style.color="var(--text-muted)"},children:[a.jsx("span",{children:"+"}),a.jsx("span",{children:"插入业务动作"})]})})]},M.id):M.controlType==="fork"?a.jsxs(N.Fragment,{children:[a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 4px"},children:[a.jsxs("span",{style:{fontSize:12,fontWeight:700,color:"var(--color-accent, #3b82f6)"},children:["#",I+1," 并发泳道组"]}),!n&&a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[a.jsx("button",{disabled:I===0,onClick:()=>D(I,I-1),title:"上移",style:{background:"none",border:"none",color:I===0?"rgba(255,255,255,0.2)":"var(--text-secondary)",cursor:I===0?"default":"pointer",fontSize:13,padding:"2px 4px"},children:"↑"}),a.jsx("button",{disabled:I===R.length-1,onClick:()=>D(I,I+1),title:"下移",style:{background:"none",border:"none",color:I===R.length-1?"rgba(255,255,255,0.2)":"var(--text-secondary)",cursor:I===R.length-1?"default":"pointer",fontSize:13,padding:"2px 4px"},children:"↓"}),a.jsx("button",{onClick:()=>w(I),title:"删除步骤",style:{background:"none",border:"none",color:"#ef4444",cursor:"pointer",fontSize:13,padding:"2px 4px"},children:"🗑️"})]})]}),a.jsx(ug,{step:M,upstreamSteps:J,registry:r,disabled:n,onChange:A=>T(I,A),onOpenInsertModal:E})]}),!n&&a.jsx("div",{style:{display:"flex",justifyContent:"center",margin:"-4px 0"},children:a.jsxs("button",{onClick:()=>u(I+1),style:{padding:"4px 12px",borderRadius:16,background:"var(--bg-tertiary)",border:"1px dashed var(--border-secondary)",color:"var(--text-muted)",fontSize:11,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4,transition:"all 0.15s ease"},onMouseEnter:A=>{A.currentTarget.style.borderColor="var(--color-accent, #3b82f6)",A.currentTarget.style.color="var(--color-accent, #3b82f6)"},onMouseLeave:A=>{A.currentTarget.style.borderColor="var(--border-secondary)",A.currentTarget.style.color="var(--text-muted)"},children:[a.jsx("span",{children:"+"}),a.jsx("span",{children:"插入业务动作"})]})})]},M.id):M.controlType==="loop"?a.jsxs(N.Fragment,{children:[a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 4px"},children:[a.jsxs("span",{style:{fontSize:12,fontWeight:700,color:"var(--color-accent, #3b82f6)"},children:["#",I+1," 循环迭代体"]}),!n&&a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[a.jsx("button",{disabled:I===0,onClick:()=>D(I,I-1),title:"上移",style:{background:"none",border:"none",color:I===0?"rgba(255,255,255,0.2)":"var(--text-secondary)",cursor:I===0?"default":"pointer",fontSize:13,padding:"2px 4px"},children:"↑"}),a.jsx("button",{disabled:I===R.length-1,onClick:()=>D(I,I+1),title:"下移",style:{background:"none",border:"none",color:I===R.length-1?"rgba(255,255,255,0.2)":"var(--text-secondary)",cursor:I===R.length-1?"default":"pointer",fontSize:13,padding:"2px 4px"},children:"↓"}),a.jsx("button",{onClick:()=>w(I),title:"删除步骤",style:{background:"none",border:"none",color:"#ef4444",cursor:"pointer",fontSize:13,padding:"2px 4px"},children:"🗑️"})]})]}),a.jsx(pg,{step:M,upstreamSteps:J,registry:r,disabled:n,onChange:A=>T(I,A),onOpenInsertModal:E})]}),!n&&a.jsx("div",{style:{display:"flex",justifyContent:"center",margin:"-4px 0"},children:a.jsxs("button",{onClick:()=>u(I+1),style:{padding:"4px 12px",borderRadius:16,background:"var(--bg-tertiary)",border:"1px dashed var(--border-secondary)",color:"var(--text-muted)",fontSize:11,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4,transition:"all 0.15s ease"},onMouseEnter:A=>{A.currentTarget.style.borderColor="var(--color-accent, #3b82f6)",A.currentTarget.style.color="var(--color-accent, #3b82f6)"},onMouseLeave:A=>{A.currentTarget.style.borderColor="var(--border-secondary)",A.currentTarget.style.color="var(--text-muted)"},children:[a.jsx("span",{children:"+"}),a.jsx("span",{children:"插入业务动作"})]})})]},M.id):a.jsxs(N.Fragment,{children:[a.jsxs("div",{style:{background:"var(--bg-secondary, #1e293b)",borderRadius:10,border:O?"1px solid var(--color-accent, #3b82f6)":"1px solid var(--border-primary, rgba(255,255,255,0.12))",boxShadow:O?"0 8px 24px rgba(59, 130, 246, 0.15)":"0 4px 12px rgba(0,0,0,0.15)",overflow:"hidden",transition:"all 0.2s ease"},children:[a.jsxs("div",{onClick:()=>l(O?null:M.id),style:{padding:"12px 16px",display:"flex",alignItems:"center",justifyContent:"space-between",cursor:"pointer",userSelect:"none",background:O?"rgba(59, 130, 246, 0.05)":"transparent"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,flex:1,overflow:"hidden"},children:[a.jsxs("div",{style:{width:28,height:28,borderRadius:6,background:"var(--bg-primary, #0f172a)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:12,fontWeight:700,color:"var(--color-accent, #3b82f6)",border:"1px solid var(--border-primary, rgba(255,255,255,0.1))"},children:["#",I+1]}),a.jsx("span",{style:{fontSize:20},children:F?.icon||"⚙️"}),a.jsxs("div",{style:{overflow:"hidden"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[a.jsx("span",{style:{fontWeight:600,fontSize:14,color:"var(--text-primary, #f8fafc)"},children:M.name||F?.name||M.taskReferenceName}),F?.riskLevel==="sensitive"&&a.jsx("span",{style:{fontSize:10,padding:"1px 5px",borderRadius:4,background:"rgba(239, 68, 68, 0.15)",color:"#f87171",fontWeight:600},children:"⚠️ 敏感"}),Z&&a.jsx("span",{style:{fontSize:11,padding:"1px 6px",borderRadius:4,background:"rgba(16, 185, 129, 0.2)",color:"#34d399",fontWeight:600},children:"✓ 试跑成功"})]}),a.jsx("div",{style:{fontSize:11,color:"var(--text-muted, #94a3b8)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:F?.description||M.description||M.taskReferenceName})]})]}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},onClick:A=>A.stopPropagation(),children:[!n&&a.jsxs(a.Fragment,{children:[a.jsx("button",{disabled:I===0,onClick:()=>D(I,I-1),title:"上移",style:{background:"none",border:"none",color:I===0?"rgba(255,255,255,0.2)":"var(--text-secondary, #b0bec5)",cursor:I===0?"default":"pointer",fontSize:14,padding:"4px"},children:"↑"}),a.jsx("button",{disabled:I===R.length-1,onClick:()=>D(I,I+1),title:"下移",style:{background:"none",border:"none",color:I===R.length-1?"rgba(255,255,255,0.2)":"var(--text-secondary, #b0bec5)",cursor:I===R.length-1?"default":"pointer",fontSize:14,padding:"4px"},children:"↓"}),a.jsx("button",{onClick:()=>w(I),title:"删除步骤",style:{background:"none",border:"none",color:"#ef4444",cursor:"pointer",fontSize:14,padding:"4px"},children:"🗑️"})]}),a.jsx("span",{style:{fontSize:12,color:"var(--text-muted, #94a3b8)",transform:O?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease"},children:"▼"})]})]}),O&&a.jsx("div",{style:{padding:"14px 16px",borderTop:"1px solid var(--border-primary)",background:"var(--bg-primary)"},children:a.jsx(Ut,{step:M,upstreamSteps:J,registry:r,disabled:n,onChange:A=>T(I,A)})})]}),!n&&a.jsx("div",{style:{display:"flex",justifyContent:"center",margin:"-4px 0"},children:a.jsxs("button",{onClick:()=>u(I+1),style:{padding:"4px 12px",borderRadius:16,background:"var(--bg-tertiary)",border:"1px dashed var(--border-secondary)",color:"var(--text-muted)",fontSize:11,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4,transition:"all 0.15s ease"},onMouseEnter:A=>{A.currentTarget.style.borderColor="var(--color-accent, #3b82f6)",A.currentTarget.style.color="var(--color-accent, #3b82f6)"},onMouseLeave:A=>{A.currentTarget.style.borderColor="var(--border-secondary)",A.currentTarget.style.color="var(--text-muted)"},children:[a.jsx("span",{children:"+"}),a.jsx("span",{children:"插入业务动作"})]})})]},M.id)})]}),c!==null&&typeof document<"u"&&Ye.createPortal(a.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.68)",backdropFilter:"blur(5px)",zIndex:2e3,display:"flex",alignItems:"center",justifyContent:"center",padding:24,fontFamily:"inherit"},onClick:()=>u(null),children:a.jsxs("div",{onClick:M=>M.stopPropagation(),style:{width:680,maxWidth:"calc(100vw - 48px)",maxHeight:"82vh",background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",borderRadius:14,boxShadow:"0 24px 64px rgba(0,0,0,0.45)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[a.jsxs("div",{style:{padding:"14px 20px",borderBottom:"1px solid var(--border-primary)",display:"flex",alignItems:"center",justifyContent:"space-between",background:"var(--bg-primary)"},children:[a.jsxs("div",{style:{fontWeight:600,fontSize:15,color:"var(--text-primary)"},children:["选择要插入的业务动作 (第 ",c+1," 步)"]}),a.jsx("button",{onClick:()=>u(null),style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:16,padding:4},children:"✕"})]}),a.jsxs("div",{style:{padding:"10px 18px",borderBottom:"1px solid var(--border-primary)",display:"flex",gap:10,alignItems:"center",background:"var(--bg-tertiary)"},children:[a.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap",flex:1},children:[{id:"all",label:"全部动作"},{id:"compute",label:"🖥️ 计算与主机"},{id:"storage",label:"💾 存储快照"},{id:"monitor",label:"📊 监控指标"},{id:"notify",label:"📢 通知消息"},{id:"human",label:"👤 人工审批"},{id:"logic",label:"⏳ 流程控制"}].map(M=>a.jsx("button",{onClick:()=>f(M.id),style:{padding:"4px 10px",borderRadius:6,background:h===M.id?"var(--color-accent, #3b82f6)":"transparent",color:h===M.id?"#fff":"var(--text-secondary)",border:"none",fontSize:12,cursor:"pointer",fontWeight:h===M.id?600:400},children:M.label},M.id))}),a.jsx("input",{type:"text",placeholder:"搜索动作...",value:m,onChange:M=>g(M.target.value),style:{width:150,padding:"5px 10px",borderRadius:6,background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",color:"var(--text-primary)",fontSize:12,outline:"none"}})]}),a.jsx("div",{style:{flex:1,overflowY:"auto",padding:"14px 18px",display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:12},children:K.map(M=>a.jsxs("div",{onClick:()=>C(M,c),style:{padding:"12px 14px",borderRadius:8,background:"var(--bg-primary)",border:"1px solid var(--border-primary)",cursor:"pointer",display:"flex",flexDirection:"column",gap:6,transition:"all 0.15s ease"},onMouseEnter:I=>{I.currentTarget.style.borderColor="var(--color-accent, #3b82f6)",I.currentTarget.style.transform="translateY(-2px)"},onMouseLeave:I=>{I.currentTarget.style.borderColor="var(--border-primary)",I.currentTarget.style.transform="translateY(0)"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[a.jsx("span",{style:{fontSize:20},children:M.icon}),a.jsx("span",{style:{fontWeight:600,fontSize:13,color:"var(--text-primary)"},children:M.name})]}),M.riskLevel==="sensitive"&&a.jsx("span",{style:{fontSize:10,padding:"1px 5px",borderRadius:4,background:"color-mix(in srgb, var(--status-failed, #ef4444) 15%, transparent)",color:"var(--status-failed, #ef4444)",fontWeight:600},children:"⚠️ 敏感"})]}),a.jsx("div",{style:{fontSize:11,color:"var(--text-muted)",lineHeight:1.4},children:M.description})]},M.id))})]})}),document.body)]})};function p0(e,t,r){if(!e||!t)return;const n=t.replace(/\[(\d+)\]/g,".$1").split(".").filter(Boolean);let s=e;for(let i=0;i<n.length-1;i++){const l=n[i];if(s[l]===void 0||s[l]===null){const c=n[i+1];s[l]=/^\d+$/.test(c)?[]:{}}s=s[l]}const o=n[n.length-1];s[o]=r}function Nl(e,t){const r=structuredClone(e.definition);for(const n of e.variables){const s=t[n.key]??n.defaultValue;if(s!==void 0)for(const o of n.bindings)p0(r,o,s)}return r}const yg=({template:e,onApply:t,onClose:r})=>{const[n,s]=N.useState(1),[o,i]=N.useState(()=>{const m={};for(const g of e.variables)g.defaultValue!==void 0&&(m[g.key]=g.defaultValue);return m}),[l,c]=N.useState(!1),[u,d]=N.useState(null),p=(m,g)=>{i(y=>({...y,[m]:g}))},h=()=>{c(!0);try{const m=Nl(e,o),g=e.mockDataset.scenarios[0],y=$t(m,{workflowInput:g?.workflowInput||{},taskMocks:g?.taskOutputs||{}});y.status==="COMPLETED"?d(`全部 ${y.tasks.length} 个步骤在浏览器本地顺利模拟通过,各上游数据与通知已正确串联。`):d(`模拟运行结束,状态为: ${y.status}`)}catch(m){d(`模拟试跑出错: ${m.message}`)}finally{c(!1)}},f=()=>{const m=Nl(e,o);t(m),r()};return typeof document>"u"?null:Ye.createPortal(a.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0, 0, 0, 0.72)",backdropFilter:"blur(5px)",zIndex:1300,display:"flex",alignItems:"center",justifyContent:"center",padding:20,fontFamily:"inherit"},onClick:r,children:a.jsxs("div",{onClick:m=>m.stopPropagation(),style:{width:680,maxHeight:"85vh",background:"var(--bg-secondary, #1e293b)",border:"1px solid var(--border-secondary, rgba(255, 255, 255, 0.2))",borderRadius:14,boxShadow:"0 24px 64px rgba(0, 0, 0, 0.6)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[a.jsxs("div",{style:{padding:"14px 20px",borderBottom:"1px solid var(--border-primary, rgba(255, 255, 255, 0.1))",display:"flex",alignItems:"center",justifyContent:"space-between",background:"var(--bg-primary, #0f172a)"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[a.jsx("span",{style:{fontSize:22},children:e.icon}),a.jsxs("div",{children:[a.jsx("div",{style:{fontWeight:600,fontSize:15,color:"var(--text-primary, #f8fafc)"},children:e.title}),a.jsx("div",{style:{fontSize:11,color:"var(--text-muted, #94a3b8)"},children:"3 步填空式模板快速启用向导"})]})]}),a.jsx("button",{onClick:r,style:{background:"none",border:"none",color:"var(--text-muted, #94a3b8)",cursor:"pointer",fontSize:16},children:"✕"})]}),a.jsx("div",{style:{padding:"10px 20px",background:"rgba(0,0,0,0.15)",borderBottom:"1px solid var(--border-primary, rgba(255, 255, 255, 0.08))",display:"flex",alignItems:"center",justifyContent:"center",gap:24},children:[{step:1,label:"1. 了解方案"},{step:2,label:"2. 参数填空"},{step:3,label:"3. 试跑验证与激活"}].map(m=>{const g=n===m.step,y=n>m.step;return a.jsxs("div",{onClick:()=>y&&s(m.step),style:{display:"flex",alignItems:"center",gap:6,cursor:y?"pointer":"default",opacity:g||y?1:.5},children:[a.jsx("div",{style:{width:22,height:22,borderRadius:11,background:y?"var(--color-success, #10b981)":g?"var(--color-accent, #3b82f6)":"rgba(255,255,255,0.1)",color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:700},children:y?"✓":m.step}),a.jsx("span",{style:{fontSize:12,fontWeight:g?600:400,color:g?"var(--text-primary, #f8fafc)":"var(--text-secondary, #b0bec5)"},children:m.label})]},m.step)})}),a.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px"},children:[n===1&&a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[a.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:12},children:[a.jsxs("div",{style:{padding:"12px 14px",borderRadius:8,background:"rgba(16, 185, 129, 0.1)",border:"1px solid rgba(16, 185, 129, 0.25)"},children:[a.jsx("div",{style:{fontSize:11,color:"#34d399"},children:"⚡ 预期单次节省人工"}),a.jsxs("div",{style:{fontSize:20,fontWeight:700,color:"#10b981",marginTop:4},children:["约 ",e.roi.minutesSavedPerRun," 分钟"]})]}),a.jsxs("div",{style:{padding:"12px 14px",borderRadius:8,background:"rgba(59, 130, 246, 0.1)",border:"1px solid rgba(59, 130, 246, 0.25)"},children:[a.jsx("div",{style:{fontSize:11,color:"#60a5fa"},children:"🔄 典型每周频次"}),a.jsxs("div",{style:{fontSize:20,fontWeight:700,color:"#3b82f6",marginTop:4},children:["约 ",e.roi.typicalRunsPerWeek," 次 / 周"]})]}),a.jsxs("div",{style:{padding:"12px 14px",borderRadius:8,background:"rgba(245, 158, 11, 0.1)",border:"1px solid rgba(245, 158, 11, 0.25)"},children:[a.jsx("div",{style:{fontSize:11,color:"#fbbf24"},children:"🔥 累计被采用"}),a.jsxs("div",{style:{fontSize:20,fontWeight:700,color:"#f59e0b",marginTop:4},children:[e.roi.popularityCount??1200," 次"]})]})]}),a.jsxs("div",{style:{padding:"12px 16px",borderRadius:8,background:"var(--bg-primary, #0f172a)",border:"1px solid var(--border-primary, rgba(255,255,255,0.1))",lineHeight:1.6},children:[a.jsx("div",{style:{fontWeight:600,color:"var(--text-primary, #f8fafc)",fontSize:13,marginBottom:4},children:"💡 解决的痛点"}),a.jsx("div",{style:{fontSize:13,color:"var(--text-secondary, #b0bec5)"},children:e.valueProposition}),a.jsx("p",{style:{fontSize:12,color:"var(--text-muted, #94a3b8)",margin:"8px 0 0 0"},children:e.description})]}),a.jsxs("div",{children:[a.jsxs("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-muted, #94a3b8)",marginBottom:8},children:["包含的标准步骤流程 (",e.definition.tasks?.length??0," 个步骤):"]}),a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:e.definition.tasks?.map((m,g)=>a.jsxs("div",{style:{padding:"8px 12px",borderRadius:6,background:"rgba(255,255,255,0.03)",border:"1px solid var(--border-primary, rgba(255,255,255,0.08))",display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:12},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[a.jsxs("span",{style:{color:"var(--color-accent, #3b82f6)",fontWeight:600},children:["#",g+1]}),a.jsx("span",{style:{color:"var(--text-primary, #f8fafc)"},children:m.description||m.name})]}),a.jsx("span",{style:{fontSize:10,color:"var(--text-muted, #94a3b8)",fontFamily:"monospace"},children:m.taskReferenceName})]},m.taskReferenceName))})]})]}),n===2&&a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[a.jsxs("div",{style:{padding:"8px 12px",borderRadius:6,background:"rgba(59, 130, 246, 0.08)",border:"1px solid rgba(59, 130, 246, 0.25)",fontSize:12,color:"#93c5fd"},children:["✏️ ",a.jsx("strong",{children:"开箱即用填空"}),":无需修改复杂的流程连线与 JSON,仅需确认以下几个业务变量即可:"]}),e.variables.map(m=>{const g=o[m.key]??m.defaultValue;return a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[a.jsxs("label",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary, #f8fafc)",display:"flex",alignItems:"center",gap:4},children:[m.label,m.required&&a.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),m.type==="select"?a.jsx("select",{value:g??"",onChange:y=>p(m.key,y.target.value),style:{padding:"8px 10px",borderRadius:6,background:"var(--bg-primary, #0f172a)",border:"1px solid var(--border-secondary, rgba(255,255,255,0.2))",color:"var(--text-primary, #f8fafc)",fontSize:13,outline:"none"},children:m.options?.map(y=>a.jsx("option",{value:y.value,children:y.label},y.value))}):m.type==="boolean"?a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13,color:"var(--text-secondary, #b0bec5)"},children:[a.jsx("input",{type:"checkbox",checked:!!g,onChange:y=>p(m.key,y.target.checked),style:{width:16,height:16}}),a.jsx("span",{children:"开启启用"})]}):a.jsx("input",{type:m.type==="number"?"number":"text",value:g??"",placeholder:m.placeholder,onChange:y=>p(m.key,m.type==="number"?Number(y.target.value):y.target.value),style:{padding:"8px 10px",borderRadius:6,background:"var(--bg-primary, #0f172a)",border:"1px solid var(--border-secondary, rgba(255,255,255,0.2))",color:"var(--text-primary, #f8fafc)",fontSize:13,outline:"none"}}),m.help&&a.jsx("div",{style:{fontSize:11,color:"var(--text-muted, #94a3b8)"},children:m.help})]},m.key)})]}),n===3&&a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[a.jsxs("div",{style:{padding:"12px 14px",borderRadius:8,background:"var(--bg-primary, #0f172a)",border:"1px solid var(--border-primary, rgba(255,255,255,0.1))",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[a.jsxs("div",{children:[a.jsx("div",{style:{fontWeight:600,color:"var(--text-primary, #f8fafc)",fontSize:13},children:"零风险浏览器沙盒试跑"}),a.jsx("div",{style:{fontSize:11,color:"var(--text-muted, #94a3b8)",marginTop:2},children:"使用内置的保真云主机 Mock 数据,无需真实生产权限即可预览完整数据流转"})]}),a.jsx("button",{onClick:h,disabled:l,style:{padding:"6px 14px",borderRadius:6,background:"var(--color-accent, #3b82f6)",color:"#fff",border:"none",fontWeight:600,fontSize:12,cursor:l?"not-allowed":"pointer"},children:l?"⏳ 模拟试跑中...":"▶ 立即试跑验证"})]}),u&&a.jsxs("div",{style:{padding:"12px 14px",borderRadius:8,background:"rgba(16, 185, 129, 0.1)",border:"1px solid rgba(16, 185, 129, 0.3)",color:"#34d399",fontSize:12,lineHeight:1.5},children:["🎉 ",a.jsx("strong",{children:"试跑通过"}),": ",u]}),a.jsxs("div",{style:{padding:"12px 14px",borderRadius:8,background:"rgba(255,255,255,0.03)",border:"1px solid var(--border-primary, rgba(255,255,255,0.08))"},children:[a.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-muted, #94a3b8)",marginBottom:8},children:"已配置的业务变量参数清单:"}),a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:e.variables.map(m=>a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:12,padding:"4px 0",borderBottom:"1px dashed rgba(255,255,255,0.06)"},children:[a.jsxs("span",{style:{color:"var(--text-secondary, #b0bec5)"},children:[m.label,":"]}),a.jsx("span",{style:{color:"var(--color-accent, #3b82f6)",fontWeight:600},children:String(o[m.key]??m.defaultValue)})]},m.key))})]})]})]}),a.jsxs("div",{style:{padding:"12px 20px",borderTop:"1px solid var(--border-primary, rgba(255, 255, 255, 0.1))",background:"var(--bg-primary, #0f172a)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[n>1?a.jsx("button",{onClick:()=>s(m=>m-1),style:{padding:"6px 14px",borderRadius:6,background:"transparent",border:"1px solid var(--border-secondary, rgba(255,255,255,0.2))",color:"var(--text-secondary, #b0bec5)",fontSize:12,cursor:"pointer"},children:"← 上一步"}):a.jsx("div",{}),a.jsx("div",{style:{display:"flex",gap:10},children:n<3?a.jsx("button",{onClick:()=>s(m=>m+1),style:{padding:"6px 16px",borderRadius:6,background:"var(--color-accent, #3b82f6)",color:"#fff",border:"none",fontSize:12,fontWeight:600,cursor:"pointer"},children:"下一步 →"}):a.jsxs("button",{onClick:f,style:{padding:"6px 18px",borderRadius:6,background:"var(--color-success, #10b981)",color:"#fff",border:"none",fontSize:12,fontWeight:600,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:6},children:[a.jsx("span",{children:"⚡"}),a.jsx("span",{children:"注入参数并进入流程编辑器"})]})})]})]})}),document.body)},xg=({isOpen:e,onClose:t,onSelectTemplate:r,templateStore:n=Tl})=>{const[s,o]=N.useState("all"),[i,l]=N.useState(""),[c,u]=N.useState(null),[d,p]=N.useState(null),h=N.useMemo(()=>n.search(i,s),[n,i,s]);if(!e||typeof document>"u")return null;const f=m=>{try{const g=m.mockDataset.scenarios[0],y=$t(m.definition,{workflowInput:g?.workflowInput||{},taskMocks:g?.taskOutputs||{}});p(`《${m.title}》在本地沙盒试跑通过!共执行 ${y.tasks.length} 个任务节点,状态: ${y.status}。点击「使用模板」即可完成填空并上屏编辑。`)}catch(g){p(`试跑出错: ${g.message}`)}};return Ye.createPortal(a.jsxs("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0, 0, 0, 0.72)",backdropFilter:"blur(5px)",zIndex:1250,display:"flex",alignItems:"center",justifyContent:"center",padding:24,fontFamily:"inherit"},onClick:t,children:[a.jsxs("div",{onClick:m=>m.stopPropagation(),style:{width:980,maxWidth:"92vw",height:"84vh",background:"var(--bg-secondary, #1e293b)",border:"1px solid var(--border-secondary, rgba(255, 255, 255, 0.2))",borderRadius:16,boxShadow:"0 28px 72px rgba(0, 0, 0, 0.65)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[a.jsxs("div",{style:{padding:"16px 24px",borderBottom:"1px solid var(--border-primary, rgba(255, 255, 255, 0.1))",display:"flex",alignItems:"center",justifyContent:"space-between",background:"var(--bg-primary, #0f172a)"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[a.jsx("span",{style:{fontSize:24},children:"📁"}),a.jsxs("div",{children:[a.jsx("div",{style:{fontWeight:700,fontSize:16,color:"var(--text-primary, #f8fafc)"},children:"场景化工作流模板中心"}),a.jsx("div",{style:{fontSize:12,color:"var(--text-muted, #94a3b8)"},children:"源于真实云平台高价值运维实战萃取 · 拒绝空白画布 · 开箱即用"})]})]}),a.jsx("button",{onClick:t,style:{background:"none",border:"none",color:"var(--text-muted, #94a3b8)",cursor:"pointer",fontSize:18,padding:"4px"},children:"✕"})]}),a.jsxs("div",{style:{padding:"10px 24px",borderBottom:"1px solid var(--border-primary, rgba(255, 255, 255, 0.08))",display:"flex",alignItems:"center",justifyContent:"space-between",gap:16,background:"rgba(0, 0, 0, 0.15)"},children:[a.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[{id:"all",label:"全部场景 (8)"},{id:"compute",label:"🖥️ 交付与计算"},{id:"security",label:"💾 安全与容灾"},{id:"ops",label:"⚡ 运维与自愈"},{id:"cost",label:"🌙 节能与降本"}].map(m=>a.jsx("button",{onClick:()=>o(m.id),style:{padding:"5px 12px",borderRadius:6,background:s===m.id?"var(--color-accent, #3b82f6)":"transparent",color:s===m.id?"#fff":"var(--text-secondary, #b0bec5)",border:"none",fontSize:12,cursor:"pointer",fontWeight:s===m.id?600:400,transition:"all 0.15s ease"},children:m.label},m.id))}),a.jsx("input",{type:"text",placeholder:"搜索模板名称、痛点或场景...",value:i,onChange:m=>l(m.target.value),style:{width:220,padding:"6px 12px",borderRadius:6,background:"var(--bg-primary, #0f172a)",border:"1px solid var(--border-secondary, rgba(255, 255, 255, 0.2))",color:"var(--text-primary, #f8fafc)",fontSize:12,outline:"none"}})]}),d&&a.jsxs("div",{style:{margin:"12px 24px 0 24px",padding:"10px 14px",borderRadius:8,background:"rgba(16, 185, 129, 0.12)",border:"1px solid rgba(16, 185, 129, 0.35)",color:"#34d399",fontSize:12,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[a.jsxs("div",{children:["✨ ",d]}),a.jsx("button",{onClick:()=>p(null),style:{background:"none",border:"none",color:"#34d399",cursor:"pointer",fontSize:12},children:"关闭"})]}),a.jsx("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px",display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:16},children:h.map(m=>a.jsxs("div",{style:{borderRadius:12,background:"var(--bg-primary, #0f172a)",border:"1px solid var(--border-primary, rgba(255, 255, 255, 0.12))",padding:"16px 18px",display:"flex",flexDirection:"column",justifyContent:"space-between",gap:12,transition:"all 0.2s ease"},onMouseEnter:g=>{g.currentTarget.style.borderColor="var(--color-accent, #3b82f6)",g.currentTarget.style.transform="translateY(-2px)",g.currentTarget.style.boxShadow="0 8px 24px rgba(0, 0, 0, 0.3)"},onMouseLeave:g=>{g.currentTarget.style.borderColor="rgba(255, 255, 255, 0.12)",g.currentTarget.style.transform="translateY(0)",g.currentTarget.style.boxShadow="none"},children:[a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[a.jsx("span",{style:{fontSize:26},children:m.icon}),a.jsx("span",{style:{fontWeight:600,fontSize:14,color:"var(--text-primary, #f8fafc)"},children:m.title})]}),a.jsx("span",{style:{fontSize:10,padding:"2px 6px",borderRadius:4,background:"rgba(255, 255, 255, 0.08)",color:"var(--text-muted, #94a3b8)",fontWeight:500},children:m.difficulty==="starter"?"入门":m.difficulty==="intermediate"?"进阶":"专业"})]}),a.jsx("div",{style:{fontSize:12,color:"var(--text-secondary, #b0bec5)",lineHeight:1.5},children:m.valueProposition})]}),a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[a.jsxs("span",{style:{fontSize:11,padding:"2px 7px",borderRadius:4,background:"rgba(16, 185, 129, 0.15)",color:"#34d399",fontWeight:600},children:["⚡ 单次约省 ",m.roi.minutesSavedPerRun," 分钟"]}),a.jsxs("span",{style:{fontSize:11,padding:"2px 7px",borderRadius:4,background:"rgba(59, 130, 246, 0.15)",color:"#60a5fa"},children:["🔥 已使用 ",m.roi.popularityCount??1e3," 次"]})]}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:4},children:[a.jsxs("button",{onClick:()=>f(m),style:{flex:1,padding:"6px 10px",borderRadius:6,background:"rgba(255, 255, 255, 0.05)",border:"1px solid var(--border-secondary, rgba(255, 255, 255, 0.15))",color:"var(--text-secondary, #b0bec5)",fontSize:12,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:4},children:[a.jsx("span",{children:"▶"}),a.jsx("span",{children:"试跑演示"})]}),a.jsxs("button",{onClick:()=>u(m),style:{flex:1.2,padding:"6px 12px",borderRadius:6,background:"var(--color-accent, #3b82f6)",color:"#fff",border:"none",fontSize:12,fontWeight:600,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:4},children:[a.jsx("span",{children:"⚡"}),a.jsx("span",{children:"使用此模板"})]})]})]})]},m.id))})]}),c&&a.jsx(yg,{template:c,onClose:()=>u(null),onApply:m=>{u(null),r(m),t()}})]}),document.body)},bg=N.forwardRef(({workflowDef:e,readOnly:t=!1,theme:r="dark",themeColor:n="blue",layoutDirection:s="LR",searchQuery:o="",workflowExecution:i,onRequestImport:l,executionActions:c,aiConfig:u,viewMode:d="developer",uiMode:p="pro",actions:h,onSave:f,onWorkflowChange:m,height:g="100%",onTriggerExecution:y,onPollExecution:b,executionPollInterval:x=3e3},v)=>{const[k,_]=N.useState("card"),[S,j]=N.useState(!1),R=N.useMemo(()=>{if(!h||h.length===0)return Le;const se=new Cl(Le.getAllActions());return se.registerAll(h),se},[h]),{setWorkflow:L,setTheme:T,setThemeColor:w,setLayoutDirection:D,setNodesLocked:E,selectedTask:C,setSelectedTask:z,edgeType:W,importExecutionJSON:K,setMode:M,setViewMode:I,isDetailPanelOpen:F,setIsDetailPanelOpen:O,selectTaskAction:J,workflowDef:Z,isSimRunning:A,startSimulation:B,stopSimulation:U,mode:H,setShowRunPanel:X,showAnalysisPanel:ie,setShowAnalysisPanel:ge,executionData:Se,workflowInstance:we}=le(),$=N.useCallback(()=>{if(!Z)return;const se=new Blob([JSON.stringify(Z,null,2)],{type:"application/json"}),re=URL.createObjectURL(se),ve=document.createElement("a");ve.href=re,ve.download=`${Z.name||"workflow"}.json`,ve.click(),URL.revokeObjectURL(re)},[Z]),ke=N.useCallback(()=>{Z&&navigator.clipboard.writeText(JSON.stringify(Z,null,2))},[Z]);N.useEffect(()=>{T(r),w(n),D(s),E(t||!!i)},[r,n,s,t,i,T,w,D,E]),N.useEffect(()=>{I(i?"developer":d)},[d,i,I]),N.useEffect(()=>{e&&(L(e,s),le.temporal.getState().clear())},[e,L,s]),N.useEffect(()=>{i?K(i):M(t?"view":"edit")},[i,K,M,t]),N.useImperativeHandle(v,()=>({getWorkflowDef:()=>le.getState().workflowDef,getValidationResults:()=>le.getState().validationResults,save:()=>{const se=le.getState().workflowDef;se&&f&&f(se)},createBlankWorkflow:se=>{le.getState().createBlankWorkflow(se),le.temporal.getState().clear()}}),[f]),N.useEffect(()=>{if(!m)return;let se=!0,re=le.getState().workflowDef;return le.subscribe(ue=>{const pe=ue.workflowDef;if(pe!==re){if(re=pe,se){se=!1;return}pe&&m(pe)}})},[m]);const te=se=>{H!=="run"&&!i?J(se,!0):z(se)};return a.jsxs("div",{className:`workflow-ide ${r==="light"?"light-theme":""}`,"data-mode":r,"data-brand":n,style:{width:"100%",height:g,display:"flex",flexDirection:"column",position:"relative",overflow:"hidden"},children:[a.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:[p==="business"&&H!=="run"&&a.jsxs("div",{style:{display:"inline-flex",background:"rgba(255, 255, 255, 0.06)",borderRadius:6,padding:2,border:"1px solid var(--border-secondary)"},children:[a.jsx("button",{onClick:()=>_("card"),style:{height:24,padding:"0 8px",borderRadius:4,border:"none",background:k==="card"?"var(--color-accent)":"transparent",color:k==="card"?"#fff":"var(--text-secondary)",cursor:"pointer",fontSize:11,fontWeight:500,display:"inline-flex",alignItems:"center",gap:4},children:"📋 业务卡片流"}),a.jsx("button",{onClick:()=>_("canvas"),style:{height:24,padding:"0 8px",borderRadius:4,border:"none",background:k==="canvas"?"var(--color-accent)":"transparent",color:k==="canvas"?"#fff":"var(--text-secondary)",cursor:"pointer",fontSize:11,fontWeight:500,display:"inline-flex",alignItems:"center",gap:4},children:"🕸️ 全景画布"})]}),a.jsx("div",{style:{flex:1}}),H!=="run"&&a.jsxs("button",{onClick:()=>j(!0),style:{height:28,padding:"0 10px",background:"color-mix(in srgb, var(--color-brand-blue) 15%, transparent)",color:"var(--color-brand-blue)",border:"1px solid color-mix(in srgb, var(--color-brand-blue) 40%, transparent)",borderRadius:6,cursor:"pointer",fontSize:12,fontWeight:600,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"打开场景化工作流模板中心",children:[a.jsx("span",{children:"📁"}),a.jsx("span",{children:"模板中心"})]}),H==="edit"&&Z&&a.jsxs("button",{onClick:()=>X(!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:[a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"currentColor",children:a.jsx("path",{d:"M4 3l9 5-9 5z"})}),"执行验证"]}),H==="run"&&Se&&a.jsxs("button",{onClick:()=>ge(!ie),style:{height:28,padding:"0 10px",background:ie?"color-mix(in srgb, var(--color-accent) 20%, transparent)":"transparent",color:ie?"var(--color-accent)":"var(--text-secondary)",border:`1px solid ${ie?"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:[a.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[a.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"2"}),a.jsx("path",{d:"M5 8h6M5 5h3M5 11h4"})]}),"分析"]}),H!=="run"&&Z&&(A?a.jsxs("button",{onClick:U,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:[a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"currentColor",children:a.jsx("rect",{x:"4",y:"4",width:"8",height:"8",rx:"1"})}),"停止"]}):a.jsxs("button",{onClick:B,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:[a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"currentColor",children:a.jsx("path",{d:"M4 3l9 5-9 5z"})}),"模拟运行"]})),Z&&a.jsxs(a.Fragment,{children:[a.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:"导出工作流 JSON 文件",children:[a.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:a.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"]}),a.jsxs("button",{onClick:ke,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:[a.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[a.jsx("rect",{x:"4",y:"4",width:"9",height:"10",rx:"1"}),a.jsx("path",{d:"M2 10V3a1 1 0 0 1 1-1h7",strokeLinecap:"round"})]}),"复制 DSL"]})]})]}),p==="business"&&k==="card"?a.jsx("div",{style:{flex:1,position:"relative",overflow:"hidden"},children:a.jsx(gg,{workflowDef:Z,workflowExecution:we??void 0,registry:R,readOnly:t||H==="run",onChange:se=>{L(se,s)}})}):a.jsx("div",{className:"workflow-viewer",style:{flex:1,position:"relative",overflow:"hidden"},children:a.jsx(q.ReactFlowProvider,{children:a.jsx(L1,{onNodeClick:te,edgeType:W,theme:r,nodesLocked:t||H==="run"||!!i,searchQuery:o,onSave:f,onRequestImport:l,executionActions:c})})}),a.jsx(H1,{task:C,isOpen:F&&H!=="run",onClose:()=>O(!1),theme:r,aiConfig:u}),(i||H==="run")&&a.jsx(K1,{executionActions:c}),a.jsx(t0,{aiConfig:u}),a.jsx(n0,{onTriggerExecution:y,onPollExecution:b,executionPollInterval:x}),H==="run"&&a.jsx(c0,{}),a.jsx(xg,{isOpen:S,onClose:()=>j(!1),onSelectTemplate:se=>{L(se,s)}})]})});bg.displayName="WorkflowIDE",ce.ActionForm=Ut,ce.ActionRegistry=Cl,ce.BUILTIN_COMMON_ACTIONS=og,ce.BUILTIN_ECS_ACTIONS=sg,ce.BUILTIN_WORKFLOW_TEMPLATES=eg,ce.DataPillInput=cg,ce.DecisionBranchCard=dg,ce.ForkJoinCard=ug,ce.FriendlyErrorCard=hg,ce.LoopDoWhileCard=pg,ce.RunStoryTimeline=mg,ce.StepFlowEditor=gg,ce.TemplateExtractor=rg,ce.TemplateGallery=xg,ce.TemplateSetupWizard=yg,ce.TemplateStore=tg,ce.WorkflowIDE=bg,ce.analyzeTasksForPruning=Xm,ce.applyTaskPruning=Zm,ce.applyTemplateVariables=Nl,ce.buildDataFlowGraph=hm,ce.buildDefaultWorkflowMockInput=zt,ce.compileStepModelToWorkflowDef=ig,ce.compileStepToTaskDef=It,ce.decompileTaskDefToStep=Tt,ce.decompileWorkflowDefToStepModel=lg,ce.defaultActionRegistry=Le,ce.defaultTemplateStore=Tl,ce.executeLocalSandboxDryRun=$t,ce.extractTemplateFromInstance=Qm,ce.generateDefaultTaskOutputPreview=yr,ce.getCompletionItems=fm,ce.getUpstreamAncestors=gl,ce.inferTaskOutputSchema=pm,ce.parseWorkflowInputParams=qt,ce.refactorTaskReferenceName=mm,ce.scanObjectForSensitiveFindings=_r,ce.scanWorkflowDef=Gm,ce.translateTechnicalError=fg,Object.defineProperty(ce,Symbol.toStringTag,{value:"Module"})}));
|