@yiyi_zhang/reactflow-ui 0.1.0 → 0.3.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.
@@ -1,199 +1,34 @@
1
- (function(Se,D){typeof exports=="object"&&typeof module<"u"?D(exports,require("react"),require("reactflow")):typeof define=="function"&&define.amd?define(["exports","react","reactflow"],D):(Se=typeof globalThis<"u"?globalThis:Se||self,D(Se.ReactflowUI={},Se.React,Se.ReactFlow))})(this,(function(Se,D,q){"use strict";var sr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ch(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ur={exports:{}},Ke={};var ks;function Nh(){if(ks)return Ke;ks=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function r(n,a,i){var o=null;if(i!==void 0&&(o=""+i),a.key!==void 0&&(o=""+a.key),"key"in a){i={};for(var s in a)s!=="key"&&(i[s]=a[s])}else i=a;return a=i.ref,{$$typeof:e,type:n,key:o,ref:a!==void 0?a:null,props:i}}return Ke.Fragment=t,Ke.jsx=r,Ke.jsxs=r,Ke}var Je={};var Ss;function Rh(){return Ss||(Ss=1,process.env.NODE_ENV!=="production"&&(function(){function e(j){if(j==null)return null;if(typeof j=="function")return j.$$typeof===A?null:j.displayName||j.name||null;if(typeof j=="string")return j;switch(j){case v:return"Fragment";case b:return"Profiler";case x:return"StrictMode";case w:return"Suspense";case E:return"SuspenseList";case R:return"Activity"}if(typeof j=="object")switch(typeof j.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),j.$$typeof){case g:return"Portal";case y:return j.displayName||"Context";case _:return(j._context.displayName||"Context")+".Consumer";case S:var F=j.render;return j=j.displayName,j||(j=F.displayName||F.name||"",j=j!==""?"ForwardRef("+j+")":"ForwardRef"),j;case T:return F=j.displayName||null,F!==null?F:e(j.type)||"Memo";case C:F=j._payload,j=j._init;try{return e(j(F))}catch{}}return null}function t(j){return""+j}function r(j){try{t(j);var F=!1}catch{F=!0}if(F){F=console;var G=F.error,k=typeof Symbol=="function"&&Symbol.toStringTag&&j[Symbol.toStringTag]||j.constructor.name||"Object";return G.call(F,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",k),t(j)}}function n(j){if(j===v)return"<>";if(typeof j=="object"&&j!==null&&j.$$typeof===C)return"<...>";try{var F=e(j);return F?"<"+F+">":"<...>"}catch{return"<...>"}}function a(){var j=B.A;return j===null?null:j.getOwner()}function i(){return Error("react-stack-top-frame")}function o(j){if(N.call(j,"key")){var F=Object.getOwnPropertyDescriptor(j,"key").get;if(F&&F.isReactWarning)return!1}return j.key!==void 0}function s(j,F){function G(){$||($=!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)",F))}G.isReactWarning=!0,Object.defineProperty(j,"key",{get:G,configurable:!0})}function c(){var j=e(this.type);return U[j]||(U[j]=!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.")),j=this.props.ref,j!==void 0?j:null}function u(j,F,G,k,I,P){var O=G.ref;return j={$$typeof:m,type:j,key:F,props:G,_owner:k},(O!==void 0?O:null)!==null?Object.defineProperty(j,"ref",{enumerable:!1,get:c}):Object.defineProperty(j,"ref",{enumerable:!1,value:null}),j._store={},Object.defineProperty(j._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(j,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(j,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:I}),Object.defineProperty(j,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:P}),Object.freeze&&(Object.freeze(j.props),Object.freeze(j)),j}function d(j,F,G,k,I,P){var O=F.children;if(O!==void 0)if(k)if(M(O)){for(k=0;k<O.length;k++)l(O[k]);Object.freeze&&Object.freeze(O)}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 l(O);if(N.call(F,"key")){O=e(j);var H=Object.keys(F).filter(function(Z){return Z!=="key"});k=0<H.length?"{key: someKey, "+H.join(": ..., ")+": ...}":"{key: someKey}",K[O+k]||(H=0<H.length?"{"+H.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
1
+ (function(Le,q){typeof exports=="object"&&typeof module<"u"?q(exports,require("react"),require("reactflow"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","reactflow","react-dom"],q):(Le=typeof globalThis<"u"?globalThis:Le||self,q(Le.ReactflowUI={},Le.React,Le.ReactFlow,Le.ReactDOM))})(this,(function(Le,q,O,Gr){"use strict";var _r=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Vh(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Sr={exports:{}},cr={};var zs;function Yh(){if(zs)return cr;zs=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function t(n,o,a){var i=null;if(a!==void 0&&(i=""+a),o.key!==void 0&&(i=""+o.key),"key"in o){a={};for(var s in o)s!=="key"&&(a[s]=o[s])}else a=o;return o=a.ref,{$$typeof:e,type:n,key:i,ref:o!==void 0?o:null,props:a}}return cr.Fragment=r,cr.jsx=t,cr.jsxs=t,cr}var ur={};var $s;function Xh(){return $s||($s=1,process.env.NODE_ENV!=="production"&&(function(){function e(_){if(_==null)return null;if(typeof _=="function")return _.$$typeof===R?null:_.displayName||_.name||null;if(typeof _=="string")return _;switch(_){case m:return"Fragment";case y:return"Profiler";case x:return"StrictMode";case C:return"Suspense";case N:return"SuspenseList";case I:return"Activity"}if(typeof _=="object")switch(typeof _.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),_.$$typeof){case v:return"Portal";case k:return _.displayName||"Context";case b:return(_._context.displayName||"Context")+".Consumer";case S:var Y=_.render;return _=_.displayName,_||(_=Y.displayName||Y.name||"",_=_!==""?"ForwardRef("+_+")":"ForwardRef"),_;case A:return Y=_.displayName||null,Y!==null?Y:e(_.type)||"Memo";case w:Y=_._payload,_=_._init;try{return e(_(Y))}catch{}}return null}function r(_){return""+_}function t(_){try{r(_);var Y=!1}catch{Y=!0}if(Y){Y=console;var K=Y.error,E=typeof Symbol=="function"&&Symbol.toStringTag&&_[Symbol.toStringTag]||_.constructor.name||"Object";return K.call(Y,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",E),r(_)}}function n(_){if(_===m)return"<>";if(typeof _=="object"&&_!==null&&_.$$typeof===w)return"<...>";try{var Y=e(_);return Y?"<"+Y+">":"<...>"}catch{return"<...>"}}function o(){var _=B.A;return _===null?null:_.getOwner()}function a(){return Error("react-stack-top-frame")}function i(_){if(D.call(_,"key")){var Y=Object.getOwnPropertyDescriptor(_,"key").get;if(Y&&Y.isReactWarning)return!1}return _.key!==void 0}function s(_,Y){function K(){W||(W=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",Y))}K.isReactWarning=!0,Object.defineProperty(_,"key",{get:K,configurable:!0})}function l(){var _=e(this.type);return V[_]||(V[_]=!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.")),_=this.props.ref,_!==void 0?_:null}function u(_,Y,K,E,j,M){var P=K.ref;return _={$$typeof:g,type:_,key:Y,props:K,_owner:E},(P!==void 0?P:null)!==null?Object.defineProperty(_,"ref",{enumerable:!1,get:l}):Object.defineProperty(_,"ref",{enumerable:!1,value:null}),_._store={},Object.defineProperty(_._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(_,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(_,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:j}),Object.defineProperty(_,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:M}),Object.freeze&&(Object.freeze(_.props),Object.freeze(_)),_}function c(_,Y,K,E,j,M){var P=Y.children;if(P!==void 0)if(E)if(L(P)){for(E=0;E<P.length;E++)f(P[E]);Object.freeze&&Object.freeze(P)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else f(P);if(D.call(Y,"key")){P=e(_);var z=Object.keys(Y).filter(function(ae){return ae!=="key"});E=0<z.length?"{key: someKey, "+z.join(": ..., ")+": ...}":"{key: someKey}",se[P+E]||(z=0<z.length?"{"+z.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} />`,k,O,H,O),K[O+k]=!0)}if(O=null,G!==void 0&&(r(G),O=""+G),o(F)&&(r(F.key),O=""+F.key),"key"in F){G={};for(var J in F)J!=="key"&&(G[J]=F[J])}else G=F;return O&&s(G,typeof j=="function"?j.displayName||j.name||"Unknown":j),u(j,O,G,a(),I,P)}function l(j){p(j)?j._store&&(j._store.validated=1):typeof j=="object"&&j!==null&&j.$$typeof===C&&(j._payload.status==="fulfilled"?p(j._payload.value)&&j._payload.value._store&&(j._payload.value._store.validated=1):j._store&&(j._store.validated=1))}function p(j){return typeof j=="object"&&j!==null&&j.$$typeof===m}var h=D,m=Symbol.for("react.transitional.element"),g=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),x=Symbol.for("react.strict_mode"),b=Symbol.for("react.profiler"),_=Symbol.for("react.consumer"),y=Symbol.for("react.context"),S=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),E=Symbol.for("react.suspense_list"),T=Symbol.for("react.memo"),C=Symbol.for("react.lazy"),R=Symbol.for("react.activity"),A=Symbol.for("react.client.reference"),B=h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,N=Object.prototype.hasOwnProperty,M=Array.isArray,L=console.createTask?console.createTask:function(){return null};h={react_stack_bottom_frame:function(j){return j()}};var $,U={},W=h.react_stack_bottom_frame.bind(h,i)(),z=L(n(i)),K={};Je.Fragment=v,Je.jsx=function(j,F,G){var k=1e4>B.recentlyCreatedOwnerStacks++;return d(j,F,G,!1,k?Error("react-stack-top-frame"):W,k?L(n(j)):z)},Je.jsxs=function(j,F,G){var k=1e4>B.recentlyCreatedOwnerStacks++;return d(j,F,G,!0,k?Error("react-stack-top-frame"):W,k?L(n(j)):z)}})()),Je}var ws;function Ih(){return ws||(ws=1,process.env.NODE_ENV==="production"?ur.exports=Nh():ur.exports=Rh()),ur.exports}var f=Ih();const Es=e=>{let t;const r=new Set,n=(u,d)=>{const l=typeof u=="function"?u(t):u;if(!Object.is(l,t)){const p=t;t=d??(typeof l!="object"||l===null)?l:Object.assign({},t,l),r.forEach(h=>h(t,p))}},a=()=>t,s={setState:n,getState:a,getInitialState:()=>c,subscribe:u=>(r.add(u),()=>r.delete(u))},c=t=e(n,a,s);return s},Ts=(e=>e?Es(e):Es),jh=e=>e;function jr(e,t=jh){const r=D.useSyncExternalStore(e.subscribe,D.useCallback(()=>t(e.getState()),[e,t]),D.useCallback(()=>t(e.getInitialState()),[e,t]));return D.useDebugValue(r),r}const Oh=e=>{const t=Ts(e),r=n=>jr(t,n);return Object.assign(r,t),r},qh=(e=>Oh);function Cs(e,t){let r;try{r=e()}catch{return}return{getItem:a=>{var i;const o=c=>c===null?null:JSON.parse(c,void 0),s=(i=r.getItem(a))!=null?i:null;return s instanceof Promise?s.then(o):o(s)},setItem:(a,i)=>r.setItem(a,JSON.stringify(i,void 0)),removeItem:a=>r.removeItem(a)}}const Or=e=>t=>{try{const r=e(t);return r instanceof Promise?r:{then(n){return Or(n)(r)},catch(n){return this}}}catch(r){return{then(n){return this},catch(n){return Or(n)(r)}}}},Ph=(e,t)=>(r,n,a)=>{let i={storage:Cs(()=>localStorage),partialize:g=>g,version:0,merge:(g,v)=>({...v,...g}),...t},o=!1;const s=new Set,c=new Set;let u=i.storage;if(!u)return e((...g)=>{console.warn(`[zustand persist middleware] Unable to update item '${i.name}', the given storage is currently unavailable.`),r(...g)},n,a);const d=()=>{const g=i.partialize({...n()});return u.setItem(i.name,{state:g,version:i.version})},l=a.setState;a.setState=(g,v)=>(l(g,v),d());const p=e((...g)=>(r(...g),d()),n,a);a.getInitialState=()=>p;let h;const m=()=>{var g,v;if(!u)return;o=!1,s.forEach(b=>{var _;return b((_=n())!=null?_:p)});const x=((v=i.onRehydrateStorage)==null?void 0:v.call(i,(g=n())!=null?g:p))||void 0;return Or(u.getItem.bind(u))(i.name).then(b=>{if(b)if(typeof b.version=="number"&&b.version!==i.version){if(i.migrate){const _=i.migrate(b.state,b.version);return _ instanceof Promise?_.then(y=>[!0,y]):[!0,_]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,b.state];return[!1,void 0]}).then(b=>{var _;const[y,S]=b;if(h=i.merge(S,(_=n())!=null?_:p),r(h,!0),y)return d()}).then(()=>{x?.(h,void 0),h=n(),o=!0,c.forEach(b=>b(h))}).catch(b=>{x?.(void 0,b)})};return a.persist={setOptions:g=>{i={...i,...g},g.storage&&(u=g.storage)},clearStorage:()=>{u?.removeItem(i.name)},getOptions:()=>i,rehydrate:()=>m(),hasHydrated:()=>o,onHydrate:g=>(s.add(g),()=>{s.delete(g)}),onFinishHydration:g=>(c.add(g),()=>{c.delete(g)})},i.skipHydration||m(),h||p};var Ns=(e,t,r)=>(a,i)=>({pastStates:r?.pastStates||[],futureStates:r?.futureStates||[],undo:(o=1)=>{if(i().pastStates.length){const s=r?.partialize?.(t())||t(),c=i().pastStates.splice(-o,o),u=c.shift();e(u),a({pastStates:i().pastStates,futureStates:i().futureStates.concat(r?.diff?.(s,u)||s,c.reverse())})}},redo:(o=1)=>{if(i().futureStates.length){const s=r?.partialize?.(t())||t(),c=i().futureStates.splice(-o,o),u=c.shift();e(u),a({pastStates:i().pastStates.concat(r?.diff?.(s,u)||s,c.reverse()),futureStates:i().futureStates})}},clear:()=>a({pastStates:[],futureStates:[]}),isTracking:!0,pause:()=>a({isTracking:!1}),resume:()=>a({isTracking:!0}),setOnSave:o=>a({_onSave:o}),_onSave:r?.onSave,_handleSet:(o,s,c,u)=>{r?.limit&&i().pastStates.length>=r?.limit&&i().pastStates.shift(),i()._onSave?.(o,c),a({pastStates:i().pastStates.concat(u||o),futureStates:[]})}}),Ah=(e,t)=>(n,a,i)=>{i.temporal=Ts(t?.wrapTemporal?.(Ns(n,a,t))||Ns(n,a,t));const o=t?.handleSet?.(i.temporal.getState()._handleSet)||i.temporal.getState()._handleSet,s=u=>{if(!i.temporal.getState().isTracking)return;const d=t?.partialize?.(a())||a(),l=t?.diff?.(u,d);l===null||t?.equality?.(u,d)||o(u,void 0,d,l)},c=i.setState;return i.setState=(...u)=>{const d=t?.partialize?.(a())||a();c(...u),s(d)},e((...u)=>{const d=t?.partialize?.(a())||a();n(...u),s(d)},a,i)};function Lh(e,t="TB",r){const n=r?.hideEmptyBranches??!1;if(!e||!e.tasks)return{nodes:[],edges:[],taskMap:{}};const a=[],i=[],o={};let s=0;const c={id:"start",type:"input",data:{label:"开始",layoutDirection:t,taskReferenceName:"start",taskType:"START"},position:{x:0,y:0},sourcePosition:t==="LR"?q.Position.Right:q.Position.Bottom,style:{background:"#4ade80",color:"#fff",border:"2px solid #22c55e",borderRadius:"50%",width:60,height:60,display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",fontWeight:"bold"}};a.push(c);const u=e.tasks;for(let p=0;p<u.length;p++){const h=u[p],m=Rs(h,s,o,t,u,n);if(a.push(...m.nodes),i.push(...m.edges),s=m.nextId,p===0)i.push({id:`e-start-${h.taskReferenceName}`,source:"start",target:h.taskReferenceName,animated:!0});else{const g=u[p-1];Is(g,h,i)}Object.assign(o,m.taskMap)}const d=u[u.length-1],l={id:"end",type:"output",data:{label:"结束",layoutDirection:t,taskReferenceName:"end",taskType:"END"},position:{x:0,y:0},targetPosition:t==="LR"?q.Position.Left:q.Position.Top,style:{background:"#f87171",color:"#fff",border:"2px solid #ef4444",borderRadius:"50%",width:60,height:60,display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",fontWeight:"bold"}};if(a.push(l),d){const p=Pr(d);i.push({id:`e-${p}-end`,source:p,target:"end",animated:!0})}else i.push({id:"e-start-end",source:"start",target:"end",type:"addableEdge",animated:!0});return{nodes:a,edges:i,taskMap:o}}function Rs(e,t,r,n="TB",a=[],i=!1){switch(e.type||"SIMPLE"){case"DECISION":case"SWITCH":return Mh(e,t,r,n,i);case"FORK_JOIN":case"FORK_JOIN_DYNAMIC":return Bh(e,t,r,n);case"JOIN":return $h(e,t,r,n,a,i);case"DO_WHILE":return Wh(e,t,r,n);case"SUB_WORKFLOW":return Fh(e,t,r,n);default:return Dh(e,t,r,n)}}function Dh(e,t,r,n="TB"){const a={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},i={[e.taskReferenceName]:e};return{nodes:[a],edges:[],taskMap:i,nextId:t+1}}function Mh(e,t,r,n="TB",a=!1){const i=[],o=[];let s=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};i.push(u),c[e.taskReferenceName]=e;const d=`${e.taskReferenceName}_join`,l={id:d,type:"default",data:{label:"合并",layoutDirection:n,taskReferenceName:d,taskType:"DECISION_JOIN"},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:"#a78bfa",color:"#fff",border:"2px solid #8b5cf6",borderRadius:"8px",padding:"10px",fontSize:"12px"}};i.push(l);const p=e.decisionCases||{},h=e.defaultCase||[],m=Object.keys(p),g=(v,x)=>{if(n==="TB"){if(v===0&&x>1)return"left";if(v===1&&x>2)return"right"}else{if(v===0&&x>1)return"top";if(v===1&&x>2)return"bottom"}return null};if(m.forEach((v,x)=>{const b=p[v],_=g(x,m.length+1);if(b&&b.length>0){const y=qr(b,s,{...r,...c},n);i.push(...y.nodes),o.push(...y.edges),Object.assign(c,y.taskMap),s=y.nextId;const S=b[0].taskReferenceName;o.push({id:`e-${e.taskReferenceName}-${S}`,source:e.taskReferenceName,sourceHandle:_||void 0,target:S,label:v,animated:!0,data:{branchCase:v},style:{stroke:"#3b82f6"}});const w=b[b.length-1].taskReferenceName;o.push({id:`e-${w}-${d}`,source:w,target:d,animated:!0})}else if(!a){const y=`${e.taskReferenceName}_empty_${v}`;i.push({id:y,type:"default",data:{label:`${v} (空)`,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"}}),o.push({id:`e-${e.taskReferenceName}-${y}`,source:e.taskReferenceName,sourceHandle:_||void 0,target:y,label:v,animated:!0,data:{branchCase:v},style:{stroke:"#3b82f6",strokeDasharray:"5,5"}}),o.push({id:`e-${y}-${d}`,source:y,target:d,animated:!0,style:{strokeDasharray:"5,5"}})}}),h&&h.length>0){const v=qr(h,s,{...r,...c},n);i.push(...v.nodes),o.push(...v.edges),Object.assign(c,v.taskMap),s=v.nextId;const x=h[0].taskReferenceName;o.push({id:`e-${e.taskReferenceName}-${x}`,source:e.taskReferenceName,target:x,label:"default",animated:!0,data:{branchCase:"default"},style:{stroke:"#f59e0b"}});const b=h[h.length-1].taskReferenceName;o.push({id:`e-${b}-${d}`,source:b,target:d,animated:!0})}else if(!a){const v=`${e.taskReferenceName}_empty_default`;i.push({id:v,type:"default",data:{label:"default (空)",layoutDirection:n,taskReferenceName:v,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"}}),o.push({id:`e-${e.taskReferenceName}-${v}`,source:e.taskReferenceName,target:v,label:"default",animated:!0,data:{branchCase:"default"},style:{stroke:"#f59e0b",strokeDasharray:"5,5"}}),o.push({id:`e-${v}-${d}`,source:v,target:d,animated:!0,style:{strokeDasharray:"5,5"}})}return Object.keys(p).length===0&&(!h||h.length===0)&&o.push({id:`e-${e.taskReferenceName}-${d}`,source:e.taskReferenceName,target:d,animated:!0}),{nodes:i,edges:o,taskMap:c,nextId:s,joinNodeId:d}}function Bh(e,t,r,n="TB"){const a=[],i=[];let o=t;const s={},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};return a.push(u),s[e.taskReferenceName]=e,c||(e.forkTasks||[]).forEach((l,p)=>{if(l&&l.length>0){const h=qr(l,o,{...r,...s},n);a.push(...h.nodes),i.push(...h.edges),Object.assign(s,h.taskMap),o=h.nextId;const m=l[0].taskReferenceName;i.push({id:`e-${e.taskReferenceName}-${m}`,source:e.taskReferenceName,sourceHandle:`branch_${p}`,target:m,label:`分支 ${p+1}`,animated:!0,data:{forkIndex:p},style:{stroke:"#10b981"}})}}),{nodes:a,edges:i,taskMap:s,nextId:o}}function Wh(e,t,r,n="TB"){const a={},i={id:e.taskReferenceName,type:"loopNode",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};return a[e.taskReferenceName]=e,(e.loopOver||[]).forEach(s=>{a[s.taskReferenceName]=s}),{nodes:[i],edges:[],taskMap:a,nextId:t+1}}function Fh(e,t,r,n="TB"){const a={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},i={[e.taskReferenceName]:e};return{nodes:[a],edges:[],taskMap:i,nextId:t+1}}function $h(e,t,r,n="TB",a=[],i=!1){const o={id:e.taskReferenceName,type:"joinNode",data:{label:e.name||"JOIN",taskReferenceName:e.taskReferenceName,taskType:e.type,task:e,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?q.Position.Right:q.Position.Bottom,targetPosition:n==="LR"?q.Position.Left:q.Position.Top},s={[e.taskReferenceName]:e},c=[],u=[];(e.joinOn||[]).forEach(p=>{const h=a.find(m=>m.taskReferenceName===p)||r[p];if(h){const m=Pr(h);u.push({id:`e-${m}-${e.taskReferenceName}`,source:m,target:e.taskReferenceName,animated:!0})}});const l=a.findIndex(p=>p.taskReferenceName===e.taskReferenceName);if(l>0){const p=a[l-1];p.type==="FORK_JOIN_DYNAMIC"?u.push({id:`e-${p.taskReferenceName}-${e.taskReferenceName}-dynamic`,source:p.taskReferenceName,target:e.taskReferenceName,label:"动态分支",animated:!0,style:{stroke:"#10b981",strokeWidth:4,strokeDasharray:"5,5",opacity:.8}}):p.type==="FORK_JOIN"&&(p.forkTasks||[]).forEach((m,g)=>{if((!m||m.length===0)&&!i){const v=`${p.taskReferenceName}_empty_branch_${g}`;c.push({id:v,type:"default",data:{label:`分支 ${g+1} (空)`,layoutDirection:n,taskReferenceName:v,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-${p.taskReferenceName}-${v}`,source:p.taskReferenceName,sourceHandle:`branch_${g}`,target:v,label:`分支 ${g+1}`,animated:!0,data:{forkIndex:g},style:{stroke:"#10b981",strokeDasharray:"5,5"}}),u.push({id:`e-${v}-${e.taskReferenceName}`,source:v,target:e.taskReferenceName,animated:!0,style:{strokeDasharray:"5,5"}})}})}return{nodes:[o,...c],edges:u,taskMap:s,nextId:t+1}}function qr(e,t,r,n="TB"){const a=[],i=[];let o=t;const s={};for(let c=0;c<e.length;c++){const u=e[c],d={...r,...s},l=Rs(u,o,d,n,e);if(a.push(...l.nodes),i.push(...l.edges),Object.assign(s,l.taskMap),o=l.nextId,c>0){const p=e[c-1];Is(p,u,i)}}return{nodes:a,edges:i,taskMap:s,nextId:o}}function Is(e,t,r){if(e.type==="FORK_JOIN"||e.type==="FORK_JOIN_DYNAMIC")return;const n=Pr(e),a=t.taskReferenceName,i=`e-${n}-${a}`;r.find(o=>o.id===i)||r.push({id:i,source:n,target:a,animated:!0})}function Pr(e){const t=e.type||"SIMPLE";return t==="DECISION"||t==="SWITCH"?`${e.taskReferenceName}_join`:e.taskReferenceName}const ue=Lh;function Ar(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 Lr,js;function zh(){if(js)return Lr;js=1;function e(){this.__data__=[],this.size=0}return Lr=e,Lr}var Dr,Os;function Pe(){if(Os)return Dr;Os=1;function e(t,r){return t===r||t!==t&&r!==r}return Dr=e,Dr}var Mr,qs;function cr(){if(qs)return Mr;qs=1;var e=Pe();function t(r,n){for(var a=r.length;a--;)if(e(r[a][0],n))return a;return-1}return Mr=t,Mr}var Br,Ps;function Hh(){if(Ps)return Br;Ps=1;var e=cr(),t=Array.prototype,r=t.splice;function n(a){var i=this.__data__,o=e(i,a);if(o<0)return!1;var s=i.length-1;return o==s?i.pop():r.call(i,o,1),--this.size,!0}return Br=n,Br}var Wr,As;function Gh(){if(As)return Wr;As=1;var e=cr();function t(r){var n=this.__data__,a=e(n,r);return a<0?void 0:n[a][1]}return Wr=t,Wr}var Fr,Ls;function Uh(){if(Ls)return Fr;Ls=1;var e=cr();function t(r){return e(this.__data__,r)>-1}return Fr=t,Fr}var $r,Ds;function Kh(){if(Ds)return $r;Ds=1;var e=cr();function t(r,n){var a=this.__data__,i=e(a,r);return i<0?(++this.size,a.push([r,n])):a[i][1]=n,this}return $r=t,$r}var zr,Ms;function dr(){if(Ms)return zr;Ms=1;var e=zh(),t=Hh(),r=Gh(),n=Uh(),a=Kh();function i(o){var s=-1,c=o==null?0:o.length;for(this.clear();++s<c;){var u=o[s];this.set(u[0],u[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=a,zr=i,zr}var Hr,Bs;function Jh(){if(Bs)return Hr;Bs=1;var e=dr();function t(){this.__data__=new e,this.size=0}return Hr=t,Hr}var Gr,Ws;function Vh(){if(Ws)return Gr;Ws=1;function e(t){var r=this.__data__,n=r.delete(t);return this.size=r.size,n}return Gr=e,Gr}var Ur,Fs;function Yh(){if(Fs)return Ur;Fs=1;function e(t){return this.__data__.get(t)}return Ur=e,Ur}var Kr,$s;function Xh(){if($s)return Kr;$s=1;function e(t){return this.__data__.has(t)}return Kr=e,Kr}var Jr,zs;function Hs(){if(zs)return Jr;zs=1;var e=typeof sr=="object"&&sr&&sr.Object===Object&&sr;return Jr=e,Jr}var Vr,Gs;function he(){if(Gs)return Vr;Gs=1;var e=Hs(),t=typeof self=="object"&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return Vr=r,Vr}var Yr,Us;function Ae(){if(Us)return Yr;Us=1;var e=he(),t=e.Symbol;return Yr=t,Yr}var Xr,Ks;function Zh(){if(Ks)return Xr;Ks=1;var e=Ae(),t=Object.prototype,r=t.hasOwnProperty,n=t.toString,a=e?e.toStringTag:void 0;function i(o){var s=r.call(o,a),c=o[a];try{o[a]=void 0;var u=!0}catch{}var d=n.call(o);return u&&(s?o[a]=c:delete o[a]),d}return Xr=i,Xr}var Zr,Js;function Qh(){if(Js)return Zr;Js=1;var e=Object.prototype,t=e.toString;function r(n){return t.call(n)}return Zr=r,Zr}var Qr,Vs;function Ne(){if(Vs)return Qr;Vs=1;var e=Ae(),t=Zh(),r=Qh(),n="[object Null]",a="[object Undefined]",i=e?e.toStringTag:void 0;function o(s){return s==null?s===void 0?a:n:i&&i in Object(s)?t(s):r(s)}return Qr=o,Qr}var et,Ys;function de(){if(Ys)return et;Ys=1;function e(t){var r=typeof t;return t!=null&&(r=="object"||r=="function")}return et=e,et}var rt,Xs;function Ve(){if(Xs)return rt;Xs=1;var e=Ne(),t=de(),r="[object AsyncFunction]",n="[object Function]",a="[object GeneratorFunction]",i="[object Proxy]";function o(s){if(!t(s))return!1;var c=e(s);return c==n||c==a||c==r||c==i}return rt=o,rt}var tt,Zs;function ev(){if(Zs)return tt;Zs=1;var e=he(),t=e["__core-js_shared__"];return tt=t,tt}var nt,Qs;function rv(){if(Qs)return nt;Qs=1;var e=ev(),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 nt=r,nt}var at,eu;function ru(){if(eu)return at;eu=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 at=r,at}var it,tu;function tv(){if(tu)return it;tu=1;var e=Ve(),t=rv(),r=de(),n=ru(),a=/[\\^$.*+?()[\]{}|]/g,i=/^\[object .+?Constructor\]$/,o=Function.prototype,s=Object.prototype,c=o.toString,u=s.hasOwnProperty,d=RegExp("^"+c.call(u).replace(a,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function l(p){if(!r(p)||t(p))return!1;var h=e(p)?d:i;return h.test(n(p))}return it=l,it}var ot,nu;function nv(){if(nu)return ot;nu=1;function e(t,r){return t?.[r]}return ot=e,ot}var st,au;function Re(){if(au)return st;au=1;var e=tv(),t=nv();function r(n,a){var i=t(n,a);return e(i)?i:void 0}return st=r,st}var ut,iu;function ct(){if(iu)return ut;iu=1;var e=Re(),t=he(),r=e(t,"Map");return ut=r,ut}var dt,ou;function lr(){if(ou)return dt;ou=1;var e=Re(),t=e(Object,"create");return dt=t,dt}var lt,su;function av(){if(su)return lt;su=1;var e=lr();function t(){this.__data__=e?e(null):{},this.size=0}return lt=t,lt}var ft,uu;function iv(){if(uu)return ft;uu=1;function e(t){var r=this.has(t)&&delete this.__data__[t];return this.size-=r?1:0,r}return ft=e,ft}var pt,cu;function ov(){if(cu)return pt;cu=1;var e=lr(),t="__lodash_hash_undefined__",r=Object.prototype,n=r.hasOwnProperty;function a(i){var o=this.__data__;if(e){var s=o[i];return s===t?void 0:s}return n.call(o,i)?o[i]:void 0}return pt=a,pt}var ht,du;function sv(){if(du)return ht;du=1;var e=lr(),t=Object.prototype,r=t.hasOwnProperty;function n(a){var i=this.__data__;return e?i[a]!==void 0:r.call(i,a)}return ht=n,ht}var vt,lu;function uv(){if(lu)return vt;lu=1;var e=lr(),t="__lodash_hash_undefined__";function r(n,a){var i=this.__data__;return this.size+=this.has(n)?0:1,i[n]=e&&a===void 0?t:a,this}return vt=r,vt}var gt,fu;function cv(){if(fu)return gt;fu=1;var e=av(),t=iv(),r=ov(),n=sv(),a=uv();function i(o){var s=-1,c=o==null?0:o.length;for(this.clear();++s<c;){var u=o[s];this.set(u[0],u[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=a,gt=i,gt}var mt,pu;function dv(){if(pu)return mt;pu=1;var e=cv(),t=dr(),r=ct();function n(){this.size=0,this.__data__={hash:new e,map:new(r||t),string:new e}}return mt=n,mt}var yt,hu;function lv(){if(hu)return yt;hu=1;function e(t){var r=typeof t;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?t!=="__proto__":t===null}return yt=e,yt}var bt,vu;function fr(){if(vu)return bt;vu=1;var e=lv();function t(r,n){var a=r.__data__;return e(n)?a[typeof n=="string"?"string":"hash"]:a.map}return bt=t,bt}var xt,gu;function fv(){if(gu)return xt;gu=1;var e=fr();function t(r){var n=e(this,r).delete(r);return this.size-=n?1:0,n}return xt=t,xt}var _t,mu;function pv(){if(mu)return _t;mu=1;var e=fr();function t(r){return e(this,r).get(r)}return _t=t,_t}var kt,yu;function hv(){if(yu)return kt;yu=1;var e=fr();function t(r){return e(this,r).has(r)}return kt=t,kt}var St,bu;function vv(){if(bu)return St;bu=1;var e=fr();function t(r,n){var a=e(this,r),i=a.size;return a.set(r,n),this.size+=a.size==i?0:1,this}return St=t,St}var wt,xu;function Et(){if(xu)return wt;xu=1;var e=dv(),t=fv(),r=pv(),n=hv(),a=vv();function i(o){var s=-1,c=o==null?0:o.length;for(this.clear();++s<c;){var u=o[s];this.set(u[0],u[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=a,wt=i,wt}var Tt,_u;function gv(){if(_u)return Tt;_u=1;var e=dr(),t=ct(),r=Et(),n=200;function a(i,o){var s=this.__data__;if(s instanceof e){var c=s.__data__;if(!t||c.length<n-1)return c.push([i,o]),this.size=++s.size,this;s=this.__data__=new r(c)}return s.set(i,o),this.size=s.size,this}return Tt=a,Tt}var Ct,ku;function pr(){if(ku)return Ct;ku=1;var e=dr(),t=Jh(),r=Vh(),n=Yh(),a=Xh(),i=gv();function o(s){var c=this.__data__=new e(s);this.size=c.size}return o.prototype.clear=t,o.prototype.delete=r,o.prototype.get=n,o.prototype.has=a,o.prototype.set=i,Ct=o,Ct}var Nt,Su;function Rt(){if(Su)return Nt;Su=1;function e(t,r){for(var n=-1,a=t==null?0:t.length;++n<a&&r(t[n],n,t)!==!1;);return t}return Nt=e,Nt}var It,wu;function Eu(){if(wu)return It;wu=1;var e=Re(),t=(function(){try{var r=e(Object,"defineProperty");return r({},"",{}),r}catch{}})();return It=t,It}var jt,Tu;function hr(){if(Tu)return jt;Tu=1;var e=Eu();function t(r,n,a){n=="__proto__"&&e?e(r,n,{configurable:!0,enumerable:!0,value:a,writable:!0}):r[n]=a}return jt=t,jt}var Ot,Cu;function vr(){if(Cu)return Ot;Cu=1;var e=hr(),t=Pe(),r=Object.prototype,n=r.hasOwnProperty;function a(i,o,s){var c=i[o];(!(n.call(i,o)&&t(c,s))||s===void 0&&!(o in i))&&e(i,o,s)}return Ot=a,Ot}var qt,Nu;function Ye(){if(Nu)return qt;Nu=1;var e=vr(),t=hr();function r(n,a,i,o){var s=!i;i||(i={});for(var c=-1,u=a.length;++c<u;){var d=a[c],l=o?o(i[d],n[d],d,i,n):void 0;l===void 0&&(l=n[d]),s?t(i,d,l):e(i,d,l)}return i}return qt=r,qt}var Pt,Ru;function mv(){if(Ru)return Pt;Ru=1;function e(t,r){for(var n=-1,a=Array(t);++n<t;)a[n]=r(n);return a}return Pt=e,Pt}var At,Iu;function ye(){if(Iu)return At;Iu=1;function e(t){return t!=null&&typeof t=="object"}return At=e,At}var Lt,ju;function yv(){if(ju)return Lt;ju=1;var e=Ne(),t=ye(),r="[object Arguments]";function n(a){return t(a)&&e(a)==r}return Lt=n,Lt}var Dt,Ou;function Xe(){if(Ou)return Dt;Ou=1;var e=yv(),t=ye(),r=Object.prototype,n=r.hasOwnProperty,a=r.propertyIsEnumerable,i=e((function(){return arguments})())?e:function(o){return t(o)&&n.call(o,"callee")&&!a.call(o,"callee")};return Dt=i,Dt}var Mt,qu;function ne(){if(qu)return Mt;qu=1;var e=Array.isArray;return Mt=e,Mt}var Ze={exports:{}},Bt,Pu;function bv(){if(Pu)return Bt;Pu=1;function e(){return!1}return Bt=e,Bt}Ze.exports;var Au;function Le(){return Au||(Au=1,(function(e,t){var r=he(),n=bv(),a=t&&!t.nodeType&&t,i=a&&!0&&e&&!e.nodeType&&e,o=i&&i.exports===a,s=o?r.Buffer:void 0,c=s?s.isBuffer:void 0,u=c||n;e.exports=u})(Ze,Ze.exports)),Ze.exports}var Wt,Lu;function gr(){if(Lu)return Wt;Lu=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function r(n,a){var i=typeof n;return a=a??e,!!a&&(i=="number"||i!="symbol"&&t.test(n))&&n>-1&&n%1==0&&n<a}return Wt=r,Wt}var Ft,Du;function $t(){if(Du)return Ft;Du=1;var e=9007199254740991;function t(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=e}return Ft=t,Ft}var zt,Mu;function xv(){if(Mu)return zt;Mu=1;var e=Ne(),t=$t(),r=ye(),n="[object Arguments]",a="[object Array]",i="[object Boolean]",o="[object Date]",s="[object Error]",c="[object Function]",u="[object Map]",d="[object Number]",l="[object Object]",p="[object RegExp]",h="[object Set]",m="[object String]",g="[object WeakMap]",v="[object ArrayBuffer]",x="[object DataView]",b="[object Float32Array]",_="[object Float64Array]",y="[object Int8Array]",S="[object Int16Array]",w="[object Int32Array]",E="[object Uint8Array]",T="[object Uint8ClampedArray]",C="[object Uint16Array]",R="[object Uint32Array]",A={};A[b]=A[_]=A[y]=A[S]=A[w]=A[E]=A[T]=A[C]=A[R]=!0,A[n]=A[a]=A[v]=A[i]=A[x]=A[o]=A[s]=A[c]=A[u]=A[d]=A[l]=A[p]=A[h]=A[m]=A[g]=!1;function B(N){return r(N)&&t(N.length)&&!!A[e(N)]}return zt=B,zt}var Ht,Bu;function mr(){if(Bu)return Ht;Bu=1;function e(t){return function(r){return t(r)}}return Ht=e,Ht}var Qe={exports:{}};Qe.exports;var Wu;function Gt(){return Wu||(Wu=1,(function(e,t){var r=Hs(),n=t&&!t.nodeType&&t,a=n&&!0&&e&&!e.nodeType&&e,i=a&&a.exports===n,o=i&&r.process,s=(function(){try{var c=a&&a.require&&a.require("util").types;return c||o&&o.binding&&o.binding("util")}catch{}})();e.exports=s})(Qe,Qe.exports)),Qe.exports}var Ut,Fu;function er(){if(Fu)return Ut;Fu=1;var e=xv(),t=mr(),r=Gt(),n=r&&r.isTypedArray,a=n?t(n):e;return Ut=a,Ut}var Kt,$u;function zu(){if($u)return Kt;$u=1;var e=mv(),t=Xe(),r=ne(),n=Le(),a=gr(),i=er(),o=Object.prototype,s=o.hasOwnProperty;function c(u,d){var l=r(u),p=!l&&t(u),h=!l&&!p&&n(u),m=!l&&!p&&!h&&i(u),g=l||p||h||m,v=g?e(u.length,String):[],x=v.length;for(var b in u)(d||s.call(u,b))&&!(g&&(b=="length"||h&&(b=="offset"||b=="parent")||m&&(b=="buffer"||b=="byteLength"||b=="byteOffset")||a(b,x)))&&v.push(b);return v}return Kt=c,Kt}var Jt,Hu;function yr(){if(Hu)return Jt;Hu=1;var e=Object.prototype;function t(r){var n=r&&r.constructor,a=typeof n=="function"&&n.prototype||e;return r===a}return Jt=t,Jt}var Vt,Gu;function Uu(){if(Gu)return Vt;Gu=1;function e(t,r){return function(n){return t(r(n))}}return Vt=e,Vt}var Yt,Ku;function _v(){if(Ku)return Yt;Ku=1;var e=Uu(),t=e(Object.keys,Object);return Yt=t,Yt}var Xt,Ju;function Zt(){if(Ju)return Xt;Ju=1;var e=yr(),t=_v(),r=Object.prototype,n=r.hasOwnProperty;function a(i){if(!e(i))return t(i);var o=[];for(var s in Object(i))n.call(i,s)&&s!="constructor"&&o.push(s);return o}return Xt=a,Xt}var Qt,Vu;function xe(){if(Vu)return Qt;Vu=1;var e=Ve(),t=$t();function r(n){return n!=null&&t(n.length)&&!e(n)}return Qt=r,Qt}var en,Yu;function we(){if(Yu)return en;Yu=1;var e=zu(),t=Zt(),r=xe();function n(a){return r(a)?e(a):t(a)}return en=n,en}var rn,Xu;function kv(){if(Xu)return rn;Xu=1;var e=Ye(),t=we();function r(n,a){return n&&e(a,t(a),n)}return rn=r,rn}var tn,Zu;function Sv(){if(Zu)return tn;Zu=1;function e(t){var r=[];if(t!=null)for(var n in Object(t))r.push(n);return r}return tn=e,tn}var nn,Qu;function wv(){if(Qu)return nn;Qu=1;var e=de(),t=yr(),r=Sv(),n=Object.prototype,a=n.hasOwnProperty;function i(o){if(!e(o))return r(o);var s=t(o),c=[];for(var u in o)u=="constructor"&&(s||!a.call(o,u))||c.push(u);return c}return nn=i,nn}var an,ec;function Ie(){if(ec)return an;ec=1;var e=zu(),t=wv(),r=xe();function n(a){return r(a)?e(a,!0):t(a)}return an=n,an}var on,rc;function Ev(){if(rc)return on;rc=1;var e=Ye(),t=Ie();function r(n,a){return n&&e(a,t(a),n)}return on=r,on}var rr={exports:{}};rr.exports;var tc;function nc(){return tc||(tc=1,(function(e,t){var r=he(),n=t&&!t.nodeType&&t,a=n&&!0&&e&&!e.nodeType&&e,i=a&&a.exports===n,o=i?r.Buffer:void 0,s=o?o.allocUnsafe:void 0;function c(u,d){if(d)return u.slice();var l=u.length,p=s?s(l):new u.constructor(l);return u.copy(p),p}e.exports=c})(rr,rr.exports)),rr.exports}var sn,ac;function ic(){if(ac)return sn;ac=1;function e(t,r){var n=-1,a=t.length;for(r||(r=Array(a));++n<a;)r[n]=t[n];return r}return sn=e,sn}var un,oc;function sc(){if(oc)return un;oc=1;function e(t,r){for(var n=-1,a=t==null?0:t.length,i=0,o=[];++n<a;){var s=t[n];r(s,n,t)&&(o[i++]=s)}return o}return un=e,un}var cn,uc;function cc(){if(uc)return cn;uc=1;function e(){return[]}return cn=e,cn}var dn,dc;function ln(){if(dc)return dn;dc=1;var e=sc(),t=cc(),r=Object.prototype,n=r.propertyIsEnumerable,a=Object.getOwnPropertySymbols,i=a?function(o){return o==null?[]:(o=Object(o),e(a(o),function(s){return n.call(o,s)}))}:t;return dn=i,dn}var fn,lc;function Tv(){if(lc)return fn;lc=1;var e=Ye(),t=ln();function r(n,a){return e(n,t(n),a)}return fn=r,fn}var pn,fc;function hn(){if(fc)return pn;fc=1;function e(t,r){for(var n=-1,a=r.length,i=t.length;++n<a;)t[i+n]=r[n];return t}return pn=e,pn}var vn,pc;function br(){if(pc)return vn;pc=1;var e=Uu(),t=e(Object.getPrototypeOf,Object);return vn=t,vn}var gn,hc;function vc(){if(hc)return gn;hc=1;var e=hn(),t=br(),r=ln(),n=cc(),a=Object.getOwnPropertySymbols,i=a?function(o){for(var s=[];o;)e(s,r(o)),o=t(o);return s}:n;return gn=i,gn}var mn,gc;function Cv(){if(gc)return mn;gc=1;var e=Ye(),t=vc();function r(n,a){return e(n,t(n),a)}return mn=r,mn}var yn,mc;function yc(){if(mc)return yn;mc=1;var e=hn(),t=ne();function r(n,a,i){var o=a(n);return t(n)?o:e(o,i(n))}return yn=r,yn}var bn,bc;function xc(){if(bc)return bn;bc=1;var e=yc(),t=ln(),r=we();function n(a){return e(a,r,t)}return bn=n,bn}var xn,_c;function Nv(){if(_c)return xn;_c=1;var e=yc(),t=vc(),r=Ie();function n(a){return e(a,r,t)}return xn=n,xn}var _n,kc;function Rv(){if(kc)return _n;kc=1;var e=Re(),t=he(),r=e(t,"DataView");return _n=r,_n}var kn,Sc;function Iv(){if(Sc)return kn;Sc=1;var e=Re(),t=he(),r=e(t,"Promise");return kn=r,kn}var Sn,wc;function Ec(){if(wc)return Sn;wc=1;var e=Re(),t=he(),r=e(t,"Set");return Sn=r,Sn}var wn,Tc;function jv(){if(Tc)return wn;Tc=1;var e=Re(),t=he(),r=e(t,"WeakMap");return wn=r,wn}var En,Cc;function De(){if(Cc)return En;Cc=1;var e=Rv(),t=ct(),r=Iv(),n=Ec(),a=jv(),i=Ne(),o=ru(),s="[object Map]",c="[object Object]",u="[object Promise]",d="[object Set]",l="[object WeakMap]",p="[object DataView]",h=o(e),m=o(t),g=o(r),v=o(n),x=o(a),b=i;return(e&&b(new e(new ArrayBuffer(1)))!=p||t&&b(new t)!=s||r&&b(r.resolve())!=u||n&&b(new n)!=d||a&&b(new a)!=l)&&(b=function(_){var y=i(_),S=y==c?_.constructor:void 0,w=S?o(S):"";if(w)switch(w){case h:return p;case m:return s;case g:return u;case v:return d;case x:return l}return y}),En=b,En}var Tn,Nc;function Ov(){if(Nc)return Tn;Nc=1;var e=Object.prototype,t=e.hasOwnProperty;function r(n){var a=n.length,i=new n.constructor(a);return a&&typeof n[0]=="string"&&t.call(n,"index")&&(i.index=n.index,i.input=n.input),i}return Tn=r,Tn}var Cn,Rc;function Ic(){if(Rc)return Cn;Rc=1;var e=he(),t=e.Uint8Array;return Cn=t,Cn}var Nn,jc;function Rn(){if(jc)return Nn;jc=1;var e=Ic();function t(r){var n=new r.constructor(r.byteLength);return new e(n).set(new e(r)),n}return Nn=t,Nn}var In,Oc;function qv(){if(Oc)return In;Oc=1;var e=Rn();function t(r,n){var a=n?e(r.buffer):r.buffer;return new r.constructor(a,r.byteOffset,r.byteLength)}return In=t,In}var jn,qc;function Pv(){if(qc)return jn;qc=1;var e=/\w*$/;function t(r){var n=new r.constructor(r.source,e.exec(r));return n.lastIndex=r.lastIndex,n}return jn=t,jn}var On,Pc;function Av(){if(Pc)return On;Pc=1;var e=Ae(),t=e?e.prototype:void 0,r=t?t.valueOf:void 0;function n(a){return r?Object(r.call(a)):{}}return On=n,On}var qn,Ac;function Lc(){if(Ac)return qn;Ac=1;var e=Rn();function t(r,n){var a=n?e(r.buffer):r.buffer;return new r.constructor(a,r.byteOffset,r.length)}return qn=t,qn}var Pn,Dc;function Lv(){if(Dc)return Pn;Dc=1;var e=Rn(),t=qv(),r=Pv(),n=Av(),a=Lc(),i="[object Boolean]",o="[object Date]",s="[object Map]",c="[object Number]",u="[object RegExp]",d="[object Set]",l="[object String]",p="[object Symbol]",h="[object ArrayBuffer]",m="[object DataView]",g="[object Float32Array]",v="[object Float64Array]",x="[object Int8Array]",b="[object Int16Array]",_="[object Int32Array]",y="[object Uint8Array]",S="[object Uint8ClampedArray]",w="[object Uint16Array]",E="[object Uint32Array]";function T(C,R,A){var B=C.constructor;switch(R){case h:return e(C);case i:case o:return new B(+C);case m:return t(C,A);case g:case v:case x:case b:case _:case y:case S:case w:case E:return a(C,A);case s:return new B;case c:case l:return new B(C);case u:return r(C);case d:return new B;case p:return n(C)}}return Pn=T,Pn}var An,Mc;function Bc(){if(Mc)return An;Mc=1;var e=de(),t=Object.create,r=(function(){function n(){}return function(a){if(!e(a))return{};if(t)return t(a);n.prototype=a;var i=new n;return n.prototype=void 0,i}})();return An=r,An}var Ln,Wc;function Fc(){if(Wc)return Ln;Wc=1;var e=Bc(),t=br(),r=yr();function n(a){return typeof a.constructor=="function"&&!r(a)?e(t(a)):{}}return Ln=n,Ln}var Dn,$c;function Dv(){if($c)return Dn;$c=1;var e=De(),t=ye(),r="[object Map]";function n(a){return t(a)&&e(a)==r}return Dn=n,Dn}var Mn,zc;function Mv(){if(zc)return Mn;zc=1;var e=Dv(),t=mr(),r=Gt(),n=r&&r.isMap,a=n?t(n):e;return Mn=a,Mn}var Bn,Hc;function Bv(){if(Hc)return Bn;Hc=1;var e=De(),t=ye(),r="[object Set]";function n(a){return t(a)&&e(a)==r}return Bn=n,Bn}var Wn,Gc;function Wv(){if(Gc)return Wn;Gc=1;var e=Bv(),t=mr(),r=Gt(),n=r&&r.isSet,a=n?t(n):e;return Wn=a,Wn}var Fn,Uc;function Kc(){if(Uc)return Fn;Uc=1;var e=pr(),t=Rt(),r=vr(),n=kv(),a=Ev(),i=nc(),o=ic(),s=Tv(),c=Cv(),u=xc(),d=Nv(),l=De(),p=Ov(),h=Lv(),m=Fc(),g=ne(),v=Le(),x=Mv(),b=de(),_=Wv(),y=we(),S=Ie(),w=1,E=2,T=4,C="[object Arguments]",R="[object Array]",A="[object Boolean]",B="[object Date]",N="[object Error]",M="[object Function]",L="[object GeneratorFunction]",$="[object Map]",U="[object Number]",W="[object Object]",z="[object RegExp]",K="[object Set]",j="[object String]",F="[object Symbol]",G="[object WeakMap]",k="[object ArrayBuffer]",I="[object DataView]",P="[object Float32Array]",O="[object Float64Array]",H="[object Int8Array]",J="[object Int16Array]",Z="[object Int32Array]",ee="[object Uint8Array]",ce="[object Uint8ClampedArray]",te="[object Uint16Array]",re="[object Uint32Array]",Y={};Y[C]=Y[R]=Y[k]=Y[I]=Y[A]=Y[B]=Y[P]=Y[O]=Y[H]=Y[J]=Y[Z]=Y[$]=Y[U]=Y[W]=Y[z]=Y[K]=Y[j]=Y[F]=Y[ee]=Y[ce]=Y[te]=Y[re]=!0,Y[N]=Y[M]=Y[G]=!1;function Oe(X,He,Ge,wb,Nr,Te){var se,Rr=He&w,Ir=He&E,Eb=He&T;if(Ge&&(se=Nr?Ge(X,wb,Nr,Te):Ge(X)),se!==void 0)return se;if(!b(X))return X;var Sh=g(X);if(Sh){if(se=p(X),!Rr)return o(X,se)}else{var Ue=l(X),wh=Ue==M||Ue==L;if(v(X))return i(X,Rr);if(Ue==W||Ue==C||wh&&!Nr){if(se=Ir||wh?{}:m(X),!Rr)return Ir?c(X,a(se,X)):s(X,n(se,X))}else{if(!Y[Ue])return Nr?X:{};se=h(X,Ue,Rr)}}Te||(Te=new e);var Eh=Te.get(X);if(Eh)return Eh;Te.set(X,se),_(X)?X.forEach(function(Ce){se.add(Oe(Ce,He,Ge,Ce,X,Te))}):x(X)&&X.forEach(function(Ce,qe){se.set(qe,Oe(Ce,He,Ge,qe,X,Te))});var Tb=Eb?Ir?d:u:Ir?S:y,Th=Sh?void 0:Tb(X);return t(Th||X,function(Ce,qe){Th&&(qe=Ce,Ce=X[qe]),r(se,qe,Oe(Ce,He,Ge,qe,X,Te))}),se}return Fn=Oe,Fn}var $n,Jc;function Fv(){if(Jc)return $n;Jc=1;var e=Kc(),t=4;function r(n){return e(n,t)}return $n=r,$n}var zn,Vc;function Hn(){if(Vc)return zn;Vc=1;function e(t){return function(){return t}}return zn=e,zn}var Gn,Yc;function $v(){if(Yc)return Gn;Yc=1;function e(t){return function(r,n,a){for(var i=-1,o=Object(r),s=a(r),c=s.length;c--;){var u=s[t?c:++i];if(n(o[u],u,o)===!1)break}return r}}return Gn=e,Gn}var Un,Xc;function Kn(){if(Xc)return Un;Xc=1;var e=$v(),t=e();return Un=t,Un}var Jn,Zc;function Vn(){if(Zc)return Jn;Zc=1;var e=Kn(),t=we();function r(n,a){return n&&e(n,a,t)}return Jn=r,Jn}var Yn,Qc;function zv(){if(Qc)return Yn;Qc=1;var e=xe();function t(r,n){return function(a,i){if(a==null)return a;if(!e(a))return r(a,i);for(var o=a.length,s=n?o:-1,c=Object(a);(n?s--:++s<o)&&i(c[s],s,c)!==!1;);return a}}return Yn=t,Yn}var Xn,ed;function xr(){if(ed)return Xn;ed=1;var e=Vn(),t=zv(),r=t(e);return Xn=r,Xn}var Zn,rd;function je(){if(rd)return Zn;rd=1;function e(t){return t}return Zn=e,Zn}var Qn,td;function nd(){if(td)return Qn;td=1;var e=je();function t(r){return typeof r=="function"?r:e}return Qn=t,Qn}var ea,ad;function id(){if(ad)return ea;ad=1;var e=Rt(),t=xr(),r=nd(),n=ne();function a(i,o){var s=n(i)?e:t;return s(i,r(o))}return ea=a,ea}var ra,od;function sd(){return od||(od=1,ra=id()),ra}var ta,ud;function Hv(){if(ud)return ta;ud=1;var e=xr();function t(r,n){var a=[];return e(r,function(i,o,s){n(i,o,s)&&a.push(i)}),a}return ta=t,ta}var na,cd;function Gv(){if(cd)return na;cd=1;var e="__lodash_hash_undefined__";function t(r){return this.__data__.set(r,e),this}return na=t,na}var aa,dd;function Uv(){if(dd)return aa;dd=1;function e(t){return this.__data__.has(t)}return aa=e,aa}var ia,ld;function fd(){if(ld)return ia;ld=1;var e=Et(),t=Gv(),r=Uv();function n(a){var i=-1,o=a==null?0:a.length;for(this.__data__=new e;++i<o;)this.add(a[i])}return n.prototype.add=n.prototype.push=t,n.prototype.has=r,ia=n,ia}var oa,pd;function Kv(){if(pd)return oa;pd=1;function e(t,r){for(var n=-1,a=t==null?0:t.length;++n<a;)if(r(t[n],n,t))return!0;return!1}return oa=e,oa}var sa,hd;function vd(){if(hd)return sa;hd=1;function e(t,r){return t.has(r)}return sa=e,sa}var ua,gd;function md(){if(gd)return ua;gd=1;var e=fd(),t=Kv(),r=vd(),n=1,a=2;function i(o,s,c,u,d,l){var p=c&n,h=o.length,m=s.length;if(h!=m&&!(p&&m>h))return!1;var g=l.get(o),v=l.get(s);if(g&&v)return g==s&&v==o;var x=-1,b=!0,_=c&a?new e:void 0;for(l.set(o,s),l.set(s,o);++x<h;){var y=o[x],S=s[x];if(u)var w=p?u(S,y,x,s,o,l):u(y,S,x,o,s,l);if(w!==void 0){if(w)continue;b=!1;break}if(_){if(!t(s,function(E,T){if(!r(_,T)&&(y===E||d(y,E,c,u,l)))return _.push(T)})){b=!1;break}}else if(!(y===S||d(y,S,c,u,l))){b=!1;break}}return l.delete(o),l.delete(s),b}return ua=i,ua}var ca,yd;function Jv(){if(yd)return ca;yd=1;function e(t){var r=-1,n=Array(t.size);return t.forEach(function(a,i){n[++r]=[i,a]}),n}return ca=e,ca}var da,bd;function la(){if(bd)return da;bd=1;function e(t){var r=-1,n=Array(t.size);return t.forEach(function(a){n[++r]=a}),n}return da=e,da}var fa,xd;function Vv(){if(xd)return fa;xd=1;var e=Ae(),t=Ic(),r=Pe(),n=md(),a=Jv(),i=la(),o=1,s=2,c="[object Boolean]",u="[object Date]",d="[object Error]",l="[object Map]",p="[object Number]",h="[object RegExp]",m="[object Set]",g="[object String]",v="[object Symbol]",x="[object ArrayBuffer]",b="[object DataView]",_=e?e.prototype:void 0,y=_?_.valueOf:void 0;function S(w,E,T,C,R,A,B){switch(T){case b:if(w.byteLength!=E.byteLength||w.byteOffset!=E.byteOffset)return!1;w=w.buffer,E=E.buffer;case x:return!(w.byteLength!=E.byteLength||!A(new t(w),new t(E)));case c:case u:case p:return r(+w,+E);case d:return w.name==E.name&&w.message==E.message;case h:case g:return w==E+"";case l:var N=a;case m:var M=C&o;if(N||(N=i),w.size!=E.size&&!M)return!1;var L=B.get(w);if(L)return L==E;C|=s,B.set(w,E);var $=n(N(w),N(E),C,R,A,B);return B.delete(w),$;case v:if(y)return y.call(w)==y.call(E)}return!1}return fa=S,fa}var pa,_d;function Yv(){if(_d)return pa;_d=1;var e=xc(),t=1,r=Object.prototype,n=r.hasOwnProperty;function a(i,o,s,c,u,d){var l=s&t,p=e(i),h=p.length,m=e(o),g=m.length;if(h!=g&&!l)return!1;for(var v=h;v--;){var x=p[v];if(!(l?x in o:n.call(o,x)))return!1}var b=d.get(i),_=d.get(o);if(b&&_)return b==o&&_==i;var y=!0;d.set(i,o),d.set(o,i);for(var S=l;++v<h;){x=p[v];var w=i[x],E=o[x];if(c)var T=l?c(E,w,x,o,i,d):c(w,E,x,i,o,d);if(!(T===void 0?w===E||u(w,E,s,c,d):T)){y=!1;break}S||(S=x=="constructor")}if(y&&!S){var C=i.constructor,R=o.constructor;C!=R&&"constructor"in i&&"constructor"in o&&!(typeof C=="function"&&C instanceof C&&typeof R=="function"&&R instanceof R)&&(y=!1)}return d.delete(i),d.delete(o),y}return pa=a,pa}var ha,kd;function Xv(){if(kd)return ha;kd=1;var e=pr(),t=md(),r=Vv(),n=Yv(),a=De(),i=ne(),o=Le(),s=er(),c=1,u="[object Arguments]",d="[object Array]",l="[object Object]",p=Object.prototype,h=p.hasOwnProperty;function m(g,v,x,b,_,y){var S=i(g),w=i(v),E=S?d:a(g),T=w?d:a(v);E=E==u?l:E,T=T==u?l:T;var C=E==l,R=T==l,A=E==T;if(A&&o(g)){if(!o(v))return!1;S=!0,C=!1}if(A&&!C)return y||(y=new e),S||s(g)?t(g,v,x,b,_,y):r(g,v,E,x,b,_,y);if(!(x&c)){var B=C&&h.call(g,"__wrapped__"),N=R&&h.call(v,"__wrapped__");if(B||N){var M=B?g.value():g,L=N?v.value():v;return y||(y=new e),_(M,L,x,b,y)}}return A?(y||(y=new e),n(g,v,x,b,_,y)):!1}return ha=m,ha}var va,Sd;function wd(){if(Sd)return va;Sd=1;var e=Xv(),t=ye();function r(n,a,i,o,s){return n===a?!0:n==null||a==null||!t(n)&&!t(a)?n!==n&&a!==a:e(n,a,i,o,r,s)}return va=r,va}var ga,Ed;function Zv(){if(Ed)return ga;Ed=1;var e=pr(),t=wd(),r=1,n=2;function a(i,o,s,c){var u=s.length,d=u,l=!c;if(i==null)return!d;for(i=Object(i);u--;){var p=s[u];if(l&&p[2]?p[1]!==i[p[0]]:!(p[0]in i))return!1}for(;++u<d;){p=s[u];var h=p[0],m=i[h],g=p[1];if(l&&p[2]){if(m===void 0&&!(h in i))return!1}else{var v=new e;if(c)var x=c(m,g,h,i,o,v);if(!(x===void 0?t(g,m,r|n,c,v):x))return!1}}return!0}return ga=a,ga}var ma,Td;function Cd(){if(Td)return ma;Td=1;var e=de();function t(r){return r===r&&!e(r)}return ma=t,ma}var ya,Nd;function Qv(){if(Nd)return ya;Nd=1;var e=Cd(),t=we();function r(n){for(var a=t(n),i=a.length;i--;){var o=a[i],s=n[o];a[i]=[o,s,e(s)]}return a}return ya=r,ya}var ba,Rd;function Id(){if(Rd)return ba;Rd=1;function e(t,r){return function(n){return n==null?!1:n[t]===r&&(r!==void 0||t in Object(n))}}return ba=e,ba}var xa,jd;function eg(){if(jd)return xa;jd=1;var e=Zv(),t=Qv(),r=Id();function n(a){var i=t(a);return i.length==1&&i[0][2]?r(i[0][0],i[0][1]):function(o){return o===a||e(o,a,i)}}return xa=n,xa}var _a,Od;function Me(){if(Od)return _a;Od=1;var e=Ne(),t=ye(),r="[object Symbol]";function n(a){return typeof a=="symbol"||t(a)&&e(a)==r}return _a=n,_a}var ka,qd;function Sa(){if(qd)return ka;qd=1;var e=ne(),t=Me(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;function a(i,o){if(e(i))return!1;var s=typeof i;return s=="number"||s=="symbol"||s=="boolean"||i==null||t(i)?!0:n.test(i)||!r.test(i)||o!=null&&i in Object(o)}return ka=a,ka}var wa,Pd;function rg(){if(Pd)return wa;Pd=1;var e=Et(),t="Expected a function";function r(n,a){if(typeof n!="function"||a!=null&&typeof a!="function")throw new TypeError(t);var i=function(){var o=arguments,s=a?a.apply(this,o):o[0],c=i.cache;if(c.has(s))return c.get(s);var u=n.apply(this,o);return i.cache=c.set(s,u)||c,u};return i.cache=new(r.Cache||e),i}return r.Cache=e,wa=r,wa}var Ea,Ad;function tg(){if(Ad)return Ea;Ad=1;var e=rg(),t=500;function r(n){var a=e(n,function(o){return i.size===t&&i.clear(),o}),i=a.cache;return a}return Ea=r,Ea}var Ta,Ld;function ng(){if(Ld)return Ta;Ld=1;var e=tg(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,n=e(function(a){var i=[];return a.charCodeAt(0)===46&&i.push(""),a.replace(t,function(o,s,c,u){i.push(c?u.replace(r,"$1"):s||o)}),i});return Ta=n,Ta}var Ca,Dd;function _r(){if(Dd)return Ca;Dd=1;function e(t,r){for(var n=-1,a=t==null?0:t.length,i=Array(a);++n<a;)i[n]=r(t[n],n,t);return i}return Ca=e,Ca}var Na,Md;function ag(){if(Md)return Na;Md=1;var e=Ae(),t=_r(),r=ne(),n=Me(),a=e?e.prototype:void 0,i=a?a.toString:void 0;function o(s){if(typeof s=="string")return s;if(r(s))return t(s,o)+"";if(n(s))return i?i.call(s):"";var c=s+"";return c=="0"&&1/s==-1/0?"-0":c}return Na=o,Na}var Ra,Bd;function Wd(){if(Bd)return Ra;Bd=1;var e=ag();function t(r){return r==null?"":e(r)}return Ra=t,Ra}var Ia,Fd;function kr(){if(Fd)return Ia;Fd=1;var e=ne(),t=Sa(),r=ng(),n=Wd();function a(i,o){return e(i)?i:t(i,o)?[i]:r(n(i))}return Ia=a,Ia}var ja,$d;function tr(){if($d)return ja;$d=1;var e=Me();function t(r){if(typeof r=="string"||e(r))return r;var n=r+"";return n=="0"&&1/r==-1/0?"-0":n}return ja=t,ja}var Oa,zd;function Sr(){if(zd)return Oa;zd=1;var e=kr(),t=tr();function r(n,a){a=e(a,n);for(var i=0,o=a.length;n!=null&&i<o;)n=n[t(a[i++])];return i&&i==o?n:void 0}return Oa=r,Oa}var qa,Hd;function ig(){if(Hd)return qa;Hd=1;var e=Sr();function t(r,n,a){var i=r==null?void 0:e(r,n);return i===void 0?a:i}return qa=t,qa}var Pa,Gd;function og(){if(Gd)return Pa;Gd=1;function e(t,r){return t!=null&&r in Object(t)}return Pa=e,Pa}var Aa,Ud;function Kd(){if(Ud)return Aa;Ud=1;var e=kr(),t=Xe(),r=ne(),n=gr(),a=$t(),i=tr();function o(s,c,u){c=e(c,s);for(var d=-1,l=c.length,p=!1;++d<l;){var h=i(c[d]);if(!(p=s!=null&&u(s,h)))break;s=s[h]}return p||++d!=l?p:(l=s==null?0:s.length,!!l&&a(l)&&n(h,l)&&(r(s)||t(s)))}return Aa=o,Aa}var La,Jd;function Vd(){if(Jd)return La;Jd=1;var e=og(),t=Kd();function r(n,a){return n!=null&&t(n,a,e)}return La=r,La}var Da,Yd;function sg(){if(Yd)return Da;Yd=1;var e=wd(),t=ig(),r=Vd(),n=Sa(),a=Cd(),i=Id(),o=tr(),s=1,c=2;function u(d,l){return n(d)&&a(l)?i(o(d),l):function(p){var h=t(p,d);return h===void 0&&h===l?r(p,d):e(l,h,s|c)}}return Da=u,Da}var Ma,Xd;function Zd(){if(Xd)return Ma;Xd=1;function e(t){return function(r){return r?.[t]}}return Ma=e,Ma}var Ba,Qd;function ug(){if(Qd)return Ba;Qd=1;var e=Sr();function t(r){return function(n){return e(n,r)}}return Ba=t,Ba}var Wa,el;function cg(){if(el)return Wa;el=1;var e=Zd(),t=ug(),r=Sa(),n=tr();function a(i){return r(i)?e(n(i)):t(i)}return Wa=a,Wa}var Fa,rl;function _e(){if(rl)return Fa;rl=1;var e=eg(),t=sg(),r=je(),n=ne(),a=cg();function i(o){return typeof o=="function"?o:o==null?r:typeof o=="object"?n(o)?t(o[0],o[1]):e(o):a(o)}return Fa=i,Fa}var $a,tl;function nl(){if(tl)return $a;tl=1;var e=sc(),t=Hv(),r=_e(),n=ne();function a(i,o){var s=n(i)?e:t;return s(i,r(o,3))}return $a=a,$a}var za,al;function dg(){if(al)return za;al=1;var e=Object.prototype,t=e.hasOwnProperty;function r(n,a){return n!=null&&t.call(n,a)}return za=r,za}var Ha,il;function ol(){if(il)return Ha;il=1;var e=dg(),t=Kd();function r(n,a){return n!=null&&t(n,a,e)}return Ha=r,Ha}var Ga,sl;function lg(){if(sl)return Ga;sl=1;var e=Zt(),t=De(),r=Xe(),n=ne(),a=xe(),i=Le(),o=yr(),s=er(),c="[object Map]",u="[object Set]",d=Object.prototype,l=d.hasOwnProperty;function p(h){if(h==null)return!0;if(a(h)&&(n(h)||typeof h=="string"||typeof h.splice=="function"||i(h)||s(h)||r(h)))return!h.length;var m=t(h);if(m==c||m==u)return!h.size;if(o(h))return!e(h).length;for(var g in h)if(l.call(h,g))return!1;return!0}return Ga=p,Ga}var Ua,ul;function cl(){if(ul)return Ua;ul=1;function e(t){return t===void 0}return Ua=e,Ua}var Ka,dl;function ll(){if(dl)return Ka;dl=1;var e=xr(),t=xe();function r(n,a){var i=-1,o=t(n)?Array(n.length):[];return e(n,function(s,c,u){o[++i]=a(s,c,u)}),o}return Ka=r,Ka}var Ja,fl;function pl(){if(fl)return Ja;fl=1;var e=_r(),t=_e(),r=ll(),n=ne();function a(i,o){var s=n(i)?e:r;return s(i,t(o,3))}return Ja=a,Ja}var Va,hl;function fg(){if(hl)return Va;hl=1;function e(t,r,n,a){var i=-1,o=t==null?0:t.length;for(a&&o&&(n=t[++i]);++i<o;)n=r(n,t[i],i,t);return n}return Va=e,Va}var Ya,vl;function pg(){if(vl)return Ya;vl=1;function e(t,r,n,a,i){return i(t,function(o,s,c){n=a?(a=!1,o):r(n,o,s,c)}),n}return Ya=e,Ya}var Xa,gl;function ml(){if(gl)return Xa;gl=1;var e=fg(),t=xr(),r=_e(),n=pg(),a=ne();function i(o,s,c){var u=a(o)?e:n,d=arguments.length<3;return u(o,r(s,4),c,d,t)}return Xa=i,Xa}var Za,yl;function hg(){if(yl)return Za;yl=1;var e=Ne(),t=ne(),r=ye(),n="[object String]";function a(i){return typeof i=="string"||!t(i)&&r(i)&&e(i)==n}return Za=a,Za}var Qa,bl;function vg(){if(bl)return Qa;bl=1;var e=Zd(),t=e("length");return Qa=t,Qa}var ei,xl;function gg(){if(xl)return ei;xl=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",a=t+r+n,i="\\ufe0e\\ufe0f",o="\\u200d",s=RegExp("["+o+e+a+i+"]");function c(u){return s.test(u)}return ei=c,ei}var ri,_l;function mg(){if(_l)return ri;_l=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",a=t+r+n,i="\\ufe0e\\ufe0f",o="["+e+"]",s="["+a+"]",c="\\ud83c[\\udffb-\\udfff]",u="(?:"+s+"|"+c+")",d="[^"+e+"]",l="(?:\\ud83c[\\udde6-\\uddff]){2}",p="[\\ud800-\\udbff][\\udc00-\\udfff]",h="\\u200d",m=u+"?",g="["+i+"]?",v="(?:"+h+"(?:"+[d,l,p].join("|")+")"+g+m+")*",x=g+m+v,b="(?:"+[d+s+"?",s,l,p,o].join("|")+")",_=RegExp(c+"(?="+c+")|"+b+x,"g");function y(S){for(var w=_.lastIndex=0;_.test(S);)++w;return w}return ri=y,ri}var ti,kl;function yg(){if(kl)return ti;kl=1;var e=vg(),t=gg(),r=mg();function n(a){return t(a)?r(a):e(a)}return ti=n,ti}var ni,Sl;function bg(){if(Sl)return ni;Sl=1;var e=Zt(),t=De(),r=xe(),n=hg(),a=yg(),i="[object Map]",o="[object Set]";function s(c){if(c==null)return 0;if(r(c))return n(c)?a(c):c.length;var u=t(c);return u==i||u==o?c.size:e(c).length}return ni=s,ni}var ai,wl;function xg(){if(wl)return ai;wl=1;var e=Rt(),t=Bc(),r=Vn(),n=_e(),a=br(),i=ne(),o=Le(),s=Ve(),c=de(),u=er();function d(l,p,h){var m=i(l),g=m||o(l)||u(l);if(p=n(p,4),h==null){var v=l&&l.constructor;g?h=m?new v:[]:c(l)?h=s(v)?t(a(l)):{}:h={}}return(g?e:r)(l,function(x,b,_){return p(h,x,b,_)}),h}return ai=d,ai}var ii,El;function _g(){if(El)return ii;El=1;var e=Ae(),t=Xe(),r=ne(),n=e?e.isConcatSpreadable:void 0;function a(i){return r(i)||t(i)||!!(n&&i&&i[n])}return ii=a,ii}var oi,Tl;function si(){if(Tl)return oi;Tl=1;var e=hn(),t=_g();function r(n,a,i,o,s){var c=-1,u=n.length;for(i||(i=t),s||(s=[]);++c<u;){var d=n[c];a>0&&i(d)?a>1?r(d,a-1,i,o,s):e(s,d):o||(s[s.length]=d)}return s}return oi=r,oi}var ui,Cl;function kg(){if(Cl)return ui;Cl=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 ui=e,ui}var ci,Nl;function Rl(){if(Nl)return ci;Nl=1;var e=kg(),t=Math.max;function r(n,a,i){return a=t(a===void 0?n.length-1:a,0),function(){for(var o=arguments,s=-1,c=t(o.length-a,0),u=Array(c);++s<c;)u[s]=o[a+s];s=-1;for(var d=Array(a+1);++s<a;)d[s]=o[s];return d[a]=i(u),e(n,this,d)}}return ci=r,ci}var di,Il;function Sg(){if(Il)return di;Il=1;var e=Hn(),t=Eu(),r=je(),n=t?function(a,i){return t(a,"toString",{configurable:!0,enumerable:!1,value:e(i),writable:!0})}:r;return di=n,di}var li,jl;function wg(){if(jl)return li;jl=1;var e=800,t=16,r=Date.now;function n(a){var i=0,o=0;return function(){var s=r(),c=t-(s-o);if(o=s,c>0){if(++i>=e)return arguments[0]}else i=0;return a.apply(void 0,arguments)}}return li=n,li}var fi,Ol;function ql(){if(Ol)return fi;Ol=1;var e=Sg(),t=wg(),r=t(e);return fi=r,fi}var pi,Pl;function wr(){if(Pl)return pi;Pl=1;var e=je(),t=Rl(),r=ql();function n(a,i){return r(t(a,i,e),a+"")}return pi=n,pi}var hi,Al;function Ll(){if(Al)return hi;Al=1;function e(t,r,n,a){for(var i=t.length,o=n+(a?1:-1);a?o--:++o<i;)if(r(t[o],o,t))return o;return-1}return hi=e,hi}var vi,Dl;function Eg(){if(Dl)return vi;Dl=1;function e(t){return t!==t}return vi=e,vi}var gi,Ml;function Tg(){if(Ml)return gi;Ml=1;function e(t,r,n){for(var a=n-1,i=t.length;++a<i;)if(t[a]===r)return a;return-1}return gi=e,gi}var mi,Bl;function Cg(){if(Bl)return mi;Bl=1;var e=Ll(),t=Eg(),r=Tg();function n(a,i,o){return i===i?r(a,i,o):e(a,t,o)}return mi=n,mi}var yi,Wl;function Ng(){if(Wl)return yi;Wl=1;var e=Cg();function t(r,n){var a=r==null?0:r.length;return!!a&&e(r,n,0)>-1}return yi=t,yi}var bi,Fl;function Rg(){if(Fl)return bi;Fl=1;function e(t,r,n){for(var a=-1,i=t==null?0:t.length;++a<i;)if(n(r,t[a]))return!0;return!1}return bi=e,bi}var xi,$l;function Ig(){if($l)return xi;$l=1;function e(){}return xi=e,xi}var _i,zl;function jg(){if(zl)return _i;zl=1;var e=Ec(),t=Ig(),r=la(),n=1/0,a=e&&1/r(new e([,-0]))[1]==n?function(i){return new e(i)}:t;return _i=a,_i}var ki,Hl;function Og(){if(Hl)return ki;Hl=1;var e=fd(),t=Ng(),r=Rg(),n=vd(),a=jg(),i=la(),o=200;function s(c,u,d){var l=-1,p=t,h=c.length,m=!0,g=[],v=g;if(d)m=!1,p=r;else if(h>=o){var x=u?null:a(c);if(x)return i(x);m=!1,p=n,v=new e}else v=u?[]:g;e:for(;++l<h;){var b=c[l],_=u?u(b):b;if(b=d||b!==0?b:0,m&&_===_){for(var y=v.length;y--;)if(v[y]===_)continue e;u&&v.push(_),g.push(b)}else p(v,_,d)||(v!==g&&v.push(_),g.push(b))}return g}return ki=s,ki}var Si,Gl;function Ul(){if(Gl)return Si;Gl=1;var e=xe(),t=ye();function r(n){return t(n)&&e(n)}return Si=r,Si}var wi,Kl;function qg(){if(Kl)return wi;Kl=1;var e=si(),t=wr(),r=Og(),n=Ul(),a=t(function(i){return r(e(i,1,n,!0))});return wi=a,wi}var Ei,Jl;function Pg(){if(Jl)return Ei;Jl=1;var e=_r();function t(r,n){return e(n,function(a){return r[a]})}return Ei=t,Ei}var Ti,Vl;function Yl(){if(Vl)return Ti;Vl=1;var e=Pg(),t=we();function r(n){return n==null?[]:e(n,t(n))}return Ti=r,Ti}var Ci,Xl;function le(){if(Xl)return Ci;Xl=1;var e;if(typeof Ar=="function")try{e={clone:Fv(),constant:Hn(),each:sd(),filter:nl(),has:ol(),isArray:ne(),isEmpty:lg(),isFunction:Ve(),isUndefined:cl(),keys:we(),map:pl(),reduce:ml(),size:bg(),transform:xg(),union:qg(),values:Yl()}}catch{}return e||(e=window._),Ci=e,Ci}var Ni,Zl;function Ri(){if(Zl)return Ni;Zl=1;var e=le();Ni=a;var t="\0",r="\0",n="";function a(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={}}a.prototype._nodeCount=0,a.prototype._edgeCount=0,a.prototype.isDirected=function(){return this._isDirected},a.prototype.isMultigraph=function(){return this._isMultigraph},a.prototype.isCompound=function(){return this._isCompound},a.prototype.setGraph=function(d){return this._label=d,this},a.prototype.graph=function(){return this._label},a.prototype.setDefaultNodeLabel=function(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultNodeLabelFn=d,this},a.prototype.nodeCount=function(){return this._nodeCount},a.prototype.nodes=function(){return e.keys(this._nodes)},a.prototype.sources=function(){var d=this;return e.filter(this.nodes(),function(l){return e.isEmpty(d._in[l])})},a.prototype.sinks=function(){var d=this;return e.filter(this.nodes(),function(l){return e.isEmpty(d._out[l])})},a.prototype.setNodes=function(d,l){var p=arguments,h=this;return e.each(d,function(m){p.length>1?h.setNode(m,l):h.setNode(m)}),this},a.prototype.setNode=function(d,l){return e.has(this._nodes,d)?(arguments.length>1&&(this._nodes[d]=l),this):(this._nodes[d]=arguments.length>1?l: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)},a.prototype.node=function(d){return this._nodes[d]},a.prototype.hasNode=function(d){return e.has(this._nodes,d)},a.prototype.removeNode=function(d){var l=this;if(e.has(this._nodes,d)){var p=function(h){l.removeEdge(l._edgeObjs[h])};delete this._nodes[d],this._isCompound&&(this._removeFromParentsChildList(d),delete this._parent[d],e.each(this.children(d),function(h){l.setParent(h)}),delete this._children[d]),e.each(e.keys(this._in[d]),p),delete this._in[d],delete this._preds[d],e.each(e.keys(this._out[d]),p),delete this._out[d],delete this._sucs[d],--this._nodeCount}return this},a.prototype.setParent=function(d,l){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(l))l=r;else{l+="";for(var p=l;!e.isUndefined(p);p=this.parent(p))if(p===d)throw new Error("Setting "+l+" as parent of "+d+" would create a cycle");this.setNode(l)}return this.setNode(d),this._removeFromParentsChildList(d),this._parent[d]=l,this._children[l][d]=!0,this},a.prototype._removeFromParentsChildList=function(d){delete this._children[this._parent[d]][d]},a.prototype.parent=function(d){if(this._isCompound){var l=this._parent[d];if(l!==r)return l}},a.prototype.children=function(d){if(e.isUndefined(d)&&(d=r),this._isCompound){var l=this._children[d];if(l)return e.keys(l)}else{if(d===r)return this.nodes();if(this.hasNode(d))return[]}},a.prototype.predecessors=function(d){var l=this._preds[d];if(l)return e.keys(l)},a.prototype.successors=function(d){var l=this._sucs[d];if(l)return e.keys(l)},a.prototype.neighbors=function(d){var l=this.predecessors(d);if(l)return e.union(l,this.successors(d))},a.prototype.isLeaf=function(d){var l;return this.isDirected()?l=this.successors(d):l=this.neighbors(d),l.length===0},a.prototype.filterNodes=function(d){var l=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});l.setGraph(this.graph());var p=this;e.each(this._nodes,function(g,v){d(v)&&l.setNode(v,g)}),e.each(this._edgeObjs,function(g){l.hasNode(g.v)&&l.hasNode(g.w)&&l.setEdge(g,p.edge(g))});var h={};function m(g){var v=p.parent(g);return v===void 0||l.hasNode(v)?(h[g]=v,v):v in h?h[v]:m(v)}return this._isCompound&&e.each(l.nodes(),function(g){l.setParent(g,m(g))}),l},a.prototype.setDefaultEdgeLabel=function(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultEdgeLabelFn=d,this},a.prototype.edgeCount=function(){return this._edgeCount},a.prototype.edges=function(){return e.values(this._edgeObjs)},a.prototype.setPath=function(d,l){var p=this,h=arguments;return e.reduce(d,function(m,g){return h.length>1?p.setEdge(m,g,l):p.setEdge(m,g),g}),this},a.prototype.setEdge=function(){var d,l,p,h,m=!1,g=arguments[0];typeof g=="object"&&g!==null&&"v"in g?(d=g.v,l=g.w,p=g.name,arguments.length===2&&(h=arguments[1],m=!0)):(d=g,l=arguments[1],p=arguments[3],arguments.length>2&&(h=arguments[2],m=!0)),d=""+d,l=""+l,e.isUndefined(p)||(p=""+p);var v=s(this._isDirected,d,l,p);if(e.has(this._edgeLabels,v))return m&&(this._edgeLabels[v]=h),this;if(!e.isUndefined(p)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(d),this.setNode(l),this._edgeLabels[v]=m?h:this._defaultEdgeLabelFn(d,l,p);var x=c(this._isDirected,d,l,p);return d=x.v,l=x.w,Object.freeze(x),this._edgeObjs[v]=x,i(this._preds[l],d),i(this._sucs[d],l),this._in[l][v]=x,this._out[d][v]=x,this._edgeCount++,this},a.prototype.edge=function(d,l,p){var h=arguments.length===1?u(this._isDirected,arguments[0]):s(this._isDirected,d,l,p);return this._edgeLabels[h]},a.prototype.hasEdge=function(d,l,p){var h=arguments.length===1?u(this._isDirected,arguments[0]):s(this._isDirected,d,l,p);return e.has(this._edgeLabels,h)},a.prototype.removeEdge=function(d,l,p){var h=arguments.length===1?u(this._isDirected,arguments[0]):s(this._isDirected,d,l,p),m=this._edgeObjs[h];return m&&(d=m.v,l=m.w,delete this._edgeLabels[h],delete this._edgeObjs[h],o(this._preds[l],d),o(this._sucs[d],l),delete this._in[l][h],delete this._out[d][h],this._edgeCount--),this},a.prototype.inEdges=function(d,l){var p=this._in[d];if(p){var h=e.values(p);return l?e.filter(h,function(m){return m.v===l}):h}},a.prototype.outEdges=function(d,l){var p=this._out[d];if(p){var h=e.values(p);return l?e.filter(h,function(m){return m.w===l}):h}},a.prototype.nodeEdges=function(d,l){var p=this.inEdges(d,l);if(p)return p.concat(this.outEdges(d,l))};function i(d,l){d[l]?d[l]++:d[l]=1}function o(d,l){--d[l]||delete d[l]}function s(d,l,p,h){var m=""+l,g=""+p;if(!d&&m>g){var v=m;m=g,g=v}return m+n+g+n+(e.isUndefined(h)?t:h)}function c(d,l,p,h){var m=""+l,g=""+p;if(!d&&m>g){var v=m;m=g,g=v}var x={v:m,w:g};return h&&(x.name=h),x}function u(d,l){return s(d,l.v,l.w,l.name)}return Ni}var Ii,Ql;function Ag(){return Ql||(Ql=1,Ii="2.1.8"),Ii}var ji,ef;function Lg(){return ef||(ef=1,ji={Graph:Ri(),version:Ag()}),ji}var Oi,rf;function Dg(){if(rf)return Oi;rf=1;var e=le(),t=Ri();Oi={write:r,read:i};function r(o){var s={options:{directed:o.isDirected(),multigraph:o.isMultigraph(),compound:o.isCompound()},nodes:n(o),edges:a(o)};return e.isUndefined(o.graph())||(s.value=e.clone(o.graph())),s}function n(o){return e.map(o.nodes(),function(s){var c=o.node(s),u=o.parent(s),d={v:s};return e.isUndefined(c)||(d.value=c),e.isUndefined(u)||(d.parent=u),d})}function a(o){return e.map(o.edges(),function(s){var c=o.edge(s),u={v:s.v,w:s.w};return e.isUndefined(s.name)||(u.name=s.name),e.isUndefined(c)||(u.value=c),u})}function i(o){var s=new t(o.options).setGraph(o.value);return e.each(o.nodes,function(c){s.setNode(c.v,c.value),c.parent&&s.setParent(c.v,c.parent)}),e.each(o.edges,function(c){s.setEdge({v:c.v,w:c.w,name:c.name},c.value)}),s}return Oi}var qi,tf;function Mg(){if(tf)return qi;tf=1;var e=le();qi=t;function t(r){var n={},a=[],i;function o(s){e.has(n,s)||(n[s]=!0,i.push(s),e.each(r.successors(s),o),e.each(r.predecessors(s),o))}return e.each(r.nodes(),function(s){i=[],o(s),i.length&&a.push(i)}),a}return qi}var Pi,nf;function af(){if(nf)return Pi;nf=1;var e=le();Pi=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 a=this._keyIndices;if(r=String(r),!e.has(a,r)){var i=this._arr,o=i.length;return a[r]=o,i.push({key:r,priority:n}),this._decrease(o),!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 a=this._keyIndices[r];if(n>this._arr[a].priority)throw new Error("New priority is greater than current priority. Key: "+r+" Old: "+this._arr[a].priority+" New: "+n);this._arr[a].priority=n,this._decrease(a)},t.prototype._heapify=function(r){var n=this._arr,a=2*r,i=a+1,o=r;a<n.length&&(o=n[a].priority<n[o].priority?a:o,i<n.length&&(o=n[i].priority<n[o].priority?i:o),o!==r&&(this._swap(r,o),this._heapify(o)))},t.prototype._decrease=function(r){for(var n=this._arr,a=n[r].priority,i;r!==0&&(i=r>>1,!(n[i].priority<a));)this._swap(r,i),r=i},t.prototype._swap=function(r,n){var a=this._arr,i=this._keyIndices,o=a[r],s=a[n];a[r]=s,a[n]=o,i[s.key]=r,i[o.key]=n},Pi}var Ai,of;function sf(){if(of)return Ai;of=1;var e=le(),t=af();Ai=n;var r=e.constant(1);function n(i,o,s,c){return a(i,String(o),s||r,c||function(u){return i.outEdges(u)})}function a(i,o,s,c){var u={},d=new t,l,p,h=function(m){var g=m.v!==l?m.v:m.w,v=u[g],x=s(m),b=p.distance+x;if(x<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+m+" Weight: "+x);b<v.distance&&(v.distance=b,v.predecessor=l,d.decrease(g,b))};for(i.nodes().forEach(function(m){var g=m===o?0:Number.POSITIVE_INFINITY;u[m]={distance:g},d.add(m,g)});d.size()>0&&(l=d.removeMin(),p=u[l],p.distance!==Number.POSITIVE_INFINITY);)c(l).forEach(h);return u}return Ai}var Li,uf;function Bg(){if(uf)return Li;uf=1;var e=sf(),t=le();Li=r;function r(n,a,i){return t.transform(n.nodes(),function(o,s){o[s]=e(n,s,a,i)},{})}return Li}var Di,cf;function df(){if(cf)return Di;cf=1;var e=le();Di=t;function t(r){var n=0,a=[],i={},o=[];function s(c){var u=i[c]={onStack:!0,lowlink:n,index:n++};if(a.push(c),r.successors(c).forEach(function(p){e.has(i,p)?i[p].onStack&&(u.lowlink=Math.min(u.lowlink,i[p].index)):(s(p),u.lowlink=Math.min(u.lowlink,i[p].lowlink))}),u.lowlink===u.index){var d=[],l;do l=a.pop(),i[l].onStack=!1,d.push(l);while(c!==l);o.push(d)}}return r.nodes().forEach(function(c){e.has(i,c)||s(c)}),o}return Di}var Mi,lf;function Wg(){if(lf)return Mi;lf=1;var e=le(),t=df();Mi=r;function r(n){return e.filter(t(n),function(a){return a.length>1||a.length===1&&n.hasEdge(a[0],a[0])})}return Mi}var Bi,ff;function Fg(){if(ff)return Bi;ff=1;var e=le();Bi=r;var t=e.constant(1);function r(a,i,o){return n(a,i||t,o||function(s){return a.outEdges(s)})}function n(a,i,o){var s={},c=a.nodes();return c.forEach(function(u){s[u]={},s[u][u]={distance:0},c.forEach(function(d){u!==d&&(s[u][d]={distance:Number.POSITIVE_INFINITY})}),o(u).forEach(function(d){var l=d.v===u?d.w:d.v,p=i(d);s[u][l]={distance:p,predecessor:u}})}),c.forEach(function(u){var d=s[u];c.forEach(function(l){var p=s[l];c.forEach(function(h){var m=p[u],g=d[h],v=p[h],x=m.distance+g.distance;x<v.distance&&(v.distance=x,v.predecessor=g.predecessor)})})}),s}return Bi}var Wi,pf;function hf(){if(pf)return Wi;pf=1;var e=le();Wi=t,t.CycleException=r;function t(n){var a={},i={},o=[];function s(c){if(e.has(i,c))throw new r;e.has(a,c)||(i[c]=!0,a[c]=!0,e.each(n.predecessors(c),s),delete i[c],o.push(c))}if(e.each(n.sinks(),s),e.size(a)!==n.nodeCount())throw new r;return o}function r(){}return r.prototype=new Error,Wi}var Fi,vf;function $g(){if(vf)return Fi;vf=1;var e=hf();Fi=t;function t(r){try{e(r)}catch(n){if(n instanceof e.CycleException)return!1;throw n}return!0}return Fi}var $i,gf;function mf(){if(gf)return $i;gf=1;var e=le();$i=t;function t(n,a,i){e.isArray(a)||(a=[a]);var o=(n.isDirected()?n.successors:n.neighbors).bind(n),s=[],c={};return e.each(a,function(u){if(!n.hasNode(u))throw new Error("Graph does not have node: "+u);r(n,u,i==="post",c,o,s)}),s}function r(n,a,i,o,s,c){e.has(o,a)||(o[a]=!0,i||c.push(a),e.each(s(a),function(u){r(n,u,i,o,s,c)}),i&&c.push(a))}return $i}var zi,yf;function zg(){if(yf)return zi;yf=1;var e=mf();zi=t;function t(r,n){return e(r,n,"post")}return zi}var Hi,bf;function Hg(){if(bf)return Hi;bf=1;var e=mf();Hi=t;function t(r,n){return e(r,n,"pre")}return Hi}var Gi,xf;function Gg(){if(xf)return Gi;xf=1;var e=le(),t=Ri(),r=af();Gi=n;function n(a,i){var o=new t,s={},c=new r,u;function d(p){var h=p.v===u?p.w:p.v,m=c.priority(h);if(m!==void 0){var g=i(p);g<m&&(s[h]=u,c.decrease(h,g))}}if(a.nodeCount()===0)return o;e.each(a.nodes(),function(p){c.add(p,Number.POSITIVE_INFINITY),o.setNode(p)}),c.decrease(a.nodes()[0],0);for(var l=!1;c.size()>0;){if(u=c.removeMin(),e.has(s,u))o.setEdge(u,s[u]);else{if(l)throw new Error("Input graph is not connected: "+a);l=!0}a.nodeEdges(u).forEach(d)}return o}return Gi}var Ui,_f;function Ug(){return _f||(_f=1,Ui={components:Mg(),dijkstra:sf(),dijkstraAll:Bg(),findCycles:Wg(),floydWarshall:Fg(),isAcyclic:$g(),postorder:zg(),preorder:Hg(),prim:Gg(),tarjan:df(),topsort:hf()}),Ui}var Ki,kf;function Kg(){if(kf)return Ki;kf=1;var e=Lg();return Ki={Graph:e.Graph,json:Dg(),alg:Ug(),version:e.version},Ki}var Ji,Sf;function ve(){if(Sf)return Ji;Sf=1;var e;if(typeof Ar=="function")try{e=Kg()}catch{}return e||(e=window.graphlib),Ji=e,Ji}var Vi,wf;function Jg(){if(wf)return Vi;wf=1;var e=Kc(),t=1,r=4;function n(a){return e(a,t|r)}return Vi=n,Vi}var Yi,Ef;function Er(){if(Ef)return Yi;Ef=1;var e=Pe(),t=xe(),r=gr(),n=de();function a(i,o,s){if(!n(s))return!1;var c=typeof o;return(c=="number"?t(s)&&r(o,s.length):c=="string"&&o in s)?e(s[o],i):!1}return Yi=a,Yi}var Xi,Tf;function Vg(){if(Tf)return Xi;Tf=1;var e=wr(),t=Pe(),r=Er(),n=Ie(),a=Object.prototype,i=a.hasOwnProperty,o=e(function(s,c){s=Object(s);var u=-1,d=c.length,l=d>2?c[2]:void 0;for(l&&r(c[0],c[1],l)&&(d=1);++u<d;)for(var p=c[u],h=n(p),m=-1,g=h.length;++m<g;){var v=h[m],x=s[v];(x===void 0||t(x,a[v])&&!i.call(s,v))&&(s[v]=p[v])}return s});return Xi=o,Xi}var Zi,Cf;function Yg(){if(Cf)return Zi;Cf=1;var e=_e(),t=xe(),r=we();function n(a){return function(i,o,s){var c=Object(i);if(!t(i)){var u=e(o,3);i=r(i),o=function(l){return u(c[l],l,c)}}var d=a(i,o,s);return d>-1?c[u?i[d]:d]:void 0}}return Zi=n,Zi}var Qi,Nf;function Xg(){if(Nf)return Qi;Nf=1;var e=/\s/;function t(r){for(var n=r.length;n--&&e.test(r.charAt(n)););return n}return Qi=t,Qi}var eo,Rf;function Zg(){if(Rf)return eo;Rf=1;var e=Xg(),t=/^\s+/;function r(n){return n&&n.slice(0,e(n)+1).replace(t,"")}return eo=r,eo}var ro,If;function Qg(){if(If)return ro;If=1;var e=Zg(),t=de(),r=Me(),n=NaN,a=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,o=/^0o[0-7]+$/i,s=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 l=i.test(u);return l||o.test(u)?s(u.slice(2),l?2:8):a.test(u)?n:+u}return ro=c,ro}var to,jf;function Of(){if(jf)return to;jf=1;var e=Qg(),t=1/0,r=17976931348623157e292;function n(a){if(!a)return a===0?a:0;if(a=e(a),a===t||a===-t){var i=a<0?-1:1;return i*r}return a===a?a:0}return to=n,to}var no,qf;function em(){if(qf)return no;qf=1;var e=Of();function t(r){var n=e(r),a=n%1;return n===n?a?n-a:n:0}return no=t,no}var ao,Pf;function rm(){if(Pf)return ao;Pf=1;var e=Ll(),t=_e(),r=em(),n=Math.max;function a(i,o,s){var c=i==null?0:i.length;if(!c)return-1;var u=s==null?0:r(s);return u<0&&(u=n(c+u,0)),e(i,t(o,3),u)}return ao=a,ao}var io,Af;function tm(){if(Af)return io;Af=1;var e=Yg(),t=rm(),r=e(t);return io=r,io}var oo,Lf;function Df(){if(Lf)return oo;Lf=1;var e=si();function t(r){var n=r==null?0:r.length;return n?e(r,1):[]}return oo=t,oo}var so,Mf;function nm(){if(Mf)return so;Mf=1;var e=Kn(),t=nd(),r=Ie();function n(a,i){return a==null?a:e(a,t(i),r)}return so=n,so}var uo,Bf;function am(){if(Bf)return uo;Bf=1;function e(t){var r=t==null?0:t.length;return r?t[r-1]:void 0}return uo=e,uo}var co,Wf;function im(){if(Wf)return co;Wf=1;var e=hr(),t=Vn(),r=_e();function n(a,i){var o={};return i=r(i,3),t(a,function(s,c,u){e(o,c,i(s,c,u))}),o}return co=n,co}var lo,Ff;function fo(){if(Ff)return lo;Ff=1;var e=Me();function t(r,n,a){for(var i=-1,o=r.length;++i<o;){var s=r[i],c=n(s);if(c!=null&&(u===void 0?c===c&&!e(c):a(c,u)))var u=c,d=s}return d}return lo=t,lo}var po,$f;function om(){if($f)return po;$f=1;function e(t,r){return t>r}return po=e,po}var ho,zf;function sm(){if(zf)return ho;zf=1;var e=fo(),t=om(),r=je();function n(a){return a&&a.length?e(a,r,t):void 0}return ho=n,ho}var vo,Hf;function Gf(){if(Hf)return vo;Hf=1;var e=hr(),t=Pe();function r(n,a,i){(i!==void 0&&!t(n[a],i)||i===void 0&&!(a in n))&&e(n,a,i)}return vo=r,vo}var go,Uf;function um(){if(Uf)return go;Uf=1;var e=Ne(),t=br(),r=ye(),n="[object Object]",a=Function.prototype,i=Object.prototype,o=a.toString,s=i.hasOwnProperty,c=o.call(Object);function u(d){if(!r(d)||e(d)!=n)return!1;var l=t(d);if(l===null)return!0;var p=s.call(l,"constructor")&&l.constructor;return typeof p=="function"&&p instanceof p&&o.call(p)==c}return go=u,go}var mo,Kf;function Jf(){if(Kf)return mo;Kf=1;function e(t,r){if(!(r==="constructor"&&typeof t[r]=="function")&&r!="__proto__")return t[r]}return mo=e,mo}var yo,Vf;function cm(){if(Vf)return yo;Vf=1;var e=Ye(),t=Ie();function r(n){return e(n,t(n))}return yo=r,yo}var bo,Yf;function dm(){if(Yf)return bo;Yf=1;var e=Gf(),t=nc(),r=Lc(),n=ic(),a=Fc(),i=Xe(),o=ne(),s=Ul(),c=Le(),u=Ve(),d=de(),l=um(),p=er(),h=Jf(),m=cm();function g(v,x,b,_,y,S,w){var E=h(v,b),T=h(x,b),C=w.get(T);if(C){e(v,b,C);return}var R=S?S(E,T,b+"",v,x,w):void 0,A=R===void 0;if(A){var B=o(T),N=!B&&c(T),M=!B&&!N&&p(T);R=T,B||N||M?o(E)?R=E:s(E)?R=n(E):N?(A=!1,R=t(T,!0)):M?(A=!1,R=r(T,!0)):R=[]:l(T)||i(T)?(R=E,i(E)?R=m(E):(!d(E)||u(E))&&(R=a(T))):A=!1}A&&(w.set(T,R),y(R,T,_,S,w),w.delete(T)),e(v,b,R)}return bo=g,bo}var xo,Xf;function lm(){if(Xf)return xo;Xf=1;var e=pr(),t=Gf(),r=Kn(),n=dm(),a=de(),i=Ie(),o=Jf();function s(c,u,d,l,p){c!==u&&r(u,function(h,m){if(p||(p=new e),a(h))n(c,u,m,d,s,l,p);else{var g=l?l(o(c,m),h,m+"",c,u,p):void 0;g===void 0&&(g=h),t(c,m,g)}},i)}return xo=s,xo}var _o,Zf;function fm(){if(Zf)return _o;Zf=1;var e=wr(),t=Er();function r(n){return e(function(a,i){var o=-1,s=i.length,c=s>1?i[s-1]:void 0,u=s>2?i[2]:void 0;for(c=n.length>3&&typeof c=="function"?(s--,c):void 0,u&&t(i[0],i[1],u)&&(c=s<3?void 0:c,s=1),a=Object(a);++o<s;){var d=i[o];d&&n(a,d,o,c)}return a})}return _o=r,_o}var ko,Qf;function pm(){if(Qf)return ko;Qf=1;var e=lm(),t=fm(),r=t(function(n,a,i){e(n,a,i)});return ko=r,ko}var So,ep;function rp(){if(ep)return So;ep=1;function e(t,r){return t<r}return So=e,So}var wo,tp;function hm(){if(tp)return wo;tp=1;var e=fo(),t=rp(),r=je();function n(a){return a&&a.length?e(a,r,t):void 0}return wo=n,wo}var Eo,np;function vm(){if(np)return Eo;np=1;var e=fo(),t=_e(),r=rp();function n(a,i){return a&&a.length?e(a,t(i,2),r):void 0}return Eo=n,Eo}var To,ap;function gm(){if(ap)return To;ap=1;var e=he(),t=function(){return e.Date.now()};return To=t,To}var Co,ip;function mm(){if(ip)return Co;ip=1;var e=vr(),t=kr(),r=gr(),n=de(),a=tr();function i(o,s,c,u){if(!n(o))return o;s=t(s,o);for(var d=-1,l=s.length,p=l-1,h=o;h!=null&&++d<l;){var m=a(s[d]),g=c;if(m==="__proto__"||m==="constructor"||m==="prototype")return o;if(d!=p){var v=h[m];g=u?u(v,m,h):void 0,g===void 0&&(g=n(v)?v:r(s[d+1])?[]:{})}e(h,m,g),h=h[m]}return o}return Co=i,Co}var No,op;function ym(){if(op)return No;op=1;var e=Sr(),t=mm(),r=kr();function n(a,i,o){for(var s=-1,c=i.length,u={};++s<c;){var d=i[s],l=e(a,d);o(l,d)&&t(u,r(d,a),l)}return u}return No=n,No}var Ro,sp;function bm(){if(sp)return Ro;sp=1;var e=ym(),t=Vd();function r(n,a){return e(n,a,function(i,o){return t(n,o)})}return Ro=r,Ro}var Io,up;function xm(){if(up)return Io;up=1;var e=Df(),t=Rl(),r=ql();function n(a){return r(t(a,void 0,e),a+"")}return Io=n,Io}var jo,cp;function _m(){if(cp)return jo;cp=1;var e=bm(),t=xm(),r=t(function(n,a){return n==null?{}:e(n,a)});return jo=r,jo}var Oo,dp;function km(){if(dp)return Oo;dp=1;var e=Math.ceil,t=Math.max;function r(n,a,i,o){for(var s=-1,c=t(e((a-n)/(i||1)),0),u=Array(c);c--;)u[o?c:++s]=n,n+=i;return u}return Oo=r,Oo}var qo,lp;function Sm(){if(lp)return qo;lp=1;var e=km(),t=Er(),r=Of();function n(a){return function(i,o,s){return s&&typeof s!="number"&&t(i,o,s)&&(o=s=void 0),i=r(i),o===void 0?(o=i,i=0):o=r(o),s=s===void 0?i<o?1:-1:r(s),e(i,o,s,a)}}return qo=n,qo}var Po,fp;function wm(){if(fp)return Po;fp=1;var e=Sm(),t=e();return Po=t,Po}var Ao,pp;function Em(){if(pp)return Ao;pp=1;function e(t,r){var n=t.length;for(t.sort(r);n--;)t[n]=t[n].value;return t}return Ao=e,Ao}var Lo,hp;function Tm(){if(hp)return Lo;hp=1;var e=Me();function t(r,n){if(r!==n){var a=r!==void 0,i=r===null,o=r===r,s=e(r),c=n!==void 0,u=n===null,d=n===n,l=e(n);if(!u&&!l&&!s&&r>n||s&&c&&d&&!u&&!l||i&&c&&d||!a&&d||!o)return 1;if(!i&&!s&&!l&&r<n||l&&a&&o&&!i&&!s||u&&a&&o||!c&&o||!d)return-1}return 0}return Lo=t,Lo}var Do,vp;function Cm(){if(vp)return Do;vp=1;var e=Tm();function t(r,n,a){for(var i=-1,o=r.criteria,s=n.criteria,c=o.length,u=a.length;++i<c;){var d=e(o[i],s[i]);if(d){if(i>=u)return d;var l=a[i];return d*(l=="desc"?-1:1)}}return r.index-n.index}return Do=t,Do}var Mo,gp;function Nm(){if(gp)return Mo;gp=1;var e=_r(),t=Sr(),r=_e(),n=ll(),a=Em(),i=mr(),o=Cm(),s=je(),c=ne();function u(d,l,p){l.length?l=e(l,function(g){return c(g)?function(v){return t(v,g.length===1?g[0]:g)}:g}):l=[s];var h=-1;l=e(l,i(r));var m=n(d,function(g,v,x){var b=e(l,function(_){return _(g)});return{criteria:b,index:++h,value:g}});return a(m,function(g,v){return o(g,v,p)})}return Mo=u,Mo}var Bo,mp;function Rm(){if(mp)return Bo;mp=1;var e=si(),t=Nm(),r=wr(),n=Er(),a=r(function(i,o){if(i==null)return[];var s=o.length;return s>1&&n(i,o[0],o[1])?o=[]:s>2&&n(o[0],o[1],o[2])&&(o=[o[0]]),t(i,e(o,1),[])});return Bo=a,Bo}var Wo,yp;function Im(){if(yp)return Wo;yp=1;var e=Wd(),t=0;function r(n){var a=++t;return e(n)+a}return Wo=r,Wo}var Fo,bp;function jm(){if(bp)return Fo;bp=1;function e(t,r,n){for(var a=-1,i=t.length,o=r.length,s={};++a<i;){var c=a<o?r[a]:void 0;n(s,t[a],c)}return s}return Fo=e,Fo}var $o,xp;function Om(){if(xp)return $o;xp=1;var e=vr(),t=jm();function r(n,a){return t(n||[],a||[],e)}return $o=r,$o}var zo,_p;function Q(){if(_p)return zo;_p=1;var e;if(typeof Ar=="function")try{e={cloneDeep:Jg(),constant:Hn(),defaults:Vg(),each:sd(),filter:nl(),find:tm(),flatten:Df(),forEach:id(),forIn:nm(),has:ol(),isUndefined:cl(),last:am(),map:pl(),mapValues:im(),max:sm(),merge:pm(),min:hm(),minBy:vm(),now:gm(),pick:_m(),range:wm(),reduce:ml(),sortBy:Rm(),uniqueId:Im(),values:Yl(),zipObject:Om()}}catch{}return e||(e=window._),zo=e,zo}var Ho,kp;function qm(){if(kp)return Ho;kp=1,Ho=e;function e(){var n={};n._next=n._prev=n,this._sentinel=n}e.prototype.dequeue=function(){var n=this._sentinel,a=n._prev;if(a!==n)return t(a),a},e.prototype.enqueue=function(n){var a=this._sentinel;n._prev&&n._next&&t(n),n._next=a._next,a._next._prev=n,a._next=n,n._prev=a},e.prototype.toString=function(){for(var n=[],a=this._sentinel,i=a._prev;i!==a;)n.push(JSON.stringify(i,r)),i=i._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,a){if(n!=="_next"&&n!=="_prev")return a}return Ho}var Go,Sp;function Pm(){if(Sp)return Go;Sp=1;var e=Q(),t=ve().Graph,r=qm();Go=a;var n=e.constant(1);function a(u,d){if(u.nodeCount()<=1)return[];var l=s(u,d||n),p=i(l.graph,l.buckets,l.zeroIdx);return e.flatten(e.map(p,function(h){return u.outEdges(h.v,h.w)}),!0)}function i(u,d,l){for(var p=[],h=d[d.length-1],m=d[0],g;u.nodeCount();){for(;g=m.dequeue();)o(u,d,l,g);for(;g=h.dequeue();)o(u,d,l,g);if(u.nodeCount()){for(var v=d.length-2;v>0;--v)if(g=d[v].dequeue(),g){p=p.concat(o(u,d,l,g,!0));break}}}return p}function o(u,d,l,p,h){var m=h?[]:void 0;return e.forEach(u.inEdges(p.v),function(g){var v=u.edge(g),x=u.node(g.v);h&&m.push({v:g.v,w:g.w}),x.out-=v,c(d,l,x)}),e.forEach(u.outEdges(p.v),function(g){var v=u.edge(g),x=g.w,b=u.node(x);b.in-=v,c(d,l,b)}),u.removeNode(p.v),m}function s(u,d){var l=new t,p=0,h=0;e.forEach(u.nodes(),function(v){l.setNode(v,{v,in:0,out:0})}),e.forEach(u.edges(),function(v){var x=l.edge(v.v,v.w)||0,b=d(v),_=x+b;l.setEdge(v.v,v.w,_),h=Math.max(h,l.node(v.v).out+=b),p=Math.max(p,l.node(v.w).in+=b)});var m=e.range(h+p+3).map(function(){return new r}),g=p+1;return e.forEach(l.nodes(),function(v){c(m,g,l.node(v))}),{graph:l,buckets:m,zeroIdx:g}}function c(u,d,l){l.out?l.in?u[l.out-l.in+d].enqueue(l):u[u.length-1].enqueue(l):u[0].enqueue(l)}return Go}var Uo,wp;function Am(){if(wp)return Uo;wp=1;var e=Q(),t=Pm();Uo={run:r,undo:a};function r(i){var o=i.graph().acyclicer==="greedy"?t(i,s(i)):n(i);e.forEach(o,function(c){var u=i.edge(c);i.removeEdge(c),u.forwardName=c.name,u.reversed=!0,i.setEdge(c.w,c.v,u,e.uniqueId("rev"))});function s(c){return function(u){return c.edge(u).weight}}}function n(i){var o=[],s={},c={};function u(d){e.has(c,d)||(c[d]=!0,s[d]=!0,e.forEach(i.outEdges(d),function(l){e.has(s,l.w)?o.push(l):u(l.w)}),delete s[d])}return e.forEach(i.nodes(),u),o}function a(i){e.forEach(i.edges(),function(o){var s=i.edge(o);if(s.reversed){i.removeEdge(o);var c=s.forwardName;delete s.reversed,delete s.forwardName,i.setEdge(o.w,o.v,s,c)}})}return Uo}var Ko,Ep;function oe(){if(Ep)return Ko;Ep=1;var e=Q(),t=ve().Graph;Ko={addDummyNode:r,simplify:n,asNonCompoundGraph:a,successorWeights:i,predecessorWeights:o,intersectRect:s,buildLayerMatrix:c,normalizeRanks:u,removeEmptyRanks:d,addBorderNode:l,maxRank:p,partition:h,time:m,notime:g};function r(v,x,b,_){var y;do y=e.uniqueId(_);while(v.hasNode(y));return b.dummy=x,v.setNode(y,b),y}function n(v){var x=new t().setGraph(v.graph());return e.forEach(v.nodes(),function(b){x.setNode(b,v.node(b))}),e.forEach(v.edges(),function(b){var _=x.edge(b.v,b.w)||{weight:0,minlen:1},y=v.edge(b);x.setEdge(b.v,b.w,{weight:_.weight+y.weight,minlen:Math.max(_.minlen,y.minlen)})}),x}function a(v){var x=new t({multigraph:v.isMultigraph()}).setGraph(v.graph());return e.forEach(v.nodes(),function(b){v.children(b).length||x.setNode(b,v.node(b))}),e.forEach(v.edges(),function(b){x.setEdge(b,v.edge(b))}),x}function i(v){var x=e.map(v.nodes(),function(b){var _={};return e.forEach(v.outEdges(b),function(y){_[y.w]=(_[y.w]||0)+v.edge(y).weight}),_});return e.zipObject(v.nodes(),x)}function o(v){var x=e.map(v.nodes(),function(b){var _={};return e.forEach(v.inEdges(b),function(y){_[y.v]=(_[y.v]||0)+v.edge(y).weight}),_});return e.zipObject(v.nodes(),x)}function s(v,x){var b=v.x,_=v.y,y=x.x-b,S=x.y-_,w=v.width/2,E=v.height/2;if(!y&&!S)throw new Error("Not possible to find intersection inside of the rectangle");var T,C;return Math.abs(S)*w>Math.abs(y)*E?(S<0&&(E=-E),T=E*y/S,C=E):(y<0&&(w=-w),T=w,C=w*S/y),{x:b+T,y:_+C}}function c(v){var x=e.map(e.range(p(v)+1),function(){return[]});return e.forEach(v.nodes(),function(b){var _=v.node(b),y=_.rank;e.isUndefined(y)||(x[y][_.order]=b)}),x}function u(v){var x=e.min(e.map(v.nodes(),function(b){return v.node(b).rank}));e.forEach(v.nodes(),function(b){var _=v.node(b);e.has(_,"rank")&&(_.rank-=x)})}function d(v){var x=e.min(e.map(v.nodes(),function(S){return v.node(S).rank})),b=[];e.forEach(v.nodes(),function(S){var w=v.node(S).rank-x;b[w]||(b[w]=[]),b[w].push(S)});var _=0,y=v.graph().nodeRankFactor;e.forEach(b,function(S,w){e.isUndefined(S)&&w%y!==0?--_:_&&e.forEach(S,function(E){v.node(E).rank+=_})})}function l(v,x,b,_){var y={width:0,height:0};return arguments.length>=4&&(y.rank=b,y.order=_),r(v,"border",y,x)}function p(v){return e.max(e.map(v.nodes(),function(x){var b=v.node(x).rank;if(!e.isUndefined(b))return b}))}function h(v,x){var b={lhs:[],rhs:[]};return e.forEach(v,function(_){x(_)?b.lhs.push(_):b.rhs.push(_)}),b}function m(v,x){var b=e.now();try{return x()}finally{console.log(v+" time: "+(e.now()-b)+"ms")}}function g(v,x){return x()}return Ko}var Jo,Tp;function Lm(){if(Tp)return Jo;Tp=1;var e=Q(),t=oe();Jo={run:r,undo:a};function r(i){i.graph().dummyChains=[],e.forEach(i.edges(),function(o){n(i,o)})}function n(i,o){var s=o.v,c=i.node(s).rank,u=o.w,d=i.node(u).rank,l=o.name,p=i.edge(o),h=p.labelRank;if(d!==c+1){i.removeEdge(o);var m,g,v;for(v=0,++c;c<d;++v,++c)p.points=[],g={width:0,height:0,edgeLabel:p,edgeObj:o,rank:c},m=t.addDummyNode(i,"edge",g,"_d"),c===h&&(g.width=p.width,g.height=p.height,g.dummy="edge-label",g.labelpos=p.labelpos),i.setEdge(s,m,{weight:p.weight},l),v===0&&i.graph().dummyChains.push(m),s=m;i.setEdge(s,u,{weight:p.weight},l)}}function a(i){e.forEach(i.graph().dummyChains,function(o){var s=i.node(o),c=s.edgeLabel,u;for(i.setEdge(s.edgeObj,c);s.dummy;)u=i.successors(o)[0],i.removeNode(o),c.points.push({x:s.x,y:s.y}),s.dummy==="edge-label"&&(c.x=s.x,c.y=s.y,c.width=s.width,c.height=s.height),o=u,s=i.node(o)})}return Jo}var Vo,Cp;function Tr(){if(Cp)return Vo;Cp=1;var e=Q();Vo={longestPath:t,slack:r};function t(n){var a={};function i(o){var s=n.node(o);if(e.has(a,o))return s.rank;a[o]=!0;var c=e.min(e.map(n.outEdges(o),function(u){return i(u.w)-n.edge(u).minlen}));return(c===Number.POSITIVE_INFINITY||c===void 0||c===null)&&(c=0),s.rank=c}e.forEach(n.sources(),i)}function r(n,a){return n.node(a.w).rank-n.node(a.v).rank-n.edge(a).minlen}return Vo}var Yo,Np;function Rp(){if(Np)return Yo;Np=1;var e=Q(),t=ve().Graph,r=Tr().slack;Yo=n;function n(s){var c=new t({directed:!1}),u=s.nodes()[0],d=s.nodeCount();c.setNode(u,{});for(var l,p;a(c,s)<d;)l=i(c,s),p=c.hasNode(l.v)?r(s,l):-r(s,l),o(c,s,p);return c}function a(s,c){function u(d){e.forEach(c.nodeEdges(d),function(l){var p=l.v,h=d===p?l.w:p;!s.hasNode(h)&&!r(c,l)&&(s.setNode(h,{}),s.setEdge(d,h,{}),u(h))})}return e.forEach(s.nodes(),u),s.nodeCount()}function i(s,c){return e.minBy(c.edges(),function(u){if(s.hasNode(u.v)!==s.hasNode(u.w))return r(c,u)})}function o(s,c,u){e.forEach(s.nodes(),function(d){c.node(d).rank+=u})}return Yo}var Xo,Ip;function Dm(){if(Ip)return Xo;Ip=1;var e=Q(),t=Rp(),r=Tr().slack,n=Tr().longestPath,a=ve().alg.preorder,i=ve().alg.postorder,o=oe().simplify;Xo=s,s.initLowLimValues=l,s.initCutValues=c,s.calcCutValue=d,s.leaveEdge=h,s.enterEdge=m,s.exchangeEdges=g;function s(_){_=o(_),n(_);var y=t(_);l(y),c(y,_);for(var S,w;S=h(y);)w=m(y,_,S),g(y,_,S,w)}function c(_,y){var S=i(_,_.nodes());S=S.slice(0,S.length-1),e.forEach(S,function(w){u(_,y,w)})}function u(_,y,S){var w=_.node(S),E=w.parent;_.edge(S,E).cutvalue=d(_,y,S)}function d(_,y,S){var w=_.node(S),E=w.parent,T=!0,C=y.edge(S,E),R=0;return C||(T=!1,C=y.edge(E,S)),R=C.weight,e.forEach(y.nodeEdges(S),function(A){var B=A.v===S,N=B?A.w:A.v;if(N!==E){var M=B===T,L=y.edge(A).weight;if(R+=M?L:-L,x(_,S,N)){var $=_.edge(S,N).cutvalue;R+=M?-$:$}}}),R}function l(_,y){arguments.length<2&&(y=_.nodes()[0]),p(_,{},1,y)}function p(_,y,S,w,E){var T=S,C=_.node(w);return y[w]=!0,e.forEach(_.neighbors(w),function(R){e.has(y,R)||(S=p(_,y,S,R,w))}),C.low=T,C.lim=S++,E?C.parent=E:delete C.parent,S}function h(_){return e.find(_.edges(),function(y){return _.edge(y).cutvalue<0})}function m(_,y,S){var w=S.v,E=S.w;y.hasEdge(w,E)||(w=S.w,E=S.v);var T=_.node(w),C=_.node(E),R=T,A=!1;T.lim>C.lim&&(R=C,A=!0);var B=e.filter(y.edges(),function(N){return A===b(_,_.node(N.v),R)&&A!==b(_,_.node(N.w),R)});return e.minBy(B,function(N){return r(y,N)})}function g(_,y,S,w){var E=S.v,T=S.w;_.removeEdge(E,T),_.setEdge(w.v,w.w,{}),l(_),c(_,y),v(_,y)}function v(_,y){var S=e.find(_.nodes(),function(E){return!y.node(E).parent}),w=a(_,S);w=w.slice(1),e.forEach(w,function(E){var T=_.node(E).parent,C=y.edge(E,T),R=!1;C||(C=y.edge(T,E),R=!0),y.node(E).rank=y.node(T).rank+(R?C.minlen:-C.minlen)})}function x(_,y,S){return _.hasEdge(y,S)}function b(_,y,S){return S.low<=y.lim&&y.lim<=S.lim}return Xo}var Zo,jp;function Mm(){if(jp)return Zo;jp=1;var e=Tr(),t=e.longestPath,r=Rp(),n=Dm();Zo=a;function a(c){switch(c.graph().ranker){case"network-simplex":s(c);break;case"tight-tree":o(c);break;case"longest-path":i(c);break;default:s(c)}}var i=t;function o(c){t(c),r(c)}function s(c){n(c)}return Zo}var Qo,Op;function Bm(){if(Op)return Qo;Op=1;var e=Q();Qo=t;function t(a){var i=n(a);e.forEach(a.graph().dummyChains,function(o){for(var s=a.node(o),c=s.edgeObj,u=r(a,i,c.v,c.w),d=u.path,l=u.lca,p=0,h=d[p],m=!0;o!==c.w;){if(s=a.node(o),m){for(;(h=d[p])!==l&&a.node(h).maxRank<s.rank;)p++;h===l&&(m=!1)}if(!m){for(;p<d.length-1&&a.node(h=d[p+1]).minRank<=s.rank;)p++;h=d[p]}a.setParent(o,h),o=a.successors(o)[0]}})}function r(a,i,o,s){var c=[],u=[],d=Math.min(i[o].low,i[s].low),l=Math.max(i[o].lim,i[s].lim),p,h;p=o;do p=a.parent(p),c.push(p);while(p&&(i[p].low>d||l>i[p].lim));for(h=p,p=s;(p=a.parent(p))!==h;)u.push(p);return{path:c.concat(u.reverse()),lca:h}}function n(a){var i={},o=0;function s(c){var u=o;e.forEach(a.children(c),s),i[c]={low:u,lim:o++}}return e.forEach(a.children(),s),i}return Qo}var es,qp;function Wm(){if(qp)return es;qp=1;var e=Q(),t=oe();es={run:r,cleanup:o};function r(s){var c=t.addDummyNode(s,"root",{},"_root"),u=a(s),d=e.max(e.values(u))-1,l=2*d+1;s.graph().nestingRoot=c,e.forEach(s.edges(),function(h){s.edge(h).minlen*=l});var p=i(s)+1;e.forEach(s.children(),function(h){n(s,c,l,p,d,u,h)}),s.graph().nodeRankFactor=l}function n(s,c,u,d,l,p,h){var m=s.children(h);if(!m.length){h!==c&&s.setEdge(c,h,{weight:0,minlen:u});return}var g=t.addBorderNode(s,"_bt"),v=t.addBorderNode(s,"_bb"),x=s.node(h);s.setParent(g,h),x.borderTop=g,s.setParent(v,h),x.borderBottom=v,e.forEach(m,function(b){n(s,c,u,d,l,p,b);var _=s.node(b),y=_.borderTop?_.borderTop:b,S=_.borderBottom?_.borderBottom:b,w=_.borderTop?d:2*d,E=y!==S?1:l-p[h]+1;s.setEdge(g,y,{weight:w,minlen:E,nestingEdge:!0}),s.setEdge(S,v,{weight:w,minlen:E,nestingEdge:!0})}),s.parent(h)||s.setEdge(c,g,{weight:0,minlen:l+p[h]})}function a(s){var c={};function u(d,l){var p=s.children(d);p&&p.length&&e.forEach(p,function(h){u(h,l+1)}),c[d]=l}return e.forEach(s.children(),function(d){u(d,1)}),c}function i(s){return e.reduce(s.edges(),function(c,u){return c+s.edge(u).weight},0)}function o(s){var c=s.graph();s.removeNode(c.nestingRoot),delete c.nestingRoot,e.forEach(s.edges(),function(u){var d=s.edge(u);d.nestingEdge&&s.removeEdge(u)})}return es}var rs,Pp;function Fm(){if(Pp)return rs;Pp=1;var e=Q(),t=oe();rs=r;function r(a){function i(o){var s=a.children(o),c=a.node(o);if(s.length&&e.forEach(s,i),e.has(c,"minRank")){c.borderLeft=[],c.borderRight=[];for(var u=c.minRank,d=c.maxRank+1;u<d;++u)n(a,"borderLeft","_bl",o,c,u),n(a,"borderRight","_br",o,c,u)}}e.forEach(a.children(),i)}function n(a,i,o,s,c,u){var d={width:0,height:0,rank:u,borderType:i},l=c[i][u-1],p=t.addDummyNode(a,"border",d,o);c[i][u]=p,a.setParent(p,s),l&&a.setEdge(l,p,{weight:1})}return rs}var ts,Ap;function $m(){if(Ap)return ts;Ap=1;var e=Q();ts={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")&&i(u),(d==="lr"||d==="rl")&&(s(u),n(u))}function n(u){e.forEach(u.nodes(),function(d){a(u.node(d))}),e.forEach(u.edges(),function(d){a(u.edge(d))})}function a(u){var d=u.width;u.width=u.height,u.height=d}function i(u){e.forEach(u.nodes(),function(d){o(u.node(d))}),e.forEach(u.edges(),function(d){var l=u.edge(d);e.forEach(l.points,o),e.has(l,"y")&&o(l)})}function o(u){u.y=-u.y}function s(u){e.forEach(u.nodes(),function(d){c(u.node(d))}),e.forEach(u.edges(),function(d){var l=u.edge(d);e.forEach(l.points,c),e.has(l,"x")&&c(l)})}function c(u){var d=u.x;u.x=u.y,u.y=d}return ts}var ns,Lp;function zm(){if(Lp)return ns;Lp=1;var e=Q();ns=t;function t(r){var n={},a=e.filter(r.nodes(),function(u){return!r.children(u).length}),i=e.max(e.map(a,function(u){return r.node(u).rank})),o=e.map(e.range(i+1),function(){return[]});function s(u){if(!e.has(n,u)){n[u]=!0;var d=r.node(u);o[d.rank].push(u),e.forEach(r.successors(u),s)}}var c=e.sortBy(a,function(u){return r.node(u).rank});return e.forEach(c,s),o}return ns}var as,Dp;function Hm(){if(Dp)return as;Dp=1;var e=Q();as=t;function t(n,a){for(var i=0,o=1;o<a.length;++o)i+=r(n,a[o-1],a[o]);return i}function r(n,a,i){for(var o=e.zipObject(i,e.map(i,function(p,h){return h})),s=e.flatten(e.map(a,function(p){return e.sortBy(e.map(n.outEdges(p),function(h){return{pos:o[h.w],weight:n.edge(h).weight}}),"pos")}),!0),c=1;c<i.length;)c<<=1;var u=2*c-1;c-=1;var d=e.map(new Array(u),function(){return 0}),l=0;return e.forEach(s.forEach(function(p){var h=p.pos+c;d[h]+=p.weight;for(var m=0;h>0;)h%2&&(m+=d[h+1]),h=h-1>>1,d[h]+=p.weight;l+=p.weight*m})),l}return as}var is,Mp;function Gm(){if(Mp)return is;Mp=1;var e=Q();is=t;function t(r,n){return e.map(n,function(a){var i=r.inEdges(a);if(i.length){var o=e.reduce(i,function(s,c){var u=r.edge(c),d=r.node(c.v);return{sum:s.sum+u.weight*d.order,weight:s.weight+u.weight}},{sum:0,weight:0});return{v:a,barycenter:o.sum/o.weight,weight:o.weight}}else return{v:a}})}return is}var os,Bp;function Um(){if(Bp)return os;Bp=1;var e=Q();os=t;function t(a,i){var o={};e.forEach(a,function(c,u){var d=o[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(i.edges(),function(c){var u=o[c.v],d=o[c.w];!e.isUndefined(u)&&!e.isUndefined(d)&&(d.indegree++,u.out.push(o[c.w]))});var s=e.filter(o,function(c){return!c.indegree});return r(s)}function r(a){var i=[];function o(u){return function(d){d.merged||(e.isUndefined(d.barycenter)||e.isUndefined(u.barycenter)||d.barycenter>=u.barycenter)&&n(u,d)}}function s(u){return function(d){d.in.push(u),--d.indegree===0&&a.push(d)}}for(;a.length;){var c=a.pop();i.push(c),e.forEach(c.in.reverse(),o(c)),e.forEach(c.out,s(c))}return e.map(e.filter(i,function(u){return!u.merged}),function(u){return e.pick(u,["vs","i","barycenter","weight"])})}function n(a,i){var o=0,s=0;a.weight&&(o+=a.barycenter*a.weight,s+=a.weight),i.weight&&(o+=i.barycenter*i.weight,s+=i.weight),a.vs=i.vs.concat(a.vs),a.barycenter=o/s,a.weight=s,a.i=Math.min(i.i,a.i),i.merged=!0}return os}var ss,Wp;function Km(){if(Wp)return ss;Wp=1;var e=Q(),t=oe();ss=r;function r(i,o){var s=t.partition(i,function(g){return e.has(g,"barycenter")}),c=s.lhs,u=e.sortBy(s.rhs,function(g){return-g.i}),d=[],l=0,p=0,h=0;c.sort(a(!!o)),h=n(d,u,h),e.forEach(c,function(g){h+=g.vs.length,d.push(g.vs),l+=g.barycenter*g.weight,p+=g.weight,h=n(d,u,h)});var m={vs:e.flatten(d,!0)};return p&&(m.barycenter=l/p,m.weight=p),m}function n(i,o,s){for(var c;o.length&&(c=e.last(o)).i<=s;)o.pop(),i.push(c.vs),s++;return s}function a(i){return function(o,s){return o.barycenter<s.barycenter?-1:o.barycenter>s.barycenter?1:i?s.i-o.i:o.i-s.i}}return ss}var us,Fp;function Jm(){if(Fp)return us;Fp=1;var e=Q(),t=Gm(),r=Um(),n=Km();us=a;function a(s,c,u,d){var l=s.children(c),p=s.node(c),h=p?p.borderLeft:void 0,m=p?p.borderRight:void 0,g={};h&&(l=e.filter(l,function(S){return S!==h&&S!==m}));var v=t(s,l);e.forEach(v,function(S){if(s.children(S.v).length){var w=a(s,S.v,u,d);g[S.v]=w,e.has(w,"barycenter")&&o(S,w)}});var x=r(v,u);i(x,g);var b=n(x,d);if(h&&(b.vs=e.flatten([h,b.vs,m],!0),s.predecessors(h).length)){var _=s.node(s.predecessors(h)[0]),y=s.node(s.predecessors(m)[0]);e.has(b,"barycenter")||(b.barycenter=0,b.weight=0),b.barycenter=(b.barycenter*b.weight+_.order+y.order)/(b.weight+2),b.weight+=2}return b}function i(s,c){e.forEach(s,function(u){u.vs=e.flatten(u.vs.map(function(d){return c[d]?c[d].vs:d}),!0)})}function o(s,c){e.isUndefined(s.barycenter)?(s.barycenter=c.barycenter,s.weight=c.weight):(s.barycenter=(s.barycenter*s.weight+c.barycenter*c.weight)/(s.weight+c.weight),s.weight+=c.weight)}return us}var cs,$p;function Vm(){if($p)return cs;$p=1;var e=Q(),t=ve().Graph;cs=r;function r(a,i,o){var s=n(a),c=new t({compound:!0}).setGraph({root:s}).setDefaultNodeLabel(function(u){return a.node(u)});return e.forEach(a.nodes(),function(u){var d=a.node(u),l=a.parent(u);(d.rank===i||d.minRank<=i&&i<=d.maxRank)&&(c.setNode(u),c.setParent(u,l||s),e.forEach(a[o](u),function(p){var h=p.v===u?p.w:p.v,m=c.edge(h,u),g=e.isUndefined(m)?0:m.weight;c.setEdge(h,u,{weight:a.edge(p).weight+g})}),e.has(d,"minRank")&&c.setNode(u,{borderLeft:d.borderLeft[i],borderRight:d.borderRight[i]}))}),c}function n(a){for(var i;a.hasNode(i=e.uniqueId("_root")););return i}return cs}var ds,zp;function Ym(){if(zp)return ds;zp=1;var e=Q();ds=t;function t(r,n,a){var i={},o;e.forEach(a,function(s){for(var c=r.parent(s),u,d;c;){if(u=r.parent(c),u?(d=i[u],i[u]=c):(d=o,o=c),d&&d!==c){n.setEdge(d,c);return}c=u}})}return ds}var ls,Hp;function Xm(){if(Hp)return ls;Hp=1;var e=Q(),t=zm(),r=Hm(),n=Jm(),a=Vm(),i=Ym(),o=ve().Graph,s=oe();ls=c;function c(p){var h=s.maxRank(p),m=u(p,e.range(1,h+1),"inEdges"),g=u(p,e.range(h-1,-1,-1),"outEdges"),v=t(p);l(p,v);for(var x=Number.POSITIVE_INFINITY,b,_=0,y=0;y<4;++_,++y){d(_%2?m:g,_%4>=2),v=s.buildLayerMatrix(p);var S=r(p,v);S<x&&(y=0,b=e.cloneDeep(v),x=S)}l(p,b)}function u(p,h,m){return e.map(h,function(g){return a(p,g,m)})}function d(p,h){var m=new o;e.forEach(p,function(g){var v=g.graph().root,x=n(g,v,m,h);e.forEach(x.vs,function(b,_){g.node(b).order=_}),i(g,m,x.vs)})}function l(p,h){e.forEach(h,function(m){e.forEach(m,function(g,v){p.node(g).order=v})})}return ls}var fs,Gp;function Zm(){if(Gp)return fs;Gp=1;var e=Q(),t=ve().Graph,r=oe();fs={positionX:m,findType1Conflicts:n,findType2Conflicts:a,addConflict:o,hasConflict:s,verticalAlignment:c,horizontalCompaction:u,alignCoordinates:p,findSmallestWidthAlignment:l,balance:h};function n(x,b){var _={};function y(S,w){var E=0,T=0,C=S.length,R=e.last(w);return e.forEach(w,function(A,B){var N=i(x,A),M=N?x.node(N).order:C;(N||A===R)&&(e.forEach(w.slice(T,B+1),function(L){e.forEach(x.predecessors(L),function($){var U=x.node($),W=U.order;(W<E||M<W)&&!(U.dummy&&x.node(L).dummy)&&o(_,$,L)})}),T=B+1,E=M)}),w}return e.reduce(b,y),_}function a(x,b){var _={};function y(w,E,T,C,R){var A;e.forEach(e.range(E,T),function(B){A=w[B],x.node(A).dummy&&e.forEach(x.predecessors(A),function(N){var M=x.node(N);M.dummy&&(M.order<C||M.order>R)&&o(_,N,A)})})}function S(w,E){var T=-1,C,R=0;return e.forEach(E,function(A,B){if(x.node(A).dummy==="border"){var N=x.predecessors(A);N.length&&(C=x.node(N[0]).order,y(E,R,B,T,C),R=B,T=C)}y(E,R,E.length,C,w.length)}),E}return e.reduce(b,S),_}function i(x,b){if(x.node(b).dummy)return e.find(x.predecessors(b),function(_){return x.node(_).dummy})}function o(x,b,_){if(b>_){var y=b;b=_,_=y}var S=x[b];S||(x[b]=S={}),S[_]=!0}function s(x,b,_){if(b>_){var y=b;b=_,_=y}return e.has(x[b],_)}function c(x,b,_,y){var S={},w={},E={};return e.forEach(b,function(T){e.forEach(T,function(C,R){S[C]=C,w[C]=C,E[C]=R})}),e.forEach(b,function(T){var C=-1;e.forEach(T,function(R){var A=y(R);if(A.length){A=e.sortBy(A,function($){return E[$]});for(var B=(A.length-1)/2,N=Math.floor(B),M=Math.ceil(B);N<=M;++N){var L=A[N];w[R]===R&&C<E[L]&&!s(_,R,L)&&(w[L]=R,w[R]=S[R]=S[L],C=E[L])}}})}),{root:S,align:w}}function u(x,b,_,y,S){var w={},E=d(x,b,_,S),T=S?"borderLeft":"borderRight";function C(B,N){for(var M=E.nodes(),L=M.pop(),$={};L;)$[L]?B(L):($[L]=!0,M.push(L),M=M.concat(N(L))),L=M.pop()}function R(B){w[B]=E.inEdges(B).reduce(function(N,M){return Math.max(N,w[M.v]+E.edge(M))},0)}function A(B){var N=E.outEdges(B).reduce(function(L,$){return Math.min(L,w[$.w]-E.edge($))},Number.POSITIVE_INFINITY),M=x.node(B);N!==Number.POSITIVE_INFINITY&&M.borderType!==T&&(w[B]=Math.max(w[B],N))}return C(R,E.predecessors.bind(E)),C(A,E.successors.bind(E)),e.forEach(y,function(B){w[B]=w[_[B]]}),w}function d(x,b,_,y){var S=new t,w=x.graph(),E=g(w.nodesep,w.edgesep,y);return e.forEach(b,function(T){var C;e.forEach(T,function(R){var A=_[R];if(S.setNode(A),C){var B=_[C],N=S.edge(B,A);S.setEdge(B,A,Math.max(E(x,R,C),N||0))}C=R})}),S}function l(x,b){return e.minBy(e.values(b),function(_){var y=Number.NEGATIVE_INFINITY,S=Number.POSITIVE_INFINITY;return e.forIn(_,function(w,E){var T=v(x,E)/2;y=Math.max(w+T,y),S=Math.min(w-T,S)}),y-S})}function p(x,b){var _=e.values(b),y=e.min(_),S=e.max(_);e.forEach(["u","d"],function(w){e.forEach(["l","r"],function(E){var T=w+E,C=x[T],R;if(C!==b){var A=e.values(C);R=E==="l"?y-e.min(A):S-e.max(A),R&&(x[T]=e.mapValues(C,function(B){return B+R}))}})})}function h(x,b){return e.mapValues(x.ul,function(_,y){if(b)return x[b.toLowerCase()][y];var S=e.sortBy(e.map(x,y));return(S[1]+S[2])/2})}function m(x){var b=r.buildLayerMatrix(x),_=e.merge(n(x,b),a(x,b)),y={},S;e.forEach(["u","d"],function(E){S=E==="u"?b:e.values(b).reverse(),e.forEach(["l","r"],function(T){T==="r"&&(S=e.map(S,function(B){return e.values(B).reverse()}));var C=(E==="u"?x.predecessors:x.successors).bind(x),R=c(x,S,_,C),A=u(x,S,R.root,R.align,T==="r");T==="r"&&(A=e.mapValues(A,function(B){return-B})),y[E+T]=A})});var w=l(x,y);return p(y,w),h(y,x.graph().align)}function g(x,b,_){return function(y,S,w){var E=y.node(S),T=y.node(w),C=0,R;if(C+=E.width/2,e.has(E,"labelpos"))switch(E.labelpos.toLowerCase()){case"l":R=-E.width/2;break;case"r":R=E.width/2;break}if(R&&(C+=_?R:-R),R=0,C+=(E.dummy?b:x)/2,C+=(T.dummy?b:x)/2,C+=T.width/2,e.has(T,"labelpos"))switch(T.labelpos.toLowerCase()){case"l":R=T.width/2;break;case"r":R=-T.width/2;break}return R&&(C+=_?R:-R),R=0,C}}function v(x,b){return x.node(b).width}return fs}var ps,Up;function Qm(){if(Up)return ps;Up=1;var e=Q(),t=oe(),r=Zm().positionX;ps=n;function n(i){i=t.asNonCompoundGraph(i),a(i),e.forEach(r(i),function(o,s){i.node(s).x=o})}function a(i){var o=t.buildLayerMatrix(i),s=i.graph().ranksep,c=0;e.forEach(o,function(u){var d=e.max(e.map(u,function(l){return i.node(l).height}));e.forEach(u,function(l){i.node(l).y=c+d/2}),c+=d+s})}return ps}var hs,Kp;function ey(){if(Kp)return hs;Kp=1;var e=Q(),t=Am(),r=Lm(),n=Mm(),a=oe().normalizeRanks,i=Bm(),o=oe().removeEmptyRanks,s=Wm(),c=Fm(),u=$m(),d=Xm(),l=Qm(),p=oe(),h=ve().Graph;hs=m;function m(k,I){var P=I&&I.debugTiming?p.time:p.notime;P("layout",function(){var O=P(" buildLayoutGraph",function(){return C(k)});P(" runLayout",function(){g(O,P)}),P(" updateInputGraph",function(){v(k,O)})})}function g(k,I){I(" makeSpaceForEdgeLabels",function(){R(k)}),I(" removeSelfEdges",function(){z(k)}),I(" acyclic",function(){t.run(k)}),I(" nestingGraph.run",function(){s.run(k)}),I(" rank",function(){n(p.asNonCompoundGraph(k))}),I(" injectEdgeLabelProxies",function(){A(k)}),I(" removeEmptyRanks",function(){o(k)}),I(" nestingGraph.cleanup",function(){s.cleanup(k)}),I(" normalizeRanks",function(){a(k)}),I(" assignRankMinMax",function(){B(k)}),I(" removeEdgeLabelProxies",function(){N(k)}),I(" normalize.run",function(){r.run(k)}),I(" parentDummyChains",function(){i(k)}),I(" addBorderSegments",function(){c(k)}),I(" order",function(){d(k)}),I(" insertSelfEdges",function(){K(k)}),I(" adjustCoordinateSystem",function(){u.adjust(k)}),I(" position",function(){l(k)}),I(" positionSelfEdges",function(){j(k)}),I(" removeBorderNodes",function(){W(k)}),I(" normalize.undo",function(){r.undo(k)}),I(" fixupEdgeLabelCoords",function(){$(k)}),I(" undoCoordinateSystem",function(){u.undo(k)}),I(" translateGraph",function(){M(k)}),I(" assignNodeIntersects",function(){L(k)}),I(" reversePoints",function(){U(k)}),I(" acyclic.undo",function(){t.undo(k)})}function v(k,I){e.forEach(k.nodes(),function(P){var O=k.node(P),H=I.node(P);O&&(O.x=H.x,O.y=H.y,I.children(P).length&&(O.width=H.width,O.height=H.height))}),e.forEach(k.edges(),function(P){var O=k.edge(P),H=I.edge(P);O.points=H.points,e.has(H,"x")&&(O.x=H.x,O.y=H.y)}),k.graph().width=I.graph().width,k.graph().height=I.graph().height}var x=["nodesep","edgesep","ranksep","marginx","marginy"],b={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},_=["acyclicer","ranker","rankdir","align"],y=["width","height"],S={width:0,height:0},w=["minlen","weight","width","height","labeloffset"],E={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},T=["labelpos"];function C(k){var I=new h({multigraph:!0,compound:!0}),P=G(k.graph());return I.setGraph(e.merge({},b,F(P,x),e.pick(P,_))),e.forEach(k.nodes(),function(O){var H=G(k.node(O));I.setNode(O,e.defaults(F(H,y),S)),I.setParent(O,k.parent(O))}),e.forEach(k.edges(),function(O){var H=G(k.edge(O));I.setEdge(O,e.merge({},E,F(H,w),e.pick(H,T)))}),I}function R(k){var I=k.graph();I.ranksep/=2,e.forEach(k.edges(),function(P){var O=k.edge(P);O.minlen*=2,O.labelpos.toLowerCase()!=="c"&&(I.rankdir==="TB"||I.rankdir==="BT"?O.width+=O.labeloffset:O.height+=O.labeloffset)})}function A(k){e.forEach(k.edges(),function(I){var P=k.edge(I);if(P.width&&P.height){var O=k.node(I.v),H=k.node(I.w),J={rank:(H.rank-O.rank)/2+O.rank,e:I};p.addDummyNode(k,"edge-proxy",J,"_ep")}})}function B(k){var I=0;e.forEach(k.nodes(),function(P){var O=k.node(P);O.borderTop&&(O.minRank=k.node(O.borderTop).rank,O.maxRank=k.node(O.borderBottom).rank,I=e.max(I,O.maxRank))}),k.graph().maxRank=I}function N(k){e.forEach(k.nodes(),function(I){var P=k.node(I);P.dummy==="edge-proxy"&&(k.edge(P.e).labelRank=P.rank,k.removeNode(I))})}function M(k){var I=Number.POSITIVE_INFINITY,P=0,O=Number.POSITIVE_INFINITY,H=0,J=k.graph(),Z=J.marginx||0,ee=J.marginy||0;function ce(te){var re=te.x,Y=te.y,Oe=te.width,X=te.height;I=Math.min(I,re-Oe/2),P=Math.max(P,re+Oe/2),O=Math.min(O,Y-X/2),H=Math.max(H,Y+X/2)}e.forEach(k.nodes(),function(te){ce(k.node(te))}),e.forEach(k.edges(),function(te){var re=k.edge(te);e.has(re,"x")&&ce(re)}),I-=Z,O-=ee,e.forEach(k.nodes(),function(te){var re=k.node(te);re.x-=I,re.y-=O}),e.forEach(k.edges(),function(te){var re=k.edge(te);e.forEach(re.points,function(Y){Y.x-=I,Y.y-=O}),e.has(re,"x")&&(re.x-=I),e.has(re,"y")&&(re.y-=O)}),J.width=P-I+Z,J.height=H-O+ee}function L(k){e.forEach(k.edges(),function(I){var P=k.edge(I),O=k.node(I.v),H=k.node(I.w),J,Z;P.points?(J=P.points[0],Z=P.points[P.points.length-1]):(P.points=[],J=H,Z=O),P.points.unshift(p.intersectRect(O,J)),P.points.push(p.intersectRect(H,Z))})}function $(k){e.forEach(k.edges(),function(I){var P=k.edge(I);if(e.has(P,"x"))switch((P.labelpos==="l"||P.labelpos==="r")&&(P.width-=P.labeloffset),P.labelpos){case"l":P.x-=P.width/2+P.labeloffset;break;case"r":P.x+=P.width/2+P.labeloffset;break}})}function U(k){e.forEach(k.edges(),function(I){var P=k.edge(I);P.reversed&&P.points.reverse()})}function W(k){e.forEach(k.nodes(),function(I){if(k.children(I).length){var P=k.node(I),O=k.node(P.borderTop),H=k.node(P.borderBottom),J=k.node(e.last(P.borderLeft)),Z=k.node(e.last(P.borderRight));P.width=Math.abs(Z.x-J.x),P.height=Math.abs(H.y-O.y),P.x=J.x+P.width/2,P.y=O.y+P.height/2}}),e.forEach(k.nodes(),function(I){k.node(I).dummy==="border"&&k.removeNode(I)})}function z(k){e.forEach(k.edges(),function(I){if(I.v===I.w){var P=k.node(I.v);P.selfEdges||(P.selfEdges=[]),P.selfEdges.push({e:I,label:k.edge(I)}),k.removeEdge(I)}})}function K(k){var I=p.buildLayerMatrix(k);e.forEach(I,function(P){var O=0;e.forEach(P,function(H,J){var Z=k.node(H);Z.order=J+O,e.forEach(Z.selfEdges,function(ee){p.addDummyNode(k,"selfedge",{width:ee.label.width,height:ee.label.height,rank:Z.rank,order:J+ ++O,e:ee.e,label:ee.label},"_se")}),delete Z.selfEdges})})}function j(k){e.forEach(k.nodes(),function(I){var P=k.node(I);if(P.dummy==="selfedge"){var O=k.node(P.e.v),H=O.x+O.width/2,J=O.y,Z=P.x-H,ee=O.height/2;k.setEdge(P.e,P.label),k.removeNode(I),P.label.points=[{x:H+2*Z/3,y:J-ee},{x:H+5*Z/6,y:J-ee},{x:H+Z,y:J},{x:H+5*Z/6,y:J+ee},{x:H+2*Z/3,y:J+ee}],P.label.x=P.x,P.label.y=P.y}})}function F(k,I){return e.mapValues(e.pick(k,I),Number)}function G(k){var I={};return e.forEach(k,function(P,O){I[O.toLowerCase()]=P}),I}return hs}var vs,Jp;function ry(){if(Jp)return vs;Jp=1;var e=Q(),t=oe(),r=ve().Graph;vs={debugOrdering:n};function n(a){var i=t.buildLayerMatrix(a),o=new r({compound:!0,multigraph:!0}).setGraph({});return e.forEach(a.nodes(),function(s){o.setNode(s,{label:s}),o.setParent(s,"layer"+a.node(s).rank)}),e.forEach(a.edges(),function(s){o.setEdge(s.v,s.w,{},s.name)}),e.forEach(i,function(s,c){var u="layer"+c;o.setNode(u,{rank:"same"}),e.reduce(s,function(d,l){return o.setEdge(d,l,{style:"invis"}),l})}),o}return vs}var gs,Vp;function ty(){return Vp||(Vp=1,gs="0.8.5"),gs}var ms,Yp;function ny(){return Yp||(Yp=1,ms={graphlib:ve(),layout:ey(),debug:ry(),util:{time:oe().time,notime:oe().notime},version:ty()}),ms}var ay=ny();const Xp=Ch(ay);function nr(e,t="TB"){let r=240,n=80;switch(e.type){case"input":case"output":r=60,n=60;break;case"decisionNode":r=212,n=160;break;case"forkNode":r=240,n=95;break;case"joinNode":r=240,n=95;break;case"loopNode":const i=(e.data.loopOver||e.data.task?.loopOver||[]).length,o=!!(e.data.loopCondition||e.data.task?.loopCondition);t==="LR"?(r=320+i*50,r=Math.min(r,600),n=145+(o?20:0)):(r=320,n=120+i*40+(o?30:0),n=Math.min(n,400));break;case"subWorkflowNode":r=240,n=95;break;case"eventNode":r=240,n=85;break;case"default":r=240,n=40;break;default:r=240,n=95;break}return{width:r,height:n}}function iy(e,t,r=8){const n=[];if(e.length<r)return n;const a=new Map,i={},o={};e.forEach(l=>{a.set(l.id,l),i[l.id]=[],o[l.id]=[]}),t.forEach(l=>{i[l.source]&&i[l.source].push(l.target),o[l.target]&&o[l.target].push(l.source)});const s=new Set,c=new Set(["input","output","decisionNode","forkNode","joinNode","loopNode","default"]),u=l=>l.id!=="start"&&l.id!=="end"&&!c.has(l.type||""),d=[...e].sort((l,p)=>l.position.y-p.position.y);for(const l of d){if(s.has(l.id)||!u(l))continue;const p=[l.id];let h=l,m=i[h.id];for(;m&&m.length===1;){const g=m[0],v=a.get(g);if(!v||s.has(g)||!u(v)||o[g].length!==1)break;p.push(g),h=v,m=i[h.id]}p.length>=r&&(n.push(p),p.forEach(g=>s.add(g)))}return n}function oy(e,t,r,n,a,i=5,o="view"){const s=t.find(b=>b.id===e[0]),{width:c,height:u}=nr(s||t[0],r),d=Math.max(.7,1-(e.length-10)/80),l=o==="edit"||o==="run"?1.15:1,p=Math.min(n,Math.round(60*d*l)),h=Math.min(a,Math.round(80*d*l)),m=c+p,g=u+h;let v=0,x=0;if(r==="TB"){const b=Math.ceil(e.length/i);v=i*m-p,x=b*g-h}else v=Math.ceil(e.length/i)*m-p,x=i*g-h;return v+=40,x+=40,{width:v,height:x,gridKW:m,gridKH:g,cols:i}}function ae(e,t,r={}){const{direction:n="TB",mode:a="view",enableSnakeLayout:i=!0,snakeColumns:o=5,snakeMinChainLength:s=8,snakeMinNodeCount:c=10}=r,u=e.length;let d=n==="LR"?150:120,l=n==="LR"?120:100,p=d,h=l;if(u>15){let T=Math.max(.5,1-(u-15)/50),C=Math.max(.4,1-(u-15)/40);(a==="edit"||a==="run")&&(T=1-(1-T)*.5,C=1-(1-C)*.5),p=Math.round(d*T),h=Math.round(l*C)}const m=i&&u>c?iy(e,t,s):[],g={};m.forEach((T,C)=>{T.forEach(R=>{g[R]=C})});const v=new Xp.graphlib.Graph;v.setDefaultEdgeLabel(()=>({})),v.setGraph({rankdir:n,ranker:"network-simplex",ranksep:p,nodesep:h,edgesep:50,marginx:50,marginy:50});const x=new Set,b={};e.forEach(T=>{const C=g[T.id];if(C!==void 0){if(!x.has(C)){x.add(C);const R=oy(m[C],e,n,h,p,o,a);b[C]=R,v.setNode(`__CHAIN_${C}`,{width:R.width,height:R.height})}}else{const{width:R,height:A}=nr(T,n);v.setNode(T.id,{width:R,height:A})}}),t.forEach(T=>{const C=g[T.source],R=g[T.target];let A=T.source,B=T.target;C!==void 0&&(A=`__CHAIN_${C}`),R!==void 0&&(B=`__CHAIN_${R}`),A!==B&&v.setEdge(A,B)}),Xp.layout(v);const _={};for(const T of e)_[T.id]={...T};const y=[],S=new Set;e.forEach(T=>{if(g[T.id]===void 0){const C=v.node(T.id),R=_[T.id],{width:A,height:B}=nr(R,n);R.position={x:C.x-A/2,y:C.y-B/2},R.data={...R.data,sourcePosition:void 0,targetPosition:void 0},R.sourcePosition=n==="LR"?q.Position.Right:q.Position.Bottom,R.targetPosition=n==="LR"?q.Position.Left:q.Position.Top,y.push(R)}else S.add(T.id)}),m.forEach((T,C)=>{const R=`__CHAIN_${C}`,A=v.node(R),B=b[C],N=A.x-B.width/2+20,M=A.y-B.height/2+20,L=B.cols,$=B.gridKW,U=B.gridKH;T.forEach((W,z)=>{const K=_[W];let j=0,F=0,G,k;if(n==="TB"){const I=Math.floor(z/L),P=z%L,O=I%2===0,H=Math.ceil(T.length/L),J=I===H-1,Z=T.length%L||L,ee=J?(L-Z)*$/2:0;let ce;O?ce=P*$+ee:ce=(L-1-P)*$-ee;const te=I*U;j=N+ce,F=M+te;const re=J?Z:L;O?(k=q.Position.Left,G=q.Position.Right,P===re-1&&z!==T.length-1&&(G=q.Position.Bottom),P===0&&z!==0&&(k=q.Position.Top)):(k=q.Position.Right,G=q.Position.Left,P===re-1&&z!==T.length-1&&(G=q.Position.Bottom),P===0&&z!==0&&(k=q.Position.Top)),z===0&&(k=q.Position.Top),z===T.length-1&&(G=q.Position.Bottom)}else{const I=Math.floor(z/L),P=z%L,O=I%2===0,H=Math.ceil(T.length/L),J=I===H-1,Z=T.length%L||L,ee=J?(L-Z)*U/2:0,ce=I*$;let te;O?te=P*U+ee:te=(L-1-P)*U-ee,j=N+ce,F=M+te;const re=J?Z:L;O?(k=q.Position.Top,G=q.Position.Bottom,P===re-1&&z!==T.length-1&&(G=q.Position.Right),P===0&&z!==0&&(k=q.Position.Left)):(k=q.Position.Bottom,G=q.Position.Top,P===re-1&&z!==T.length-1&&(G=q.Position.Right),P===0&&z!==0&&(k=q.Position.Left)),z===0&&(k=q.Position.Left),z===T.length-1&&(G=q.Position.Right)}K.position={x:j,y:F},K.data={...K.data,sourcePosition:G,targetPosition:k},K.sourcePosition=G,K.targetPosition=k,y.push(K)})});const w=y.reduce((T,C)=>({...T,[C.id]:C}),{}),E=t.map(T=>{const C=w[T.source],R=w[T.target];if(!C||!R||S.has(C.id)||C.type!=="decisionNode")return T;const{width:A,height:B}=nr(C,n),{width:N,height:M}=nr(R,n),L={x:C.position.x+A/2,y:C.position.y+B/2},$={x:R.position.x+N/2,y:R.position.y+M/2};let U=null;if(n==="TB"){const W=A*.25;$.x<L.x-W?U="left":$.x>L.x+W&&(U="right")}else{const W=B*.25;$.y<L.y-W?U="top":$.y>L.y+W&&(U="bottom")}return{...T,sourceHandle:U}});return{nodes:y,edges:E}}function be(e,t){if(!e)return null;for(const r of e){if(r.taskReferenceName===t)return r;if(r.decisionCases){for(const a of Object.keys(r.decisionCases)){const i=be(r.decisionCases[a],t);if(i)return i}const n=be(r.defaultCase,t);if(n)return n}if(r.forkTasks)for(const n of r.forkTasks){const a=be(n,t);if(a)return a}if(r.loopOver){const n=be(r.loopOver,t);if(n)return n}}return null}function ar(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 a of Object.keys(n.decisionCases))if(ar(n.decisionCases[a],t))return!0;if(ar(n.defaultCase,t))return!0}if(n.forkTasks){for(const a of n.forkTasks)if(ar(a,t))return!0}if(n.loopOver&&ar(n.loopOver,t))return!0}return!1}function ge(e,t,r){if(!e)return!1;const n=e.findIndex(a=>a.taskReferenceName===t);if(n!==-1)return e.splice(n+1,0,r),!0;if(t==="start")return e.unshift(r),!0;for(const a of e){if(a.decisionCases){for(const i of Object.keys(a.decisionCases))if(ge(a.decisionCases[i],t,r))return!0;if(ge(a.defaultCase,t,r))return!0}if(a.forkTasks){for(const i of a.forkTasks)if(ge(i,t,r))return!0}if(a.loopOver&&ge(a.loopOver,t,r))return!0}return!1}function ir(e,t,r,n){for(const a of e||[]){if(a.taskReferenceName===t){if(r.branchCase==="default")return a.defaultCase||(a.defaultCase=[]),a.defaultCase.unshift(n),!0;if(r.branchCase!==void 0)return a.decisionCases||(a.decisionCases={}),a.decisionCases[r.branchCase]||(a.decisionCases[r.branchCase]=[]),a.decisionCases[r.branchCase].unshift(n),!0;if(r.forkIndex!==void 0)return a.forkTasks||(a.forkTasks=[]),a.forkTasks[r.forkIndex].unshift(n),!0;if(r.isLoopAdd)return a.loopOver||(a.loopOver=[]),a.loopOver.unshift(n),!0}if(a.decisionCases){for(const i of Object.keys(a.decisionCases))if(ir(a.decisionCases[i],t,r,n))return!0;if(ir(a.defaultCase,t,r,n))return!0}if(a.forkTasks){for(const i of a.forkTasks)if(ir(i,t,r,n))return!0}}return!1}function ie(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 a=[];(r.forkTasks||[]).forEach(i=>{i&&i.length>0&&a.push(i[i.length-1].taskReferenceName)}),n.joinOn=a}}r.decisionCases&&(Object.values(r.decisionCases).forEach(n=>ie(n)),r.defaultCase&&ie(r.defaultCase)),r.forkTasks&&r.forkTasks.forEach(n=>ie(n)),r.loopOver&&ie(r.loopOver)}}const sy=[{field:"name",type:"required",message:"工作流名称 (name) 必填"},{field:"version",type:"required",message:"工作流版本 (version) 必填"},{field:"tasks",type:"min_length",value:1,message:"工作流必须包含至少一个任务"}],Zp={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,建议配置"}],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)"}],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:"required",message:"循环任务缺少退出条件 (loopCondition)"}],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 任务必须至少包含一个分支"}]}},uy=(e,t)=>t.split(".").reduce((r,n)=>r&&r[n]!==void 0?r[n]:void 0,e),ys=(e,t,r,n)=>{const{errors:a,warnings:i}=n,o=e.taskReferenceName||"GLOBAL";t.forEach(s=>{const c=uy(e,s.field);let u=!0;switch(s.type){case"required":u=c!=null&&c!=="";break;case"min_length":u=Array.isArray(c)&&c.length>=s.value;break;case"pattern":u=s.value.test(c);break;case"enum":u=s.value.includes(c);break;case"unique":s.field==="taskReferenceName"&&c&&(r.taskRefs.has(c)?u=!1:r.taskRefs.add(c));break;case"custom":typeof s.validate=="function"&&(u=s.validate(c,e,r));break}if(!u){const d={type:e.taskReferenceName?"TASK":"GLOBAL",ref:o,message:s.message};s.level==="warning"?i.push(d):a.push(d)}})},me=e=>{const t=[],r=[],n={taskRefs:new Set,taskMap:{}};if(!e)return{isValid:!1,errors:[{type:"GLOBAL",ref:"",message:"工作流定义为空"}],warnings:[]};if(ys(e,sy,n,{errors:t,warnings:r}),!e.tasks||e.tasks.length===0)return{isValid:!1,errors:t,warnings:r};const a=o=>{o.forEach(s=>{ys(s,Zp.common,n,{errors:t,warnings:r});const c=Zp.types[s.type];c&&ys(s,c,n,{errors:t,warnings:r}),s.decisionCases&&Object.keys(s.decisionCases).forEach(u=>{a(s.decisionCases[u])}),s.defaultCase&&a(s.defaultCase),s.forkTasks&&s.forkTasks.forEach(u=>a(u)),s.loopOver&&a(s.loopOver)})};a(e.tasks);const i=cy(e.tasks);return t.push(...i),{isValid:t.length===0,errors:t,warnings:r}},cy=e=>{const t=[],r=new Map,n=new Set,a=d=>{for(let l=0;l<d.length;l++){const p=d[l],h=p.taskReferenceName;if(n.add(h),r.has(h)||r.set(h,[]),l<d.length-1){const m=d[l+1].taskReferenceName;p.type!=="FORK_JOIN"&&p.type!=="FORK_JOIN_DYNAMIC"&&r.get(h).push(m)}if(p.decisionCases)for(const m of Object.values(p.decisionCases))m.length>0&&(r.get(h).push(m[0].taskReferenceName),a(m));if(p.defaultCase&&p.defaultCase.length>0&&(r.get(h).push(p.defaultCase[0].taskReferenceName),a(p.defaultCase)),p.forkTasks)for(const m of p.forkTasks)m.length>0&&(r.get(h).push(m[0].taskReferenceName),a(m));if(p.loopOver)for(const m of p.loopOver)n.add(m.taskReferenceName);if(p.joinOn)for(const m of p.joinOn)r.has(m)||r.set(m,[]),r.get(m).push(h)}};a(e);const i=0,o=1,s=2,c=new Map;for(const d of n)c.set(d,i);const u=d=>{c.set(d,o);const l=r.get(d)||[];for(const p of l)if(c.has(p)){if(c.get(p)===o)return t.push({type:"GLOBAL",ref:p,message:`检测到环路:任务 "${d}" → "${p}" 形成了循环依赖`}),!0;if(c.get(p)===i&&u(p))return!0}return c.set(d,s),!1};for(const d of n)c.get(d)===i&&u(d);return t},V=qh()(Ph(Ah((e,t)=>({mode:"view",workflowDef:null,workflowInstance:null,nodes:[],edges:[],taskMap:{},layoutDirection:"TB",selectedTask:null,selectedTaskInstance:null,isDetailPanelOpen:!1,executionData:null,validationResults:{isValid:!0,errors:[],warnings:[]},theme:"dark",themeColor:"blue",edgeType:"smoothstep",nodesLocked:!0,copiedTask:null,setWorkflow:(r,n)=>{const a=n||t().layoutDirection,i=JSON.parse(JSON.stringify(r));ie(i.tasks);const{nodes:o,edges:s,taskMap:c}=ue(i,a,{hideEmptyBranches:t().mode!=="edit"}),{nodes:u,edges:d}=ae(o,s,{direction:a,mode:t().mode}),l=me(i);e({workflowDef:i,nodes:u,edges:d,taskMap:c,validationResults:l,layoutDirection:a})},setMode:r=>{t().mode==="run"&&r!=="run"&&e({executionData:null,workflowInstance:null}),e({mode:r});const{workflowDef:a,layoutDirection:i}=t();if(a){const{nodes:o,edges:s,taskMap:c}=ue(a,i,{hideEmptyBranches:r!=="edit"}),{nodes:u,edges:d}=ae(o,s,{direction:i,mode:r});e({nodes:u,edges:d,taskMap:c})}},setExecutionData:r=>e({executionData:r}),updateTaskStatus:(r,n)=>{const{executionData:a}=t();if(!a)return;const i={...a};i[r]&&(i[r]={...i[r],status:n},e({executionData:i}))},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=[],a=null,i=t().workflowDef;if(Array.isArray(r.tasks)?(n=r.tasks,r.workflowId&&r.status&&(a=r,r.workflowDefinition&&(i=r.workflowDefinition))):Array.isArray(r)&&(n=r),n.length===0)return;const o={};n.forEach(s=>{const c=s.referenceTaskName;c&&(o[c]||(o[c]={taskReferenceName:c,status:s.status,attempts:[],startTime:s.startTime,endTime:s.endTime,output:s.outputData,input:s.inputData,reasonForIncompletion:s.reasonForIncompletion,iteration:s.iteration}),o[c].attempts.push(s),o[c].status=s.status,o[c].startTime=s.startTime,o[c].endTime=s.endTime,o[c].output=s.outputData,o[c].input=s.inputData,o[c].reasonForIncompletion=s.reasonForIncompletion,o[c].iteration=s.iteration)}),i&&JSON.stringify(i)!==JSON.stringify(t().workflowDef)&&t().setWorkflow(i),e({executionData:o,workflowInstance:a,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:a,edges:i,taskMap:o}=ue(n,r,{hideEmptyBranches:t().mode!=="edit"}),{nodes:s,edges:c}=ae(a,i,{direction:r,mode:t().mode});e({nodes:s,edges:c,taskMap:o,layoutDirection:r})}else e({layoutDirection:r})},onNodesChange:r=>{const n=t().nodes,a=q.applyNodeChanges(r,n);a!==n&&e({nodes:a})},onEdgesChange:r=>{const n=t().edges,a=q.applyEdgeChanges(r,n);a!==n&&e({edges:a})},onConnect:r=>{const{edges:n,layoutDirection:a}=t(),i=q.addEdge(r,n),{nodes:o,edges:s}=ae(t().nodes,i,{direction:a,mode:t().mode});e({edges:s,nodes:o})},checkTaskRefUniqueness:(r,n)=>{if(r===n)return!0;const{taskMap:a}=t();return!a[r]},updateTask:(r,n,a)=>{const{workflowDef:i,layoutDirection:o}=t();if(!i)return;const s=JSON.parse(JSON.stringify(i)),c=be(s.tasks,r);if(c){typeof n=="object"?Object.assign(c,n):c[n]=a,ie(s.tasks);const{nodes:u,edges:d,taskMap:l}=ue(s,o,{hideEmptyBranches:t().mode!=="edit"}),{nodes:p,edges:h}=ae(u,d,{direction:o,mode:t().mode}),m=me(s);e({workflowDef:s,nodes:p,edges:h,taskMap:l,validationResults:m})}},updateWorkflowProperties:r=>{const{workflowDef:n,layoutDirection:a}=t();if(!n)return;const i=JSON.parse(JSON.stringify(n));Object.assign(i,r),ie(i.tasks);const{nodes:o,edges:s,taskMap:c}=ue(i,a,{hideEmptyBranches:t().mode!=="edit"}),{nodes:u,edges:d}=ae(o,s,{direction:a,mode:t().mode}),l=me(i);e({workflowDef:i,nodes:u,edges:d,taskMap:c,validationResults:l})},addNode:(r,n,a,i,o={})=>{const{workflowDef:s,layoutDirection:c}=t();if(!s)return;const u=JSON.parse(JSON.stringify(s)),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 x={name:`${d.name}_join`,taskReferenceName:`${d.taskReferenceName}_join`,type:"JOIN",joinOn:[]};o.branchCase!==void 0||o.forkIndex!==void 0||o.isLoopAdd?(ir(u.tasks,n,o,d),ge(u.tasks,d.taskReferenceName,x)):n==="start"&&u.tasks.length===0?u.tasks.push(d,x):(ge(u.tasks,n,d),ge(u.tasks,d.taskReferenceName,x))}else d.type==="DECISION"?(d.caseValueParam="case_param",d.decisionCases={case1:[]},d.defaultCase=[]):d.type==="DO_WHILE"&&(d.loopCondition="$.taskReferenceName.output.value < 10",d.loopOver=[]),o.branchCase!==void 0||o.forkIndex!==void 0||o.isLoopAdd?ir(u.tasks,n,o,d):n==="start"&&u.tasks.length===0?u.tasks.push(d):ge(u.tasks,n,d);ie(u.tasks);const{nodes:l,edges:p,taskMap:h}=ue(u,c,{hideEmptyBranches:t().mode!=="edit"}),{nodes:m,edges:g}=ae(l,p,{direction:c,mode:t().mode}),v=me(u);e({workflowDef:u,nodes:m,edges:g,taskMap:h,validationResults:v})},removeNode:r=>{const{workflowDef:n,layoutDirection:a}=t();if(!n||r==="start"||r==="end")return;const i=JSON.parse(JSON.stringify(n));ar(i.tasks,r),ie(i.tasks);const{nodes:o,edges:s,taskMap:c}=ue(i,a,{hideEmptyBranches:t().mode!=="edit"}),{nodes:u,edges:d}=ae(o,s,{direction:a,mode:t().mode}),l=me(i);e({workflowDef:i,nodes:u,edges:d,taskMap:c,validationResults:l})},addLoopTask:(r,n)=>{const{workflowDef:a,layoutDirection:i}=t();if(!a)return;const o=JSON.parse(JSON.stringify(a)),s=be(o.tasks,r);if(s&&s.type==="DO_WHILE"){s.loopOver||(s.loopOver=[]);const c={name:`new_${n.toLowerCase()}`,taskReferenceName:`${r}_sub_${Date.now()}`,type:n,inputParameters:{}};s.loopOver.push(c),ie(o.tasks);const{nodes:u,edges:d,taskMap:l}=ue(o,i,{hideEmptyBranches:t().mode!=="edit"}),{nodes:p,edges:h}=ae(u,d,{direction:i,mode:t().mode}),m=me(o);e({workflowDef:o,nodes:p,edges:h,taskMap:l,validationResults:m})}},removeLoopTask:(r,n)=>{const{workflowDef:a,layoutDirection:i}=t();if(!a)return;const o=JSON.parse(JSON.stringify(a)),s=be(o.tasks,r);if(s&&s.type==="DO_WHILE"&&s.loopOver){s.loopOver=s.loopOver.filter(m=>m.taskReferenceName!==n),ie(o.tasks);const{nodes:c,edges:u,taskMap:d}=ue(o,i,{hideEmptyBranches:t().mode!=="edit"}),{nodes:l,edges:p}=ae(c,u,{direction:i,mode:t().mode}),h=me(o);e({workflowDef:o,nodes:l,edges:p,taskMap:d,validationResults:h})}},addDecisionBranch:(r,n)=>{const{workflowDef:a,layoutDirection:i}=t();if(!a)return;const o=JSON.parse(JSON.stringify(a)),s=be(o.tasks,r);if(s&&(s.type==="DECISION"||s.type==="SWITCH")){n==="default"?s.defaultCase||(s.defaultCase=[]):(s.decisionCases||(s.decisionCases={}),s.decisionCases[n]||(s.decisionCases[n]=[])),ie(o.tasks);const{nodes:c,edges:u,taskMap:d}=ue(o,i,{hideEmptyBranches:t().mode!=="edit"}),{nodes:l,edges:p}=ae(c,u,{direction:i,mode:t().mode}),h=me(o);e({workflowDef:o,nodes:l,edges:p,taskMap:d,validationResults:h})}},removeDecisionBranch:(r,n)=>{const{workflowDef:a,layoutDirection:i}=t();if(!a)return;const o=JSON.parse(JSON.stringify(a)),s=be(o.tasks,r);if(s&&(s.type==="DECISION"||s.type==="SWITCH")){n==="default"?s.defaultCase=[]:s.decisionCases&&delete s.decisionCases[n],ie(o.tasks);const{nodes:c,edges:u,taskMap:d}=ue(o,i,{hideEmptyBranches:t().mode!=="edit"}),{nodes:l,edges:p}=ae(c,u,{direction:i,mode:t().mode}),h=me(o);e({workflowDef:o,nodes:l,edges:p,taskMap:d,validationResults:h})}},addForkBranch:r=>{const{workflowDef:n,layoutDirection:a}=t();if(!n)return;const i=JSON.parse(JSON.stringify(n)),o=be(i.tasks,r);if(o&&o.type==="FORK_JOIN"){o.forkTasks||(o.forkTasks=[]),o.forkTasks.push([]),ie(i.tasks);const{nodes:s,edges:c,taskMap:u}=ue(i,a,{hideEmptyBranches:t().mode!=="edit"}),{nodes:d,edges:l}=ae(s,c,{direction:a,mode:t().mode}),p=me(i);e({workflowDef:i,nodes:d,edges:l,taskMap:u,validationResults:p})}},copyTask:r=>e({copiedTask:r}),pasteTask:r=>{const{workflowDef:n,layoutDirection:a,selectedTask:i}=t();if(!n)return;const o=JSON.parse(JSON.stringify(n)),c=`_copy_${Date.now()}`,u=JSON.parse(JSON.stringify(r)),d=b=>{b.taskReferenceName=`${b.taskReferenceName}${c}`,b.decisionCases&&Object.values(b.decisionCases).forEach(_=>_.forEach(d)),b.defaultCase&&b.defaultCase.forEach(d),b.forkTasks&&b.forkTasks.forEach(_=>_.forEach(d)),b.loopOver&&b.loopOver.forEach(d)};d(u);const l=i?i.taskReferenceName:o.tasks.length>0?o.tasks[o.tasks.length-1].taskReferenceName:"start";if(u.type==="FORK_JOIN"){u.forkTasks||(u.forkTasks=[[],[]]);const b={name:`${u.name}_join`,taskReferenceName:`${u.taskReferenceName}_join`,type:"JOIN",joinOn:[]};l==="start"&&o.tasks.length===0?o.tasks.push(u,b):(ge(o.tasks,l,u),ge(o.tasks,u.taskReferenceName,b))}else l==="start"&&o.tasks.length===0?o.tasks.push(u):ge(o.tasks,l,u);ie(o.tasks);const{nodes:p,edges:h,taskMap:m}=ue(o,a,{hideEmptyBranches:t().mode!=="edit"}),{nodes:g,edges:v}=ae(p,h,{direction:a,mode:t().mode}),x=me(o);e({workflowDef:o,nodes:g,edges:v,taskMap:m,validationResults:x})},setTheme:r=>e({theme:r}),setThemeColor:r=>e({themeColor:r}),setEdgeType:r=>e({edgeType:r}),setNodesLocked:r=>e({nodesLocked:r}),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,...a}=r,i={...a,name:r.name||"AI_Generated_Workflow",tasks:n||[],version:r.version||1,schemaVersion:2};t().setWorkflow(i)}}),{partialize:e=>({workflowDef:e.workflowDef,layoutDirection:e.layoutDirection,nodes:e.nodes,edges:e.edges,taskMap:e.taskMap,theme:e.theme,themeColor:e.themeColor,mode:e.mode,edgeType:e.edgeType,nodesLocked:e.nodesLocked,copiedTask:e.copiedTask}),equality:(e,t)=>JSON.stringify(e.workflowDef)===JSON.stringify(t.workflowDef)}),{name:"conductor-ui-prefs",version:1,storage:Cs(()=>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})})),Qp=({message:e,onConfirm:t,onCancel:r})=>{const n=D.useRef(null);return D.useEffect(()=>{n.current?.focus();const a=i=>{i.key==="Escape"&&r()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[r]),f.jsx("div",{role:"dialog","aria-modal":"true","aria-label":"确认操作",style:{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",backgroundColor:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:2e3,backdropFilter:"blur(4px)",animation:"fadeIn 0.15s ease-out"},onClick:r,children:f.jsxs("div",{style:{backgroundColor:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",borderRadius:"12px",padding:"24px",maxWidth:"400px",width:"90%",boxShadow:"0 16px 40px rgba(0,0,0,0.3)",animation:"popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275)"},onClick:a=>a.stopPropagation(),children:[f.jsx("div",{style:{fontSize:"14px",color:"var(--text-primary)",marginBottom:"20px",lineHeight:"1.5"},children:e}),f.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px"},children:[f.jsx("button",{ref:n,onClick:r,style:{padding:"8px 16px",backgroundColor:"var(--bg-tertiary)",border:"1px solid var(--border-primary)",borderRadius:"6px",color:"var(--text-primary)",cursor:"pointer",fontSize:"13px"},children:"取消"}),f.jsx("button",{onClick:t,style:{padding:"8px 16px",backgroundColor:"#ef4444",border:"none",borderRadius:"6px",color:"#fff",cursor:"pointer",fontSize:"13px",fontWeight:600},children:"确定"})]})]})})},Be=({children:e,nodeId:t,selected:r=!1,isStartOrEnd:n=!1,isError:a=!1,hasWarning:i=!1,isDecision:o=!1,isHighlighted:s=!1,executionStatus:c})=>{const{mode:u,removeNode:d}=V(),[l,p]=D.useState(!1),h=x=>{x.stopPropagation(),p(!0)},m=u==="edit"&&!n,g=o?`decision-node-wrapper ${r?"node-wrapper-selected":""} ${s?"node-wrapper-highlighted":""}`:`node-wrapper-glass ${r?"node-wrapper-selected":""} ${s?"node-wrapper-highlighted":""}`,v=D.useMemo(()=>{if(u!=="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{}}},[u,c]);return f.jsxs("div",{className:g,style:{position:"relative",...v},children:[m&&f.jsx("button",{onClick:h,"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:"×"}),a&&f.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:"❗"}),!a&&i&&f.jsx("div",{style:{position:"absolute",top:"-10px",left:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#f59e0b",color:"white",border:"2px solid white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:101,boxShadow:"0 2px 8px rgba(0,0,0,0.2)"},title:"此节点有警告信息",children:"⚠️"}),e,l&&f.jsx(Qp,{message:"确定要删除此任务吗?",onConfirm:()=>{d(t),p(!1)},onCancel:()=>p(!1)})]})},dy=({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 f.jsx("div",{className:`execution-status-badge ${n}`,title:e,children:f.jsx("span",{className:"badge-icon",children:r})})},eh=D.memo(dy),ly=({icon:e,header:t,title:r,meta:n,color:a,status:i,isRunning:o,children:s,width:c="240px",border:u=!0})=>f.jsxs("div",{style:{display:"flex",flexDirection:"row",width:c,height:"100%",position:"relative",overflow:"hidden",border:u?"4px solid var(--border-primary)":"none",borderRadius:"8px"},children:[f.jsx("div",{style:{width:"48px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(205, 74, 74, 0.03)",borderRight:"1px solid var(--color-accent)",color:a},children:f.jsx(e,{size:20,strokeWidth:1.5})}),f.jsxs("div",{style:{flex:1,padding:"10px 14px",display:"flex",flexDirection:"column",justifyContent:"center",overflow:"hidden"},children:[f.jsx("div",{style:{fontSize:"14px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.5px",opacity:.7,marginBottom:"4px",color:a},children:t}),f.jsx("div",{style:{fontSize:"18px",fontWeight:600,color:"var(--text-primary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginBottom:"2px"},title:r,children:r}),n&&f.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)",fontStyle:"italic",lineHeight:"1.4",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},title:n,children:n}),s&&f.jsx("div",{style:{marginTop:"8px"},children:s})]}),o&&i&&f.jsx("div",{style:{position:"absolute",top:"8px",right:"8px"},children:f.jsx(eh,{status:i})})]}),or=D.memo(ly),We=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}},Fe=e=>{const{mode:t,executionData:r}=V(),n=t==="run"?r?.[e]:null;return{mode:t,execution:n,isRunning:t==="run"}};const fy=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),py=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,n)=>n?n.toUpperCase():r.toLowerCase()),rh=e=>{const t=py(e);return t.charAt(0).toUpperCase()+t.slice(1)},th=(...e)=>e.filter((t,r,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===r).join(" ").trim(),hy=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var vy={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 gy=D.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:a="",children:i,iconNode:o,...s},c)=>D.createElement("svg",{ref:c,...vy,width:t,height:t,stroke:e,strokeWidth:n?Number(r)*24/Number(t):r,className:th("lucide",a),...!i&&!hy(s)&&{"aria-hidden":"true"},...s},[...o.map(([u,d])=>D.createElement(u,d)),...Array.isArray(i)?i:[i]]));const fe=(e,t)=>{const r=D.forwardRef(({className:n,...a},i)=>D.createElement(gy,{ref:i,iconNode:t,className:th(`lucide-${fy(rh(e))}`,`lucide-${e}`,n),...a}));return r.displayName=rh(e),r};const nh=fe("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 my=fe("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 yy=fe("clock",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const by=fe("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 ah=fe("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 Cr=fe("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 xy=fe("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 _y=fe("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 ih=fe("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 ky=fe("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 Sy=fe("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);const wy=fe("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"}]]),$e=[{type:"SIMPLE",label:"任务节点 (Worker)",description:"在远程 Worker 上执行的任务",category:"CORE",icon:nh},{type:"SUB_WORKFLOW",label:"子工作流 (Sub Workflow)",description:"调用并执行另一个工作流",category:"CORE",icon:Cr},{type:"HTTP",label:"HTTP 请求",description:"发起 REST/HTTP 调用",category:"SYSTEM",icon:xy},{type:"JSON_JQ_TRANSFORM",label:"JSON 转换 (JQ)",description:"使用 JQ 表达式转换 JSON 数据",category:"SYSTEM",icon:Sy},{type:"KAFKA_PUBLISH",label:"Kafka 推送",description:"向 Kafka 主题推送消息",category:"SYSTEM",icon:_y},{type:"EVENT",label:"事件 (Event)",description:"向外部队列系统发布事件",category:"SYSTEM",icon:wy},{type:"WAIT",label:"等待 (Wait)",description:"暂停流程,直到特定时间或时长",category:"SYSTEM",icon:yy},{type:"SET_VARIABLE",label:"设置变量 (Set Variable)",description:"设置工作流上下文变量",category:"SYSTEM",icon:by},{type:"TERMINATE",label:"终止 (Terminate)",description:"提前结束工作流执行",category:"SYSTEM",icon:my},{type:"DECISION",label:"判断 (Switch)",description:"基于条件的逻辑分支 (Switch/Case)",category:"FLOW",icon:ky},{type:"FORK_JOIN",label:"并行分支 (Fork)",description:"并行执行多个任务分支",category:"FLOW",icon:ah},{type:"DO_WHILE",label:"循环 (Do-While)",description:"循环执行直到满足条件",category:"FLOW",icon:ih},{type:"JOIN",label:"汇聚 (Join)",description:"等待并行分支执行完成",category:"FLOW",icon:Cr}],Ey=[{key:"CORE",label:"基础任务"},{key:"FLOW",label:"逻辑控制"},{key:"SYSTEM",label:"系统集成"}],Ty=({id:e,data:t,selected:r})=>{const n=t.taskType||"SIMPLE",{sourcePosition:a,targetPosition:i}=We(t),{execution:o,isRunning:s}=Fe(t.taskReferenceName),c=D.useMemo(()=>$e.find(p=>p.type===n),[n]),u=c?.icon||nh,d="var(--color-accent)",l=D.useMemo(()=>n==="SIMPLE"?t.label==="Worker Task"?"Execute on Worker":"Worker Task":n==="HTTP"?"REST API Call":n==="JSON_JQ_TRANSFORM"?"JQ Expression":c?.label||n,[n,c,t.label]);return f.jsx(Be,{nodeId:e,selected:r,isError:t.isError,hasWarning:t.hasWarning,isHighlighted:t.isHighlighted,executionStatus:o?.status,children:f.jsxs("div",{style:{borderRadius:"8px",background:"var(--bg-secondary)"},children:[f.jsx(or,{icon:u,header:n,title:t.taskReferenceName,meta:l,color:d,status:o?.status,isRunning:s}),f.jsx(q.Handle,{type:"target",position:i,style:{background:"#fff"}}),f.jsx(q.Handle,{type:"source",position:a,style:{background:"#fff"}})]})})},Cy=D.memo(Ty),Ny=({id:e,data:t,selected:r})=>{const{layoutDirection:n}=We(t),{mode:a,execution:i,isRunning:o}=Fe(t.taskReferenceName),{addDecisionBranch:s,removeDecisionBranch:c}=V(),[u,d]=D.useState(!1),l=n==="LR"?q.Position.Left:q.Position.Top,p=Object.keys(t.decisionCases||t.task?.decisionCases||{}),h=()=>{const x=window.prompt("请输入新分支的名称 (case value):",`case_${p.length+1}`);x&&s(e,x),d(!1)},m=(x,b)=>{x.stopPropagation(),window.confirm(`确定要删除分支 "${b}" 及其下的所有任务吗?`)&&c(e,b)},v=o?(x=>x&&{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"}[x]||"")(i?.status):"";return f.jsx(Be,{nodeId:e,selected:r,isError:t.isError,hasWarning:t.hasWarning,isDecision:!0,isHighlighted:t.isHighlighted,executionStatus:i?.status,children:f.jsxs("div",{style:{position:"relative"},children:[f.jsx(q.Handle,{type:"target",position:l,style:{background:"#fff",[n==="LR"?"left":"top"]:"-5px"}}),o&&i?.status&&f.jsx("div",{style:{position:"absolute",top:0,right:0,zIndex:20},children:f.jsx(eh,{status:i.status})}),f.jsx("div",{className:v,style:{width:"150px",height:"150px",background:o&&i?.status?void 0:"var(--bg-secondary)",border:r?"4px solid #fbbf24":o&&i?.status?void 0:"4px solid var(--border-primary)",transform:"rotate(45deg)",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:r?"0 10px 30px rgba(0,0,0,0.3), 0 0 0 4px rgba(251, 191, 36, 0.3)":o&&i?.status?void 0:"0 4px 12px rgba(0,0,0,0.15)",transition:"all 0.3s ease",cursor:"pointer"},onClick:()=>a==="edit"&&d(!u),children:f.jsxs("div",{style:{transform:"rotate(-45deg)",color:"#fff",textAlign:"center",padding:"10px",width:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},children:[f.jsx("div",{style:{fontSize:"14px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.5px",opacity:.7,marginBottom:"4px",color:"var(--color-accent)"},children:t.taskType}),f.jsx("div",{style:{fontSize:"18px",fontWeight:600,color:"var(--text-primary)",lineHeight:"1.2",wordBreak:"break-word",maxHeight:"60px",overflow:"hidden",marginBottom:"4px"},children:t.label}),a==="edit"&&f.jsx("div",{style:{marginTop:"4px",width:"24px",height:"24px",fontSize:"16px",background:"rgba(255,255,255,0.1)",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",margin:"4px auto 0",color:"var(--text-secondary)"},children:"+"}),o&&i?.startTime&&f.jsx("div",{style:{fontSize:"9px",opacity:.7,marginTop:"8px"},children:i.endTime?`${((i.endTime-i.startTime)/1e3).toFixed(1)}s`:"◌"})]})}),a==="edit"&&u&&f.jsxs("div",{className:"glass-panel",style:{position:"absolute",top:"160px",left:"50%",transform:"translateX(-50%)",backgroundColor:"var(--glass-surface)",border:"1px solid var(--glass-border)",borderRadius:"8px",padding:"8px",zIndex:1e3,minWidth:"180px",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:[f.jsx("div",{style:{padding:"4px 8px",fontSize:"11px",color:"var(--text-secondary)",borderBottom:"1px solid var(--glass-border)",marginBottom:"4px"},children:"分支管理"}),p.map(x=>f.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 8px",fontSize:"12px",color:"var(--text-primary)"},children:[f.jsx("span",{children:x}),f.jsx("button",{onClick:b=>m(b,x),style:{width:"20px",height:"20px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",padding:0},children:"×"})]},x)),f.jsx("button",{onClick:h,style:{width:"100%",marginTop:"4px",padding:"8px",backgroundColor:"var(--color-accent)",border:"none",borderRadius:"4px",color:"#fff",cursor:"pointer",fontSize:"12px",fontWeight:"bold"},children:"+ 添加新分支"})]}),n==="TB"?f.jsxs(f.Fragment,{children:[f.jsx(q.Handle,{type:"source",position:q.Position.Bottom,style:{background:"#fff",bottom:"-5px"}}),f.jsx(q.Handle,{type:"source",position:q.Position.Left,id:"left",style:{background:"#fff",left:"-5px"}}),f.jsx(q.Handle,{type:"source",position:q.Position.Right,id:"right",style:{background:"#fff",right:"-5px"}})]}):f.jsxs(f.Fragment,{children:[f.jsx(q.Handle,{type:"source",position:q.Position.Right,style:{background:"#fff",right:"-5px"}}),f.jsx(q.Handle,{type:"source",position:q.Position.Top,id:"top",style:{background:"#fff",top:"-5px"}}),f.jsx(q.Handle,{type:"source",position:q.Position.Bottom,id:"bottom",style:{background:"#fff",bottom:"-5px"}})]})]})})},Ry=D.memo(Ny),oh="var(--color-accent)",sh=D.memo(({id:e,data:t,selected:r})=>{const{layoutDirection:n,sourcePosition:a,targetPosition:i}=We(t),{mode:o,execution:s,isRunning:c}=Fe(t.taskReferenceName),{addForkBranch:u}=V(),d=q.useUpdateNodeInternals(),l=t.task?.forkTasks?.length||0;D.useEffect(()=>{d(e)},[l,e,d]);const p=t.isDynamic||t.taskType==="FORK_JOIN_DYNAMIC",m=D.useMemo(()=>$e.find(g=>g.type==="FORK_JOIN"),[])?.icon||ah;return f.jsx(Be,{isHighlighted:t.isHighlighted,nodeId:e,selected:r,isError:t.isError,hasWarning:t.hasWarning,executionStatus:s?.status,children:f.jsxs("div",{className:`fork-node ${p?"dynamic":"static"}`,style:{borderRadius:"8px",background:"var(--bg-secondary)",position:"relative"},children:[f.jsx(or,{icon:m,header:p?"DYNAMIC FORK":"FORK",title:t.taskReferenceName,meta:p?"Dynamic Parallel Execution":"Parallel Execution",color:oh,status:s?.status,isRunning:c}),o==="edit"&&!p&&f.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:g=>{g.stopPropagation(),u(e)},title:"添加分支",children:"+"}),f.jsx(q.Handle,{type:"target",position:i,style:{background:"#fff"}}),!p&&(t.task?.forkTasks||[]).map((g,v,x)=>{if(o!=="edit"&&(!g||g.length===0))return null;const b=o!=="edit"?x.filter(w=>w&&w.length>0):x,_=b.length,S=(b.indexOf(g)+1)/(_+1)*100;return f.jsx(q.Handle,{id:`branch_${v}`,type:"source",position:a,style:{background:"#fff",[n==="LR"?"top":"left"]:`${S}%`,[n==="LR"?"left":"top"]:void 0,[n==="LR"?"right":"bottom"]:"-4px",zIndex:10}},`branch_${v}`)}),!p&&(!t.task?.forkTasks||t.task.forkTasks.length===0)&&f.jsx(q.Handle,{type:"source",position:a,style:{background:"#fff"}})]})})});sh.displayName="ForkNode";const uh=D.memo(({id:e,data:t,selected:r})=>{const{layoutDirection:n,sourcePosition:a,targetPosition:i}=We(t),{execution:o,isRunning:s}=Fe(t.taskReferenceName),u=D.useMemo(()=>$e.find(d=>d.type==="JOIN"),[])?.icon||Cr;return f.jsx(Be,{isHighlighted:t.isHighlighted,nodeId:e,selected:r,isError:t.isError,hasWarning:t.hasWarning,executionStatus:o?.status,children:f.jsxs("div",{style:{borderRadius:"8px",background:"var(--bg-secondary)",position:"relative"},children:[f.jsx(or,{icon:u,header:"JOIN",title:t.taskReferenceName,meta:"Wait for tasks",color:oh,status:o?.status,isRunning:s}),f.jsx(q.Handle,{type:"target",position:i,style:{background:"#fff"}}),n==="TB"&&f.jsxs(f.Fragment,{children:[f.jsx(q.Handle,{type:"target",position:q.Position.Left,id:"left",style:{background:"#fff"}}),f.jsx(q.Handle,{type:"target",position:q.Position.Right,id:"right",style:{background:"#fff"}})]}),n==="LR"&&f.jsxs(f.Fragment,{children:[f.jsx(q.Handle,{type:"target",position:q.Position.Top,id:"top",style:{background:"#fff"}}),f.jsx(q.Handle,{type:"target",position:q.Position.Bottom,id:"bottom",style:{background:"#fff"}})]}),f.jsx(q.Handle,{type:"source",position:a,style:{background:"#fff"}})]})})});uh.displayName="JoinNode";const ch={ForkNode:sh,JoinNode:uh},Iy="var(--color-accent)",jy=({id:e,data:t,selected:r})=>{const{layoutDirection:n,sourcePosition:a,targetPosition:i}=We(t),{mode:o,execution:s,isRunning:c}=Fe(t.taskReferenceName),{removeLoopTask:u}=V(),d=t.loopOver||t.task?.loopOver||[],l=d.length,p=D.useCallback((_,y)=>{y.stopPropagation();const S=new CustomEvent("miniTaskClick",{detail:{task:_},bubbles:!0});document.dispatchEvent(S)},[]),h=(_,y)=>{_.stopPropagation(),window.confirm("确定要从循环中删除此任务吗?")&&u(e,y)},g=D.useMemo(()=>$e.find(_=>_.type==="DO_WHILE"),[])?.icon||ih,v=(_,y)=>{const S=n==="LR";return f.jsxs("div",{style:{position:"relative",marginBottom:!S&&(y<l-1||o==="edit")?"8px":"0",marginRight:S&&(y<l-1||o==="edit")?"8px":"0",display:S?"inline-block":"block"},children:[f.jsxs("div",{onClick:C=>p(_,C),style:{background:"var(--bg-tertiary)",borderRadius:"6px",padding:"6px 10px",fontSize:"10px",color:"var(--text-primary)",border:"1px solid var(--border-secondary)",cursor:"pointer",transition:"all 0.2s ease",minWidth:S?"80px":"auto",textAlign:"center",position:"relative"},children:[o==="edit"&&f.jsx("div",{onClick:C=>h(C,_.taskReferenceName),style:{position:"absolute",top:"-6px",right:"-6px",width:"16px",height:"16px",borderRadius:"50%",backgroundColor:"#ef4444",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"10px",border:"1px solid white"},children:"×"}),f.jsx("div",{style:{fontWeight:"600",marginBottom:"2px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"100px"},children:_.name||_.taskReferenceName})]}),y<l-1&&(S?f.jsx("div",{style:{position:"absolute",right:"-8px",top:"50%",transform:"translateY(-50%)",width:"8px",height:"2px",background:"var(--border-secondary)",pointerEvents:"none"}}):f.jsx("div",{style:{position:"absolute",left:"50%",bottom:"-8px",transform:"translateX(-50%)",width:"2px",height:"8px",background:"var(--border-secondary)",pointerEvents:"none"}}))]},y)},x=n==="LR",b=c&&s?.iteration!==void 0?`Condition: ${t.loopCondition||"None"} | Iteration: ${s.iteration}`:`Condition: ${t.loopCondition||"None"}`;return f.jsx(Be,{nodeId:e,selected:r,isError:t.isError,hasWarning:t.hasWarning,isHighlighted:t.isHighlighted,executionStatus:s?.status,children:f.jsxs("div",{style:{borderRadius:"8px",background:"var(--bg-secondary)",minWidth:x&&n==="LR"?"320px":"240px",position:"relative",overflow:"visible"},children:[f.jsx(or,{icon:g,header:"DO WHILE",title:t.taskReferenceName,meta:b,color:Iy,status:s?.status,isRunning:c,width:"100%",children:(l>0||o==="edit")&&f.jsxs("div",{style:{background:"var(--bg-primary)",borderRadius:"6px",padding:"12px",marginTop:"8px",border:"1px dashed var(--border-secondary)",display:"flex",flexDirection:x?"row":"column",alignItems:x?"center":"stretch",flexWrap:"nowrap",gap:"8px",justifyContent:"flex-start"},children:[d.map((_,y)=>v(_,y)),o==="edit"&&f.jsx("div",{onClick:()=>{const _=new CustomEvent("loopAddNodeRequested",{detail:{loopId:e}});document.dispatchEvent(_)},style:{background:"var(--color-accent)",color:"#fff",borderRadius:"50%",width:"24px",height:"24px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:"16px",fontWeight:"bold",marginLeft:"0",marginRight:"0",flexShrink:0},children:"+"})]})}),f.jsx(q.Handle,{type:"target",position:i,style:{background:"#fff"}}),f.jsx(q.Handle,{type:"source",position:a,style:{background:"#fff"}})]})})},Oy=D.memo(jy),qy="var(--color-accent)",Py=({id:e,data:t,selected:r})=>{const{sourcePosition:n,targetPosition:a}=We(t),{execution:i,isRunning:o}=Fe(t.taskReferenceName),c=D.useMemo(()=>$e.find(l=>l.type==="SUB_WORKFLOW"),[])?.icon||Cr,u=t.task?.subWorkflowParam?.name||t.subWorkflowName||"Unknown",d=t.task?.subWorkflowParam?.version;return f.jsx(Be,{nodeId:e,selected:r,isError:t.isError,hasWarning:t.hasWarning,isHighlighted:t.isHighlighted,executionStatus:i?.status,children:f.jsxs("div",{style:{borderRadius:"8px",background:"var(--bg-secondary)",position:"relative"},children:[f.jsx(or,{icon:c,header:"SUB WORKFLOW",title:t.taskReferenceName,meta:`Flow: ${u} (v${d})`,color:qy,status:i?.status,isRunning:o}),f.jsx(q.Handle,{type:"target",position:a,style:{background:"#fff"}}),f.jsx(q.Handle,{type:"source",position:n,style:{background:"#fff"}})]})})},Ay=D.memo(Py),Ly=({onSelect:e,onCancel:t})=>{const[r,n]=D.useState("CORE");D.useEffect(()=>{const i=o=>{o.key==="Escape"&&t()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[t]);const a=$e.filter(i=>i.category===r);return f.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:[f.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:i=>i.stopPropagation(),children:[f.jsxs("div",{style:{padding:"20px 24px 0",borderBottom:"1px solid var(--border-primary)",backgroundColor:"var(--bg-secondary)"},children:[f.jsx("h3",{style:{marginTop:0,marginBottom:"16px",color:"var(--text-primary)",fontSize:"18px",fontWeight:"600"},children:"添加任务"}),f.jsx("div",{style:{display:"flex",gap:"24px"},children:Ey.map(i=>f.jsx("button",{onClick:()=>n(i.key),style:{background:"none",border:"none",padding:"0 0 12px 0",fontSize:"14px",fontWeight:r===i.key?"600":"500",color:r===i.key?"var(--color-accent)":"var(--text-secondary)",borderBottom:r===i.key?"2px solid var(--color-accent)":"2px solid transparent",cursor:"pointer",transition:"all 0.2s"},children:i.label},i.key))})]}),f.jsx("div",{style:{flex:1,overflowY:"auto",padding:"24px",backgroundColor:"var(--bg-primary)"},children:f.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"12px"},children:a.map(i=>{const o=i.icon;return f.jsxs("button",{onClick:()=>e(i.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:s=>{s.currentTarget.style.borderColor="var(--color-accent)",s.currentTarget.style.backgroundColor="var(--bg-highlight)",s.currentTarget.style.transform="translateY(-2px)",s.currentTarget.style.boxShadow="0 4px 12px rgba(0,0,0,0.1)"},onMouseLeave:s=>{s.currentTarget.style.borderColor="var(--border-primary)",s.currentTarget.style.backgroundColor="var(--bg-tertiary)",s.currentTarget.style.transform="translateY(0)",s.currentTarget.style.boxShadow="none"},children:[f.jsx("div",{style:{padding:"10px",borderRadius:"8px",backgroundColor:"var(--bg-secondary)",color:"var(--color-accent)",display:"flex",alignItems:"center",justifyContent:"center"},children:f.jsx(o,{size:24,strokeWidth:1.5})}),f.jsxs("div",{children:[f.jsx("div",{style:{fontWeight:"600",fontSize:"14px",marginBottom:"4px"},children:i.label}),f.jsx("div",{style:{fontSize:"12px",color:"var(--text-secondary)",lineHeight:"1.4"},children:i.description})]})]},i.type)})})}),f.jsx("div",{style:{padding:"16px 24px",borderTop:"1px solid var(--border-primary)",backgroundColor:"var(--bg-secondary)",display:"flex",justifyContent:"flex-end"},children:f.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:i=>i.currentTarget.style.backgroundColor="var(--bg-tertiary)",onMouseLeave:i=>i.currentTarget.style.backgroundColor="transparent",children:"取消"})})]}),f.jsx("style",{children:`
6
+ <%s key={someKey} {...props} />`,E,P,z,P),se[P+E]=!0)}if(P=null,K!==void 0&&(t(K),P=""+K),i(Y)&&(t(Y.key),P=""+Y.key),"key"in Y){K={};for(var ee in Y)ee!=="key"&&(K[ee]=Y[ee])}else K=Y;return P&&s(K,typeof _=="function"?_.displayName||_.name||"Unknown":_),u(_,P,K,o(),j,M)}function f(_){p(_)?_._store&&(_._store.validated=1):typeof _=="object"&&_!==null&&_.$$typeof===w&&(_._payload.status==="fulfilled"?p(_._payload.value)&&_._payload.value._store&&(_._payload.value._store.validated=1):_._store&&(_._store.validated=1))}function p(_){return typeof _=="object"&&_!==null&&_.$$typeof===g}var h=q,g=Symbol.for("react.transitional.element"),v=Symbol.for("react.portal"),m=Symbol.for("react.fragment"),x=Symbol.for("react.strict_mode"),y=Symbol.for("react.profiler"),b=Symbol.for("react.consumer"),k=Symbol.for("react.context"),S=Symbol.for("react.forward_ref"),C=Symbol.for("react.suspense"),N=Symbol.for("react.suspense_list"),A=Symbol.for("react.memo"),w=Symbol.for("react.lazy"),I=Symbol.for("react.activity"),R=Symbol.for("react.client.reference"),B=h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D=Object.prototype.hasOwnProperty,L=Array.isArray,F=console.createTask?console.createTask:function(){return null};h={react_stack_bottom_frame:function(_){return _()}};var W,V={},Z=h.react_stack_bottom_frame.bind(h,a)(),le=F(n(a)),se={};ur.Fragment=m,ur.jsx=function(_,Y,K){var E=1e4>B.recentlyCreatedOwnerStacks++;return c(_,Y,K,!1,E?Error("react-stack-top-frame"):Z,E?F(n(_)):le)},ur.jsxs=function(_,Y,K){var E=1e4>B.recentlyCreatedOwnerStacks++;return c(_,Y,K,!0,E?Error("react-stack-top-frame"):Z,E?F(n(_)):le)}})()),ur}var Hs;function Zh(){return Hs||(Hs=1,process.env.NODE_ENV==="production"?Sr.exports=Yh():Sr.exports=Xh()),Sr.exports}var d=Zh();const Ks=e=>{let r;const t=new Set,n=(u,c)=>{const f=typeof u=="function"?u(r):u;if(!Object.is(f,r)){const p=r;r=c??(typeof f!="object"||f===null)?f:Object.assign({},r,f),t.forEach(h=>h(r,p))}},o=()=>r,s={setState:n,getState:o,getInitialState:()=>l,subscribe:u=>(t.add(u),()=>t.delete(u))},l=r=e(n,o,s);return s},Us=(e=>e?Ks(e):Ks),Qh=e=>e;function Vr(e,r=Qh){const t=q.useSyncExternalStore(e.subscribe,q.useCallback(()=>r(e.getState()),[e,r]),q.useCallback(()=>r(e.getInitialState()),[e,r]));return q.useDebugValue(t),t}const eg=e=>{const r=Us(e),t=n=>Vr(r,n);return Object.assign(t,r),t},rg=(e=>eg);function Js(e,r){let t;try{t=e()}catch{return}return{getItem:o=>{var a;const i=l=>l===null?null:JSON.parse(l,void 0),s=(a=t.getItem(o))!=null?a:null;return s instanceof Promise?s.then(i):i(s)},setItem:(o,a)=>t.setItem(o,JSON.stringify(a,void 0)),removeItem:o=>t.removeItem(o)}}const Yr=e=>r=>{try{const t=e(r);return t instanceof Promise?t:{then(n){return Yr(n)(t)},catch(n){return this}}}catch(t){return{then(n){return this},catch(n){return Yr(n)(t)}}}},tg=(e,r)=>(t,n,o)=>{let a={storage:Js(()=>localStorage),partialize:v=>v,version:0,merge:(v,m)=>({...m,...v}),...r},i=!1;const s=new Set,l=new Set;let u=a.storage;if(!u)return e((...v)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),t(...v)},n,o);const c=()=>{const v=a.partialize({...n()});return u.setItem(a.name,{state:v,version:a.version})},f=o.setState;o.setState=(v,m)=>(f(v,m),c());const p=e((...v)=>(t(...v),c()),n,o);o.getInitialState=()=>p;let h;const g=()=>{var v,m;if(!u)return;i=!1,s.forEach(y=>{var b;return y((b=n())!=null?b:p)});const x=((m=a.onRehydrateStorage)==null?void 0:m.call(a,(v=n())!=null?v:p))||void 0;return Yr(u.getItem.bind(u))(a.name).then(y=>{if(y)if(typeof y.version=="number"&&y.version!==a.version){if(a.migrate){const b=a.migrate(y.state,y.version);return b instanceof Promise?b.then(k=>[!0,k]):[!0,b]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,y.state];return[!1,void 0]}).then(y=>{var b;const[k,S]=y;if(h=a.merge(S,(b=n())!=null?b:p),t(h,!0),k)return c()}).then(()=>{x?.(h,void 0),h=n(),i=!0,l.forEach(y=>y(h))}).catch(y=>{x?.(void 0,y)})};return o.persist={setOptions:v=>{a={...a,...v},v.storage&&(u=v.storage)},clearStorage:()=>{u?.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>g(),hasHydrated:()=>i,onHydrate:v=>(s.add(v),()=>{s.delete(v)}),onFinishHydration:v=>(l.add(v),()=>{l.delete(v)})},a.skipHydration||g(),h||p};var Gs=(e,r,t)=>(o,a)=>({pastStates:t?.pastStates||[],futureStates:t?.futureStates||[],undo:(i=1)=>{if(a().pastStates.length){const s=t?.partialize?.(r())||r(),l=a().pastStates.splice(-i,i),u=l.shift();e(u),o({pastStates:a().pastStates,futureStates:a().futureStates.concat(t?.diff?.(s,u)||s,l.reverse())})}},redo:(i=1)=>{if(a().futureStates.length){const s=t?.partialize?.(r())||r(),l=a().futureStates.splice(-i,i),u=l.shift();e(u),o({pastStates:a().pastStates.concat(t?.diff?.(s,u)||s,l.reverse()),futureStates:a().futureStates})}},clear:()=>o({pastStates:[],futureStates:[]}),isTracking:!0,pause:()=>o({isTracking:!1}),resume:()=>o({isTracking:!0}),setOnSave:i=>o({_onSave:i}),_onSave:t?.onSave,_handleSet:(i,s,l,u)=>{t?.limit&&a().pastStates.length>=t?.limit&&a().pastStates.shift(),a()._onSave?.(i,l),o({pastStates:a().pastStates.concat(u||i),futureStates:[]})}}),ng=(e,r)=>(n,o,a)=>{a.temporal=Us(r?.wrapTemporal?.(Gs(n,o,r))||Gs(n,o,r));const i=r?.handleSet?.(a.temporal.getState()._handleSet)||a.temporal.getState()._handleSet,s=u=>{if(!a.temporal.getState().isTracking)return;const c=r?.partialize?.(o())||o(),f=r?.diff?.(u,c);f===null||r?.equality?.(u,c)||i(u,void 0,c,f)},l=a.setState;return a.setState=(...u)=>{const c=r?.partialize?.(o())||o();l(...u),s(c)},e((...u)=>{const c=r?.partialize?.(o())||o();n(...u),s(c)},o,a)};function ag(e,r="TB",t){const n=t?.hideEmptyBranches??!1;if(!e||!e.tasks)return{nodes:[],edges:[],taskMap:{}};const o=[],a=[],i={};let s=0;const l=e.tasks;for(let u=0;u<l.length;u++){const c=l[u],f=Vs(c,s,i,r,l,n);if(o.push(...f.nodes),a.push(...f.edges),s=f.nextId,u>0){const p=l[u-1];Xr(p,c,a,n)}Object.assign(i,f.taskMap)}if(!n&&l.length>0){const u=l[0],c="__workflow_start__";o.push({id:c,type:"plusNode",data:{label:"+",taskReferenceName:c,taskType:"PLUS",parentRef:c,edgeData:{isWorkflowStart:!0},layoutDirection:r},position:{x:0,y:0},sourcePosition:r==="LR"?O.Position.Right:O.Position.Bottom,targetPosition:r==="LR"?O.Position.Left:O.Position.Top}),a.push({id:`e-${c}-${u.taskReferenceName}`,source:c,target:u.taskReferenceName,animated:!0});const f=l[l.length-1],p="__workflow_end__";o.push({id:p,type:"plusNode",data:{label:"+",taskReferenceName:p,taskType:"PLUS",parentRef:f.taskReferenceName,layoutDirection:r},position:{x:0,y:0},sourcePosition:r==="LR"?O.Position.Right:O.Position.Bottom,targetPosition:r==="LR"?O.Position.Left:O.Position.Top}),Xr(f,{taskReferenceName:p},a,n)}return{nodes:o,edges:a,taskMap:i}}function Vs(e,r,t,n="TB",o=[],a=!1){switch(e.type||"SIMPLE"){case"DECISION":case"SWITCH":return ig(e,r,t,n,a);case"FORK_JOIN":case"FORK_JOIN_DYNAMIC":return sg(e,r,t,n);case"JOIN":case"EXCLUSIVE_JOIN":return lg(e,r,t,n,o,a);case"DO_WHILE":return cg(e,r,t,n,a);case"SUB_WORKFLOW":return ug(e,r,t,n);default:return og(e,r,t,n)}}function og(e,r,t,n="TB"){const o={id:e.taskReferenceName,type:"taskNode",data:{label:e.name,taskReferenceName:e.taskReferenceName,taskType:e.type||"SIMPLE",task:e,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?O.Position.Right:O.Position.Bottom,targetPosition:n==="LR"?O.Position.Left:O.Position.Top},a={[e.taskReferenceName]:e};return{nodes:[o],edges:[],taskMap:a,nextId:r+1}}function ig(e,r,t,n="TB",o=!1){const a=[],i=[];let s=r;const l={},u={id:e.taskReferenceName,type:"decisionNode",data:{label:e.name,taskReferenceName:e.taskReferenceName,taskType:e.type,task:e,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?O.Position.Right:O.Position.Bottom,targetPosition:n==="LR"?O.Position.Left:O.Position.Top};a.push(u),l[e.taskReferenceName]=e;const c=e.decisionCases||{},f=e.defaultCase||[],p=Object.keys(c),h=(g,v)=>{if(n==="TB"){if(g===0&&v>1)return"left";if(g===1&&v>2)return"right"}else{if(g===0&&v>1)return"top";if(g===1&&v>2)return"bottom"}return null};if(p.forEach((g,v)=>{const m=c[g],x=h(v,p.length+1);if(m&&m.length>0){const y=wr(m,s,{...t,...l},n,o);a.push(...y.nodes),i.push(...y.edges),Object.assign(l,y.taskMap),s=y.nextId;const b=m[0].taskReferenceName;i.push({id:`e-${e.taskReferenceName}-${b}`,source:e.taskReferenceName,sourceHandle:x||void 0,target:b,label:g,animated:!0,data:{branchCase:g},style:{stroke:"#3b82f6"}})}else if(!o){const y=`${e.taskReferenceName}_empty_${g}`;a.push({id:y,type:"plusNode",data:{label:`${g} (空)`,parentRef:e.taskReferenceName,edgeData:{branchCase:g},layoutDirection:n,taskReferenceName:y,taskType:"EMPTY_BRANCH"},position:{x:0,y:0},sourcePosition:n==="LR"?O.Position.Right:O.Position.Bottom,targetPosition:n==="LR"?O.Position.Left:O.Position.Top,style:{background:"transparent",border:"2px dashed var(--border-secondary, #64748b)",borderRadius:"8px",padding:"6px 12px",fontSize:"11px",color:"var(--text-tertiary, #94a3b8)",minWidth:"80px",textAlign:"center"}}),i.push({id:`e-${e.taskReferenceName}-${y}`,source:e.taskReferenceName,sourceHandle:x||void 0,target:y,label:g,animated:!0,data:{branchCase:g},style:{stroke:"#3b82f6",strokeDasharray:"5,5"}})}}),f&&f.length>0){const g=wr(f,s,{...t,...l},n,o);a.push(...g.nodes),i.push(...g.edges),Object.assign(l,g.taskMap),s=g.nextId;const v=f[0].taskReferenceName;i.push({id:`e-${e.taskReferenceName}-${v}`,source:e.taskReferenceName,target:v,label:"default",animated:!0,data:{branchCase:"default"},style:{stroke:"#f59e0b"}})}else if(!o){const g=`${e.taskReferenceName}_empty_default`;a.push({id:g,type:"plusNode",data:{label:"default (空)",parentRef:e.taskReferenceName,edgeData:{branchCase:"default"},layoutDirection:n,taskReferenceName:g,taskType:"EMPTY_BRANCH"},position:{x:0,y:0},sourcePosition:n==="LR"?O.Position.Right:O.Position.Bottom,targetPosition:n==="LR"?O.Position.Left:O.Position.Top,style:{background:"transparent",border:"2px dashed var(--border-secondary, #64748b)",borderRadius:"8px",padding:"6px 12px",fontSize:"11px",color:"var(--text-tertiary, #94a3b8)",minWidth:"80px",textAlign:"center"}}),i.push({id:`e-${e.taskReferenceName}-${g}`,source:e.taskReferenceName,target:g,label:"default",animated:!0,data:{branchCase:"default"},style:{stroke:"#f59e0b",strokeDasharray:"5,5"}})}return{nodes:a,edges:i,taskMap:l,nextId:s}}function sg(e,r,t,n="TB"){const o=[],a=[];let i=r;const s={},l=e.type==="FORK_JOIN_DYNAMIC",u={id:e.taskReferenceName,type:"forkNode",data:{label:e.name,taskReferenceName:e.taskReferenceName,taskType:e.type,task:e,isDynamic:l,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?O.Position.Right:O.Position.Bottom,targetPosition:n==="LR"?O.Position.Left:O.Position.Top};if(o.push(u),s[e.taskReferenceName]=e,l){const c=`${e.taskReferenceName}_dynamic_placeholder`;o.push({id:c,type:"dynamicPlaceholderNode",data:{label:"动态分支",taskReferenceName:c,taskType:"DYNAMIC_PLACEHOLDER",layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?O.Position.Right:O.Position.Bottom,targetPosition:n==="LR"?O.Position.Left:O.Position.Top}),a.push({id:`e-${e.taskReferenceName}-${c}`,source:e.taskReferenceName,target:c,animated:!0,style:{stroke:"#10b981",strokeDasharray:"5,5",strokeWidth:2}}),s[c]={taskReferenceName:c,type:"DYNAMIC_PLACEHOLDER"}}return l||(e.forkTasks||[]).forEach((f,p)=>{if(f&&f.length>0){const h=wr(f,i,{...t,...s},n,!1);o.push(...h.nodes),a.push(...h.edges),Object.assign(s,h.taskMap),i=h.nextId;const g=f[0].taskReferenceName;a.push({id:`e-${e.taskReferenceName}-${g}`,source:e.taskReferenceName,sourceHandle:`branch_${p}`,target:g,label:`分支 ${p+1}`,animated:!0,data:{forkIndex:p},style:{stroke:"#10b981"}})}}),{nodes:o,edges:a,taskMap:s,nextId:i}}function cg(e,r,t,n="TB",o=!1){const a={},i=e.taskReferenceName,s={id:i,type:"loopNode",data:{label:e.name,taskReferenceName:i,taskType:e.type,task:e,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?O.Position.Right:O.Position.Bottom,targetPosition:n==="LR"?O.Position.Left:O.Position.Top,style:{pointerEvents:"none"}};a[i]=e;const l=e.loopOver||[],u=[],c=[];let f=r+1;if(l.length>0){const p=wr(l,f,{...t,...a},n,o);if(f=p.nextId,Object.assign(a,p.taskMap),p.nodes.forEach(h=>{u.push({...h,parentId:h.parentId??i,extent:h.parentId?h.extent:"parent"})}),c.push(...p.edges),!o){const h=l[0],g=`__loop_start__${i}`;u.push({id:g,type:"plusNode",parentId:i,extent:"parent",data:{label:"+",taskReferenceName:g,taskType:"PLUS",parentRef:i,edgeData:{isLoopBodyStart:!0,loopId:i},layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?O.Position.Right:O.Position.Bottom,targetPosition:n==="LR"?O.Position.Left:O.Position.Top}),c.push({id:`e-${g}-${h.taskReferenceName}`,source:g,target:h.taskReferenceName,animated:!0})}if(!o){const h=l[l.length-1],g=`__loop_end__${i}`;u.push({id:g,type:"plusNode",parentId:i,extent:"parent",data:{label:"+",taskReferenceName:g,taskType:"PLUS",parentRef:h.taskReferenceName,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?O.Position.Right:O.Position.Bottom,targetPosition:n==="LR"?O.Position.Left:O.Position.Top}),c.push({id:`e-${h.taskReferenceName}-${g}`,source:h.taskReferenceName,target:g,animated:!0})}}else if(!o){const p=`${i}_loop_empty_plus`;u.push({id:p,type:"plusNode",parentId:i,extent:"parent",data:{label:"+ 添加",taskReferenceName:p,taskType:"PLUS",parentRef:i,edgeData:{isLoopAdd:!0},layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?O.Position.Right:O.Position.Bottom,targetPosition:n==="LR"?O.Position.Left:O.Position.Top})}return{nodes:[s,...u],edges:c,taskMap:a,nextId:f}}function ug(e,r,t,n="TB"){const o={id:e.taskReferenceName,type:"subWorkflowNode",data:{label:e.name,taskReferenceName:e.taskReferenceName,taskType:e.type,task:e,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?O.Position.Right:O.Position.Bottom,targetPosition:n==="LR"?O.Position.Left:O.Position.Top},a={[e.taskReferenceName]:e};return{nodes:[o],edges:[],taskMap:a,nextId:r+1}}function lg(e,r,t,n="TB",o=[],a=!1){const i={id:e.taskReferenceName,type:"joinNode",data:{label:e.name||"JOIN",taskReferenceName:e.taskReferenceName,taskType:e.type,task:e,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?O.Position.Right:O.Position.Bottom,targetPosition:n==="LR"?O.Position.Left:O.Position.Top},s={[e.taskReferenceName]:e},l=[],u=[];(e.joinOn||[]).forEach(p=>{const h=o.find(g=>g.taskReferenceName===p)||t[p];h&&Tr(h,a).forEach(v=>{u.push({id:`e-${v}-${e.taskReferenceName}`,source:v,target:e.taskReferenceName,animated:!0})})});const f=o.findIndex(p=>p.taskReferenceName===e.taskReferenceName);if(f>0){const p=o[f-1];if(p.type==="FORK_JOIN_DYNAMIC"){const h=`${p.taskReferenceName}_dynamic_placeholder`;u.push({id:`e-${h}-${e.taskReferenceName}-dynamic`,source:h,target:e.taskReferenceName,animated:!0,style:{stroke:"#10b981",strokeWidth:2,strokeDasharray:"5,5",opacity:.8}})}else p.type==="FORK_JOIN"&&(p.forkTasks||[]).forEach((g,v)=>{if((!g||g.length===0)&&!a){const m=`${p.taskReferenceName}_empty_branch_${v}`;l.push({id:m,type:"default",data:{label:`分支 ${v+1} (空)`,layoutDirection:n,taskReferenceName:m,taskType:"EMPTY_BRANCH"},position:{x:0,y:0},sourcePosition:n==="LR"?O.Position.Right:O.Position.Bottom,targetPosition:n==="LR"?O.Position.Left:O.Position.Top,style:{background:"transparent",border:"2px dashed var(--border-secondary, #64748b)",borderRadius:"8px",padding:"6px 12px",fontSize:"11px",color:"var(--text-tertiary, #94a3b8)",minWidth:"80px",textAlign:"center"}}),u.push({id:`e-${p.taskReferenceName}-${m}`,source:p.taskReferenceName,sourceHandle:`branch_${v}`,target:m,label:`分支 ${v+1}`,animated:!0,data:{forkIndex:v},style:{stroke:"#10b981",strokeDasharray:"5,5"}}),u.push({id:`e-${m}-${e.taskReferenceName}`,source:m,target:e.taskReferenceName,animated:!0,style:{strokeDasharray:"5,5"}})}})}return{nodes:[i,...l],edges:u,taskMap:s,nextId:r+1}}function wr(e,r,t,n="TB",o=!1){const a=[],i=[];let s=r;const l={};for(let u=0;u<e.length;u++){const c=e[u],f={...t,...l},p=Vs(c,s,f,n,e,o);if(a.push(...p.nodes),i.push(...p.edges),Object.assign(l,p.taskMap),s=p.nextId,u>0){const h=e[u-1];Xr(h,c,i,o)}}return{nodes:a,edges:i,taskMap:l,nextId:s}}function Xr(e,r,t,n=!1){if(e.type==="FORK_JOIN"||e.type==="FORK_JOIN_DYNAMIC")return;const o=Tr(e,n),a=r.taskReferenceName;o.forEach(i=>{const s=`e-${i}-${a}`;t.find(l=>l.id===s)||t.push({id:s,source:i,target:a,animated:!0})})}function Tr(e,r=!1){const t=e.type||"SIMPLE";if(t==="DECISION"||t==="SWITCH"){const n=[],o=e.decisionCases||{},a=e.defaultCase||[];if(Object.entries(o).forEach(([i,s])=>{if(s&&s.length>0){const l=s[s.length-1];n.push(...Tr(l,r))}else r||n.push(`${e.taskReferenceName}_empty_${i}`)}),a.length>0){const i=a[a.length-1];n.push(...Tr(i,r))}else r||n.push(`${e.taskReferenceName}_empty_default`);return n.length>0?n:[e.taskReferenceName]}return[e.taskReferenceName]}const _e=ag;function Zr(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Qr,Ys;function dg(){if(Ys)return Qr;Ys=1;function e(){this.__data__=[],this.size=0}return Qr=e,Qr}var et,Xs;function Ze(){if(Xs)return et;Xs=1;function e(r,t){return r===t||r!==r&&t!==t}return et=e,et}var rt,Zs;function Er(){if(Zs)return rt;Zs=1;var e=Ze();function r(t,n){for(var o=t.length;o--;)if(e(t[o][0],n))return o;return-1}return rt=r,rt}var tt,Qs;function fg(){if(Qs)return tt;Qs=1;var e=Er(),r=Array.prototype,t=r.splice;function n(o){var a=this.__data__,i=e(a,o);if(i<0)return!1;var s=a.length-1;return i==s?a.pop():t.call(a,i,1),--this.size,!0}return tt=n,tt}var nt,ec;function pg(){if(ec)return nt;ec=1;var e=Er();function r(t){var n=this.__data__,o=e(n,t);return o<0?void 0:n[o][1]}return nt=r,nt}var at,rc;function hg(){if(rc)return at;rc=1;var e=Er();function r(t){return e(this.__data__,t)>-1}return at=r,at}var ot,tc;function gg(){if(tc)return ot;tc=1;var e=Er();function r(t,n){var o=this.__data__,a=e(o,t);return a<0?(++this.size,o.push([t,n])):o[a][1]=n,this}return ot=r,ot}var it,nc;function Nr(){if(nc)return it;nc=1;var e=dg(),r=fg(),t=pg(),n=hg(),o=gg();function a(i){var s=-1,l=i==null?0:i.length;for(this.clear();++s<l;){var u=i[s];this.set(u[0],u[1])}}return a.prototype.clear=e,a.prototype.delete=r,a.prototype.get=t,a.prototype.has=n,a.prototype.set=o,it=a,it}var st,ac;function vg(){if(ac)return st;ac=1;var e=Nr();function r(){this.__data__=new e,this.size=0}return st=r,st}var ct,oc;function mg(){if(oc)return ct;oc=1;function e(r){var t=this.__data__,n=t.delete(r);return this.size=t.size,n}return ct=e,ct}var ut,ic;function yg(){if(ic)return ut;ic=1;function e(r){return this.__data__.get(r)}return ut=e,ut}var lt,sc;function xg(){if(sc)return lt;sc=1;function e(r){return this.__data__.has(r)}return lt=e,lt}var dt,cc;function uc(){if(cc)return dt;cc=1;var e=typeof _r=="object"&&_r&&_r.Object===Object&&_r;return dt=e,dt}var ft,lc;function Re(){if(lc)return ft;lc=1;var e=uc(),r=typeof self=="object"&&self&&self.Object===Object&&self,t=e||r||Function("return this")();return ft=t,ft}var pt,dc;function Qe(){if(dc)return pt;dc=1;var e=Re(),r=e.Symbol;return pt=r,pt}var ht,fc;function bg(){if(fc)return ht;fc=1;var e=Qe(),r=Object.prototype,t=r.hasOwnProperty,n=r.toString,o=e?e.toStringTag:void 0;function a(i){var s=t.call(i,o),l=i[o];try{i[o]=void 0;var u=!0}catch{}var c=n.call(i);return u&&(s?i[o]=l:delete i[o]),c}return ht=a,ht}var gt,pc;function kg(){if(pc)return gt;pc=1;var e=Object.prototype,r=e.toString;function t(n){return r.call(n)}return gt=t,gt}var vt,hc;function He(){if(hc)return vt;hc=1;var e=Qe(),r=bg(),t=kg(),n="[object Null]",o="[object Undefined]",a=e?e.toStringTag:void 0;function i(s){return s==null?s===void 0?o:n:a&&a in Object(s)?r(s):t(s)}return vt=i,vt}var mt,gc;function Te(){if(gc)return mt;gc=1;function e(r){var t=typeof r;return r!=null&&(t=="object"||t=="function")}return mt=e,mt}var yt,vc;function lr(){if(vc)return yt;vc=1;var e=He(),r=Te(),t="[object AsyncFunction]",n="[object Function]",o="[object GeneratorFunction]",a="[object Proxy]";function i(s){if(!r(s))return!1;var l=e(s);return l==n||l==o||l==t||l==a}return yt=i,yt}var xt,mc;function _g(){if(mc)return xt;mc=1;var e=Re(),r=e["__core-js_shared__"];return xt=r,xt}var bt,yc;function Sg(){if(yc)return bt;yc=1;var e=_g(),r=(function(){var n=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""})();function t(n){return!!r&&r in n}return bt=t,bt}var kt,xc;function bc(){if(xc)return kt;xc=1;var e=Function.prototype,r=e.toString;function t(n){if(n!=null){try{return r.call(n)}catch{}try{return n+""}catch{}}return""}return kt=t,kt}var _t,kc;function wg(){if(kc)return _t;kc=1;var e=lr(),r=Sg(),t=Te(),n=bc(),o=/[\\^$.*+?()[\]{}|]/g,a=/^\[object .+?Constructor\]$/,i=Function.prototype,s=Object.prototype,l=i.toString,u=s.hasOwnProperty,c=RegExp("^"+l.call(u).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function f(p){if(!t(p)||r(p))return!1;var h=e(p)?c:a;return h.test(n(p))}return _t=f,_t}var St,_c;function Tg(){if(_c)return St;_c=1;function e(r,t){return r?.[t]}return St=e,St}var wt,Sc;function Ke(){if(Sc)return wt;Sc=1;var e=wg(),r=Tg();function t(n,o){var a=r(n,o);return e(a)?a:void 0}return wt=t,wt}var Tt,wc;function Et(){if(wc)return Tt;wc=1;var e=Ke(),r=Re(),t=e(r,"Map");return Tt=t,Tt}var Nt,Tc;function Cr(){if(Tc)return Nt;Tc=1;var e=Ke(),r=e(Object,"create");return Nt=r,Nt}var Ct,Ec;function Eg(){if(Ec)return Ct;Ec=1;var e=Cr();function r(){this.__data__=e?e(null):{},this.size=0}return Ct=r,Ct}var It,Nc;function Ng(){if(Nc)return It;Nc=1;function e(r){var t=this.has(r)&&delete this.__data__[r];return this.size-=t?1:0,t}return It=e,It}var Rt,Cc;function Cg(){if(Cc)return Rt;Cc=1;var e=Cr(),r="__lodash_hash_undefined__",t=Object.prototype,n=t.hasOwnProperty;function o(a){var i=this.__data__;if(e){var s=i[a];return s===r?void 0:s}return n.call(i,a)?i[a]:void 0}return Rt=o,Rt}var jt,Ic;function Ig(){if(Ic)return jt;Ic=1;var e=Cr(),r=Object.prototype,t=r.hasOwnProperty;function n(o){var a=this.__data__;return e?a[o]!==void 0:t.call(a,o)}return jt=n,jt}var Ot,Rc;function Rg(){if(Rc)return Ot;Rc=1;var e=Cr(),r="__lodash_hash_undefined__";function t(n,o){var a=this.__data__;return this.size+=this.has(n)?0:1,a[n]=e&&o===void 0?r:o,this}return Ot=t,Ot}var Pt,jc;function jg(){if(jc)return Pt;jc=1;var e=Eg(),r=Ng(),t=Cg(),n=Ig(),o=Rg();function a(i){var s=-1,l=i==null?0:i.length;for(this.clear();++s<l;){var u=i[s];this.set(u[0],u[1])}}return a.prototype.clear=e,a.prototype.delete=r,a.prototype.get=t,a.prototype.has=n,a.prototype.set=o,Pt=a,Pt}var At,Oc;function Og(){if(Oc)return At;Oc=1;var e=jg(),r=Nr(),t=Et();function n(){this.size=0,this.__data__={hash:new e,map:new(t||r),string:new e}}return At=n,At}var qt,Pc;function Pg(){if(Pc)return qt;Pc=1;function e(r){var t=typeof r;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?r!=="__proto__":r===null}return qt=e,qt}var Lt,Ac;function Ir(){if(Ac)return Lt;Ac=1;var e=Pg();function r(t,n){var o=t.__data__;return e(n)?o[typeof n=="string"?"string":"hash"]:o.map}return Lt=r,Lt}var Dt,qc;function Ag(){if(qc)return Dt;qc=1;var e=Ir();function r(t){var n=e(this,t).delete(t);return this.size-=n?1:0,n}return Dt=r,Dt}var Mt,Lc;function qg(){if(Lc)return Mt;Lc=1;var e=Ir();function r(t){return e(this,t).get(t)}return Mt=r,Mt}var Wt,Dc;function Lg(){if(Dc)return Wt;Dc=1;var e=Ir();function r(t){return e(this,t).has(t)}return Wt=r,Wt}var Bt,Mc;function Dg(){if(Mc)return Bt;Mc=1;var e=Ir();function r(t,n){var o=e(this,t),a=o.size;return o.set(t,n),this.size+=o.size==a?0:1,this}return Bt=r,Bt}var Ft,Wc;function zt(){if(Wc)return Ft;Wc=1;var e=Og(),r=Ag(),t=qg(),n=Lg(),o=Dg();function a(i){var s=-1,l=i==null?0:i.length;for(this.clear();++s<l;){var u=i[s];this.set(u[0],u[1])}}return a.prototype.clear=e,a.prototype.delete=r,a.prototype.get=t,a.prototype.has=n,a.prototype.set=o,Ft=a,Ft}var $t,Bc;function Mg(){if(Bc)return $t;Bc=1;var e=Nr(),r=Et(),t=zt(),n=200;function o(a,i){var s=this.__data__;if(s instanceof e){var l=s.__data__;if(!r||l.length<n-1)return l.push([a,i]),this.size=++s.size,this;s=this.__data__=new t(l)}return s.set(a,i),this.size=s.size,this}return $t=o,$t}var Ht,Fc;function Rr(){if(Fc)return Ht;Fc=1;var e=Nr(),r=vg(),t=mg(),n=yg(),o=xg(),a=Mg();function i(s){var l=this.__data__=new e(s);this.size=l.size}return i.prototype.clear=r,i.prototype.delete=t,i.prototype.get=n,i.prototype.has=o,i.prototype.set=a,Ht=i,Ht}var Kt,zc;function Ut(){if(zc)return Kt;zc=1;function e(r,t){for(var n=-1,o=r==null?0:r.length;++n<o&&t(r[n],n,r)!==!1;);return r}return Kt=e,Kt}var Jt,$c;function Hc(){if($c)return Jt;$c=1;var e=Ke(),r=(function(){try{var t=e(Object,"defineProperty");return t({},"",{}),t}catch{}})();return Jt=r,Jt}var Gt,Kc;function jr(){if(Kc)return Gt;Kc=1;var e=Hc();function r(t,n,o){n=="__proto__"&&e?e(t,n,{configurable:!0,enumerable:!0,value:o,writable:!0}):t[n]=o}return Gt=r,Gt}var Vt,Uc;function Or(){if(Uc)return Vt;Uc=1;var e=jr(),r=Ze(),t=Object.prototype,n=t.hasOwnProperty;function o(a,i,s){var l=a[i];(!(n.call(a,i)&&r(l,s))||s===void 0&&!(i in a))&&e(a,i,s)}return Vt=o,Vt}var Yt,Jc;function dr(){if(Jc)return Yt;Jc=1;var e=Or(),r=jr();function t(n,o,a,i){var s=!a;a||(a={});for(var l=-1,u=o.length;++l<u;){var c=o[l],f=i?i(a[c],n[c],c,a,n):void 0;f===void 0&&(f=n[c]),s?r(a,c,f):e(a,c,f)}return a}return Yt=t,Yt}var Xt,Gc;function Wg(){if(Gc)return Xt;Gc=1;function e(r,t){for(var n=-1,o=Array(r);++n<r;)o[n]=t(n);return o}return Xt=e,Xt}var Zt,Vc;function Ae(){if(Vc)return Zt;Vc=1;function e(r){return r!=null&&typeof r=="object"}return Zt=e,Zt}var Qt,Yc;function Bg(){if(Yc)return Qt;Yc=1;var e=He(),r=Ae(),t="[object Arguments]";function n(o){return r(o)&&e(o)==t}return Qt=n,Qt}var en,Xc;function fr(){if(Xc)return en;Xc=1;var e=Bg(),r=Ae(),t=Object.prototype,n=t.hasOwnProperty,o=t.propertyIsEnumerable,a=e((function(){return arguments})())?e:function(i){return r(i)&&n.call(i,"callee")&&!o.call(i,"callee")};return en=a,en}var rn,Zc;function me(){if(Zc)return rn;Zc=1;var e=Array.isArray;return rn=e,rn}var pr={exports:{}},tn,Qc;function Fg(){if(Qc)return tn;Qc=1;function e(){return!1}return tn=e,tn}pr.exports;var eu;function er(){return eu||(eu=1,(function(e,r){var t=Re(),n=Fg(),o=r&&!r.nodeType&&r,a=o&&!0&&e&&!e.nodeType&&e,i=a&&a.exports===o,s=i?t.Buffer:void 0,l=s?s.isBuffer:void 0,u=l||n;e.exports=u})(pr,pr.exports)),pr.exports}var nn,ru;function Pr(){if(ru)return nn;ru=1;var e=9007199254740991,r=/^(?:0|[1-9]\d*)$/;function t(n,o){var a=typeof n;return o=o??e,!!o&&(a=="number"||a!="symbol"&&r.test(n))&&n>-1&&n%1==0&&n<o}return nn=t,nn}var an,tu;function on(){if(tu)return an;tu=1;var e=9007199254740991;function r(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=e}return an=r,an}var sn,nu;function zg(){if(nu)return sn;nu=1;var e=He(),r=on(),t=Ae(),n="[object Arguments]",o="[object Array]",a="[object Boolean]",i="[object Date]",s="[object Error]",l="[object Function]",u="[object Map]",c="[object Number]",f="[object Object]",p="[object RegExp]",h="[object Set]",g="[object String]",v="[object WeakMap]",m="[object ArrayBuffer]",x="[object DataView]",y="[object Float32Array]",b="[object Float64Array]",k="[object Int8Array]",S="[object Int16Array]",C="[object Int32Array]",N="[object Uint8Array]",A="[object Uint8ClampedArray]",w="[object Uint16Array]",I="[object Uint32Array]",R={};R[y]=R[b]=R[k]=R[S]=R[C]=R[N]=R[A]=R[w]=R[I]=!0,R[n]=R[o]=R[m]=R[a]=R[x]=R[i]=R[s]=R[l]=R[u]=R[c]=R[f]=R[p]=R[h]=R[g]=R[v]=!1;function B(D){return t(D)&&r(D.length)&&!!R[e(D)]}return sn=B,sn}var cn,au;function Ar(){if(au)return cn;au=1;function e(r){return function(t){return r(t)}}return cn=e,cn}var hr={exports:{}};hr.exports;var ou;function un(){return ou||(ou=1,(function(e,r){var t=uc(),n=r&&!r.nodeType&&r,o=n&&!0&&e&&!e.nodeType&&e,a=o&&o.exports===n,i=a&&t.process,s=(function(){try{var l=o&&o.require&&o.require("util").types;return l||i&&i.binding&&i.binding("util")}catch{}})();e.exports=s})(hr,hr.exports)),hr.exports}var ln,iu;function gr(){if(iu)return ln;iu=1;var e=zg(),r=Ar(),t=un(),n=t&&t.isTypedArray,o=n?r(n):e;return ln=o,ln}var dn,su;function cu(){if(su)return dn;su=1;var e=Wg(),r=fr(),t=me(),n=er(),o=Pr(),a=gr(),i=Object.prototype,s=i.hasOwnProperty;function l(u,c){var f=t(u),p=!f&&r(u),h=!f&&!p&&n(u),g=!f&&!p&&!h&&a(u),v=f||p||h||g,m=v?e(u.length,String):[],x=m.length;for(var y in u)(c||s.call(u,y))&&!(v&&(y=="length"||h&&(y=="offset"||y=="parent")||g&&(y=="buffer"||y=="byteLength"||y=="byteOffset")||o(y,x)))&&m.push(y);return m}return dn=l,dn}var fn,uu;function qr(){if(uu)return fn;uu=1;var e=Object.prototype;function r(t){var n=t&&t.constructor,o=typeof n=="function"&&n.prototype||e;return t===o}return fn=r,fn}var pn,lu;function du(){if(lu)return pn;lu=1;function e(r,t){return function(n){return r(t(n))}}return pn=e,pn}var hn,fu;function $g(){if(fu)return hn;fu=1;var e=du(),r=e(Object.keys,Object);return hn=r,hn}var gn,pu;function vn(){if(pu)return gn;pu=1;var e=qr(),r=$g(),t=Object.prototype,n=t.hasOwnProperty;function o(a){if(!e(a))return r(a);var i=[];for(var s in Object(a))n.call(a,s)&&s!="constructor"&&i.push(s);return i}return gn=o,gn}var mn,hu;function De(){if(hu)return mn;hu=1;var e=lr(),r=on();function t(n){return n!=null&&r(n.length)&&!e(n)}return mn=t,mn}var yn,gu;function Be(){if(gu)return yn;gu=1;var e=cu(),r=vn(),t=De();function n(o){return t(o)?e(o):r(o)}return yn=n,yn}var xn,vu;function Hg(){if(vu)return xn;vu=1;var e=dr(),r=Be();function t(n,o){return n&&e(o,r(o),n)}return xn=t,xn}var bn,mu;function Kg(){if(mu)return bn;mu=1;function e(r){var t=[];if(r!=null)for(var n in Object(r))t.push(n);return t}return bn=e,bn}var kn,yu;function Ug(){if(yu)return kn;yu=1;var e=Te(),r=qr(),t=Kg(),n=Object.prototype,o=n.hasOwnProperty;function a(i){if(!e(i))return t(i);var s=r(i),l=[];for(var u in i)u=="constructor"&&(s||!o.call(i,u))||l.push(u);return l}return kn=a,kn}var _n,xu;function Ue(){if(xu)return _n;xu=1;var e=cu(),r=Ug(),t=De();function n(o){return t(o)?e(o,!0):r(o)}return _n=n,_n}var Sn,bu;function Jg(){if(bu)return Sn;bu=1;var e=dr(),r=Ue();function t(n,o){return n&&e(o,r(o),n)}return Sn=t,Sn}var vr={exports:{}};vr.exports;var ku;function _u(){return ku||(ku=1,(function(e,r){var t=Re(),n=r&&!r.nodeType&&r,o=n&&!0&&e&&!e.nodeType&&e,a=o&&o.exports===n,i=a?t.Buffer:void 0,s=i?i.allocUnsafe:void 0;function l(u,c){if(c)return u.slice();var f=u.length,p=s?s(f):new u.constructor(f);return u.copy(p),p}e.exports=l})(vr,vr.exports)),vr.exports}var wn,Su;function wu(){if(Su)return wn;Su=1;function e(r,t){var n=-1,o=r.length;for(t||(t=Array(o));++n<o;)t[n]=r[n];return t}return wn=e,wn}var Tn,Tu;function Eu(){if(Tu)return Tn;Tu=1;function e(r,t){for(var n=-1,o=r==null?0:r.length,a=0,i=[];++n<o;){var s=r[n];t(s,n,r)&&(i[a++]=s)}return i}return Tn=e,Tn}var En,Nu;function Cu(){if(Nu)return En;Nu=1;function e(){return[]}return En=e,En}var Nn,Iu;function Cn(){if(Iu)return Nn;Iu=1;var e=Eu(),r=Cu(),t=Object.prototype,n=t.propertyIsEnumerable,o=Object.getOwnPropertySymbols,a=o?function(i){return i==null?[]:(i=Object(i),e(o(i),function(s){return n.call(i,s)}))}:r;return Nn=a,Nn}var In,Ru;function Gg(){if(Ru)return In;Ru=1;var e=dr(),r=Cn();function t(n,o){return e(n,r(n),o)}return In=t,In}var Rn,ju;function jn(){if(ju)return Rn;ju=1;function e(r,t){for(var n=-1,o=t.length,a=r.length;++n<o;)r[a+n]=t[n];return r}return Rn=e,Rn}var On,Ou;function Lr(){if(Ou)return On;Ou=1;var e=du(),r=e(Object.getPrototypeOf,Object);return On=r,On}var Pn,Pu;function Au(){if(Pu)return Pn;Pu=1;var e=jn(),r=Lr(),t=Cn(),n=Cu(),o=Object.getOwnPropertySymbols,a=o?function(i){for(var s=[];i;)e(s,t(i)),i=r(i);return s}:n;return Pn=a,Pn}var An,qu;function Vg(){if(qu)return An;qu=1;var e=dr(),r=Au();function t(n,o){return e(n,r(n),o)}return An=t,An}var qn,Lu;function Du(){if(Lu)return qn;Lu=1;var e=jn(),r=me();function t(n,o,a){var i=o(n);return r(n)?i:e(i,a(n))}return qn=t,qn}var Ln,Mu;function Wu(){if(Mu)return Ln;Mu=1;var e=Du(),r=Cn(),t=Be();function n(o){return e(o,t,r)}return Ln=n,Ln}var Dn,Bu;function Yg(){if(Bu)return Dn;Bu=1;var e=Du(),r=Au(),t=Ue();function n(o){return e(o,t,r)}return Dn=n,Dn}var Mn,Fu;function Xg(){if(Fu)return Mn;Fu=1;var e=Ke(),r=Re(),t=e(r,"DataView");return Mn=t,Mn}var Wn,zu;function Zg(){if(zu)return Wn;zu=1;var e=Ke(),r=Re(),t=e(r,"Promise");return Wn=t,Wn}var Bn,$u;function Hu(){if($u)return Bn;$u=1;var e=Ke(),r=Re(),t=e(r,"Set");return Bn=t,Bn}var Fn,Ku;function Qg(){if(Ku)return Fn;Ku=1;var e=Ke(),r=Re(),t=e(r,"WeakMap");return Fn=t,Fn}var zn,Uu;function rr(){if(Uu)return zn;Uu=1;var e=Xg(),r=Et(),t=Zg(),n=Hu(),o=Qg(),a=He(),i=bc(),s="[object Map]",l="[object Object]",u="[object Promise]",c="[object Set]",f="[object WeakMap]",p="[object DataView]",h=i(e),g=i(r),v=i(t),m=i(n),x=i(o),y=a;return(e&&y(new e(new ArrayBuffer(1)))!=p||r&&y(new r)!=s||t&&y(t.resolve())!=u||n&&y(new n)!=c||o&&y(new o)!=f)&&(y=function(b){var k=a(b),S=k==l?b.constructor:void 0,C=S?i(S):"";if(C)switch(C){case h:return p;case g:return s;case v:return u;case m:return c;case x:return f}return k}),zn=y,zn}var $n,Ju;function ev(){if(Ju)return $n;Ju=1;var e=Object.prototype,r=e.hasOwnProperty;function t(n){var o=n.length,a=new n.constructor(o);return o&&typeof n[0]=="string"&&r.call(n,"index")&&(a.index=n.index,a.input=n.input),a}return $n=t,$n}var Hn,Gu;function Vu(){if(Gu)return Hn;Gu=1;var e=Re(),r=e.Uint8Array;return Hn=r,Hn}var Kn,Yu;function Un(){if(Yu)return Kn;Yu=1;var e=Vu();function r(t){var n=new t.constructor(t.byteLength);return new e(n).set(new e(t)),n}return Kn=r,Kn}var Jn,Xu;function rv(){if(Xu)return Jn;Xu=1;var e=Un();function r(t,n){var o=n?e(t.buffer):t.buffer;return new t.constructor(o,t.byteOffset,t.byteLength)}return Jn=r,Jn}var Gn,Zu;function tv(){if(Zu)return Gn;Zu=1;var e=/\w*$/;function r(t){var n=new t.constructor(t.source,e.exec(t));return n.lastIndex=t.lastIndex,n}return Gn=r,Gn}var Vn,Qu;function nv(){if(Qu)return Vn;Qu=1;var e=Qe(),r=e?e.prototype:void 0,t=r?r.valueOf:void 0;function n(o){return t?Object(t.call(o)):{}}return Vn=n,Vn}var Yn,el;function rl(){if(el)return Yn;el=1;var e=Un();function r(t,n){var o=n?e(t.buffer):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}return Yn=r,Yn}var Xn,tl;function av(){if(tl)return Xn;tl=1;var e=Un(),r=rv(),t=tv(),n=nv(),o=rl(),a="[object Boolean]",i="[object Date]",s="[object Map]",l="[object Number]",u="[object RegExp]",c="[object Set]",f="[object String]",p="[object Symbol]",h="[object ArrayBuffer]",g="[object DataView]",v="[object Float32Array]",m="[object Float64Array]",x="[object Int8Array]",y="[object Int16Array]",b="[object Int32Array]",k="[object Uint8Array]",S="[object Uint8ClampedArray]",C="[object Uint16Array]",N="[object Uint32Array]";function A(w,I,R){var B=w.constructor;switch(I){case h:return e(w);case a:case i:return new B(+w);case g:return r(w,R);case v:case m:case x:case y:case b:case k:case S:case C:case N:return o(w,R);case s:return new B;case l:case f:return new B(w);case u:return t(w);case c:return new B;case p:return n(w)}}return Xn=A,Xn}var Zn,nl;function al(){if(nl)return Zn;nl=1;var e=Te(),r=Object.create,t=(function(){function n(){}return function(o){if(!e(o))return{};if(r)return r(o);n.prototype=o;var a=new n;return n.prototype=void 0,a}})();return Zn=t,Zn}var Qn,ol;function il(){if(ol)return Qn;ol=1;var e=al(),r=Lr(),t=qr();function n(o){return typeof o.constructor=="function"&&!t(o)?e(r(o)):{}}return Qn=n,Qn}var ea,sl;function ov(){if(sl)return ea;sl=1;var e=rr(),r=Ae(),t="[object Map]";function n(o){return r(o)&&e(o)==t}return ea=n,ea}var ra,cl;function iv(){if(cl)return ra;cl=1;var e=ov(),r=Ar(),t=un(),n=t&&t.isMap,o=n?r(n):e;return ra=o,ra}var ta,ul;function sv(){if(ul)return ta;ul=1;var e=rr(),r=Ae(),t="[object Set]";function n(o){return r(o)&&e(o)==t}return ta=n,ta}var na,ll;function cv(){if(ll)return na;ll=1;var e=sv(),r=Ar(),t=un(),n=t&&t.isSet,o=n?r(n):e;return na=o,na}var aa,dl;function fl(){if(dl)return aa;dl=1;var e=Rr(),r=Ut(),t=Or(),n=Hg(),o=Jg(),a=_u(),i=wu(),s=Gg(),l=Vg(),u=Wu(),c=Yg(),f=rr(),p=ev(),h=av(),g=il(),v=me(),m=er(),x=iv(),y=Te(),b=cv(),k=Be(),S=Ue(),C=1,N=2,A=4,w="[object Arguments]",I="[object Array]",R="[object Boolean]",B="[object Date]",D="[object Error]",L="[object Function]",F="[object GeneratorFunction]",W="[object Map]",V="[object Number]",Z="[object Object]",le="[object RegExp]",se="[object Set]",_="[object String]",Y="[object Symbol]",K="[object WeakMap]",E="[object ArrayBuffer]",j="[object DataView]",M="[object Float32Array]",P="[object Float64Array]",z="[object Int8Array]",ee="[object Int16Array]",ae="[object Int32Array]",ie="[object Uint8Array]",ne="[object Uint8ClampedArray]",G="[object Uint16Array]",J="[object Uint32Array]",H={};H[w]=H[I]=H[E]=H[j]=H[R]=H[B]=H[M]=H[P]=H[z]=H[ee]=H[ae]=H[W]=H[V]=H[Z]=H[le]=H[se]=H[_]=H[Y]=H[ie]=H[ne]=H[G]=H[J]=!0,H[D]=H[L]=H[K]=!1;function $(X,de,ue,he,T,U){var Q,te=de&C,re=de&N,ge=de&A;if(ue&&(Q=T?ue(X,he,T,U):ue(X)),Q!==void 0)return Q;if(!y(X))return X;var ve=v(X);if(ve){if(Q=p(X),!te)return i(X,Q)}else{var ce=f(X),ye=ce==L||ce==F;if(m(X))return a(X,te);if(ce==Z||ce==w||ye&&!T){if(Q=re||ye?{}:g(X),!te)return re?l(X,o(Q,X)):s(X,n(Q,X))}else{if(!H[ce])return T?X:{};Q=h(X,ce,te)}}U||(U=new e);var $e=U.get(X);if($e)return $e;U.set(X,Q),b(X)?X.forEach(function(fe){Q.add($(fe,de,ue,fe,X,U))}):x(X)&&X.forEach(function(fe,Ie){Q.set(Ie,$(fe,de,ue,Ie,X,U))});var Ce=ge?re?c:u:re?S:k,Xe=ve?void 0:Ce(X);return r(Xe||X,function(fe,Ie){Xe&&(Ie=fe,fe=X[Ie]),t(Q,Ie,$(fe,de,ue,Ie,X,U))}),Q}return aa=$,aa}var oa,pl;function uv(){if(pl)return oa;pl=1;var e=fl(),r=4;function t(n){return e(n,r)}return oa=t,oa}var ia,hl;function sa(){if(hl)return ia;hl=1;function e(r){return function(){return r}}return ia=e,ia}var ca,gl;function lv(){if(gl)return ca;gl=1;function e(r){return function(t,n,o){for(var a=-1,i=Object(t),s=o(t),l=s.length;l--;){var u=s[r?l:++a];if(n(i[u],u,i)===!1)break}return t}}return ca=e,ca}var ua,vl;function la(){if(vl)return ua;vl=1;var e=lv(),r=e();return ua=r,ua}var da,ml;function fa(){if(ml)return da;ml=1;var e=la(),r=Be();function t(n,o){return n&&e(n,o,r)}return da=t,da}var pa,yl;function dv(){if(yl)return pa;yl=1;var e=De();function r(t,n){return function(o,a){if(o==null)return o;if(!e(o))return t(o,a);for(var i=o.length,s=n?i:-1,l=Object(o);(n?s--:++s<i)&&a(l[s],s,l)!==!1;);return o}}return pa=r,pa}var ha,xl;function Dr(){if(xl)return ha;xl=1;var e=fa(),r=dv(),t=r(e);return ha=t,ha}var ga,bl;function Je(){if(bl)return ga;bl=1;function e(r){return r}return ga=e,ga}var va,kl;function _l(){if(kl)return va;kl=1;var e=Je();function r(t){return typeof t=="function"?t:e}return va=r,va}var ma,Sl;function wl(){if(Sl)return ma;Sl=1;var e=Ut(),r=Dr(),t=_l(),n=me();function o(a,i){var s=n(a)?e:r;return s(a,t(i))}return ma=o,ma}var ya,Tl;function El(){return Tl||(Tl=1,ya=wl()),ya}var xa,Nl;function fv(){if(Nl)return xa;Nl=1;var e=Dr();function r(t,n){var o=[];return e(t,function(a,i,s){n(a,i,s)&&o.push(a)}),o}return xa=r,xa}var ba,Cl;function pv(){if(Cl)return ba;Cl=1;var e="__lodash_hash_undefined__";function r(t){return this.__data__.set(t,e),this}return ba=r,ba}var ka,Il;function hv(){if(Il)return ka;Il=1;function e(r){return this.__data__.has(r)}return ka=e,ka}var _a,Rl;function jl(){if(Rl)return _a;Rl=1;var e=zt(),r=pv(),t=hv();function n(o){var a=-1,i=o==null?0:o.length;for(this.__data__=new e;++a<i;)this.add(o[a])}return n.prototype.add=n.prototype.push=r,n.prototype.has=t,_a=n,_a}var Sa,Ol;function gv(){if(Ol)return Sa;Ol=1;function e(r,t){for(var n=-1,o=r==null?0:r.length;++n<o;)if(t(r[n],n,r))return!0;return!1}return Sa=e,Sa}var wa,Pl;function Al(){if(Pl)return wa;Pl=1;function e(r,t){return r.has(t)}return wa=e,wa}var Ta,ql;function Ll(){if(ql)return Ta;ql=1;var e=jl(),r=gv(),t=Al(),n=1,o=2;function a(i,s,l,u,c,f){var p=l&n,h=i.length,g=s.length;if(h!=g&&!(p&&g>h))return!1;var v=f.get(i),m=f.get(s);if(v&&m)return v==s&&m==i;var x=-1,y=!0,b=l&o?new e:void 0;for(f.set(i,s),f.set(s,i);++x<h;){var k=i[x],S=s[x];if(u)var C=p?u(S,k,x,s,i,f):u(k,S,x,i,s,f);if(C!==void 0){if(C)continue;y=!1;break}if(b){if(!r(s,function(N,A){if(!t(b,A)&&(k===N||c(k,N,l,u,f)))return b.push(A)})){y=!1;break}}else if(!(k===S||c(k,S,l,u,f))){y=!1;break}}return f.delete(i),f.delete(s),y}return Ta=a,Ta}var Ea,Dl;function vv(){if(Dl)return Ea;Dl=1;function e(r){var t=-1,n=Array(r.size);return r.forEach(function(o,a){n[++t]=[a,o]}),n}return Ea=e,Ea}var Na,Ml;function Ca(){if(Ml)return Na;Ml=1;function e(r){var t=-1,n=Array(r.size);return r.forEach(function(o){n[++t]=o}),n}return Na=e,Na}var Ia,Wl;function mv(){if(Wl)return Ia;Wl=1;var e=Qe(),r=Vu(),t=Ze(),n=Ll(),o=vv(),a=Ca(),i=1,s=2,l="[object Boolean]",u="[object Date]",c="[object Error]",f="[object Map]",p="[object Number]",h="[object RegExp]",g="[object Set]",v="[object String]",m="[object Symbol]",x="[object ArrayBuffer]",y="[object DataView]",b=e?e.prototype:void 0,k=b?b.valueOf:void 0;function S(C,N,A,w,I,R,B){switch(A){case y:if(C.byteLength!=N.byteLength||C.byteOffset!=N.byteOffset)return!1;C=C.buffer,N=N.buffer;case x:return!(C.byteLength!=N.byteLength||!R(new r(C),new r(N)));case l:case u:case p:return t(+C,+N);case c:return C.name==N.name&&C.message==N.message;case h:case v:return C==N+"";case f:var D=o;case g:var L=w&i;if(D||(D=a),C.size!=N.size&&!L)return!1;var F=B.get(C);if(F)return F==N;w|=s,B.set(C,N);var W=n(D(C),D(N),w,I,R,B);return B.delete(C),W;case m:if(k)return k.call(C)==k.call(N)}return!1}return Ia=S,Ia}var Ra,Bl;function yv(){if(Bl)return Ra;Bl=1;var e=Wu(),r=1,t=Object.prototype,n=t.hasOwnProperty;function o(a,i,s,l,u,c){var f=s&r,p=e(a),h=p.length,g=e(i),v=g.length;if(h!=v&&!f)return!1;for(var m=h;m--;){var x=p[m];if(!(f?x in i:n.call(i,x)))return!1}var y=c.get(a),b=c.get(i);if(y&&b)return y==i&&b==a;var k=!0;c.set(a,i),c.set(i,a);for(var S=f;++m<h;){x=p[m];var C=a[x],N=i[x];if(l)var A=f?l(N,C,x,i,a,c):l(C,N,x,a,i,c);if(!(A===void 0?C===N||u(C,N,s,l,c):A)){k=!1;break}S||(S=x=="constructor")}if(k&&!S){var w=a.constructor,I=i.constructor;w!=I&&"constructor"in a&&"constructor"in i&&!(typeof w=="function"&&w instanceof w&&typeof I=="function"&&I instanceof I)&&(k=!1)}return c.delete(a),c.delete(i),k}return Ra=o,Ra}var ja,Fl;function xv(){if(Fl)return ja;Fl=1;var e=Rr(),r=Ll(),t=mv(),n=yv(),o=rr(),a=me(),i=er(),s=gr(),l=1,u="[object Arguments]",c="[object Array]",f="[object Object]",p=Object.prototype,h=p.hasOwnProperty;function g(v,m,x,y,b,k){var S=a(v),C=a(m),N=S?c:o(v),A=C?c:o(m);N=N==u?f:N,A=A==u?f:A;var w=N==f,I=A==f,R=N==A;if(R&&i(v)){if(!i(m))return!1;S=!0,w=!1}if(R&&!w)return k||(k=new e),S||s(v)?r(v,m,x,y,b,k):t(v,m,N,x,y,b,k);if(!(x&l)){var B=w&&h.call(v,"__wrapped__"),D=I&&h.call(m,"__wrapped__");if(B||D){var L=B?v.value():v,F=D?m.value():m;return k||(k=new e),b(L,F,x,y,k)}}return R?(k||(k=new e),n(v,m,x,y,b,k)):!1}return ja=g,ja}var Oa,zl;function $l(){if(zl)return Oa;zl=1;var e=xv(),r=Ae();function t(n,o,a,i,s){return n===o?!0:n==null||o==null||!r(n)&&!r(o)?n!==n&&o!==o:e(n,o,a,i,t,s)}return Oa=t,Oa}var Pa,Hl;function bv(){if(Hl)return Pa;Hl=1;var e=Rr(),r=$l(),t=1,n=2;function o(a,i,s,l){var u=s.length,c=u,f=!l;if(a==null)return!c;for(a=Object(a);u--;){var p=s[u];if(f&&p[2]?p[1]!==a[p[0]]:!(p[0]in a))return!1}for(;++u<c;){p=s[u];var h=p[0],g=a[h],v=p[1];if(f&&p[2]){if(g===void 0&&!(h in a))return!1}else{var m=new e;if(l)var x=l(g,v,h,a,i,m);if(!(x===void 0?r(v,g,t|n,l,m):x))return!1}}return!0}return Pa=o,Pa}var Aa,Kl;function Ul(){if(Kl)return Aa;Kl=1;var e=Te();function r(t){return t===t&&!e(t)}return Aa=r,Aa}var qa,Jl;function kv(){if(Jl)return qa;Jl=1;var e=Ul(),r=Be();function t(n){for(var o=r(n),a=o.length;a--;){var i=o[a],s=n[i];o[a]=[i,s,e(s)]}return o}return qa=t,qa}var La,Gl;function Vl(){if(Gl)return La;Gl=1;function e(r,t){return function(n){return n==null?!1:n[r]===t&&(t!==void 0||r in Object(n))}}return La=e,La}var Da,Yl;function _v(){if(Yl)return Da;Yl=1;var e=bv(),r=kv(),t=Vl();function n(o){var a=r(o);return a.length==1&&a[0][2]?t(a[0][0],a[0][1]):function(i){return i===o||e(i,o,a)}}return Da=n,Da}var Ma,Xl;function tr(){if(Xl)return Ma;Xl=1;var e=He(),r=Ae(),t="[object Symbol]";function n(o){return typeof o=="symbol"||r(o)&&e(o)==t}return Ma=n,Ma}var Wa,Zl;function Ba(){if(Zl)return Wa;Zl=1;var e=me(),r=tr(),t=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;function o(a,i){if(e(a))return!1;var s=typeof a;return s=="number"||s=="symbol"||s=="boolean"||a==null||r(a)?!0:n.test(a)||!t.test(a)||i!=null&&a in Object(i)}return Wa=o,Wa}var Fa,Ql;function Sv(){if(Ql)return Fa;Ql=1;var e=zt(),r="Expected a function";function t(n,o){if(typeof n!="function"||o!=null&&typeof o!="function")throw new TypeError(r);var a=function(){var i=arguments,s=o?o.apply(this,i):i[0],l=a.cache;if(l.has(s))return l.get(s);var u=n.apply(this,i);return a.cache=l.set(s,u)||l,u};return a.cache=new(t.Cache||e),a}return t.Cache=e,Fa=t,Fa}var za,ed;function wv(){if(ed)return za;ed=1;var e=Sv(),r=500;function t(n){var o=e(n,function(i){return a.size===r&&a.clear(),i}),a=o.cache;return o}return za=t,za}var $a,rd;function Tv(){if(rd)return $a;rd=1;var e=wv(),r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,t=/\\(\\)?/g,n=e(function(o){var a=[];return o.charCodeAt(0)===46&&a.push(""),o.replace(r,function(i,s,l,u){a.push(l?u.replace(t,"$1"):s||i)}),a});return $a=n,$a}var Ha,td;function Mr(){if(td)return Ha;td=1;function e(r,t){for(var n=-1,o=r==null?0:r.length,a=Array(o);++n<o;)a[n]=t(r[n],n,r);return a}return Ha=e,Ha}var Ka,nd;function Ev(){if(nd)return Ka;nd=1;var e=Qe(),r=Mr(),t=me(),n=tr(),o=e?e.prototype:void 0,a=o?o.toString:void 0;function i(s){if(typeof s=="string")return s;if(t(s))return r(s,i)+"";if(n(s))return a?a.call(s):"";var l=s+"";return l=="0"&&1/s==-1/0?"-0":l}return Ka=i,Ka}var Ua,ad;function od(){if(ad)return Ua;ad=1;var e=Ev();function r(t){return t==null?"":e(t)}return Ua=r,Ua}var Ja,id;function Wr(){if(id)return Ja;id=1;var e=me(),r=Ba(),t=Tv(),n=od();function o(a,i){return e(a)?a:r(a,i)?[a]:t(n(a))}return Ja=o,Ja}var Ga,sd;function mr(){if(sd)return Ga;sd=1;var e=tr();function r(t){if(typeof t=="string"||e(t))return t;var n=t+"";return n=="0"&&1/t==-1/0?"-0":n}return Ga=r,Ga}var Va,cd;function Br(){if(cd)return Va;cd=1;var e=Wr(),r=mr();function t(n,o){o=e(o,n);for(var a=0,i=o.length;n!=null&&a<i;)n=n[r(o[a++])];return a&&a==i?n:void 0}return Va=t,Va}var Ya,ud;function Nv(){if(ud)return Ya;ud=1;var e=Br();function r(t,n,o){var a=t==null?void 0:e(t,n);return a===void 0?o:a}return Ya=r,Ya}var Xa,ld;function Cv(){if(ld)return Xa;ld=1;function e(r,t){return r!=null&&t in Object(r)}return Xa=e,Xa}var Za,dd;function fd(){if(dd)return Za;dd=1;var e=Wr(),r=fr(),t=me(),n=Pr(),o=on(),a=mr();function i(s,l,u){l=e(l,s);for(var c=-1,f=l.length,p=!1;++c<f;){var h=a(l[c]);if(!(p=s!=null&&u(s,h)))break;s=s[h]}return p||++c!=f?p:(f=s==null?0:s.length,!!f&&o(f)&&n(h,f)&&(t(s)||r(s)))}return Za=i,Za}var Qa,pd;function hd(){if(pd)return Qa;pd=1;var e=Cv(),r=fd();function t(n,o){return n!=null&&r(n,o,e)}return Qa=t,Qa}var eo,gd;function Iv(){if(gd)return eo;gd=1;var e=$l(),r=Nv(),t=hd(),n=Ba(),o=Ul(),a=Vl(),i=mr(),s=1,l=2;function u(c,f){return n(c)&&o(f)?a(i(c),f):function(p){var h=r(p,c);return h===void 0&&h===f?t(p,c):e(f,h,s|l)}}return eo=u,eo}var ro,vd;function md(){if(vd)return ro;vd=1;function e(r){return function(t){return t?.[r]}}return ro=e,ro}var to,yd;function Rv(){if(yd)return to;yd=1;var e=Br();function r(t){return function(n){return e(n,t)}}return to=r,to}var no,xd;function jv(){if(xd)return no;xd=1;var e=md(),r=Rv(),t=Ba(),n=mr();function o(a){return t(a)?e(n(a)):r(a)}return no=o,no}var ao,bd;function Me(){if(bd)return ao;bd=1;var e=_v(),r=Iv(),t=Je(),n=me(),o=jv();function a(i){return typeof i=="function"?i:i==null?t:typeof i=="object"?n(i)?r(i[0],i[1]):e(i):o(i)}return ao=a,ao}var oo,kd;function _d(){if(kd)return oo;kd=1;var e=Eu(),r=fv(),t=Me(),n=me();function o(a,i){var s=n(a)?e:r;return s(a,t(i,3))}return oo=o,oo}var io,Sd;function Ov(){if(Sd)return io;Sd=1;var e=Object.prototype,r=e.hasOwnProperty;function t(n,o){return n!=null&&r.call(n,o)}return io=t,io}var so,wd;function Td(){if(wd)return so;wd=1;var e=Ov(),r=fd();function t(n,o){return n!=null&&r(n,o,e)}return so=t,so}var co,Ed;function Pv(){if(Ed)return co;Ed=1;var e=vn(),r=rr(),t=fr(),n=me(),o=De(),a=er(),i=qr(),s=gr(),l="[object Map]",u="[object Set]",c=Object.prototype,f=c.hasOwnProperty;function p(h){if(h==null)return!0;if(o(h)&&(n(h)||typeof h=="string"||typeof h.splice=="function"||a(h)||s(h)||t(h)))return!h.length;var g=r(h);if(g==l||g==u)return!h.size;if(i(h))return!e(h).length;for(var v in h)if(f.call(h,v))return!1;return!0}return co=p,co}var uo,Nd;function Cd(){if(Nd)return uo;Nd=1;function e(r){return r===void 0}return uo=e,uo}var lo,Id;function Rd(){if(Id)return lo;Id=1;var e=Dr(),r=De();function t(n,o){var a=-1,i=r(n)?Array(n.length):[];return e(n,function(s,l,u){i[++a]=o(s,l,u)}),i}return lo=t,lo}var fo,jd;function Od(){if(jd)return fo;jd=1;var e=Mr(),r=Me(),t=Rd(),n=me();function o(a,i){var s=n(a)?e:t;return s(a,r(i,3))}return fo=o,fo}var po,Pd;function Av(){if(Pd)return po;Pd=1;function e(r,t,n,o){var a=-1,i=r==null?0:r.length;for(o&&i&&(n=r[++a]);++a<i;)n=t(n,r[a],a,r);return n}return po=e,po}var ho,Ad;function qv(){if(Ad)return ho;Ad=1;function e(r,t,n,o,a){return a(r,function(i,s,l){n=o?(o=!1,i):t(n,i,s,l)}),n}return ho=e,ho}var go,qd;function Ld(){if(qd)return go;qd=1;var e=Av(),r=Dr(),t=Me(),n=qv(),o=me();function a(i,s,l){var u=o(i)?e:n,c=arguments.length<3;return u(i,t(s,4),l,c,r)}return go=a,go}var vo,Dd;function Lv(){if(Dd)return vo;Dd=1;var e=He(),r=me(),t=Ae(),n="[object String]";function o(a){return typeof a=="string"||!r(a)&&t(a)&&e(a)==n}return vo=o,vo}var mo,Md;function Dv(){if(Md)return mo;Md=1;var e=md(),r=e("length");return mo=r,mo}var yo,Wd;function Mv(){if(Wd)return yo;Wd=1;var e="\\ud800-\\udfff",r="\\u0300-\\u036f",t="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",o=r+t+n,a="\\ufe0e\\ufe0f",i="\\u200d",s=RegExp("["+i+e+o+a+"]");function l(u){return s.test(u)}return yo=l,yo}var xo,Bd;function Wv(){if(Bd)return xo;Bd=1;var e="\\ud800-\\udfff",r="\\u0300-\\u036f",t="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",o=r+t+n,a="\\ufe0e\\ufe0f",i="["+e+"]",s="["+o+"]",l="\\ud83c[\\udffb-\\udfff]",u="(?:"+s+"|"+l+")",c="[^"+e+"]",f="(?:\\ud83c[\\udde6-\\uddff]){2}",p="[\\ud800-\\udbff][\\udc00-\\udfff]",h="\\u200d",g=u+"?",v="["+a+"]?",m="(?:"+h+"(?:"+[c,f,p].join("|")+")"+v+g+")*",x=v+g+m,y="(?:"+[c+s+"?",s,f,p,i].join("|")+")",b=RegExp(l+"(?="+l+")|"+y+x,"g");function k(S){for(var C=b.lastIndex=0;b.test(S);)++C;return C}return xo=k,xo}var bo,Fd;function Bv(){if(Fd)return bo;Fd=1;var e=Dv(),r=Mv(),t=Wv();function n(o){return r(o)?t(o):e(o)}return bo=n,bo}var ko,zd;function Fv(){if(zd)return ko;zd=1;var e=vn(),r=rr(),t=De(),n=Lv(),o=Bv(),a="[object Map]",i="[object Set]";function s(l){if(l==null)return 0;if(t(l))return n(l)?o(l):l.length;var u=r(l);return u==a||u==i?l.size:e(l).length}return ko=s,ko}var _o,$d;function zv(){if($d)return _o;$d=1;var e=Ut(),r=al(),t=fa(),n=Me(),o=Lr(),a=me(),i=er(),s=lr(),l=Te(),u=gr();function c(f,p,h){var g=a(f),v=g||i(f)||u(f);if(p=n(p,4),h==null){var m=f&&f.constructor;v?h=g?new m:[]:l(f)?h=s(m)?r(o(f)):{}:h={}}return(v?e:t)(f,function(x,y,b){return p(h,x,y,b)}),h}return _o=c,_o}var So,Hd;function $v(){if(Hd)return So;Hd=1;var e=Qe(),r=fr(),t=me(),n=e?e.isConcatSpreadable:void 0;function o(a){return t(a)||r(a)||!!(n&&a&&a[n])}return So=o,So}var wo,Kd;function To(){if(Kd)return wo;Kd=1;var e=jn(),r=$v();function t(n,o,a,i,s){var l=-1,u=n.length;for(a||(a=r),s||(s=[]);++l<u;){var c=n[l];o>0&&a(c)?o>1?t(c,o-1,a,i,s):e(s,c):i||(s[s.length]=c)}return s}return wo=t,wo}var Eo,Ud;function Hv(){if(Ud)return Eo;Ud=1;function e(r,t,n){switch(n.length){case 0:return r.call(t);case 1:return r.call(t,n[0]);case 2:return r.call(t,n[0],n[1]);case 3:return r.call(t,n[0],n[1],n[2])}return r.apply(t,n)}return Eo=e,Eo}var No,Jd;function Gd(){if(Jd)return No;Jd=1;var e=Hv(),r=Math.max;function t(n,o,a){return o=r(o===void 0?n.length-1:o,0),function(){for(var i=arguments,s=-1,l=r(i.length-o,0),u=Array(l);++s<l;)u[s]=i[o+s];s=-1;for(var c=Array(o+1);++s<o;)c[s]=i[s];return c[o]=a(u),e(n,this,c)}}return No=t,No}var Co,Vd;function Kv(){if(Vd)return Co;Vd=1;var e=sa(),r=Hc(),t=Je(),n=r?function(o,a){return r(o,"toString",{configurable:!0,enumerable:!1,value:e(a),writable:!0})}:t;return Co=n,Co}var Io,Yd;function Uv(){if(Yd)return Io;Yd=1;var e=800,r=16,t=Date.now;function n(o){var a=0,i=0;return function(){var s=t(),l=r-(s-i);if(i=s,l>0){if(++a>=e)return arguments[0]}else a=0;return o.apply(void 0,arguments)}}return Io=n,Io}var Ro,Xd;function Zd(){if(Xd)return Ro;Xd=1;var e=Kv(),r=Uv(),t=r(e);return Ro=t,Ro}var jo,Qd;function Fr(){if(Qd)return jo;Qd=1;var e=Je(),r=Gd(),t=Zd();function n(o,a){return t(r(o,a,e),o+"")}return jo=n,jo}var Oo,ef;function rf(){if(ef)return Oo;ef=1;function e(r,t,n,o){for(var a=r.length,i=n+(o?1:-1);o?i--:++i<a;)if(t(r[i],i,r))return i;return-1}return Oo=e,Oo}var Po,tf;function Jv(){if(tf)return Po;tf=1;function e(r){return r!==r}return Po=e,Po}var Ao,nf;function Gv(){if(nf)return Ao;nf=1;function e(r,t,n){for(var o=n-1,a=r.length;++o<a;)if(r[o]===t)return o;return-1}return Ao=e,Ao}var qo,af;function Vv(){if(af)return qo;af=1;var e=rf(),r=Jv(),t=Gv();function n(o,a,i){return a===a?t(o,a,i):e(o,r,i)}return qo=n,qo}var Lo,of;function Yv(){if(of)return Lo;of=1;var e=Vv();function r(t,n){var o=t==null?0:t.length;return!!o&&e(t,n,0)>-1}return Lo=r,Lo}var Do,sf;function Xv(){if(sf)return Do;sf=1;function e(r,t,n){for(var o=-1,a=r==null?0:r.length;++o<a;)if(n(t,r[o]))return!0;return!1}return Do=e,Do}var Mo,cf;function Zv(){if(cf)return Mo;cf=1;function e(){}return Mo=e,Mo}var Wo,uf;function Qv(){if(uf)return Wo;uf=1;var e=Hu(),r=Zv(),t=Ca(),n=1/0,o=e&&1/t(new e([,-0]))[1]==n?function(a){return new e(a)}:r;return Wo=o,Wo}var Bo,lf;function em(){if(lf)return Bo;lf=1;var e=jl(),r=Yv(),t=Xv(),n=Al(),o=Qv(),a=Ca(),i=200;function s(l,u,c){var f=-1,p=r,h=l.length,g=!0,v=[],m=v;if(c)g=!1,p=t;else if(h>=i){var x=u?null:o(l);if(x)return a(x);g=!1,p=n,m=new e}else m=u?[]:v;e:for(;++f<h;){var y=l[f],b=u?u(y):y;if(y=c||y!==0?y:0,g&&b===b){for(var k=m.length;k--;)if(m[k]===b)continue e;u&&m.push(b),v.push(y)}else p(m,b,c)||(m!==v&&m.push(b),v.push(y))}return v}return Bo=s,Bo}var Fo,df;function ff(){if(df)return Fo;df=1;var e=De(),r=Ae();function t(n){return r(n)&&e(n)}return Fo=t,Fo}var zo,pf;function rm(){if(pf)return zo;pf=1;var e=To(),r=Fr(),t=em(),n=ff(),o=r(function(a){return t(e(a,1,n,!0))});return zo=o,zo}var $o,hf;function tm(){if(hf)return $o;hf=1;var e=Mr();function r(t,n){return e(n,function(o){return t[o]})}return $o=r,$o}var Ho,gf;function vf(){if(gf)return Ho;gf=1;var e=tm(),r=Be();function t(n){return n==null?[]:e(n,r(n))}return Ho=t,Ho}var Ko,mf;function Ee(){if(mf)return Ko;mf=1;var e;if(typeof Zr=="function")try{e={clone:uv(),constant:sa(),each:El(),filter:_d(),has:Td(),isArray:me(),isEmpty:Pv(),isFunction:lr(),isUndefined:Cd(),keys:Be(),map:Od(),reduce:Ld(),size:Fv(),transform:zv(),union:rm(),values:vf()}}catch{}return e||(e=window._),Ko=e,Ko}var Uo,yf;function Jo(){if(yf)return Uo;yf=1;var e=Ee();Uo=o;var r="\0",t="\0",n="";function o(c){this._isDirected=e.has(c,"directed")?c.directed:!0,this._isMultigraph=e.has(c,"multigraph")?c.multigraph:!1,this._isCompound=e.has(c,"compound")?c.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[t]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}o.prototype._nodeCount=0,o.prototype._edgeCount=0,o.prototype.isDirected=function(){return this._isDirected},o.prototype.isMultigraph=function(){return this._isMultigraph},o.prototype.isCompound=function(){return this._isCompound},o.prototype.setGraph=function(c){return this._label=c,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(c){return e.isFunction(c)||(c=e.constant(c)),this._defaultNodeLabelFn=c,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return e.keys(this._nodes)},o.prototype.sources=function(){var c=this;return e.filter(this.nodes(),function(f){return e.isEmpty(c._in[f])})},o.prototype.sinks=function(){var c=this;return e.filter(this.nodes(),function(f){return e.isEmpty(c._out[f])})},o.prototype.setNodes=function(c,f){var p=arguments,h=this;return e.each(c,function(g){p.length>1?h.setNode(g,f):h.setNode(g)}),this},o.prototype.setNode=function(c,f){return e.has(this._nodes,c)?(arguments.length>1&&(this._nodes[c]=f),this):(this._nodes[c]=arguments.length>1?f:this._defaultNodeLabelFn(c),this._isCompound&&(this._parent[c]=t,this._children[c]={},this._children[t][c]=!0),this._in[c]={},this._preds[c]={},this._out[c]={},this._sucs[c]={},++this._nodeCount,this)},o.prototype.node=function(c){return this._nodes[c]},o.prototype.hasNode=function(c){return e.has(this._nodes,c)},o.prototype.removeNode=function(c){var f=this;if(e.has(this._nodes,c)){var p=function(h){f.removeEdge(f._edgeObjs[h])};delete this._nodes[c],this._isCompound&&(this._removeFromParentsChildList(c),delete this._parent[c],e.each(this.children(c),function(h){f.setParent(h)}),delete this._children[c]),e.each(e.keys(this._in[c]),p),delete this._in[c],delete this._preds[c],e.each(e.keys(this._out[c]),p),delete this._out[c],delete this._sucs[c],--this._nodeCount}return this},o.prototype.setParent=function(c,f){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(f))f=t;else{f+="";for(var p=f;!e.isUndefined(p);p=this.parent(p))if(p===c)throw new Error("Setting "+f+" as parent of "+c+" would create a cycle");this.setNode(f)}return this.setNode(c),this._removeFromParentsChildList(c),this._parent[c]=f,this._children[f][c]=!0,this},o.prototype._removeFromParentsChildList=function(c){delete this._children[this._parent[c]][c]},o.prototype.parent=function(c){if(this._isCompound){var f=this._parent[c];if(f!==t)return f}},o.prototype.children=function(c){if(e.isUndefined(c)&&(c=t),this._isCompound){var f=this._children[c];if(f)return e.keys(f)}else{if(c===t)return this.nodes();if(this.hasNode(c))return[]}},o.prototype.predecessors=function(c){var f=this._preds[c];if(f)return e.keys(f)},o.prototype.successors=function(c){var f=this._sucs[c];if(f)return e.keys(f)},o.prototype.neighbors=function(c){var f=this.predecessors(c);if(f)return e.union(f,this.successors(c))},o.prototype.isLeaf=function(c){var f;return this.isDirected()?f=this.successors(c):f=this.neighbors(c),f.length===0},o.prototype.filterNodes=function(c){var f=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});f.setGraph(this.graph());var p=this;e.each(this._nodes,function(v,m){c(m)&&f.setNode(m,v)}),e.each(this._edgeObjs,function(v){f.hasNode(v.v)&&f.hasNode(v.w)&&f.setEdge(v,p.edge(v))});var h={};function g(v){var m=p.parent(v);return m===void 0||f.hasNode(m)?(h[v]=m,m):m in h?h[m]:g(m)}return this._isCompound&&e.each(f.nodes(),function(v){f.setParent(v,g(v))}),f},o.prototype.setDefaultEdgeLabel=function(c){return e.isFunction(c)||(c=e.constant(c)),this._defaultEdgeLabelFn=c,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(c,f){var p=this,h=arguments;return e.reduce(c,function(g,v){return h.length>1?p.setEdge(g,v,f):p.setEdge(g,v),v}),this},o.prototype.setEdge=function(){var c,f,p,h,g=!1,v=arguments[0];typeof v=="object"&&v!==null&&"v"in v?(c=v.v,f=v.w,p=v.name,arguments.length===2&&(h=arguments[1],g=!0)):(c=v,f=arguments[1],p=arguments[3],arguments.length>2&&(h=arguments[2],g=!0)),c=""+c,f=""+f,e.isUndefined(p)||(p=""+p);var m=s(this._isDirected,c,f,p);if(e.has(this._edgeLabels,m))return g&&(this._edgeLabels[m]=h),this;if(!e.isUndefined(p)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(c),this.setNode(f),this._edgeLabels[m]=g?h:this._defaultEdgeLabelFn(c,f,p);var x=l(this._isDirected,c,f,p);return c=x.v,f=x.w,Object.freeze(x),this._edgeObjs[m]=x,a(this._preds[f],c),a(this._sucs[c],f),this._in[f][m]=x,this._out[c][m]=x,this._edgeCount++,this},o.prototype.edge=function(c,f,p){var h=arguments.length===1?u(this._isDirected,arguments[0]):s(this._isDirected,c,f,p);return this._edgeLabels[h]},o.prototype.hasEdge=function(c,f,p){var h=arguments.length===1?u(this._isDirected,arguments[0]):s(this._isDirected,c,f,p);return e.has(this._edgeLabels,h)},o.prototype.removeEdge=function(c,f,p){var h=arguments.length===1?u(this._isDirected,arguments[0]):s(this._isDirected,c,f,p),g=this._edgeObjs[h];return g&&(c=g.v,f=g.w,delete this._edgeLabels[h],delete this._edgeObjs[h],i(this._preds[f],c),i(this._sucs[c],f),delete this._in[f][h],delete this._out[c][h],this._edgeCount--),this},o.prototype.inEdges=function(c,f){var p=this._in[c];if(p){var h=e.values(p);return f?e.filter(h,function(g){return g.v===f}):h}},o.prototype.outEdges=function(c,f){var p=this._out[c];if(p){var h=e.values(p);return f?e.filter(h,function(g){return g.w===f}):h}},o.prototype.nodeEdges=function(c,f){var p=this.inEdges(c,f);if(p)return p.concat(this.outEdges(c,f))};function a(c,f){c[f]?c[f]++:c[f]=1}function i(c,f){--c[f]||delete c[f]}function s(c,f,p,h){var g=""+f,v=""+p;if(!c&&g>v){var m=g;g=v,v=m}return g+n+v+n+(e.isUndefined(h)?r:h)}function l(c,f,p,h){var g=""+f,v=""+p;if(!c&&g>v){var m=g;g=v,v=m}var x={v:g,w:v};return h&&(x.name=h),x}function u(c,f){return s(c,f.v,f.w,f.name)}return Uo}var Go,xf;function nm(){return xf||(xf=1,Go="2.1.8"),Go}var Vo,bf;function am(){return bf||(bf=1,Vo={Graph:Jo(),version:nm()}),Vo}var Yo,kf;function om(){if(kf)return Yo;kf=1;var e=Ee(),r=Jo();Yo={write:t,read:a};function t(i){var s={options:{directed:i.isDirected(),multigraph:i.isMultigraph(),compound:i.isCompound()},nodes:n(i),edges:o(i)};return e.isUndefined(i.graph())||(s.value=e.clone(i.graph())),s}function n(i){return e.map(i.nodes(),function(s){var l=i.node(s),u=i.parent(s),c={v:s};return e.isUndefined(l)||(c.value=l),e.isUndefined(u)||(c.parent=u),c})}function o(i){return e.map(i.edges(),function(s){var l=i.edge(s),u={v:s.v,w:s.w};return e.isUndefined(s.name)||(u.name=s.name),e.isUndefined(l)||(u.value=l),u})}function a(i){var s=new r(i.options).setGraph(i.value);return e.each(i.nodes,function(l){s.setNode(l.v,l.value),l.parent&&s.setParent(l.v,l.parent)}),e.each(i.edges,function(l){s.setEdge({v:l.v,w:l.w,name:l.name},l.value)}),s}return Yo}var Xo,_f;function im(){if(_f)return Xo;_f=1;var e=Ee();Xo=r;function r(t){var n={},o=[],a;function i(s){e.has(n,s)||(n[s]=!0,a.push(s),e.each(t.successors(s),i),e.each(t.predecessors(s),i))}return e.each(t.nodes(),function(s){a=[],i(s),a.length&&o.push(a)}),o}return Xo}var Zo,Sf;function wf(){if(Sf)return Zo;Sf=1;var e=Ee();Zo=r;function r(){this._arr=[],this._keyIndices={}}return r.prototype.size=function(){return this._arr.length},r.prototype.keys=function(){return this._arr.map(function(t){return t.key})},r.prototype.has=function(t){return e.has(this._keyIndices,t)},r.prototype.priority=function(t){var n=this._keyIndices[t];if(n!==void 0)return this._arr[n].priority},r.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},r.prototype.add=function(t,n){var o=this._keyIndices;if(t=String(t),!e.has(o,t)){var a=this._arr,i=a.length;return o[t]=i,a.push({key:t,priority:n}),this._decrease(i),!0}return!1},r.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key},r.prototype.decrease=function(t,n){var o=this._keyIndices[t];if(n>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[o].priority+" New: "+n);this._arr[o].priority=n,this._decrease(o)},r.prototype._heapify=function(t){var n=this._arr,o=2*t,a=o+1,i=t;o<n.length&&(i=n[o].priority<n[i].priority?o:i,a<n.length&&(i=n[a].priority<n[i].priority?a:i),i!==t&&(this._swap(t,i),this._heapify(i)))},r.prototype._decrease=function(t){for(var n=this._arr,o=n[t].priority,a;t!==0&&(a=t>>1,!(n[a].priority<o));)this._swap(t,a),t=a},r.prototype._swap=function(t,n){var o=this._arr,a=this._keyIndices,i=o[t],s=o[n];o[t]=s,o[n]=i,a[s.key]=t,a[i.key]=n},Zo}var Qo,Tf;function Ef(){if(Tf)return Qo;Tf=1;var e=Ee(),r=wf();Qo=n;var t=e.constant(1);function n(a,i,s,l){return o(a,String(i),s||t,l||function(u){return a.outEdges(u)})}function o(a,i,s,l){var u={},c=new r,f,p,h=function(g){var v=g.v!==f?g.v:g.w,m=u[v],x=s(g),y=p.distance+x;if(x<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+g+" Weight: "+x);y<m.distance&&(m.distance=y,m.predecessor=f,c.decrease(v,y))};for(a.nodes().forEach(function(g){var v=g===i?0:Number.POSITIVE_INFINITY;u[g]={distance:v},c.add(g,v)});c.size()>0&&(f=c.removeMin(),p=u[f],p.distance!==Number.POSITIVE_INFINITY);)l(f).forEach(h);return u}return Qo}var ei,Nf;function sm(){if(Nf)return ei;Nf=1;var e=Ef(),r=Ee();ei=t;function t(n,o,a){return r.transform(n.nodes(),function(i,s){i[s]=e(n,s,o,a)},{})}return ei}var ri,Cf;function If(){if(Cf)return ri;Cf=1;var e=Ee();ri=r;function r(t){var n=0,o=[],a={},i=[];function s(l){var u=a[l]={onStack:!0,lowlink:n,index:n++};if(o.push(l),t.successors(l).forEach(function(p){e.has(a,p)?a[p].onStack&&(u.lowlink=Math.min(u.lowlink,a[p].index)):(s(p),u.lowlink=Math.min(u.lowlink,a[p].lowlink))}),u.lowlink===u.index){var c=[],f;do f=o.pop(),a[f].onStack=!1,c.push(f);while(l!==f);i.push(c)}}return t.nodes().forEach(function(l){e.has(a,l)||s(l)}),i}return ri}var ti,Rf;function cm(){if(Rf)return ti;Rf=1;var e=Ee(),r=If();ti=t;function t(n){return e.filter(r(n),function(o){return o.length>1||o.length===1&&n.hasEdge(o[0],o[0])})}return ti}var ni,jf;function um(){if(jf)return ni;jf=1;var e=Ee();ni=t;var r=e.constant(1);function t(o,a,i){return n(o,a||r,i||function(s){return o.outEdges(s)})}function n(o,a,i){var s={},l=o.nodes();return l.forEach(function(u){s[u]={},s[u][u]={distance:0},l.forEach(function(c){u!==c&&(s[u][c]={distance:Number.POSITIVE_INFINITY})}),i(u).forEach(function(c){var f=c.v===u?c.w:c.v,p=a(c);s[u][f]={distance:p,predecessor:u}})}),l.forEach(function(u){var c=s[u];l.forEach(function(f){var p=s[f];l.forEach(function(h){var g=p[u],v=c[h],m=p[h],x=g.distance+v.distance;x<m.distance&&(m.distance=x,m.predecessor=v.predecessor)})})}),s}return ni}var ai,Of;function Pf(){if(Of)return ai;Of=1;var e=Ee();ai=r,r.CycleException=t;function r(n){var o={},a={},i=[];function s(l){if(e.has(a,l))throw new t;e.has(o,l)||(a[l]=!0,o[l]=!0,e.each(n.predecessors(l),s),delete a[l],i.push(l))}if(e.each(n.sinks(),s),e.size(o)!==n.nodeCount())throw new t;return i}function t(){}return t.prototype=new Error,ai}var oi,Af;function lm(){if(Af)return oi;Af=1;var e=Pf();oi=r;function r(t){try{e(t)}catch(n){if(n instanceof e.CycleException)return!1;throw n}return!0}return oi}var ii,qf;function Lf(){if(qf)return ii;qf=1;var e=Ee();ii=r;function r(n,o,a){e.isArray(o)||(o=[o]);var i=(n.isDirected()?n.successors:n.neighbors).bind(n),s=[],l={};return e.each(o,function(u){if(!n.hasNode(u))throw new Error("Graph does not have node: "+u);t(n,u,a==="post",l,i,s)}),s}function t(n,o,a,i,s,l){e.has(i,o)||(i[o]=!0,a||l.push(o),e.each(s(o),function(u){t(n,u,a,i,s,l)}),a&&l.push(o))}return ii}var si,Df;function dm(){if(Df)return si;Df=1;var e=Lf();si=r;function r(t,n){return e(t,n,"post")}return si}var ci,Mf;function fm(){if(Mf)return ci;Mf=1;var e=Lf();ci=r;function r(t,n){return e(t,n,"pre")}return ci}var ui,Wf;function pm(){if(Wf)return ui;Wf=1;var e=Ee(),r=Jo(),t=wf();ui=n;function n(o,a){var i=new r,s={},l=new t,u;function c(p){var h=p.v===u?p.w:p.v,g=l.priority(h);if(g!==void 0){var v=a(p);v<g&&(s[h]=u,l.decrease(h,v))}}if(o.nodeCount()===0)return i;e.each(o.nodes(),function(p){l.add(p,Number.POSITIVE_INFINITY),i.setNode(p)}),l.decrease(o.nodes()[0],0);for(var f=!1;l.size()>0;){if(u=l.removeMin(),e.has(s,u))i.setEdge(u,s[u]);else{if(f)throw new Error("Input graph is not connected: "+o);f=!0}o.nodeEdges(u).forEach(c)}return i}return ui}var li,Bf;function hm(){return Bf||(Bf=1,li={components:im(),dijkstra:Ef(),dijkstraAll:sm(),findCycles:cm(),floydWarshall:um(),isAcyclic:lm(),postorder:dm(),preorder:fm(),prim:pm(),tarjan:If(),topsort:Pf()}),li}var di,Ff;function gm(){if(Ff)return di;Ff=1;var e=am();return di={Graph:e.Graph,json:om(),alg:hm(),version:e.version},di}var fi,zf;function je(){if(zf)return fi;zf=1;var e;if(typeof Zr=="function")try{e=gm()}catch{}return e||(e=window.graphlib),fi=e,fi}var pi,$f;function vm(){if($f)return pi;$f=1;var e=fl(),r=1,t=4;function n(o){return e(o,r|t)}return pi=n,pi}var hi,Hf;function zr(){if(Hf)return hi;Hf=1;var e=Ze(),r=De(),t=Pr(),n=Te();function o(a,i,s){if(!n(s))return!1;var l=typeof i;return(l=="number"?r(s)&&t(i,s.length):l=="string"&&i in s)?e(s[i],a):!1}return hi=o,hi}var gi,Kf;function mm(){if(Kf)return gi;Kf=1;var e=Fr(),r=Ze(),t=zr(),n=Ue(),o=Object.prototype,a=o.hasOwnProperty,i=e(function(s,l){s=Object(s);var u=-1,c=l.length,f=c>2?l[2]:void 0;for(f&&t(l[0],l[1],f)&&(c=1);++u<c;)for(var p=l[u],h=n(p),g=-1,v=h.length;++g<v;){var m=h[g],x=s[m];(x===void 0||r(x,o[m])&&!a.call(s,m))&&(s[m]=p[m])}return s});return gi=i,gi}var vi,Uf;function ym(){if(Uf)return vi;Uf=1;var e=Me(),r=De(),t=Be();function n(o){return function(a,i,s){var l=Object(a);if(!r(a)){var u=e(i,3);a=t(a),i=function(f){return u(l[f],f,l)}}var c=o(a,i,s);return c>-1?l[u?a[c]:c]:void 0}}return vi=n,vi}var mi,Jf;function xm(){if(Jf)return mi;Jf=1;var e=/\s/;function r(t){for(var n=t.length;n--&&e.test(t.charAt(n)););return n}return mi=r,mi}var yi,Gf;function bm(){if(Gf)return yi;Gf=1;var e=xm(),r=/^\s+/;function t(n){return n&&n.slice(0,e(n)+1).replace(r,"")}return yi=t,yi}var xi,Vf;function km(){if(Vf)return xi;Vf=1;var e=bm(),r=Te(),t=tr(),n=NaN,o=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,i=/^0o[0-7]+$/i,s=parseInt;function l(u){if(typeof u=="number")return u;if(t(u))return n;if(r(u)){var c=typeof u.valueOf=="function"?u.valueOf():u;u=r(c)?c+"":c}if(typeof u!="string")return u===0?u:+u;u=e(u);var f=a.test(u);return f||i.test(u)?s(u.slice(2),f?2:8):o.test(u)?n:+u}return xi=l,xi}var bi,Yf;function Xf(){if(Yf)return bi;Yf=1;var e=km(),r=1/0,t=17976931348623157e292;function n(o){if(!o)return o===0?o:0;if(o=e(o),o===r||o===-r){var a=o<0?-1:1;return a*t}return o===o?o:0}return bi=n,bi}var ki,Zf;function _m(){if(Zf)return ki;Zf=1;var e=Xf();function r(t){var n=e(t),o=n%1;return n===n?o?n-o:n:0}return ki=r,ki}var _i,Qf;function Sm(){if(Qf)return _i;Qf=1;var e=rf(),r=Me(),t=_m(),n=Math.max;function o(a,i,s){var l=a==null?0:a.length;if(!l)return-1;var u=s==null?0:t(s);return u<0&&(u=n(l+u,0)),e(a,r(i,3),u)}return _i=o,_i}var Si,ep;function wm(){if(ep)return Si;ep=1;var e=ym(),r=Sm(),t=e(r);return Si=t,Si}var wi,rp;function tp(){if(rp)return wi;rp=1;var e=To();function r(t){var n=t==null?0:t.length;return n?e(t,1):[]}return wi=r,wi}var Ti,np;function Tm(){if(np)return Ti;np=1;var e=la(),r=_l(),t=Ue();function n(o,a){return o==null?o:e(o,r(a),t)}return Ti=n,Ti}var Ei,ap;function Em(){if(ap)return Ei;ap=1;function e(r){var t=r==null?0:r.length;return t?r[t-1]:void 0}return Ei=e,Ei}var Ni,op;function Nm(){if(op)return Ni;op=1;var e=jr(),r=fa(),t=Me();function n(o,a){var i={};return a=t(a,3),r(o,function(s,l,u){e(i,l,a(s,l,u))}),i}return Ni=n,Ni}var Ci,ip;function Ii(){if(ip)return Ci;ip=1;var e=tr();function r(t,n,o){for(var a=-1,i=t.length;++a<i;){var s=t[a],l=n(s);if(l!=null&&(u===void 0?l===l&&!e(l):o(l,u)))var u=l,c=s}return c}return Ci=r,Ci}var Ri,sp;function Cm(){if(sp)return Ri;sp=1;function e(r,t){return r>t}return Ri=e,Ri}var ji,cp;function Im(){if(cp)return ji;cp=1;var e=Ii(),r=Cm(),t=Je();function n(o){return o&&o.length?e(o,t,r):void 0}return ji=n,ji}var Oi,up;function lp(){if(up)return Oi;up=1;var e=jr(),r=Ze();function t(n,o,a){(a!==void 0&&!r(n[o],a)||a===void 0&&!(o in n))&&e(n,o,a)}return Oi=t,Oi}var Pi,dp;function Rm(){if(dp)return Pi;dp=1;var e=He(),r=Lr(),t=Ae(),n="[object Object]",o=Function.prototype,a=Object.prototype,i=o.toString,s=a.hasOwnProperty,l=i.call(Object);function u(c){if(!t(c)||e(c)!=n)return!1;var f=r(c);if(f===null)return!0;var p=s.call(f,"constructor")&&f.constructor;return typeof p=="function"&&p instanceof p&&i.call(p)==l}return Pi=u,Pi}var Ai,fp;function pp(){if(fp)return Ai;fp=1;function e(r,t){if(!(t==="constructor"&&typeof r[t]=="function")&&t!="__proto__")return r[t]}return Ai=e,Ai}var qi,hp;function jm(){if(hp)return qi;hp=1;var e=dr(),r=Ue();function t(n){return e(n,r(n))}return qi=t,qi}var Li,gp;function Om(){if(gp)return Li;gp=1;var e=lp(),r=_u(),t=rl(),n=wu(),o=il(),a=fr(),i=me(),s=ff(),l=er(),u=lr(),c=Te(),f=Rm(),p=gr(),h=pp(),g=jm();function v(m,x,y,b,k,S,C){var N=h(m,y),A=h(x,y),w=C.get(A);if(w){e(m,y,w);return}var I=S?S(N,A,y+"",m,x,C):void 0,R=I===void 0;if(R){var B=i(A),D=!B&&l(A),L=!B&&!D&&p(A);I=A,B||D||L?i(N)?I=N:s(N)?I=n(N):D?(R=!1,I=r(A,!0)):L?(R=!1,I=t(A,!0)):I=[]:f(A)||a(A)?(I=N,a(N)?I=g(N):(!c(N)||u(N))&&(I=o(A))):R=!1}R&&(C.set(A,I),k(I,A,b,S,C),C.delete(A)),e(m,y,I)}return Li=v,Li}var Di,vp;function Pm(){if(vp)return Di;vp=1;var e=Rr(),r=lp(),t=la(),n=Om(),o=Te(),a=Ue(),i=pp();function s(l,u,c,f,p){l!==u&&t(u,function(h,g){if(p||(p=new e),o(h))n(l,u,g,c,s,f,p);else{var v=f?f(i(l,g),h,g+"",l,u,p):void 0;v===void 0&&(v=h),r(l,g,v)}},a)}return Di=s,Di}var Mi,mp;function Am(){if(mp)return Mi;mp=1;var e=Fr(),r=zr();function t(n){return e(function(o,a){var i=-1,s=a.length,l=s>1?a[s-1]:void 0,u=s>2?a[2]:void 0;for(l=n.length>3&&typeof l=="function"?(s--,l):void 0,u&&r(a[0],a[1],u)&&(l=s<3?void 0:l,s=1),o=Object(o);++i<s;){var c=a[i];c&&n(o,c,i,l)}return o})}return Mi=t,Mi}var Wi,yp;function qm(){if(yp)return Wi;yp=1;var e=Pm(),r=Am(),t=r(function(n,o,a){e(n,o,a)});return Wi=t,Wi}var Bi,xp;function bp(){if(xp)return Bi;xp=1;function e(r,t){return r<t}return Bi=e,Bi}var Fi,kp;function Lm(){if(kp)return Fi;kp=1;var e=Ii(),r=bp(),t=Je();function n(o){return o&&o.length?e(o,t,r):void 0}return Fi=n,Fi}var zi,_p;function Dm(){if(_p)return zi;_p=1;var e=Ii(),r=Me(),t=bp();function n(o,a){return o&&o.length?e(o,r(a,2),t):void 0}return zi=n,zi}var $i,Sp;function Mm(){if(Sp)return $i;Sp=1;var e=Re(),r=function(){return e.Date.now()};return $i=r,$i}var Hi,wp;function Wm(){if(wp)return Hi;wp=1;var e=Or(),r=Wr(),t=Pr(),n=Te(),o=mr();function a(i,s,l,u){if(!n(i))return i;s=r(s,i);for(var c=-1,f=s.length,p=f-1,h=i;h!=null&&++c<f;){var g=o(s[c]),v=l;if(g==="__proto__"||g==="constructor"||g==="prototype")return i;if(c!=p){var m=h[g];v=u?u(m,g,h):void 0,v===void 0&&(v=n(m)?m:t(s[c+1])?[]:{})}e(h,g,v),h=h[g]}return i}return Hi=a,Hi}var Ki,Tp;function Bm(){if(Tp)return Ki;Tp=1;var e=Br(),r=Wm(),t=Wr();function n(o,a,i){for(var s=-1,l=a.length,u={};++s<l;){var c=a[s],f=e(o,c);i(f,c)&&r(u,t(c,o),f)}return u}return Ki=n,Ki}var Ui,Ep;function Fm(){if(Ep)return Ui;Ep=1;var e=Bm(),r=hd();function t(n,o){return e(n,o,function(a,i){return r(n,i)})}return Ui=t,Ui}var Ji,Np;function zm(){if(Np)return Ji;Np=1;var e=tp(),r=Gd(),t=Zd();function n(o){return t(r(o,void 0,e),o+"")}return Ji=n,Ji}var Gi,Cp;function $m(){if(Cp)return Gi;Cp=1;var e=Fm(),r=zm(),t=r(function(n,o){return n==null?{}:e(n,o)});return Gi=t,Gi}var Vi,Ip;function Hm(){if(Ip)return Vi;Ip=1;var e=Math.ceil,r=Math.max;function t(n,o,a,i){for(var s=-1,l=r(e((o-n)/(a||1)),0),u=Array(l);l--;)u[i?l:++s]=n,n+=a;return u}return Vi=t,Vi}var Yi,Rp;function Km(){if(Rp)return Yi;Rp=1;var e=Hm(),r=zr(),t=Xf();function n(o){return function(a,i,s){return s&&typeof s!="number"&&r(a,i,s)&&(i=s=void 0),a=t(a),i===void 0?(i=a,a=0):i=t(i),s=s===void 0?a<i?1:-1:t(s),e(a,i,s,o)}}return Yi=n,Yi}var Xi,jp;function Um(){if(jp)return Xi;jp=1;var e=Km(),r=e();return Xi=r,Xi}var Zi,Op;function Jm(){if(Op)return Zi;Op=1;function e(r,t){var n=r.length;for(r.sort(t);n--;)r[n]=r[n].value;return r}return Zi=e,Zi}var Qi,Pp;function Gm(){if(Pp)return Qi;Pp=1;var e=tr();function r(t,n){if(t!==n){var o=t!==void 0,a=t===null,i=t===t,s=e(t),l=n!==void 0,u=n===null,c=n===n,f=e(n);if(!u&&!f&&!s&&t>n||s&&l&&c&&!u&&!f||a&&l&&c||!o&&c||!i)return 1;if(!a&&!s&&!f&&t<n||f&&o&&i&&!a&&!s||u&&o&&i||!l&&i||!c)return-1}return 0}return Qi=r,Qi}var es,Ap;function Vm(){if(Ap)return es;Ap=1;var e=Gm();function r(t,n,o){for(var a=-1,i=t.criteria,s=n.criteria,l=i.length,u=o.length;++a<l;){var c=e(i[a],s[a]);if(c){if(a>=u)return c;var f=o[a];return c*(f=="desc"?-1:1)}}return t.index-n.index}return es=r,es}var rs,qp;function Ym(){if(qp)return rs;qp=1;var e=Mr(),r=Br(),t=Me(),n=Rd(),o=Jm(),a=Ar(),i=Vm(),s=Je(),l=me();function u(c,f,p){f.length?f=e(f,function(v){return l(v)?function(m){return r(m,v.length===1?v[0]:v)}:v}):f=[s];var h=-1;f=e(f,a(t));var g=n(c,function(v,m,x){var y=e(f,function(b){return b(v)});return{criteria:y,index:++h,value:v}});return o(g,function(v,m){return i(v,m,p)})}return rs=u,rs}var ts,Lp;function Xm(){if(Lp)return ts;Lp=1;var e=To(),r=Ym(),t=Fr(),n=zr(),o=t(function(a,i){if(a==null)return[];var s=i.length;return s>1&&n(a,i[0],i[1])?i=[]:s>2&&n(i[0],i[1],i[2])&&(i=[i[0]]),r(a,e(i,1),[])});return ts=o,ts}var ns,Dp;function Zm(){if(Dp)return ns;Dp=1;var e=od(),r=0;function t(n){var o=++r;return e(n)+o}return ns=t,ns}var as,Mp;function Qm(){if(Mp)return as;Mp=1;function e(r,t,n){for(var o=-1,a=r.length,i=t.length,s={};++o<a;){var l=o<i?t[o]:void 0;n(s,r[o],l)}return s}return as=e,as}var os,Wp;function ey(){if(Wp)return os;Wp=1;var e=Or(),r=Qm();function t(n,o){return r(n||[],o||[],e)}return os=t,os}var is,Bp;function pe(){if(Bp)return is;Bp=1;var e;if(typeof Zr=="function")try{e={cloneDeep:vm(),constant:sa(),defaults:mm(),each:El(),filter:_d(),find:wm(),flatten:tp(),forEach:wl(),forIn:Tm(),has:Td(),isUndefined:Cd(),last:Em(),map:Od(),mapValues:Nm(),max:Im(),merge:qm(),min:Lm(),minBy:Dm(),now:Mm(),pick:$m(),range:Um(),reduce:Ld(),sortBy:Xm(),uniqueId:Zm(),values:vf(),zipObject:ey()}}catch{}return e||(e=window._),is=e,is}var ss,Fp;function ry(){if(Fp)return ss;Fp=1,ss=e;function e(){var n={};n._next=n._prev=n,this._sentinel=n}e.prototype.dequeue=function(){var n=this._sentinel,o=n._prev;if(o!==n)return r(o),o},e.prototype.enqueue=function(n){var o=this._sentinel;n._prev&&n._next&&r(n),n._next=o._next,o._next._prev=n,o._next=n,n._prev=o},e.prototype.toString=function(){for(var n=[],o=this._sentinel,a=o._prev;a!==o;)n.push(JSON.stringify(a,t)),a=a._prev;return"["+n.join(", ")+"]"};function r(n){n._prev._next=n._next,n._next._prev=n._prev,delete n._next,delete n._prev}function t(n,o){if(n!=="_next"&&n!=="_prev")return o}return ss}var cs,zp;function ty(){if(zp)return cs;zp=1;var e=pe(),r=je().Graph,t=ry();cs=o;var n=e.constant(1);function o(u,c){if(u.nodeCount()<=1)return[];var f=s(u,c||n),p=a(f.graph,f.buckets,f.zeroIdx);return e.flatten(e.map(p,function(h){return u.outEdges(h.v,h.w)}),!0)}function a(u,c,f){for(var p=[],h=c[c.length-1],g=c[0],v;u.nodeCount();){for(;v=g.dequeue();)i(u,c,f,v);for(;v=h.dequeue();)i(u,c,f,v);if(u.nodeCount()){for(var m=c.length-2;m>0;--m)if(v=c[m].dequeue(),v){p=p.concat(i(u,c,f,v,!0));break}}}return p}function i(u,c,f,p,h){var g=h?[]:void 0;return e.forEach(u.inEdges(p.v),function(v){var m=u.edge(v),x=u.node(v.v);h&&g.push({v:v.v,w:v.w}),x.out-=m,l(c,f,x)}),e.forEach(u.outEdges(p.v),function(v){var m=u.edge(v),x=v.w,y=u.node(x);y.in-=m,l(c,f,y)}),u.removeNode(p.v),g}function s(u,c){var f=new r,p=0,h=0;e.forEach(u.nodes(),function(m){f.setNode(m,{v:m,in:0,out:0})}),e.forEach(u.edges(),function(m){var x=f.edge(m.v,m.w)||0,y=c(m),b=x+y;f.setEdge(m.v,m.w,b),h=Math.max(h,f.node(m.v).out+=y),p=Math.max(p,f.node(m.w).in+=y)});var g=e.range(h+p+3).map(function(){return new t}),v=p+1;return e.forEach(f.nodes(),function(m){l(g,v,f.node(m))}),{graph:f,buckets:g,zeroIdx:v}}function l(u,c,f){f.out?f.in?u[f.out-f.in+c].enqueue(f):u[u.length-1].enqueue(f):u[0].enqueue(f)}return cs}var us,$p;function ny(){if($p)return us;$p=1;var e=pe(),r=ty();us={run:t,undo:o};function t(a){var i=a.graph().acyclicer==="greedy"?r(a,s(a)):n(a);e.forEach(i,function(l){var u=a.edge(l);a.removeEdge(l),u.forwardName=l.name,u.reversed=!0,a.setEdge(l.w,l.v,u,e.uniqueId("rev"))});function s(l){return function(u){return l.edge(u).weight}}}function n(a){var i=[],s={},l={};function u(c){e.has(l,c)||(l[c]=!0,s[c]=!0,e.forEach(a.outEdges(c),function(f){e.has(s,f.w)?i.push(f):u(f.w)}),delete s[c])}return e.forEach(a.nodes(),u),i}function o(a){e.forEach(a.edges(),function(i){var s=a.edge(i);if(s.reversed){a.removeEdge(i);var l=s.forwardName;delete s.reversed,delete s.forwardName,a.setEdge(i.w,i.v,s,l)}})}return us}var ls,Hp;function Se(){if(Hp)return ls;Hp=1;var e=pe(),r=je().Graph;ls={addDummyNode:t,simplify:n,asNonCompoundGraph:o,successorWeights:a,predecessorWeights:i,intersectRect:s,buildLayerMatrix:l,normalizeRanks:u,removeEmptyRanks:c,addBorderNode:f,maxRank:p,partition:h,time:g,notime:v};function t(m,x,y,b){var k;do k=e.uniqueId(b);while(m.hasNode(k));return y.dummy=x,m.setNode(k,y),k}function n(m){var x=new r().setGraph(m.graph());return e.forEach(m.nodes(),function(y){x.setNode(y,m.node(y))}),e.forEach(m.edges(),function(y){var b=x.edge(y.v,y.w)||{weight:0,minlen:1},k=m.edge(y);x.setEdge(y.v,y.w,{weight:b.weight+k.weight,minlen:Math.max(b.minlen,k.minlen)})}),x}function o(m){var x=new r({multigraph:m.isMultigraph()}).setGraph(m.graph());return e.forEach(m.nodes(),function(y){m.children(y).length||x.setNode(y,m.node(y))}),e.forEach(m.edges(),function(y){x.setEdge(y,m.edge(y))}),x}function a(m){var x=e.map(m.nodes(),function(y){var b={};return e.forEach(m.outEdges(y),function(k){b[k.w]=(b[k.w]||0)+m.edge(k).weight}),b});return e.zipObject(m.nodes(),x)}function i(m){var x=e.map(m.nodes(),function(y){var b={};return e.forEach(m.inEdges(y),function(k){b[k.v]=(b[k.v]||0)+m.edge(k).weight}),b});return e.zipObject(m.nodes(),x)}function s(m,x){var y=m.x,b=m.y,k=x.x-y,S=x.y-b,C=m.width/2,N=m.height/2;if(!k&&!S)throw new Error("Not possible to find intersection inside of the rectangle");var A,w;return Math.abs(S)*C>Math.abs(k)*N?(S<0&&(N=-N),A=N*k/S,w=N):(k<0&&(C=-C),A=C,w=C*S/k),{x:y+A,y:b+w}}function l(m){var x=e.map(e.range(p(m)+1),function(){return[]});return e.forEach(m.nodes(),function(y){var b=m.node(y),k=b.rank;e.isUndefined(k)||(x[k][b.order]=y)}),x}function u(m){var x=e.min(e.map(m.nodes(),function(y){return m.node(y).rank}));e.forEach(m.nodes(),function(y){var b=m.node(y);e.has(b,"rank")&&(b.rank-=x)})}function c(m){var x=e.min(e.map(m.nodes(),function(S){return m.node(S).rank})),y=[];e.forEach(m.nodes(),function(S){var C=m.node(S).rank-x;y[C]||(y[C]=[]),y[C].push(S)});var b=0,k=m.graph().nodeRankFactor;e.forEach(y,function(S,C){e.isUndefined(S)&&C%k!==0?--b:b&&e.forEach(S,function(N){m.node(N).rank+=b})})}function f(m,x,y,b){var k={width:0,height:0};return arguments.length>=4&&(k.rank=y,k.order=b),t(m,"border",k,x)}function p(m){return e.max(e.map(m.nodes(),function(x){var y=m.node(x).rank;if(!e.isUndefined(y))return y}))}function h(m,x){var y={lhs:[],rhs:[]};return e.forEach(m,function(b){x(b)?y.lhs.push(b):y.rhs.push(b)}),y}function g(m,x){var y=e.now();try{return x()}finally{console.log(m+" time: "+(e.now()-y)+"ms")}}function v(m,x){return x()}return ls}var ds,Kp;function ay(){if(Kp)return ds;Kp=1;var e=pe(),r=Se();ds={run:t,undo:o};function t(a){a.graph().dummyChains=[],e.forEach(a.edges(),function(i){n(a,i)})}function n(a,i){var s=i.v,l=a.node(s).rank,u=i.w,c=a.node(u).rank,f=i.name,p=a.edge(i),h=p.labelRank;if(c!==l+1){a.removeEdge(i);var g,v,m;for(m=0,++l;l<c;++m,++l)p.points=[],v={width:0,height:0,edgeLabel:p,edgeObj:i,rank:l},g=r.addDummyNode(a,"edge",v,"_d"),l===h&&(v.width=p.width,v.height=p.height,v.dummy="edge-label",v.labelpos=p.labelpos),a.setEdge(s,g,{weight:p.weight},f),m===0&&a.graph().dummyChains.push(g),s=g;a.setEdge(s,u,{weight:p.weight},f)}}function o(a){e.forEach(a.graph().dummyChains,function(i){var s=a.node(i),l=s.edgeLabel,u;for(a.setEdge(s.edgeObj,l);s.dummy;)u=a.successors(i)[0],a.removeNode(i),l.points.push({x:s.x,y:s.y}),s.dummy==="edge-label"&&(l.x=s.x,l.y=s.y,l.width=s.width,l.height=s.height),i=u,s=a.node(i)})}return ds}var fs,Up;function $r(){if(Up)return fs;Up=1;var e=pe();fs={longestPath:r,slack:t};function r(n){var o={};function a(i){var s=n.node(i);if(e.has(o,i))return s.rank;o[i]=!0;var l=e.min(e.map(n.outEdges(i),function(u){return a(u.w)-n.edge(u).minlen}));return(l===Number.POSITIVE_INFINITY||l===void 0||l===null)&&(l=0),s.rank=l}e.forEach(n.sources(),a)}function t(n,o){return n.node(o.w).rank-n.node(o.v).rank-n.edge(o).minlen}return fs}var ps,Jp;function Gp(){if(Jp)return ps;Jp=1;var e=pe(),r=je().Graph,t=$r().slack;ps=n;function n(s){var l=new r({directed:!1}),u=s.nodes()[0],c=s.nodeCount();l.setNode(u,{});for(var f,p;o(l,s)<c;)f=a(l,s),p=l.hasNode(f.v)?t(s,f):-t(s,f),i(l,s,p);return l}function o(s,l){function u(c){e.forEach(l.nodeEdges(c),function(f){var p=f.v,h=c===p?f.w:p;!s.hasNode(h)&&!t(l,f)&&(s.setNode(h,{}),s.setEdge(c,h,{}),u(h))})}return e.forEach(s.nodes(),u),s.nodeCount()}function a(s,l){return e.minBy(l.edges(),function(u){if(s.hasNode(u.v)!==s.hasNode(u.w))return t(l,u)})}function i(s,l,u){e.forEach(s.nodes(),function(c){l.node(c).rank+=u})}return ps}var hs,Vp;function oy(){if(Vp)return hs;Vp=1;var e=pe(),r=Gp(),t=$r().slack,n=$r().longestPath,o=je().alg.preorder,a=je().alg.postorder,i=Se().simplify;hs=s,s.initLowLimValues=f,s.initCutValues=l,s.calcCutValue=c,s.leaveEdge=h,s.enterEdge=g,s.exchangeEdges=v;function s(b){b=i(b),n(b);var k=r(b);f(k),l(k,b);for(var S,C;S=h(k);)C=g(k,b,S),v(k,b,S,C)}function l(b,k){var S=a(b,b.nodes());S=S.slice(0,S.length-1),e.forEach(S,function(C){u(b,k,C)})}function u(b,k,S){var C=b.node(S),N=C.parent;b.edge(S,N).cutvalue=c(b,k,S)}function c(b,k,S){var C=b.node(S),N=C.parent,A=!0,w=k.edge(S,N),I=0;return w||(A=!1,w=k.edge(N,S)),I=w.weight,e.forEach(k.nodeEdges(S),function(R){var B=R.v===S,D=B?R.w:R.v;if(D!==N){var L=B===A,F=k.edge(R).weight;if(I+=L?F:-F,x(b,S,D)){var W=b.edge(S,D).cutvalue;I+=L?-W:W}}}),I}function f(b,k){arguments.length<2&&(k=b.nodes()[0]),p(b,{},1,k)}function p(b,k,S,C,N){var A=S,w=b.node(C);return k[C]=!0,e.forEach(b.neighbors(C),function(I){e.has(k,I)||(S=p(b,k,S,I,C))}),w.low=A,w.lim=S++,N?w.parent=N:delete w.parent,S}function h(b){return e.find(b.edges(),function(k){return b.edge(k).cutvalue<0})}function g(b,k,S){var C=S.v,N=S.w;k.hasEdge(C,N)||(C=S.w,N=S.v);var A=b.node(C),w=b.node(N),I=A,R=!1;A.lim>w.lim&&(I=w,R=!0);var B=e.filter(k.edges(),function(D){return R===y(b,b.node(D.v),I)&&R!==y(b,b.node(D.w),I)});return e.minBy(B,function(D){return t(k,D)})}function v(b,k,S,C){var N=S.v,A=S.w;b.removeEdge(N,A),b.setEdge(C.v,C.w,{}),f(b),l(b,k),m(b,k)}function m(b,k){var S=e.find(b.nodes(),function(N){return!k.node(N).parent}),C=o(b,S);C=C.slice(1),e.forEach(C,function(N){var A=b.node(N).parent,w=k.edge(N,A),I=!1;w||(w=k.edge(A,N),I=!0),k.node(N).rank=k.node(A).rank+(I?w.minlen:-w.minlen)})}function x(b,k,S){return b.hasEdge(k,S)}function y(b,k,S){return S.low<=k.lim&&k.lim<=S.lim}return hs}var gs,Yp;function iy(){if(Yp)return gs;Yp=1;var e=$r(),r=e.longestPath,t=Gp(),n=oy();gs=o;function o(l){switch(l.graph().ranker){case"network-simplex":s(l);break;case"tight-tree":i(l);break;case"longest-path":a(l);break;default:s(l)}}var a=r;function i(l){r(l),t(l)}function s(l){n(l)}return gs}var vs,Xp;function sy(){if(Xp)return vs;Xp=1;var e=pe();vs=r;function r(o){var a=n(o);e.forEach(o.graph().dummyChains,function(i){for(var s=o.node(i),l=s.edgeObj,u=t(o,a,l.v,l.w),c=u.path,f=u.lca,p=0,h=c[p],g=!0;i!==l.w;){if(s=o.node(i),g){for(;(h=c[p])!==f&&o.node(h).maxRank<s.rank;)p++;h===f&&(g=!1)}if(!g){for(;p<c.length-1&&o.node(h=c[p+1]).minRank<=s.rank;)p++;h=c[p]}o.setParent(i,h),i=o.successors(i)[0]}})}function t(o,a,i,s){var l=[],u=[],c=Math.min(a[i].low,a[s].low),f=Math.max(a[i].lim,a[s].lim),p,h;p=i;do p=o.parent(p),l.push(p);while(p&&(a[p].low>c||f>a[p].lim));for(h=p,p=s;(p=o.parent(p))!==h;)u.push(p);return{path:l.concat(u.reverse()),lca:h}}function n(o){var a={},i=0;function s(l){var u=i;e.forEach(o.children(l),s),a[l]={low:u,lim:i++}}return e.forEach(o.children(),s),a}return vs}var ms,Zp;function cy(){if(Zp)return ms;Zp=1;var e=pe(),r=Se();ms={run:t,cleanup:i};function t(s){var l=r.addDummyNode(s,"root",{},"_root"),u=o(s),c=e.max(e.values(u))-1,f=2*c+1;s.graph().nestingRoot=l,e.forEach(s.edges(),function(h){s.edge(h).minlen*=f});var p=a(s)+1;e.forEach(s.children(),function(h){n(s,l,f,p,c,u,h)}),s.graph().nodeRankFactor=f}function n(s,l,u,c,f,p,h){var g=s.children(h);if(!g.length){h!==l&&s.setEdge(l,h,{weight:0,minlen:u});return}var v=r.addBorderNode(s,"_bt"),m=r.addBorderNode(s,"_bb"),x=s.node(h);s.setParent(v,h),x.borderTop=v,s.setParent(m,h),x.borderBottom=m,e.forEach(g,function(y){n(s,l,u,c,f,p,y);var b=s.node(y),k=b.borderTop?b.borderTop:y,S=b.borderBottom?b.borderBottom:y,C=b.borderTop?c:2*c,N=k!==S?1:f-p[h]+1;s.setEdge(v,k,{weight:C,minlen:N,nestingEdge:!0}),s.setEdge(S,m,{weight:C,minlen:N,nestingEdge:!0})}),s.parent(h)||s.setEdge(l,v,{weight:0,minlen:f+p[h]})}function o(s){var l={};function u(c,f){var p=s.children(c);p&&p.length&&e.forEach(p,function(h){u(h,f+1)}),l[c]=f}return e.forEach(s.children(),function(c){u(c,1)}),l}function a(s){return e.reduce(s.edges(),function(l,u){return l+s.edge(u).weight},0)}function i(s){var l=s.graph();s.removeNode(l.nestingRoot),delete l.nestingRoot,e.forEach(s.edges(),function(u){var c=s.edge(u);c.nestingEdge&&s.removeEdge(u)})}return ms}var ys,Qp;function uy(){if(Qp)return ys;Qp=1;var e=pe(),r=Se();ys=t;function t(o){function a(i){var s=o.children(i),l=o.node(i);if(s.length&&e.forEach(s,a),e.has(l,"minRank")){l.borderLeft=[],l.borderRight=[];for(var u=l.minRank,c=l.maxRank+1;u<c;++u)n(o,"borderLeft","_bl",i,l,u),n(o,"borderRight","_br",i,l,u)}}e.forEach(o.children(),a)}function n(o,a,i,s,l,u){var c={width:0,height:0,rank:u,borderType:a},f=l[a][u-1],p=r.addDummyNode(o,"border",c,i);l[a][u]=p,o.setParent(p,s),f&&o.setEdge(f,p,{weight:1})}return ys}var xs,eh;function ly(){if(eh)return xs;eh=1;var e=pe();xs={adjust:r,undo:t};function r(u){var c=u.graph().rankdir.toLowerCase();(c==="lr"||c==="rl")&&n(u)}function t(u){var c=u.graph().rankdir.toLowerCase();(c==="bt"||c==="rl")&&a(u),(c==="lr"||c==="rl")&&(s(u),n(u))}function n(u){e.forEach(u.nodes(),function(c){o(u.node(c))}),e.forEach(u.edges(),function(c){o(u.edge(c))})}function o(u){var c=u.width;u.width=u.height,u.height=c}function a(u){e.forEach(u.nodes(),function(c){i(u.node(c))}),e.forEach(u.edges(),function(c){var f=u.edge(c);e.forEach(f.points,i),e.has(f,"y")&&i(f)})}function i(u){u.y=-u.y}function s(u){e.forEach(u.nodes(),function(c){l(u.node(c))}),e.forEach(u.edges(),function(c){var f=u.edge(c);e.forEach(f.points,l),e.has(f,"x")&&l(f)})}function l(u){var c=u.x;u.x=u.y,u.y=c}return xs}var bs,rh;function dy(){if(rh)return bs;rh=1;var e=pe();bs=r;function r(t){var n={},o=e.filter(t.nodes(),function(u){return!t.children(u).length}),a=e.max(e.map(o,function(u){return t.node(u).rank})),i=e.map(e.range(a+1),function(){return[]});function s(u){if(!e.has(n,u)){n[u]=!0;var c=t.node(u);i[c.rank].push(u),e.forEach(t.successors(u),s)}}var l=e.sortBy(o,function(u){return t.node(u).rank});return e.forEach(l,s),i}return bs}var ks,th;function fy(){if(th)return ks;th=1;var e=pe();ks=r;function r(n,o){for(var a=0,i=1;i<o.length;++i)a+=t(n,o[i-1],o[i]);return a}function t(n,o,a){for(var i=e.zipObject(a,e.map(a,function(p,h){return h})),s=e.flatten(e.map(o,function(p){return e.sortBy(e.map(n.outEdges(p),function(h){return{pos:i[h.w],weight:n.edge(h).weight}}),"pos")}),!0),l=1;l<a.length;)l<<=1;var u=2*l-1;l-=1;var c=e.map(new Array(u),function(){return 0}),f=0;return e.forEach(s.forEach(function(p){var h=p.pos+l;c[h]+=p.weight;for(var g=0;h>0;)h%2&&(g+=c[h+1]),h=h-1>>1,c[h]+=p.weight;f+=p.weight*g})),f}return ks}var _s,nh;function py(){if(nh)return _s;nh=1;var e=pe();_s=r;function r(t,n){return e.map(n,function(o){var a=t.inEdges(o);if(a.length){var i=e.reduce(a,function(s,l){var u=t.edge(l),c=t.node(l.v);return{sum:s.sum+u.weight*c.order,weight:s.weight+u.weight}},{sum:0,weight:0});return{v:o,barycenter:i.sum/i.weight,weight:i.weight}}else return{v:o}})}return _s}var Ss,ah;function hy(){if(ah)return Ss;ah=1;var e=pe();Ss=r;function r(o,a){var i={};e.forEach(o,function(l,u){var c=i[l.v]={indegree:0,in:[],out:[],vs:[l.v],i:u};e.isUndefined(l.barycenter)||(c.barycenter=l.barycenter,c.weight=l.weight)}),e.forEach(a.edges(),function(l){var u=i[l.v],c=i[l.w];!e.isUndefined(u)&&!e.isUndefined(c)&&(c.indegree++,u.out.push(i[l.w]))});var s=e.filter(i,function(l){return!l.indegree});return t(s)}function t(o){var a=[];function i(u){return function(c){c.merged||(e.isUndefined(c.barycenter)||e.isUndefined(u.barycenter)||c.barycenter>=u.barycenter)&&n(u,c)}}function s(u){return function(c){c.in.push(u),--c.indegree===0&&o.push(c)}}for(;o.length;){var l=o.pop();a.push(l),e.forEach(l.in.reverse(),i(l)),e.forEach(l.out,s(l))}return e.map(e.filter(a,function(u){return!u.merged}),function(u){return e.pick(u,["vs","i","barycenter","weight"])})}function n(o,a){var i=0,s=0;o.weight&&(i+=o.barycenter*o.weight,s+=o.weight),a.weight&&(i+=a.barycenter*a.weight,s+=a.weight),o.vs=a.vs.concat(o.vs),o.barycenter=i/s,o.weight=s,o.i=Math.min(a.i,o.i),a.merged=!0}return Ss}var ws,oh;function gy(){if(oh)return ws;oh=1;var e=pe(),r=Se();ws=t;function t(a,i){var s=r.partition(a,function(v){return e.has(v,"barycenter")}),l=s.lhs,u=e.sortBy(s.rhs,function(v){return-v.i}),c=[],f=0,p=0,h=0;l.sort(o(!!i)),h=n(c,u,h),e.forEach(l,function(v){h+=v.vs.length,c.push(v.vs),f+=v.barycenter*v.weight,p+=v.weight,h=n(c,u,h)});var g={vs:e.flatten(c,!0)};return p&&(g.barycenter=f/p,g.weight=p),g}function n(a,i,s){for(var l;i.length&&(l=e.last(i)).i<=s;)i.pop(),a.push(l.vs),s++;return s}function o(a){return function(i,s){return i.barycenter<s.barycenter?-1:i.barycenter>s.barycenter?1:a?s.i-i.i:i.i-s.i}}return ws}var Ts,ih;function vy(){if(ih)return Ts;ih=1;var e=pe(),r=py(),t=hy(),n=gy();Ts=o;function o(s,l,u,c){var f=s.children(l),p=s.node(l),h=p?p.borderLeft:void 0,g=p?p.borderRight:void 0,v={};h&&(f=e.filter(f,function(S){return S!==h&&S!==g}));var m=r(s,f);e.forEach(m,function(S){if(s.children(S.v).length){var C=o(s,S.v,u,c);v[S.v]=C,e.has(C,"barycenter")&&i(S,C)}});var x=t(m,u);a(x,v);var y=n(x,c);if(h&&(y.vs=e.flatten([h,y.vs,g],!0),s.predecessors(h).length)){var b=s.node(s.predecessors(h)[0]),k=s.node(s.predecessors(g)[0]);e.has(y,"barycenter")||(y.barycenter=0,y.weight=0),y.barycenter=(y.barycenter*y.weight+b.order+k.order)/(y.weight+2),y.weight+=2}return y}function a(s,l){e.forEach(s,function(u){u.vs=e.flatten(u.vs.map(function(c){return l[c]?l[c].vs:c}),!0)})}function i(s,l){e.isUndefined(s.barycenter)?(s.barycenter=l.barycenter,s.weight=l.weight):(s.barycenter=(s.barycenter*s.weight+l.barycenter*l.weight)/(s.weight+l.weight),s.weight+=l.weight)}return Ts}var Es,sh;function my(){if(sh)return Es;sh=1;var e=pe(),r=je().Graph;Es=t;function t(o,a,i){var s=n(o),l=new r({compound:!0}).setGraph({root:s}).setDefaultNodeLabel(function(u){return o.node(u)});return e.forEach(o.nodes(),function(u){var c=o.node(u),f=o.parent(u);(c.rank===a||c.minRank<=a&&a<=c.maxRank)&&(l.setNode(u),l.setParent(u,f||s),e.forEach(o[i](u),function(p){var h=p.v===u?p.w:p.v,g=l.edge(h,u),v=e.isUndefined(g)?0:g.weight;l.setEdge(h,u,{weight:o.edge(p).weight+v})}),e.has(c,"minRank")&&l.setNode(u,{borderLeft:c.borderLeft[a],borderRight:c.borderRight[a]}))}),l}function n(o){for(var a;o.hasNode(a=e.uniqueId("_root")););return a}return Es}var Ns,ch;function yy(){if(ch)return Ns;ch=1;var e=pe();Ns=r;function r(t,n,o){var a={},i;e.forEach(o,function(s){for(var l=t.parent(s),u,c;l;){if(u=t.parent(l),u?(c=a[u],a[u]=l):(c=i,i=l),c&&c!==l){n.setEdge(c,l);return}l=u}})}return Ns}var Cs,uh;function xy(){if(uh)return Cs;uh=1;var e=pe(),r=dy(),t=fy(),n=vy(),o=my(),a=yy(),i=je().Graph,s=Se();Cs=l;function l(p){var h=s.maxRank(p),g=u(p,e.range(1,h+1),"inEdges"),v=u(p,e.range(h-1,-1,-1),"outEdges"),m=r(p);f(p,m);for(var x=Number.POSITIVE_INFINITY,y,b=0,k=0;k<4;++b,++k){c(b%2?g:v,b%4>=2),m=s.buildLayerMatrix(p);var S=t(p,m);S<x&&(k=0,y=e.cloneDeep(m),x=S)}f(p,y)}function u(p,h,g){return e.map(h,function(v){return o(p,v,g)})}function c(p,h){var g=new i;e.forEach(p,function(v){var m=v.graph().root,x=n(v,m,g,h);e.forEach(x.vs,function(y,b){v.node(y).order=b}),a(v,g,x.vs)})}function f(p,h){e.forEach(h,function(g){e.forEach(g,function(v,m){p.node(v).order=m})})}return Cs}var Is,lh;function by(){if(lh)return Is;lh=1;var e=pe(),r=je().Graph,t=Se();Is={positionX:g,findType1Conflicts:n,findType2Conflicts:o,addConflict:i,hasConflict:s,verticalAlignment:l,horizontalCompaction:u,alignCoordinates:p,findSmallestWidthAlignment:f,balance:h};function n(x,y){var b={};function k(S,C){var N=0,A=0,w=S.length,I=e.last(C);return e.forEach(C,function(R,B){var D=a(x,R),L=D?x.node(D).order:w;(D||R===I)&&(e.forEach(C.slice(A,B+1),function(F){e.forEach(x.predecessors(F),function(W){var V=x.node(W),Z=V.order;(Z<N||L<Z)&&!(V.dummy&&x.node(F).dummy)&&i(b,W,F)})}),A=B+1,N=L)}),C}return e.reduce(y,k),b}function o(x,y){var b={};function k(C,N,A,w,I){var R;e.forEach(e.range(N,A),function(B){R=C[B],x.node(R).dummy&&e.forEach(x.predecessors(R),function(D){var L=x.node(D);L.dummy&&(L.order<w||L.order>I)&&i(b,D,R)})})}function S(C,N){var A=-1,w,I=0;return e.forEach(N,function(R,B){if(x.node(R).dummy==="border"){var D=x.predecessors(R);D.length&&(w=x.node(D[0]).order,k(N,I,B,A,w),I=B,A=w)}k(N,I,N.length,w,C.length)}),N}return e.reduce(y,S),b}function a(x,y){if(x.node(y).dummy)return e.find(x.predecessors(y),function(b){return x.node(b).dummy})}function i(x,y,b){if(y>b){var k=y;y=b,b=k}var S=x[y];S||(x[y]=S={}),S[b]=!0}function s(x,y,b){if(y>b){var k=y;y=b,b=k}return e.has(x[y],b)}function l(x,y,b,k){var S={},C={},N={};return e.forEach(y,function(A){e.forEach(A,function(w,I){S[w]=w,C[w]=w,N[w]=I})}),e.forEach(y,function(A){var w=-1;e.forEach(A,function(I){var R=k(I);if(R.length){R=e.sortBy(R,function(W){return N[W]});for(var B=(R.length-1)/2,D=Math.floor(B),L=Math.ceil(B);D<=L;++D){var F=R[D];C[I]===I&&w<N[F]&&!s(b,I,F)&&(C[F]=I,C[I]=S[I]=S[F],w=N[F])}}})}),{root:S,align:C}}function u(x,y,b,k,S){var C={},N=c(x,y,b,S),A=S?"borderLeft":"borderRight";function w(B,D){for(var L=N.nodes(),F=L.pop(),W={};F;)W[F]?B(F):(W[F]=!0,L.push(F),L=L.concat(D(F))),F=L.pop()}function I(B){C[B]=N.inEdges(B).reduce(function(D,L){return Math.max(D,C[L.v]+N.edge(L))},0)}function R(B){var D=N.outEdges(B).reduce(function(F,W){return Math.min(F,C[W.w]-N.edge(W))},Number.POSITIVE_INFINITY),L=x.node(B);D!==Number.POSITIVE_INFINITY&&L.borderType!==A&&(C[B]=Math.max(C[B],D))}return w(I,N.predecessors.bind(N)),w(R,N.successors.bind(N)),e.forEach(k,function(B){C[B]=C[b[B]]}),C}function c(x,y,b,k){var S=new r,C=x.graph(),N=v(C.nodesep,C.edgesep,k);return e.forEach(y,function(A){var w;e.forEach(A,function(I){var R=b[I];if(S.setNode(R),w){var B=b[w],D=S.edge(B,R);S.setEdge(B,R,Math.max(N(x,I,w),D||0))}w=I})}),S}function f(x,y){return e.minBy(e.values(y),function(b){var k=Number.NEGATIVE_INFINITY,S=Number.POSITIVE_INFINITY;return e.forIn(b,function(C,N){var A=m(x,N)/2;k=Math.max(C+A,k),S=Math.min(C-A,S)}),k-S})}function p(x,y){var b=e.values(y),k=e.min(b),S=e.max(b);e.forEach(["u","d"],function(C){e.forEach(["l","r"],function(N){var A=C+N,w=x[A],I;if(w!==y){var R=e.values(w);I=N==="l"?k-e.min(R):S-e.max(R),I&&(x[A]=e.mapValues(w,function(B){return B+I}))}})})}function h(x,y){return e.mapValues(x.ul,function(b,k){if(y)return x[y.toLowerCase()][k];var S=e.sortBy(e.map(x,k));return(S[1]+S[2])/2})}function g(x){var y=t.buildLayerMatrix(x),b=e.merge(n(x,y),o(x,y)),k={},S;e.forEach(["u","d"],function(N){S=N==="u"?y:e.values(y).reverse(),e.forEach(["l","r"],function(A){A==="r"&&(S=e.map(S,function(B){return e.values(B).reverse()}));var w=(N==="u"?x.predecessors:x.successors).bind(x),I=l(x,S,b,w),R=u(x,S,I.root,I.align,A==="r");A==="r"&&(R=e.mapValues(R,function(B){return-B})),k[N+A]=R})});var C=f(x,k);return p(k,C),h(k,x.graph().align)}function v(x,y,b){return function(k,S,C){var N=k.node(S),A=k.node(C),w=0,I;if(w+=N.width/2,e.has(N,"labelpos"))switch(N.labelpos.toLowerCase()){case"l":I=-N.width/2;break;case"r":I=N.width/2;break}if(I&&(w+=b?I:-I),I=0,w+=(N.dummy?y:x)/2,w+=(A.dummy?y:x)/2,w+=A.width/2,e.has(A,"labelpos"))switch(A.labelpos.toLowerCase()){case"l":I=A.width/2;break;case"r":I=-A.width/2;break}return I&&(w+=b?I:-I),I=0,w}}function m(x,y){return x.node(y).width}return Is}var Rs,dh;function ky(){if(dh)return Rs;dh=1;var e=pe(),r=Se(),t=by().positionX;Rs=n;function n(a){a=r.asNonCompoundGraph(a),o(a),e.forEach(t(a),function(i,s){a.node(s).x=i})}function o(a){var i=r.buildLayerMatrix(a),s=a.graph().ranksep,l=0;e.forEach(i,function(u){var c=e.max(e.map(u,function(f){return a.node(f).height}));e.forEach(u,function(f){a.node(f).y=l+c/2}),l+=c+s})}return Rs}var js,fh;function _y(){if(fh)return js;fh=1;var e=pe(),r=ny(),t=ay(),n=iy(),o=Se().normalizeRanks,a=sy(),i=Se().removeEmptyRanks,s=cy(),l=uy(),u=ly(),c=xy(),f=ky(),p=Se(),h=je().Graph;js=g;function g(E,j){var M=j&&j.debugTiming?p.time:p.notime;M("layout",function(){var P=M(" buildLayoutGraph",function(){return w(E)});M(" runLayout",function(){v(P,M)}),M(" updateInputGraph",function(){m(E,P)})})}function v(E,j){j(" makeSpaceForEdgeLabels",function(){I(E)}),j(" removeSelfEdges",function(){le(E)}),j(" acyclic",function(){r.run(E)}),j(" nestingGraph.run",function(){s.run(E)}),j(" rank",function(){n(p.asNonCompoundGraph(E))}),j(" injectEdgeLabelProxies",function(){R(E)}),j(" removeEmptyRanks",function(){i(E)}),j(" nestingGraph.cleanup",function(){s.cleanup(E)}),j(" normalizeRanks",function(){o(E)}),j(" assignRankMinMax",function(){B(E)}),j(" removeEdgeLabelProxies",function(){D(E)}),j(" normalize.run",function(){t.run(E)}),j(" parentDummyChains",function(){a(E)}),j(" addBorderSegments",function(){l(E)}),j(" order",function(){c(E)}),j(" insertSelfEdges",function(){se(E)}),j(" adjustCoordinateSystem",function(){u.adjust(E)}),j(" position",function(){f(E)}),j(" positionSelfEdges",function(){_(E)}),j(" removeBorderNodes",function(){Z(E)}),j(" normalize.undo",function(){t.undo(E)}),j(" fixupEdgeLabelCoords",function(){W(E)}),j(" undoCoordinateSystem",function(){u.undo(E)}),j(" translateGraph",function(){L(E)}),j(" assignNodeIntersects",function(){F(E)}),j(" reversePoints",function(){V(E)}),j(" acyclic.undo",function(){r.undo(E)})}function m(E,j){e.forEach(E.nodes(),function(M){var P=E.node(M),z=j.node(M);P&&(P.x=z.x,P.y=z.y,j.children(M).length&&(P.width=z.width,P.height=z.height))}),e.forEach(E.edges(),function(M){var P=E.edge(M),z=j.edge(M);P.points=z.points,e.has(z,"x")&&(P.x=z.x,P.y=z.y)}),E.graph().width=j.graph().width,E.graph().height=j.graph().height}var x=["nodesep","edgesep","ranksep","marginx","marginy"],y={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},b=["acyclicer","ranker","rankdir","align"],k=["width","height"],S={width:0,height:0},C=["minlen","weight","width","height","labeloffset"],N={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},A=["labelpos"];function w(E){var j=new h({multigraph:!0,compound:!0}),M=K(E.graph());return j.setGraph(e.merge({},y,Y(M,x),e.pick(M,b))),e.forEach(E.nodes(),function(P){var z=K(E.node(P));j.setNode(P,e.defaults(Y(z,k),S)),j.setParent(P,E.parent(P))}),e.forEach(E.edges(),function(P){var z=K(E.edge(P));j.setEdge(P,e.merge({},N,Y(z,C),e.pick(z,A)))}),j}function I(E){var j=E.graph();j.ranksep/=2,e.forEach(E.edges(),function(M){var P=E.edge(M);P.minlen*=2,P.labelpos.toLowerCase()!=="c"&&(j.rankdir==="TB"||j.rankdir==="BT"?P.width+=P.labeloffset:P.height+=P.labeloffset)})}function R(E){e.forEach(E.edges(),function(j){var M=E.edge(j);if(M.width&&M.height){var P=E.node(j.v),z=E.node(j.w),ee={rank:(z.rank-P.rank)/2+P.rank,e:j};p.addDummyNode(E,"edge-proxy",ee,"_ep")}})}function B(E){var j=0;e.forEach(E.nodes(),function(M){var P=E.node(M);P.borderTop&&(P.minRank=E.node(P.borderTop).rank,P.maxRank=E.node(P.borderBottom).rank,j=e.max(j,P.maxRank))}),E.graph().maxRank=j}function D(E){e.forEach(E.nodes(),function(j){var M=E.node(j);M.dummy==="edge-proxy"&&(E.edge(M.e).labelRank=M.rank,E.removeNode(j))})}function L(E){var j=Number.POSITIVE_INFINITY,M=0,P=Number.POSITIVE_INFINITY,z=0,ee=E.graph(),ae=ee.marginx||0,ie=ee.marginy||0;function ne(G){var J=G.x,H=G.y,$=G.width,X=G.height;j=Math.min(j,J-$/2),M=Math.max(M,J+$/2),P=Math.min(P,H-X/2),z=Math.max(z,H+X/2)}e.forEach(E.nodes(),function(G){ne(E.node(G))}),e.forEach(E.edges(),function(G){var J=E.edge(G);e.has(J,"x")&&ne(J)}),j-=ae,P-=ie,e.forEach(E.nodes(),function(G){var J=E.node(G);J.x-=j,J.y-=P}),e.forEach(E.edges(),function(G){var J=E.edge(G);e.forEach(J.points,function(H){H.x-=j,H.y-=P}),e.has(J,"x")&&(J.x-=j),e.has(J,"y")&&(J.y-=P)}),ee.width=M-j+ae,ee.height=z-P+ie}function F(E){e.forEach(E.edges(),function(j){var M=E.edge(j),P=E.node(j.v),z=E.node(j.w),ee,ae;M.points?(ee=M.points[0],ae=M.points[M.points.length-1]):(M.points=[],ee=z,ae=P),M.points.unshift(p.intersectRect(P,ee)),M.points.push(p.intersectRect(z,ae))})}function W(E){e.forEach(E.edges(),function(j){var M=E.edge(j);if(e.has(M,"x"))switch((M.labelpos==="l"||M.labelpos==="r")&&(M.width-=M.labeloffset),M.labelpos){case"l":M.x-=M.width/2+M.labeloffset;break;case"r":M.x+=M.width/2+M.labeloffset;break}})}function V(E){e.forEach(E.edges(),function(j){var M=E.edge(j);M.reversed&&M.points.reverse()})}function Z(E){e.forEach(E.nodes(),function(j){if(E.children(j).length){var M=E.node(j),P=E.node(M.borderTop),z=E.node(M.borderBottom),ee=E.node(e.last(M.borderLeft)),ae=E.node(e.last(M.borderRight));M.width=Math.abs(ae.x-ee.x),M.height=Math.abs(z.y-P.y),M.x=ee.x+M.width/2,M.y=P.y+M.height/2}}),e.forEach(E.nodes(),function(j){E.node(j).dummy==="border"&&E.removeNode(j)})}function le(E){e.forEach(E.edges(),function(j){if(j.v===j.w){var M=E.node(j.v);M.selfEdges||(M.selfEdges=[]),M.selfEdges.push({e:j,label:E.edge(j)}),E.removeEdge(j)}})}function se(E){var j=p.buildLayerMatrix(E);e.forEach(j,function(M){var P=0;e.forEach(M,function(z,ee){var ae=E.node(z);ae.order=ee+P,e.forEach(ae.selfEdges,function(ie){p.addDummyNode(E,"selfedge",{width:ie.label.width,height:ie.label.height,rank:ae.rank,order:ee+ ++P,e:ie.e,label:ie.label},"_se")}),delete ae.selfEdges})})}function _(E){e.forEach(E.nodes(),function(j){var M=E.node(j);if(M.dummy==="selfedge"){var P=E.node(M.e.v),z=P.x+P.width/2,ee=P.y,ae=M.x-z,ie=P.height/2;E.setEdge(M.e,M.label),E.removeNode(j),M.label.points=[{x:z+2*ae/3,y:ee-ie},{x:z+5*ae/6,y:ee-ie},{x:z+ae,y:ee},{x:z+5*ae/6,y:ee+ie},{x:z+2*ae/3,y:ee+ie}],M.label.x=M.x,M.label.y=M.y}})}function Y(E,j){return e.mapValues(e.pick(E,j),Number)}function K(E){var j={};return e.forEach(E,function(M,P){j[P.toLowerCase()]=M}),j}return js}var Os,ph;function Sy(){if(ph)return Os;ph=1;var e=pe(),r=Se(),t=je().Graph;Os={debugOrdering:n};function n(o){var a=r.buildLayerMatrix(o),i=new t({compound:!0,multigraph:!0}).setGraph({});return e.forEach(o.nodes(),function(s){i.setNode(s,{label:s}),i.setParent(s,"layer"+o.node(s).rank)}),e.forEach(o.edges(),function(s){i.setEdge(s.v,s.w,{},s.name)}),e.forEach(a,function(s,l){var u="layer"+l;i.setNode(u,{rank:"same"}),e.reduce(s,function(c,f){return i.setEdge(c,f,{style:"invis"}),f})}),i}return Os}var Ps,hh;function wy(){return hh||(hh=1,Ps="0.8.5"),Ps}var As,gh;function Ty(){return gh||(gh=1,As={graphlib:je(),layout:_y(),debug:Sy(),util:{time:Se().time,notime:Se().notime},version:wy()}),As}var Ey=Ty();const vh=Vh(Ey);function nr(e,r="TB"){if(e.data?._layoutWidth&&e.data?._layoutHeight)return{width:e.data._layoutWidth,height:e.data._layoutHeight};let t=240,n=80;switch(e.type){case"decisionNode":t=212,n=160;break;case"forkNode":t=240,n=95;break;case"joinNode":t=240,n=95;break;case"dynamicPlaceholderNode":t=220,n=70;break;case"loopNode":t=320,n=200;break;case"subWorkflowNode":t=240,n=95;break;case"eventNode":t=240,n=85;break;case"default":t=240,n=40;break;case"plusNode":t=e.data.label&&e.data.label!=="+"?120:32,n=32;break;default:t=240,n=95;break}return{width:t,height:n}}function Ny(e,r,t=8){const n=[];if(e.length<t)return n;const o=new Map,a={},i={};e.forEach(f=>{o.set(f.id,f),a[f.id]=[],i[f.id]=[]}),r.forEach(f=>{a[f.source]&&a[f.source].push(f.target),i[f.target]&&i[f.target].push(f.source)});const s=new Set,l=new Set(["input","output","decisionNode","forkNode","joinNode","loopNode","default","plusNode"]),u=f=>!l.has(f.type||""),c=[...e].sort((f,p)=>f.position.y-p.position.y);for(const f of c){if(s.has(f.id)||!u(f)||a[f.id].length>1)continue;const p=[f.id];let h=f,g=a[h.id];for(;g&&g.length===1;){const v=g[0],m=o.get(v);if(!m||s.has(v)||!u(m)||i[v].length!==1)break;p.push(v),h=m,g=a[h.id]}p.length>=t&&(n.push(p),p.forEach(v=>s.add(v)))}return n}function Cy(e,r,t,n,o,a=5,i="view"){const s=r.find(y=>y.id===e[0]),{width:l,height:u}=nr(s||r[0],t),c=Math.max(.7,1-(e.length-10)/80),f=i==="edit"||i==="run"?1.15:1,p=Math.min(n,Math.round(60*c*f)),h=Math.min(o,Math.round(80*c*f)),g=l+p,v=u+h;let m=0,x=0;if(t==="TB"){const y=Math.ceil(e.length/a);m=a*g-p,x=y*v-h}else m=Math.ceil(e.length/a)*g-p,x=a*v-h;return m+=40,x+=40,{width:m,height:x,gridKW:g,gridKH:v,cols:a}}const qs=58,mh=20,Iy=16;function Ry(e,r,t,n){if(e.length===0)return{positionedChildren:[],containerWidth:280,containerHeight:qs+50};const o=e.map(f=>({...f,parentId:void 0,extent:void 0})),{nodes:a}=Ls(o,r,{direction:t,mode:n,enableSnakeLayout:!1});let i=0,s=0;a.forEach(f=>{const{width:p,height:h}=nr(f,t);i=Math.max(i,f.position.x+p),s=Math.max(s,f.position.y+h)});const l=Math.max(300,i+mh*2),u=qs+s+Iy;return{positionedChildren:a.map(f=>{const p=e.find(h=>h.id===f.id);return{...f,parentId:p.parentId,extent:p.extent,position:{x:f.position.x+mh,y:f.position.y+qs}}}),containerWidth:l,containerHeight:u}}function Ls(e,r,t={}){const{direction:n="TB",mode:o="view",enableSnakeLayout:a=!0,snakeColumns:i=5,snakeMinChainLength:s=8,snakeMinNodeCount:l=10}=t,u=e.length,c=e.filter(w=>w.type!=="plusNode").length;let f=n==="LR"?150:120,p=n==="LR"?120:100,h=f,g=p;if(u>15){let w=Math.max(.5,1-(u-15)/50),I=Math.max(.4,1-(u-15)/40);(o==="edit"||o==="run")&&(w=1-(1-w)*.5,I=1-(1-I)*.5),h=Math.round(f*w),g=Math.round(p*I)}const v=a&&c>l?Ny(e,r,s):[],m={};v.forEach((w,I)=>{w.forEach(R=>{m[R]=I})});const x=new vh.graphlib.Graph;x.setDefaultEdgeLabel(()=>({})),x.setGraph({rankdir:n,ranker:"network-simplex",ranksep:h,nodesep:g,edgesep:50,marginx:50,marginy:50});const y=new Set,b={};e.forEach(w=>{const I=m[w.id];if(I!==void 0){if(!y.has(I)){y.add(I);const R=Cy(v[I],e,n,g,h,i,o);b[I]=R,x.setNode(`__CHAIN_${I}`,{width:R.width,height:R.height})}}else{const{width:R,height:B}=nr(w,n);x.setNode(w.id,{width:R,height:B})}}),r.forEach(w=>{const I=m[w.source],R=m[w.target];let B=w.source,D=w.target;I!==void 0&&(B=`__CHAIN_${I}`),R!==void 0&&(D=`__CHAIN_${R}`),B!==D&&x.setEdge(B,D)}),vh.layout(x);const k={};for(const w of e)k[w.id]={...w};const S=[],C=new Set;e.forEach(w=>{if(m[w.id]===void 0){const I=x.node(w.id),R=k[w.id],{width:B,height:D}=nr(R,n);R.position={x:I.x-B/2,y:I.y-D/2},R.data={...R.data,sourcePosition:void 0,targetPosition:void 0},R.sourcePosition=n==="LR"?O.Position.Right:O.Position.Bottom,R.targetPosition=n==="LR"?O.Position.Left:O.Position.Top,S.push(R)}else C.add(w.id)}),v.forEach((w,I)=>{const R=`__CHAIN_${I}`,B=x.node(R),D=b[I],L=B.x-D.width/2+20,F=B.y-D.height/2+20,W=D.cols,V=D.gridKW,Z=D.gridKH;w.forEach((le,se)=>{const _=k[le];let Y=0,K=0,E,j;if(n==="TB"){const M=Math.floor(se/W),P=se%W,z=M%2===0,ee=Math.ceil(w.length/W),ae=M===ee-1,ie=w.length%W||W,ne=ae?(W-ie)*V/2:0;let G;z?G=P*V+ne:G=(W-1-P)*V-ne;const J=M*Z;Y=L+G,K=F+J;const H=ae?ie:W;z?(j=O.Position.Left,E=O.Position.Right,P===H-1&&se!==w.length-1&&(E=O.Position.Bottom),P===0&&se!==0&&(j=O.Position.Top)):(j=O.Position.Right,E=O.Position.Left,P===H-1&&se!==w.length-1&&(E=O.Position.Bottom),P===0&&se!==0&&(j=O.Position.Top)),se===0&&(j=O.Position.Top),se===w.length-1&&(E=O.Position.Bottom)}else{const M=Math.floor(se/W),P=se%W,z=M%2===0,ee=Math.ceil(w.length/W),ae=M===ee-1,ie=w.length%W||W,ne=ae?Math.max(0,(W-ie)*Z)/2:0,G=M*V;let J;z?J=P*Z+ne:J=(W-1-P)*Z-ne,Y=L+G,K=F+J;const H=ae?ie:W;z?(j=O.Position.Top,E=O.Position.Bottom,P===H-1&&se!==w.length-1&&(E=O.Position.Right),P===0&&se!==0&&(j=O.Position.Left)):(j=O.Position.Bottom,E=O.Position.Top,P===H-1&&se!==w.length-1&&(E=O.Position.Right),P===0&&se!==0&&(j=O.Position.Left)),se===0&&(j=O.Position.Left),se===w.length-1&&(E=O.Position.Right)}_.position={x:Y,y:K},_.data={..._.data,sourcePosition:E,targetPosition:j},_.sourcePosition=E,_.targetPosition=j,S.push(_)})});const N=S.reduce((w,I)=>({...w,[I.id]:I}),{}),A=r.map(w=>{const I=N[w.source],R=N[w.target];if(!I||!R||C.has(I.id)||I.type!=="decisionNode")return w;const{width:B,height:D}=nr(I,n),{width:L,height:F}=nr(R,n),W={x:I.position.x+B/2,y:I.position.y+D/2},V={x:R.position.x+L/2,y:R.position.y+F/2};let Z=null;if(n==="TB"){const le=B*.25;V.x<W.x-le?Z="left":V.x>W.x+le&&(Z="right")}else{const le=D*.25;V.y<W.y-le?Z="top":V.y>W.y+le&&(Z="bottom")}return{...w,sourceHandle:Z}});return{nodes:S,edges:A}}function be(e,r,t={}){const n=t.direction||"TB",o=t.mode||"view",a=e.filter(x=>x.parentId),i=e.filter(x=>!x.parentId);if(a.length===0)return Ls(e,r,t);const s=new Map(a.map(x=>[x.id,x])),l={},u=[];r.forEach(x=>{const y=s.get(x.source),b=s.get(x.target);if(y?.parentId&&y.parentId===b?.parentId){const k=y.parentId;l[k]||(l[k]=[]),l[k].push(x)}else u.push(x)});const c={};a.forEach(x=>{const y=x.parentId;c[y]||(c[y]=[]),c[y].push(x)});const f={},p=[];for(const[x,y]of Object.entries(c)){const b=l[x]||[],{positionedChildren:k,containerWidth:S,containerHeight:C}=Ry(y,b,n,o);f[x]={width:S,height:C},p.push(...k)}const h=i.map(x=>{if(x.type==="loopNode"&&f[x.id]){const{width:y,height:b}=f[x.id];return{...x,data:{...x.data,_layoutWidth:y,_layoutHeight:b},style:{...x.style,width:y,height:b}}}return x}),{nodes:g,edges:v}=Ls(h,u,t);return{nodes:[...g.map(x=>{if(x.type==="loopNode"&&f[x.id]){const{width:y,height:b}=f[x.id];return{...x,width:y,height:b,style:{...x.style,width:y,height:b}}}return x}),...p],edges:[...v,...Object.values(l).flat()]}}function we(e,r){if(!e)return null;for(const t of e){if(t.taskReferenceName===r)return t;if(t.decisionCases){for(const o of Object.keys(t.decisionCases)){const a=we(t.decisionCases[o],r);if(a)return a}const n=we(t.defaultCase,r);if(n)return n}if(t.forkTasks)for(const n of t.forkTasks){const o=we(n,r);if(o)return o}if(t.loopOver){const n=we(t.loopOver,r);if(n)return n}}return null}function qe(e,r){if(!e)return!1;const t=e.findIndex(n=>n.taskReferenceName===r);if(t!==-1)return e.splice(t,1),!0;for(const n of e){if(n.decisionCases){for(const o of Object.keys(n.decisionCases))if(qe(n.decisionCases[o],r))return!0;if(qe(n.defaultCase,r))return!0}if(n.forkTasks){for(const o of n.forkTasks)if(qe(o,r))return!0}if(n.loopOver&&qe(n.loopOver,r))return!0}return!1}function ar(e,r){if(!e)return null;if(e.some(t=>t.taskReferenceName===r))return e;for(const t of e){if(t.decisionCases){for(const o of Object.values(t.decisionCases)){const a=ar(o,r);if(a)return a}const n=ar(t.defaultCase,r);if(n)return n}if(t.forkTasks)for(const n of t.forkTasks){const o=ar(n,r);if(o)return o}if(t.loopOver){const n=ar(t.loopOver,r);if(n)return n}}return null}function yh(e,r){const t=e.findIndex(n=>n.taskReferenceName===r);if(t<0)return null;for(let n=t+1;n<e.length;n++)if(e[n].type==="JOIN"||e[n].type==="EXCLUSIVE_JOIN")return e[n].taskReferenceName;return null}function xh(e,r){const t=e.findIndex(n=>n.taskReferenceName===r);if(t<0)return null;for(let n=t-1;n>=0;n--)if(e[n].type==="FORK_JOIN"||e[n].type==="FORK_JOIN_DYNAMIC")return e[n].taskReferenceName;return null}function Oe(e,r,t){if(!e)return!1;const n=e.findIndex(o=>o.taskReferenceName===r);if(n!==-1)return e.splice(n+1,0,t),!0;for(const o of e){if(o.decisionCases){for(const a of Object.keys(o.decisionCases))if(Oe(o.decisionCases[a],r,t))return!0;if(Oe(o.defaultCase,r,t))return!0}if(o.forkTasks){for(const a of o.forkTasks)if(Oe(a,r,t))return!0}if(o.loopOver&&Oe(o.loopOver,r,t))return!0}return!1}function or(e,r,t,n){for(const o of e||[]){if(o.taskReferenceName===r){if(t.branchCase==="default")return o.defaultCase||(o.defaultCase=[]),o.defaultCase.unshift(n),!0;if(t.branchCase!==void 0)return o.decisionCases||(o.decisionCases={}),o.decisionCases[t.branchCase]||(o.decisionCases[t.branchCase]=[]),o.decisionCases[t.branchCase].unshift(n),!0;if(t.forkIndex!==void 0)return o.forkTasks||(o.forkTasks=[]),o.forkTasks[t.forkIndex].unshift(n),!0;if(t.isLoopAdd)return o.loopOver||(o.loopOver=[]),o.loopOver.unshift(n),!0}if(o.decisionCases){for(const a of Object.keys(o.decisionCases))if(or(o.decisionCases[a],r,t,n))return!0;if(or(o.defaultCase,r,t,n))return!0}if(o.forkTasks){for(const a of o.forkTasks)if(or(a,r,t,n))return!0}if(o.loopOver&&or(o.loopOver,r,t,n))return!0}return!1}function ke(e){if(e)for(let r=0;r<e.length;r++){const t=e[r];if(t.type==="FORK_JOIN"&&r+1<e.length){const n=e[r+1];if(n.type==="JOIN"){const o=[];(t.forkTasks||[]).forEach(a=>{a&&a.length>0&&o.push(a[a.length-1].taskReferenceName)}),n.joinOn=o}}t.decisionCases&&(Object.values(t.decisionCases).forEach(n=>ke(n)),t.defaultCase&&ke(t.defaultCase)),t.forkTasks&&t.forkTasks.forEach(n=>ke(n)),t.loopOver&&ke(t.loopOver)}}const jy=[{field:"name",type:"required",message:"工作流名称 (name) 必填"},{field:"version",type:"required",message:"工作流版本 (version) 必填"},{field:"tasks",type:"min_length",value:1,message:"工作流必须包含至少一个任务"}],bh={common:[{field:"name",type:"required",message:"任务类型名称 (name) 必填"},{field:"taskReferenceName",type:"required",message:"引用名 (taskReferenceName) 必填"},{field:"taskReferenceName",type:"pattern",value:/^[a-zA-Z0-9_]+$/,message:"引用名仅允许字母、数字和下划线"},{field:"taskReferenceName",type:"unique",message:"引用名在工作流中必须唯一"}],types:{HTTP:[{field:"inputParameters.http_request.uri",type:"required",message:"HTTP 任务缺少请求地址 (uri) 配置"},{field:"inputParameters.http_request.method",type:"required",level:"warning",message:"HTTP 任务未指定 Method,建议配置"}],INLINE:[{field:"inputParameters.expression",type:"custom",validate:(e,r)=>!!(r?.inputParameters?.expression||r?.inputParameters?.scriptExpression),message:"INLINE 任务缺少脚本表达式 (expression)"}],LAMBDA:[{field:"inputParameters.scriptExpression",type:"required",message:"LAMBDA 任务缺少脚本表达式 (scriptExpression)"}],JSON_JQ_TRANSFORM:[{field:"inputParameters.queryExpression",type:"required",message:"JQ 任务缺少查询表达式 (queryExpression)"}],SUB_WORKFLOW:[{field:"subWorkflowParam.name",type:"required",message:"子工作流任务缺少子流程名称 (name)"}],START_WORKFLOW:[{field:"inputParameters.startWorkflow.name",type:"custom",validate:(e,r)=>!!r?.inputParameters?.startWorkflow?.name,message:"START_WORKFLOW 任务缺少目标工作流名称"}],DYNAMIC:[{field:"dynamicTaskNameParam",type:"required",message:"DYNAMIC 任务缺少 dynamicTaskNameParam 配置"}],TERMINATE:[{field:"inputParameters.terminationStatus",type:"required",level:"warning",message:"终止任务未指定状态 (terminationStatus)"},{field:"inputParameters.terminationStatus",type:"enum",value:["COMPLETED","FAILED"],message:"终止状态必须为 COMPLETED 或 FAILED"}],DO_WHILE:[{field:"loopCondition",type:"custom",validate:(e,r)=>!!(r?.loopCondition||r?.inputParameters?.items),message:"循环任务需要配置退出条件 (loopCondition) 或列表 (items)"}],DECISION:[{field:"decisionCases",type:"custom",validate:e=>Object.keys(e||{}).length>0,message:"决策任务必须至少包含一个分支 (decisionCases)"},{field:"decisionCases",type:"custom",validate:e=>{const r=Object.keys(e||{});return new Set(r).size===r.length},message:"决策分支条件不能重复"}],SWITCH:[{field:"decisionCases",type:"custom",validate:e=>Object.keys(e||{}).length>0,message:"Switch 任务必须至少包含一个分支"}],FORK_JOIN_DYNAMIC:[{field:"dynamicForkTasksParam",type:"custom",validate:(e,r)=>!!(r?.dynamicForkTasksParam||r?.forkTaskType||r?.forkTaskWorkflow),message:"FORK_JOIN_DYNAMIC 任务需要配置 dynamicForkTasksParam 或 forkTaskType 或 forkTaskWorkflow",level:"warning"}]}},Oy=(e,r)=>r.split(".").reduce((t,n)=>t&&t[n]!==void 0?t[n]:void 0,e),Ds=(e,r,t,n)=>{const{errors:o,warnings:a}=n,i=e.taskReferenceName||"GLOBAL";r.forEach(s=>{const l=Oy(e,s.field);let u=!0;switch(s.type){case"required":u=l!=null&&l!=="";break;case"min_length":u=Array.isArray(l)&&l.length>=s.value;break;case"pattern":u=s.value.test(l);break;case"enum":u=s.value.includes(l);break;case"unique":s.field==="taskReferenceName"&&l&&(t.taskRefs.has(l)?u=!1:t.taskRefs.add(l));break;case"custom":typeof s.validate=="function"&&(u=s.validate(l,e,t));break}if(!u){const c={type:e.taskReferenceName?"TASK":"GLOBAL",ref:i,message:s.message};s.level==="warning"?a.push(c):o.push(c)}})},Ne=e=>{const r=[],t=[],n={taskRefs:new Set,taskMap:{}};if(!e)return{isValid:!1,errors:[{type:"GLOBAL",ref:"",message:"工作流定义为空"}],warnings:[]};if(Ds(e,jy,n,{errors:r,warnings:t}),!e.tasks||e.tasks.length===0)return{isValid:!1,errors:r,warnings:t};const o=i=>{i.forEach(s=>{Ds(s,bh.common,n,{errors:r,warnings:t});const l=bh.types[s.type];l&&Ds(s,l,n,{errors:r,warnings:t}),s.decisionCases&&Object.keys(s.decisionCases).forEach(u=>{o(s.decisionCases[u])}),s.defaultCase&&o(s.defaultCase),s.forkTasks&&s.forkTasks.forEach(u=>o(u)),s.loopOver&&o(s.loopOver)})};o(e.tasks);const a=Py(e.tasks);return r.push(...a),{isValid:r.length===0,errors:r,warnings:t}},Py=e=>{const r=[],t=new Map,n=new Set,o=c=>{for(let f=0;f<c.length;f++){const p=c[f],h=p.taskReferenceName;if(n.add(h),t.has(h)||t.set(h,[]),f<c.length-1){const g=c[f+1].taskReferenceName;p.type!=="FORK_JOIN"&&p.type!=="FORK_JOIN_DYNAMIC"&&t.get(h).push(g)}if(p.decisionCases)for(const g of Object.values(p.decisionCases))g.length>0&&(t.get(h).push(g[0].taskReferenceName),o(g));if(p.defaultCase&&p.defaultCase.length>0&&(t.get(h).push(p.defaultCase[0].taskReferenceName),o(p.defaultCase)),p.forkTasks)for(const g of p.forkTasks)g.length>0&&(t.get(h).push(g[0].taskReferenceName),o(g));if(p.loopOver)for(const g of p.loopOver)n.add(g.taskReferenceName);if(p.joinOn)for(const g of p.joinOn)t.has(g)||t.set(g,[]),t.get(g).push(h)}};o(e);const a=0,i=1,s=2,l=new Map;for(const c of n)l.set(c,a);const u=c=>{l.set(c,i);const f=t.get(c)||[];for(const p of f)if(l.has(p)){if(l.get(p)===i)return r.push({type:"GLOBAL",ref:p,message:`检测到环路:任务 "${c}" → "${p}" 形成了循环依赖`}),!0;if(l.get(p)===a&&u(p))return!0}return l.set(c,s),!1};for(const c of n)l.get(c)===a&&u(c);return r};function Ay(e,r){const t=new Set(e),n={};e.forEach(s=>n[s]=0),r.forEach(s=>{t.has(s.source)&&t.has(s.target)&&(n[s.target]=(n[s.target]??0)+1)});const o=[];let a=e.filter(s=>n[s]===0);const i={...n};for(;a.length>0;){o.push([...a]);const s=[];a.forEach(l=>{r.forEach(u=>{u.source===l&&t.has(u.target)&&(i[u.target]--,i[u.target]===0&&s.push(u.target))})}),a=s}return o}const oe=rg()(tg(ng((e,r)=>({mode:"view",workflowDef:null,workflowInstance:null,nodes:[],edges:[],taskMap:{},layoutDirection:"TB",selectedTask:null,selectedTaskInstance:null,isDetailPanelOpen:!1,executionData:null,dynamicRuntimeTasksByFork:{},validationResults:{isValid:!0,errors:[],warnings:[]},theme:"dark",themeColor:"blue",edgeType:"smoothstep",nodesLocked:!0,copiedTask:null,viewMode:"standard",simState:{},isSimRunning:!1,workflowLoadKey:0,setWorkflow:(t,n)=>{const o=n||r().layoutDirection,a=JSON.parse(JSON.stringify(t));ke(a.tasks);const{nodes:i,edges:s,taskMap:l}=_e(a,o,{hideEmptyBranches:r().mode!=="edit"}),{nodes:u,edges:c}=be(i,s,{direction:o,mode:r().mode}),f=Ne(a);e({workflowDef:a,nodes:u,edges:c,taskMap:l,validationResults:f,layoutDirection:o,workflowLoadKey:r().workflowLoadKey+1})},setMode:t=>{r().mode==="run"&&t!=="run"&&e({executionData:null,workflowInstance:null,dynamicRuntimeTasksByFork:{}}),e({mode:t});const{workflowDef:o,layoutDirection:a}=r();if(o){const{nodes:i,edges:s,taskMap:l}=_e(o,a,{hideEmptyBranches:t!=="edit"}),{nodes:u,edges:c}=be(i,s,{direction:a,mode:t});e({nodes:u,edges:c,taskMap:l})}},setExecutionData:t=>e({executionData:t,dynamicRuntimeTasksByFork:t===null?{}:r().dynamicRuntimeTasksByFork}),updateTaskStatus:(t,n)=>{const{executionData:o}=r();if(!o)return;const a={...o};a[t]&&(a[t]={...a[t],status:n},e({executionData:a}))},loadSampleExecution:async()=>{try{const n=await(await fetch("/sample-workflows/sample-execution.json")).json();r().importExecutionJSON(n)}catch(t){console.error("Failed to load sample execution:",t),alert("加载示例运行数据失败")}},importExecutionJSON:t=>{if(!t)return;let n=[],o=null,a=r().workflowDef;if(Array.isArray(t.tasks)?(n=t.tasks,t.workflowId&&t.status&&(o=t,t.workflowDefinition&&(a=t.workflowDefinition))):Array.isArray(t)&&(n=t),n.length===0)return;const i={};n.forEach(p=>{const h=p.referenceTaskName;h&&(i[h]||(i[h]={taskReferenceName:h,status:p.status,attempts:[],startTime:p.startTime,endTime:p.endTime,output:p.outputData,input:p.inputData,reasonForIncompletion:p.reasonForIncompletion,iteration:p.iteration}),i[h].attempts.push(p))}),Object.values(i).forEach(p=>{p.attempts.some(v=>v.iteration!==void 0&&v.iteration>0)?(p.attempts.sort((v,m)=>(v.iteration??0)-(m.iteration??0)),p.totalIterations=p.attempts.reduce((v,m)=>Math.max(v,m.iteration??0),0),p.startTime=p.attempts[0]?.startTime):p.attempts.sort((v,m)=>(v.retryCount??0)-(m.retryCount??0));const g=p.attempts[p.attempts.length-1];g&&(p.status=g.status,p.endTime=g.endTime,p.output=g.outputData,p.input=g.inputData,p.reasonForIncompletion=g.reasonForIncompletion,p.iteration=g.iteration)}),a&&JSON.stringify(a)!==JSON.stringify(r().workflowDef)&&r().setWorkflow(a);const s=r().taskMap,u=r().workflowDef?.tasks||[],c=[];u.forEach((p,h)=>{if(p.type==="FORK_JOIN_DYNAMIC"){for(let g=h+1;g<u.length;g++)if(u[g].type==="JOIN"||u[g].type==="EXCLUSIVE_JOIN"){c.push({forkRef:p.taskReferenceName,joinRef:u[g].taskReferenceName});break}}});const f={};c.forEach(({forkRef:p,joinRef:h})=>{const g=n.findIndex(x=>x.referenceTaskName===p),v=n.findIndex(x=>x.referenceTaskName===h);if(g<0||v<0)return;const m=new Set;f[p]=n.slice(g+1,v).filter(x=>!x.referenceTaskName||!x.taskId||s[x.referenceTaskName]||m.has(x.referenceTaskName)?!1:(m.add(x.referenceTaskName),!0)).map(x=>x)}),e({executionData:i,dynamicRuntimeTasksByFork:f,workflowInstance:o,mode:"run"})},setSelectedTask:t=>e({selectedTask:t?{...t}:null}),setIsDetailPanelOpen:t=>e({isDetailPanelOpen:t}),selectTaskAction:(t,n=!0)=>{e({selectedTask:t?{...t}:null,isDetailPanelOpen:t?n:!1,selectedTaskInstance:null})},setSelectedTaskInstance:t=>e({selectedTaskInstance:t}),setLayoutDirection:t=>{const{workflowDef:n}=r();if(n){const{nodes:o,edges:a,taskMap:i}=_e(n,t,{hideEmptyBranches:r().mode!=="edit"}),{nodes:s,edges:l}=be(o,a,{direction:t,mode:r().mode});e({nodes:s,edges:l,taskMap:i,layoutDirection:t})}else e({layoutDirection:t})},onNodesChange:t=>{const n=r().nodes,o=new Set(n.map(i=>i.id)),a=t.filter(i=>"id"in i&&o.has(i.id));a.length!==0&&e({nodes:O.applyNodeChanges(a,n)})},onEdgesChange:t=>{const n=r().edges,o=O.applyEdgeChanges(t,n);o!==n&&e({edges:o})},onConnect:t=>{const{edges:n,layoutDirection:o}=r(),a=O.addEdge(t,n),{nodes:i,edges:s}=be(r().nodes,a,{direction:o,mode:r().mode});e({edges:s,nodes:i})},checkTaskRefUniqueness:(t,n)=>{if(t===n)return!0;const{taskMap:o}=r();return!o[t]},updateTask:(t,n,o)=>{const{workflowDef:a,layoutDirection:i}=r();if(!a)return;const s=JSON.parse(JSON.stringify(a)),l=we(s.tasks,t);if(l){typeof n=="object"?Object.assign(l,n):l[n]=o,ke(s.tasks);const{nodes:u,edges:c,taskMap:f}=_e(s,i,{hideEmptyBranches:r().mode!=="edit"}),{nodes:p,edges:h}=be(u,c,{direction:i,mode:r().mode}),g=Ne(s);e({workflowDef:s,nodes:p,edges:h,taskMap:f,validationResults:g})}},updateWorkflowProperties:t=>{const{workflowDef:n,layoutDirection:o}=r();if(!n)return;const a=JSON.parse(JSON.stringify(n));Object.assign(a,t),ke(a.tasks);const{nodes:i,edges:s,taskMap:l}=_e(a,o,{hideEmptyBranches:r().mode!=="edit"}),{nodes:u,edges:c}=be(i,s,{direction:o,mode:r().mode}),f=Ne(a);e({workflowDef:a,nodes:u,edges:c,taskMap:l,validationResults:f})},addNode:(t,n,o,a,i={})=>{const{workflowDef:s,layoutDirection:l}=r();if(!s)return;const u=JSON.parse(JSON.stringify(s)),c={name:t.data.label,taskReferenceName:t.data.taskReferenceName,type:t.data.taskType||"SIMPLE",inputParameters:{}};switch(c.type){case"HTTP":c.httpRequest={method:"GET",uri:"https://example.com/api",headers:{"Content-Type":"application/json"},body:{}};break;case"KAFKA_PUBLISH":c.inputParameters={topic:"my_topic",value:"${workflow.input.value}",bootStrapServers:"localhost:9092",headers:{},key:"msg_key"};break;case"JSON_JQ_TRANSFORM":c.inputParameters={queryExpression:".name",input:{}};break;case"SET_VARIABLE":c.inputParameters={variableName:"variableValue"};break;case"SUB_WORKFLOW":c.subWorkflowParam={name:"execution_workflow",version:1};break;case"EVENT":c.sink="conductor";break;case"WAIT":c.inputParameters={duration:"30s"};break;case"TERMINATE":c.inputParameters={terminationStatus:"COMPLETED",workflowOutput:{}};break}if(c.type==="FORK_JOIN"||c.type==="FORK_JOIN_DYNAMIC"){c.type==="FORK_JOIN"?c.forkTasks=[[],[]]:(c.dynamicForkTasksParam="dynamic_tasks",c.dynamicForkTasksInputParamName="input");const x={name:`${c.name}_join`,taskReferenceName:`${c.taskReferenceName}_join`,type:"JOIN",joinOn:[]};if(i.isWorkflowStart)u.tasks.unshift(x),u.tasks.unshift(c);else if(i.isLoopBodyStart){const y=we(u.tasks,n);y&&(y.loopOver||(y.loopOver=[]),y.loopOver.unshift(x),y.loopOver.unshift(c))}else i.branchCase!==void 0||i.forkIndex!==void 0||i.isLoopAdd?(or(u.tasks,n,i,c),Oe(u.tasks,c.taskReferenceName,x)):u.tasks.length===0?u.tasks.push(c,x):(Oe(u.tasks,n,c),Oe(u.tasks,c.taskReferenceName,x))}else if(c.type==="DECISION"||c.type==="SWITCH"?(c.evaluatorType="value-param",c.caseValueParam="case_param",c.decisionCases={case1:[]},c.defaultCase=[]):c.type==="DO_WHILE"?(c.loopCondition="$.taskReferenceName.output.value < 10",c.loopOver=[]):c.type==="INLINE"?(c.evaluatorType="graaljs",c.inputParameters={expression:`function execute(input) {
7
+ return { result: input };
8
+ }
9
+ execute($.input);`}):c.type==="DYNAMIC"?(c.dynamicTaskNameParam="taskToExecute",c.inputParameters={taskToExecute:"${workflow.input.taskName}"}):c.type==="HUMAN"?c.humanTaskDef={userFormTemplate:"",assignmentCompletionStrategy:"LEAVE_OPEN"}:c.type==="START_WORKFLOW"?c.inputParameters={startWorkflow:{name:"",version:1,input:{},correlationId:""}}:c.type==="NOOP"&&(c.inputParameters={}),i.isWorkflowStart)u.tasks.unshift(c);else if(i.isLoopBodyStart){const x=we(u.tasks,n);x&&(x.loopOver||(x.loopOver=[]),x.loopOver.unshift(c))}else i.branchCase!==void 0||i.forkIndex!==void 0||i.isLoopAdd?or(u.tasks,n,i,c):u.tasks.length===0?u.tasks.push(c):Oe(u.tasks,n,c);ke(u.tasks);const{nodes:f,edges:p,taskMap:h}=_e(u,l,{hideEmptyBranches:r().mode!=="edit"}),{nodes:g,edges:v}=be(f,p,{direction:l,mode:r().mode}),m=Ne(u);e({workflowDef:u,nodes:g,edges:v,taskMap:h,validationResults:m})},removeNode:t=>{const{workflowDef:n,layoutDirection:o,nodes:a}=r();if(!n)return;const i=JSON.parse(JSON.stringify(n)),s=ar(i.tasks,t);if(s){const g=a.find(v=>v.id===t)?.data?.taskType;if(g==="FORK_JOIN"||g==="FORK_JOIN_DYNAMIC"){const v=yh(s,t);v&&qe(i.tasks,v)}else if(g==="JOIN"||g==="EXCLUSIVE_JOIN"){const v=xh(s,t);v&&qe(i.tasks,v)}}qe(i.tasks,t),ke(i.tasks);const{nodes:l,edges:u,taskMap:c}=_e(i,o,{hideEmptyBranches:r().mode!=="edit"}),{nodes:f,edges:p}=be(l,u,{direction:o,mode:r().mode}),h=Ne(i);e({workflowDef:i,nodes:f,edges:p,taskMap:c,validationResults:h})},addLoopTask:(t,n)=>{const{workflowDef:o,layoutDirection:a}=r();if(!o)return;const i=JSON.parse(JSON.stringify(o)),s=we(i.tasks,t);if(s&&s.type==="DO_WHILE"){s.loopOver||(s.loopOver=[]);const l={name:`new_${n.toLowerCase()}`,taskReferenceName:`${t}_sub_${Date.now()}`,type:n,inputParameters:{}};s.loopOver.push(l),ke(i.tasks);const{nodes:u,edges:c,taskMap:f}=_e(i,a,{hideEmptyBranches:r().mode!=="edit"}),{nodes:p,edges:h}=be(u,c,{direction:a,mode:r().mode}),g=Ne(i);e({workflowDef:i,nodes:p,edges:h,taskMap:f,validationResults:g})}},removeLoopTask:(t,n)=>{const{workflowDef:o,layoutDirection:a}=r();if(!o)return;const i=JSON.parse(JSON.stringify(o)),s=we(i.tasks,t);if(s&&s.type==="DO_WHILE"&&s.loopOver){const l=ar(s.loopOver,n);if(l){const v=l.find(m=>m.taskReferenceName===n);if(v?.type==="FORK_JOIN"||v?.type==="FORK_JOIN_DYNAMIC"){const m=yh(l,n);m&&qe(s.loopOver,m)}else if(v?.type==="JOIN"||v?.type==="EXCLUSIVE_JOIN"){const m=xh(l,n);m&&qe(s.loopOver,m)}}qe(s.loopOver,n),ke(i.tasks);const{nodes:u,edges:c,taskMap:f}=_e(i,a,{hideEmptyBranches:r().mode!=="edit"}),{nodes:p,edges:h}=be(u,c,{direction:a,mode:r().mode}),g=Ne(i);e({workflowDef:i,nodes:p,edges:h,taskMap:f,validationResults:g})}},addDecisionBranch:(t,n)=>{const{workflowDef:o,layoutDirection:a}=r();if(!o)return;const i=JSON.parse(JSON.stringify(o)),s=we(i.tasks,t);if(s&&(s.type==="DECISION"||s.type==="SWITCH")){n==="default"?s.defaultCase||(s.defaultCase=[]):(s.decisionCases||(s.decisionCases={}),s.decisionCases[n]||(s.decisionCases[n]=[])),ke(i.tasks);const{nodes:l,edges:u,taskMap:c}=_e(i,a,{hideEmptyBranches:r().mode!=="edit"}),{nodes:f,edges:p}=be(l,u,{direction:a,mode:r().mode}),h=Ne(i);e({workflowDef:i,nodes:f,edges:p,taskMap:c,validationResults:h})}},removeDecisionBranch:(t,n)=>{const{workflowDef:o,layoutDirection:a}=r();if(!o)return;const i=JSON.parse(JSON.stringify(o)),s=we(i.tasks,t);if(s&&(s.type==="DECISION"||s.type==="SWITCH")){n==="default"?s.defaultCase=[]:s.decisionCases&&delete s.decisionCases[n],ke(i.tasks);const{nodes:l,edges:u,taskMap:c}=_e(i,a,{hideEmptyBranches:r().mode!=="edit"}),{nodes:f,edges:p}=be(l,u,{direction:a,mode:r().mode}),h=Ne(i);e({workflowDef:i,nodes:f,edges:p,taskMap:c,validationResults:h})}},renameDecisionBranch:(t,n,o)=>{const{workflowDef:a,layoutDirection:i}=r();if(!a||!o.trim()||n===o)return;const s=JSON.parse(JSON.stringify(a)),l=we(s.tasks,t);if(l&&(l.type==="DECISION"||l.type==="SWITCH")){if(!l.decisionCases||!l.decisionCases[n])return;l.decisionCases[o.trim()]=l.decisionCases[n],delete l.decisionCases[n],ke(s.tasks);const{nodes:u,edges:c,taskMap:f}=_e(s,i,{hideEmptyBranches:r().mode!=="edit"}),{nodes:p,edges:h}=be(u,c,{direction:i,mode:r().mode}),g=Ne(s);e({workflowDef:s,nodes:p,edges:h,taskMap:f,validationResults:g})}},addForkBranch:t=>{const{workflowDef:n,layoutDirection:o}=r();if(!n)return;const a=JSON.parse(JSON.stringify(n)),i=we(a.tasks,t);if(i&&i.type==="FORK_JOIN"){i.forkTasks||(i.forkTasks=[]),i.forkTasks.push([]),ke(a.tasks);const{nodes:s,edges:l,taskMap:u}=_e(a,o,{hideEmptyBranches:r().mode!=="edit"}),{nodes:c,edges:f}=be(s,l,{direction:o,mode:r().mode}),p=Ne(a);e({workflowDef:a,nodes:c,edges:f,taskMap:u,validationResults:p})}},copyTask:t=>e({copiedTask:t}),pasteTask:t=>{const{workflowDef:n,layoutDirection:o,selectedTask:a}=r();if(!n)return;const i=JSON.parse(JSON.stringify(n)),l=`_copy_${Date.now()}`,u=JSON.parse(JSON.stringify(t)),c=y=>{y.taskReferenceName=`${y.taskReferenceName}${l}`,y.decisionCases&&Object.values(y.decisionCases).forEach(b=>b.forEach(c)),y.defaultCase&&y.defaultCase.forEach(c),y.forkTasks&&y.forkTasks.forEach(b=>b.forEach(c)),y.loopOver&&y.loopOver.forEach(c)};c(u);const f=a?a.taskReferenceName:i.tasks.length>0?i.tasks[i.tasks.length-1].taskReferenceName:"start";if(u.type==="FORK_JOIN"){u.forkTasks||(u.forkTasks=[[],[]]);const y={name:`${u.name}_join`,taskReferenceName:`${u.taskReferenceName}_join`,type:"JOIN",joinOn:[]};i.tasks.length===0?i.tasks.push(u,y):(Oe(i.tasks,f,u),Oe(i.tasks,u.taskReferenceName,y))}else i.tasks.length===0?i.tasks.push(u):Oe(i.tasks,f,u);ke(i.tasks);const{nodes:p,edges:h,taskMap:g}=_e(i,o,{hideEmptyBranches:r().mode!=="edit"}),{nodes:v,edges:m}=be(p,h,{direction:o,mode:r().mode}),x=Ne(i);e({workflowDef:i,nodes:v,edges:m,taskMap:g,validationResults:x})},setTheme:t=>e({theme:t}),setThemeColor:t=>e({themeColor:t}),setEdgeType:t=>e({edgeType:t}),setNodesLocked:t=>e({nodesLocked:t}),setViewMode:t=>e({viewMode:t}),startSimulation:()=>{const{edges:t,nodes:n,isSimRunning:o}=r();if(o)return;const a=n.filter(f=>!["plusNode","dynamicPlaceholderNode"].includes(f.type??"")).map(f=>f.id),i=t.map(f=>({source:f.source,target:f.target})),s=Ay(a,i);e({isSimRunning:!0,simState:{}});const l={timer:null};r().__simHandle=l;let u=0;const c=()=>{if(u>=s.length||!r().isSimRunning){e({isSimRunning:!1});return}const f=s[u];e(p=>{const h={...p.simState};return f.forEach(g=>h[g]="running"),{simState:h}}),l.timer=setTimeout(()=>{r().isSimRunning&&(e(p=>{const h={...p.simState};return f.forEach(g=>h[g]="done"),{simState:h}}),u++,l.timer=setTimeout(c,280))},700)};c()},stopSimulation:()=>{const t=r().__simHandle;t?.timer&&clearTimeout(t.timer),e({isSimRunning:!1,simState:{}})},createBlankWorkflow:t=>{const n={name:t||"new_workflow",description:"",tasks:[],version:1,schemaVersion:2};r().setWorkflow(n),e({mode:"edit"})},applyAIGeneratedWorkflow:t=>{const{tasks:n,...o}=t,a={...o,name:t.name||"AI_Generated_Workflow",tasks:n||[],version:t.version||1,schemaVersion:2};r().setWorkflow(a)}}),{partialize:e=>({workflowDef:e.workflowDef,layoutDirection:e.layoutDirection,nodes:e.nodes,edges:e.edges,taskMap:e.taskMap,theme:e.theme,themeColor:e.themeColor,mode:e.mode,edgeType:e.edgeType,nodesLocked:e.nodesLocked,copiedTask:e.copiedTask}),equality:(e,r)=>JSON.stringify(e.workflowDef)===JSON.stringify(r.workflowDef)}),{name:"conductor-ui-prefs",version:1,storage:Js(()=>localStorage),migrate:(e,r)=>(r===0&&e.edgeType==="default"&&(e.edgeType="smoothstep"),e),partialize:e=>({theme:e.theme,themeColor:e.themeColor,layoutDirection:e.layoutDirection,edgeType:e.edgeType,nodesLocked:e.nodesLocked,copiedTask:e.copiedTask,viewMode:e.viewMode})}));const qy=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Ly=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(r,t,n)=>n?n.toUpperCase():t.toLowerCase()),kh=e=>{const r=Ly(e);return r.charAt(0).toUpperCase()+r.slice(1)},_h=(...e)=>e.filter((r,t,n)=>!!r&&r.trim()!==""&&n.indexOf(r)===t).join(" ").trim(),Dy=e=>{for(const r in e)if(r.startsWith("aria-")||r==="role"||r==="title")return!0};var My={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Wy=q.forwardRef(({color:e="currentColor",size:r=24,strokeWidth:t=2,absoluteStrokeWidth:n,className:o="",children:a,iconNode:i,...s},l)=>q.createElement("svg",{ref:l,...My,width:r,height:r,stroke:e,strokeWidth:n?Number(t)*24/Number(r):t,className:_h("lucide",o),...!a&&!Dy(s)&&{"aria-hidden":"true"},...s},[...i.map(([u,c])=>q.createElement(u,c)),...Array.isArray(a)?a:[a]]));const xe=(e,r)=>{const t=q.forwardRef(({className:n,...o},a)=>q.createElement(Wy,{ref:a,iconNode:r,className:_h(`lucide-${qy(kh(e))}`,`lucide-${e}`,n),...o}));return t.displayName=kh(e),t};const Sh=xe("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const By=xe("circle-stop",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]]);const Fy=xe("clock",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const wh=xe("code-xml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);const zy=xe("database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);const Hr=xe("git-branch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);const Kr=xe("git-merge",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]]);const $y=xe("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);const Hy=xe("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]);const Ky=xe("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);const Uy=xe("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]);const Jy=xe("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const Th=xe("repeat",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]);const Ms=xe("shuffle",[["path",{d:"m18 14 4 4-4 4",key:"10pe0f"}],["path",{d:"m18 2 4 4-4 4",key:"pucp1d"}],["path",{d:"M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22",key:"1ailkh"}],["path",{d:"M2 6h1.972a4 4 0 0 1 3.6 2.2",key:"km57vx"}],["path",{d:"M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45",key:"os18l9"}]]);const Gy=xe("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);const Vy=xe("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);const Yy=xe("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),Xy={business:["business"],standard:["business","control"],developer:["business","control","data"]},Ge=[{type:"SIMPLE",label:"任务节点 (Worker)",description:"在远程 Worker 上执行的任务",category:"CORE",icon:Sh,viewCategory:"business"},{type:"SUB_WORKFLOW",label:"子工作流 (Sub Workflow)",description:"调用并执行另一个工作流",category:"CORE",icon:Kr,viewCategory:"business"},{type:"START_WORKFLOW",label:"启动工作流 (Start Workflow)",description:"启动另一个工作流(不等待结果)",category:"SYSTEM",icon:Uy,viewCategory:"business"},{type:"HTTP",label:"HTTP 请求",description:"发起 REST/HTTP 调用",category:"SYSTEM",icon:$y,viewCategory:"business"},{type:"INLINE",label:"内联脚本 (Inline)",description:"执行内联脚本(JS/Python/GraalJS)",category:"SYSTEM",icon:wh,viewCategory:"data"},{type:"JSON_JQ_TRANSFORM",label:"JSON 转换 (JQ)",description:"使用 JQ 表达式转换 JSON 数据",category:"SYSTEM",icon:Gy,viewCategory:"data"},{type:"KAFKA_PUBLISH",label:"Kafka 推送",description:"向 Kafka 主题推送消息",category:"SYSTEM",icon:Hy,viewCategory:"data"},{type:"EVENT",label:"事件 (Event)",description:"向外部队列系统发布事件",category:"SYSTEM",icon:Yy,viewCategory:"data"},{type:"WAIT",label:"等待 (Wait)",description:"暂停流程,直到特定时间或时长",category:"SYSTEM",icon:Fy,viewCategory:"control"},{type:"SET_VARIABLE",label:"设置变量 (Set Variable)",description:"设置工作流上下文变量",category:"SYSTEM",icon:zy,viewCategory:"data"},{type:"TERMINATE",label:"终止 (Terminate)",description:"提前结束工作流执行",category:"SYSTEM",icon:By,viewCategory:"control"},{type:"HUMAN",label:"人工审批 (Human)",description:"等待人工审核或表单提交",category:"SYSTEM",icon:Vy,viewCategory:"business"},{type:"DYNAMIC",label:"动态任务 (Dynamic)",description:"运行时动态决定任务类型",category:"SYSTEM",icon:Ms,viewCategory:"data"},{type:"NOOP",label:"空操作 (Noop)",description:"占位符任务,无实际操作",category:"SYSTEM",icon:Ky,viewCategory:"data"},{type:"LAMBDA",label:"Lambda 脚本 (旧)",description:"已被 INLINE 取代",category:"SYSTEM",icon:wh,hidden:!0,viewCategory:"data"},{type:"SWITCH",label:"条件分支 (Switch)",description:"基于条件的逻辑分支 (Switch/Case)",category:"FLOW",icon:Ms,viewCategory:"control"},{type:"DECISION",label:"判断 (Decision,旧)",description:"基于条件的逻辑分支(旧版,推荐改用 Switch)",category:"FLOW",icon:Ms,hidden:!0,viewCategory:"control"},{type:"FORK_JOIN",label:"静态并行 (Fork)",description:"并行执行多个预定义任务分支",category:"FLOW",icon:Hr,viewCategory:"control"},{type:"FORK_JOIN_DYNAMIC",label:"动态并行 (Dynamic Fork)",description:"运行时动态生成并行分支",category:"FLOW",icon:Hr,viewCategory:"control"},{type:"DO_WHILE",label:"循环 (Do-While)",description:"循环执行直到满足条件",category:"FLOW",icon:Th,viewCategory:"control"},{type:"JOIN",label:"汇聚 (Join)",description:"等待所有并行分支执行完成",category:"FLOW",icon:Kr,viewCategory:"control"}],Zy=[{key:"CORE",label:"基础任务"},{key:"FLOW",label:"逻辑控制"},{key:"SYSTEM",label:"系统集成"}],Ur=({message:e,onConfirm:r,onCancel:t})=>{const n=q.useRef(null),{theme:o,themeColor:a}=oe();return q.useEffect(()=>{n.current?.focus({preventScroll:!0});const i=s=>{s.key==="Escape"&&t()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[t]),Gr.createPortal(d.jsx("div",{"data-mode":o,"data-brand":a,onClick:t,style:{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",backgroundColor:"rgba(0, 0, 0, 0.45)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:2e3},children:d.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"确认操作",onClick:i=>i.stopPropagation(),style:{backgroundColor:"var(--bg-secondary)",border:"1px solid var(--border-primary)",borderRadius:"8px",padding:"24px 28px",maxWidth:"380px",width:"90%",boxShadow:"0 8px 32px rgba(0, 0, 0, 0.18)"},children:[d.jsx("div",{style:{fontSize:"14px",color:"var(--text-primary)",marginBottom:"24px",lineHeight:"1.6"},children:e}),d.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"10px"},children:[d.jsx("button",{ref:n,onClick:t,style:{padding:"7px 18px",backgroundColor:"var(--bg-tertiary)",border:"1px solid var(--border-primary)",borderRadius:"6px",color:"var(--text-primary)",cursor:"pointer",fontSize:"13px",fontWeight:500},children:"取消"}),d.jsx("button",{onClick:r,style:{padding:"7px 18px",backgroundColor:"var(--color-accent)",border:"none",borderRadius:"6px",color:"#ffffff",cursor:"pointer",fontSize:"13px",fontWeight:600},children:"确定"})]})]})}),document.body)},yr=({children:e,nodeId:r,selected:t=!1,isStartOrEnd:n=!1,isError:o=!1,hasWarning:a=!1,isDecision:i=!1,isHighlighted:s=!1,executionStatus:l,simRunning:u=!1,simDone:c=!1})=>{const{mode:f,removeNode:p}=oe(),[h,g]=q.useState(!1),v=k=>{k.stopPropagation(),g(!0)},m=f==="edit"&&!n,y=[i?"decision-node-wrapper":"node-wrapper-glass",t?"node-wrapper-selected":"",s?"node-wrapper-highlighted":"",u?"node-sim-running":"",c?"node-sim-done":""].filter(Boolean).join(" "),b=q.useMemo(()=>{if(f!=="run")return{};if(!l)return{opacity:.4};switch(l){case"FAILED":case"FAILED_WITH_TERMINAL_ERROR":return{borderColor:"var(--status-failed)",boxShadow:"0 0 12px rgba(239, 68, 68, 0.5), 0 0 24px rgba(239, 68, 68, 0.2)"};case"TIMED_OUT":return{borderColor:"var(--status-timed-out)",boxShadow:"0 0 8px rgba(249, 115, 22, 0.4)"};case"IN_PROGRESS":case"SCHEDULED":return{borderColor:"var(--status-in-progress)",animation:"status-pulse 1.5s ease-in-out infinite"};case"COMPLETED":return{borderColor:"var(--status-completed)",opacity:.85};case"COMPLETED_WITH_ERRORS":return{borderColor:"var(--status-completed-with-errors)"};case"SKIPPED":case"CANCELED":return{opacity:.5};default:return{}}},[f,l]);return d.jsxs("div",{className:y,style:{position:"relative",...b},children:[m&&d.jsx("button",{onClick:v,"aria-label":"删除任务",style:{position:"absolute",top:"-10px",right:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"2px solid white",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:100,boxShadow:"0 2px 8px rgba(0,0,0,0.2)",animation:"popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275)",padding:0},title:"删除任务",children:"×"}),o&&d.jsx("div",{style:{position:"absolute",top:"-10px",left:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"2px solid white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:101,boxShadow:"0 2px 8px rgba(0,0,0,0.2)"},title:"此节点配置有误",children:"❗"}),!o&&a&&d.jsx("div",{style:{position:"absolute",top:"-10px",left:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#f59e0b",color:"white",border:"2px solid white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:101,boxShadow:"0 2px 8px rgba(0,0,0,0.2)"},title:"此节点有警告信息",children:"⚠️"}),e,h&&d.jsx(Ur,{message:"确定要删除此任务吗?",onConfirm:()=>{p(r),g(!1)},onCancel:()=>g(!1)})]})},Qy=({status:e})=>{const r=()=>{switch(e){case"SCHEDULED":return{icon:"○",className:"scheduled"};case"IN_PROGRESS":return{icon:"◐",className:"in-progress"};case"COMPLETED":return{icon:"✓",className:"completed"};case"COMPLETED_WITH_ERRORS":return{icon:"⚠",className:"completed-with-errors"};case"FAILED":case"FAILED_WITH_TERMINAL_ERROR":return{icon:"✗",className:"failed"};case"TIMED_OUT":return{icon:"⏱",className:"timed-out"};case"SKIPPED":return{icon:"⤳",className:"skipped"};case"CANCELED":return{icon:"⊘",className:"canceled"};default:return{icon:"?",className:"unknown"}}},{icon:t,className:n}=r();return d.jsx("div",{className:`execution-status-badge ${n}`,title:e,children:d.jsx("span",{className:"badge-icon",children:t})})},Eh=q.memo(Qy),ex=({icon:e,header:r,title:t,meta:n,color:o,status:a,isRunning:i,children:s,width:l="240px",border:u=!0})=>d.jsxs("div",{style:{display:"flex",flexDirection:"row",width:l,height:"100%",position:"relative",overflow:"hidden",border:u?"4px solid var(--border-primary)":"none",borderRadius:"8px"},children:[d.jsx("div",{style:{width:"48px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(205, 74, 74, 0.03)",borderRight:"1px solid var(--color-accent)",color:o},children:d.jsx(e,{size:20,strokeWidth:1.5})}),d.jsxs("div",{style:{flex:1,padding:"10px 14px",display:"flex",flexDirection:"column",justifyContent:"center",overflow:"hidden"},children:[d.jsx("div",{style:{fontSize:"14px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.5px",opacity:.7,marginBottom:"4px",color:o},children:r}),d.jsx("div",{style:{fontSize:"18px",fontWeight:600,color:"var(--text-primary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginBottom:"2px"},title:t,children:t}),n&&d.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)",fontStyle:"italic",lineHeight:"1.4",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},title:n,children:n}),s&&d.jsx("div",{style:{marginTop:"8px"},children:s})]}),i&&a&&d.jsx("div",{style:{position:"absolute",top:"8px",right:"8px"},children:d.jsx(Eh,{status:a})})]}),Jr=q.memo(ex),Ve=e=>{const r=e.layoutDirection||"TB",t=e.sourcePosition||(r==="LR"?O.Position.Right:O.Position.Bottom),n=e.targetPosition||(r==="LR"?O.Position.Left:O.Position.Top);return{layoutDirection:r,sourcePosition:t,targetPosition:n}},ir=e=>{const{mode:r,executionData:t}=oe(),n=r==="run"?t?.[e]:null,o=r==="run",a=n?.attempts.some(l=>l.iteration!==void 0&&l.iteration>1)??!1,i=n?.attempts[n.attempts.length-1],s=a?0:i?.retryCount??0;return{mode:r,execution:n,isRunning:o,retryCount:s}};function Fe(e,r){return e.length>r?e.slice(0,r)+"…":e}function xr(e,r,t,n){if(t==="business")return r.task?.description?.trim()||n;if(t==="standard")return n;const o=r.task;if(!o)return n;const a=o.inputParameters||{};switch(e){case"HTTP":case"HTTP_POLL":{const i=o.httpRequest||a.http_request;if(!i)return n;const s=(i.method||"GET").toUpperCase(),l=i.uri?Fe(String(i.uri),28):"";return l?`${s} ${l}`:s}case"SWITCH":{const i=o.caseExpression||a.expression,s=o.evaluatorType||a.evaluatorType;return i?Fe(i,35):s||n}case"DECISION":return o.caseValueParam?`param: ${o.caseValueParam}`:n;case"SIMPLE":return o.name?`worker: ${Fe(o.name,28)}`:n;case"INLINE":case"LAMBDA":{const i=o.evaluatorType||a.evaluatorType;return i?`${i} script`:n}case"SUB_WORKFLOW":{const i=o.subWorkflowParam;return i?`${i.name}${i.version?` v${i.version}`:""}`:n}case"DO_WHILE":{const i=o.loopCondition;return i?Fe(i,35):n}case"JSON_JQ_TRANSFORM":{const i=a.queryExpression||a.query_expression;return i?Fe(i,35):n}case"SET_VARIABLE":{const i=Object.keys(a);return i.length?`set: ${i.slice(0,2).join(", ")}${i.length>2?"…":""}`:n}case"EVENT":{const i=o.sink||a.sink;return i?`→ ${Fe(i,32)}`:n}case"KAFKA_PUBLISH":{const i=a.topic||a.kafka_request?.topic;return i?`topic: ${Fe(i,28)}`:n}case"START_WORKFLOW":{const i=o.startWorkflow?.name??a.startWorkflow?.name??a.start_workflow?.name;return i?`→ ${i}`:n}default:return n}}const rx=({id:e,data:r,selected:t})=>{const n=r.taskType||"SIMPLE",{sourcePosition:o,targetPosition:a}=Ve(r),{execution:i,isRunning:s,retryCount:l}=ir(r.taskReferenceName),u=oe(m=>m.viewMode),c=q.useMemo(()=>Ge.find(m=>m.type===n),[n]),f=c?.icon||Sh,p=n==="NOOP",h=r.isDynamicRuntime===!0,g=p?"var(--text-secondary)":"var(--color-accent)",v=q.useMemo(()=>{let m;return h?m=`Dynamic (${n})`:n==="SIMPLE"?m=r.label==="Worker Task"?"Execute on Worker":"Worker Task":n==="HTTP"?m="REST API Call":n==="JSON_JQ_TRANSFORM"?m="JQ Expression":n==="INLINE"||n==="LAMBDA"?m="Inline Script":n==="START_WORKFLOW"?m="Launch Workflow (no wait)":n==="DYNAMIC"?m="Dynamic Task Type":n==="HUMAN"?m="Human Approval":n==="NOOP"?m="No Operation":m=c?.label||n,xr(n,r,u,m)},[n,c,r,u,h]);return d.jsx(yr,{nodeId:e,selected:t,isError:r.isError,hasWarning:r.hasWarning,isHighlighted:r.isHighlighted,executionStatus:i?.status,simRunning:r.simRunning,simDone:r.simDone,children:d.jsxs("div",{style:{borderRadius:"8px",background:p?"var(--bg-tertiary)":"var(--bg-secondary)",opacity:p?.7:1,position:"relative",outline:h?"2px dashed var(--color-accent)":"none",outlineOffset:"-2px"},children:[d.jsx(Jr,{icon:f,header:n,title:r.taskReferenceName,meta:v,color:g,status:i?.status,isRunning:s}),s&&l>0&&d.jsxs("div",{style:{position:"absolute",bottom:"4px",right:"4px",background:"var(--status-failed, #ef4444)",color:"#fff",borderRadius:"10px",fontSize:"10px",fontWeight:"700",padding:"1px 6px",zIndex:10,lineHeight:"1.4",pointerEvents:"none"},children:["×",l]}),h&&d.jsx("div",{style:{position:"absolute",top:"4px",right:"4px",background:"var(--color-accent)",color:"#fff",borderRadius:"4px",fontSize:"9px",fontWeight:"700",padding:"1px 5px",zIndex:10,pointerEvents:"none",opacity:.9},children:"动态"}),d.jsx(O.Handle,{type:"target",position:a,style:{background:"#fff"}}),d.jsx(O.Handle,{type:"source",position:o,style:{background:"#fff"}})]})})},tx=q.memo(rx),Nh=({title:e,label:r,defaultValue:t="",placeholder:n="",confirmText:o="确定",cancelText:a="取消",onConfirm:i,onCancel:s})=>{const{theme:l,themeColor:u}=oe(),[c,f]=q.useState(t),p=q.useRef(null);q.useEffect(()=>{p.current&&(p.current.focus({preventScroll:!0}),p.current.select());const g=v=>{v.key==="Escape"&&(v.stopPropagation(),s())};return window.addEventListener("keydown",g,!0),()=>window.removeEventListener("keydown",g,!0)},[s]);const h=()=>{const g=c.trim();g&&i(g)};return Gr.createPortal(d.jsx("div",{"data-mode":l,"data-brand":u,onClick:s,style:{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",backgroundColor:"rgba(0, 0, 0, 0.45)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:2e3},children:d.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":e,onClick:g=>g.stopPropagation(),style:{backgroundColor:"var(--bg-secondary)",border:"1px solid var(--border-primary)",borderRadius:"10px",padding:"24px 28px",maxWidth:"400px",width:"90%",boxShadow:"0 8px 32px rgba(0, 0, 0, 0.22)"},children:[d.jsx("div",{style:{fontSize:"15px",fontWeight:600,color:"var(--text-primary)",marginBottom:"16px"},children:e}),r&&d.jsx("div",{style:{fontSize:"12px",color:"var(--text-secondary)",marginBottom:"8px"},children:r}),d.jsx("input",{ref:p,type:"text",value:c,placeholder:n,onChange:g=>f(g.target.value),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),h()),g.stopPropagation()},style:{width:"100%",padding:"9px 12px",borderRadius:"6px",border:"1px solid var(--border-primary)",background:"var(--bg-tertiary)",color:"var(--text-primary)",fontSize:"13px",outline:"none",boxSizing:"border-box",marginBottom:"20px",transition:"border-color 0.15s"},onFocus:g=>{g.currentTarget.style.borderColor="var(--color-accent)"},onBlur:g=>{g.currentTarget.style.borderColor="var(--border-primary)"}}),d.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"10px"},children:[d.jsx("button",{onClick:s,style:{padding:"7px 18px",backgroundColor:"var(--bg-tertiary)",border:"1px solid var(--border-primary)",borderRadius:"6px",color:"var(--text-primary)",cursor:"pointer",fontSize:"13px",fontWeight:500},children:a}),d.jsx("button",{onClick:h,disabled:!c.trim(),style:{padding:"7px 18px",backgroundColor:c.trim()?"var(--color-accent)":"var(--bg-tertiary)",border:"none",borderRadius:"6px",color:c.trim()?"#ffffff":"var(--text-secondary)",cursor:c.trim()?"pointer":"not-allowed",fontSize:"13px",fontWeight:600,transition:"background-color 0.15s, color 0.15s"},children:o})]})]})}),document.body)},nx=({id:e,data:r,selected:t})=>{const{layoutDirection:n}=Ve(r),{mode:o,execution:a,isRunning:i}=ir(r.taskReferenceName),{addDecisionBranch:s,removeDecisionBranch:l,renameDecisionBranch:u,viewMode:c}=oe(),[f,p]=q.useState(!1),[h,g]=q.useState({type:"none"}),v=n==="LR"?O.Position.Left:O.Position.Top,m=Object.keys(r.decisionCases||r.task?.decisionCases||{}),x=()=>{p(!1),g({type:"add"})},y=(I,R)=>{I.stopPropagation(),g({type:"delete",branch:R})},b=(I,R)=>{I.stopPropagation(),p(!1),g({type:"rename",branch:R})},k=I=>{I&&s(e,I),g({type:"none"})},S=I=>{h.type==="rename"&&(I&&I!==h.branch&&u(e,h.branch,I),g({type:"none"}))},C=()=>{h.type==="delete"&&(l(e,h.branch),g({type:"none"}))},N=()=>g({type:"none"}),w=i?(I=>I&&{SCHEDULED:"execution-node-scheduled",IN_PROGRESS:"execution-node-in-progress",COMPLETED:"execution-node-completed",COMPLETED_WITH_ERRORS:"execution-node-completed-with-errors",FAILED:"execution-node-failed",FAILED_WITH_TERMINAL_ERROR:"execution-node-failed-terminal",TIMED_OUT:"execution-node-timed-out",SKIPPED:"execution-node-skipped",CANCELED:"execution-node-canceled"}[I]||"")(a?.status):"";return d.jsxs(yr,{nodeId:e,selected:t,isError:r.isError,hasWarning:r.hasWarning,isDecision:!0,isHighlighted:r.isHighlighted,executionStatus:a?.status,simRunning:r.simRunning,simDone:r.simDone,children:[d.jsxs("div",{style:{position:"relative"},children:[d.jsx(O.Handle,{type:"target",position:v,style:{background:"#fff",[n==="LR"?"left":"top"]:"-5px"}}),i&&a?.status&&d.jsx("div",{style:{position:"absolute",top:0,right:0,zIndex:20},children:d.jsx(Eh,{status:a.status})}),d.jsx("div",{className:w,style:{width:"150px",height:"150px",background:i&&a?.status?void 0:"var(--bg-secondary)",border:t?"4px solid #fbbf24":i&&a?.status?void 0:"4px solid var(--border-primary)",transform:"rotate(45deg)",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:t?"0 10px 30px rgba(0,0,0,0.3), 0 0 0 4px rgba(251, 191, 36, 0.3)":i&&a?.status?void 0:"0 4px 12px rgba(0,0,0,0.15)",transition:"all 0.3s ease",cursor:"pointer"},onClick:()=>o==="edit"&&p(!f),children:d.jsxs("div",{style:{transform:"rotate(-45deg)",color:"#fff",textAlign:"center",padding:"10px",width:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},children:[d.jsx("div",{style:{fontSize:"14px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.5px",opacity:.7,marginBottom:"4px",color:"var(--color-accent)"},children:r.taskType}),d.jsx("div",{style:{fontSize:"18px",fontWeight:600,color:"var(--text-primary)",lineHeight:"1.2",wordBreak:"break-word",maxHeight:"60px",overflow:"hidden",marginBottom:"4px"},children:r.label}),o==="edit"&&d.jsx("div",{style:{marginTop:"4px",width:"24px",height:"24px",fontSize:"16px",background:"rgba(255,255,255,0.1)",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",margin:"4px auto 0",color:"var(--text-secondary)"},children:"+"}),i&&a?.startTime&&d.jsx("div",{style:{fontSize:"9px",opacity:.7,marginTop:"8px"},children:a.endTime?`${((a.endTime-a.startTime)/1e3).toFixed(1)}s`:"◌"})]})}),o==="edit"&&f&&d.jsxs("div",{className:"glass-panel",style:{position:"absolute",top:"160px",left:"50%",transform:"translateX(-50%)",backgroundColor:"var(--glass-surface)",border:"1px solid var(--glass-border)",borderRadius:"8px",padding:"8px",zIndex:1e3,minWidth:"200px",boxShadow:"0 10px 25px rgba(0,0,0,0.5)",animation:"popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275)",backdropFilter:"blur(12px)"},children:[d.jsx("div",{style:{padding:"4px 8px 6px",fontSize:"11px",color:"var(--text-secondary)",borderBottom:"1px solid var(--glass-border)",marginBottom:"4px",fontWeight:600,letterSpacing:"0.05em"},children:"分支管理"}),m.map(I=>d.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"5px 6px",borderRadius:"4px",gap:"4px"},children:[d.jsx("span",{style:{flex:1,fontSize:"12px",color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:I}),d.jsx("button",{onClick:R=>b(R,I),style:{width:"22px",height:"22px",borderRadius:"4px",backgroundColor:"var(--color-accent)",color:"white",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"11px",padding:0,flexShrink:0,opacity:.85},title:`重命名分支 "${I}"`,children:"✏"}),d.jsx("button",{onClick:R=>y(R,I),style:{width:"22px",height:"22px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"13px",padding:0,flexShrink:0,opacity:.9},title:`删除分支 "${I}"`,children:"×"})]},I)),d.jsx("button",{onClick:x,style:{width:"100%",marginTop:"6px",padding:"8px",backgroundColor:"var(--color-accent)",border:"none",borderRadius:"4px",color:"#fff",cursor:"pointer",fontSize:"12px",fontWeight:"bold"},children:"+ 添加新分支"})]}),c==="developer"&&(()=>{const I=r.task?.caseExpression||r.task?.inputParameters?.expression,R=r.task?.caseValueParam;return!I&&!R?null:d.jsx("div",{style:{position:"absolute",top:"158px",left:"50%",transform:"translateX(-50%)",textAlign:"center",fontSize:10,color:"var(--text-secondary)",maxWidth:140,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",pointerEvents:"none",fontFamily:"var(--font-mono, monospace)"},children:I?Fe(I,22):`param: ${R}`})})(),n==="TB"?d.jsxs(d.Fragment,{children:[d.jsx(O.Handle,{type:"source",position:O.Position.Bottom,style:{background:"#fff",bottom:"-5px"}}),d.jsx(O.Handle,{type:"source",position:O.Position.Left,id:"left",style:{background:"#fff",left:"-5px"}}),d.jsx(O.Handle,{type:"source",position:O.Position.Right,id:"right",style:{background:"#fff",right:"-5px"}})]}):d.jsxs(d.Fragment,{children:[d.jsx(O.Handle,{type:"source",position:O.Position.Right,style:{background:"#fff",right:"-5px"}}),d.jsx(O.Handle,{type:"source",position:O.Position.Top,id:"top",style:{background:"#fff",top:"-5px"}}),d.jsx(O.Handle,{type:"source",position:O.Position.Bottom,id:"bottom",style:{background:"#fff",bottom:"-5px"}})]})]}),h.type==="add"&&d.jsx(Nh,{title:"添加新分支",label:"分支条件值(Case Value)",defaultValue:`case_${m.length+1}`,placeholder:"例如:approved、rejected、pending",confirmText:"添加",onConfirm:k,onCancel:N}),h.type==="rename"&&d.jsx(Nh,{title:"重命名分支",label:`当前名称:${h.branch}`,defaultValue:h.branch,placeholder:"输入新的分支条件值",confirmText:"重命名",onConfirm:S,onCancel:N}),h.type==="delete"&&d.jsx(Ur,{message:`确定要删除分支 "${h.branch}" 及其下的所有任务吗?此操作不可撤销。`,onConfirm:C,onCancel:N})]})},ax=q.memo(nx),Ch="var(--color-accent)",Ih=q.memo(({id:e,data:r,selected:t})=>{const{layoutDirection:n,sourcePosition:o,targetPosition:a}=Ve(r),{mode:i,execution:s,isRunning:l}=ir(r.taskReferenceName),{addForkBranch:u}=oe(),c=O.useUpdateNodeInternals(),f=r.task?.forkTasks?.length||0;q.useEffect(()=>{c(e)},[f,e,c]);const p=r.isDynamic||r.taskType==="FORK_JOIN_DYNAMIC",h=oe(m=>m.viewMode),v=q.useMemo(()=>Ge.find(m=>m.type==="FORK_JOIN"),[])?.icon||Hr;return d.jsx(yr,{isHighlighted:r.isHighlighted,nodeId:e,selected:t,isError:r.isError,hasWarning:r.hasWarning,executionStatus:s?.status,simRunning:r.simRunning,simDone:r.simDone,children:d.jsxs("div",{className:`fork-node ${p?"dynamic":"static"}`,style:{borderRadius:"8px",background:"var(--bg-secondary)",position:"relative"},children:[d.jsx(Jr,{icon:v,header:p?"DYNAMIC FORK":"FORK",title:r.taskReferenceName,meta:xr(r.taskType,r,h,p?"Dynamic Parallel Execution":"Parallel Execution"),color:Ch,status:s?.status,isRunning:l}),i==="edit"&&!p&&d.jsx("div",{style:{position:"absolute",...n==="LR"?{top:"50%",right:-12,transform:"translateY(-50%)"}:{bottom:-12,left:"50%",transform:"translateX(-50%)"},width:20,height:20,background:"var(--color-accent)",borderRadius:"50%",color:"#fff",fontSize:"14px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",zIndex:1e3,boxShadow:"0 2px 5px rgba(0,0,0,0.2)",border:"2px solid var(--bg-primary)"},onClick:m=>{m.stopPropagation(),u(e)},title:"添加分支",children:"+"}),d.jsx(O.Handle,{type:"target",position:a,style:{background:"#fff"}}),!p&&(r.task?.forkTasks||[]).map((m,x,y)=>{if(i!=="edit"&&(!m||m.length===0))return null;const b=i!=="edit"?y.filter(N=>N&&N.length>0):y,k=b.length,C=(b.indexOf(m)+1)/(k+1)*100;return d.jsx(O.Handle,{id:`branch_${x}`,type:"source",position:o,style:{background:"#fff",[n==="LR"?"top":"left"]:`${C}%`,[n==="LR"?"left":"top"]:void 0,[n==="LR"?"right":"bottom"]:"-4px",zIndex:10}},`branch_${x}`)}),!p&&(!r.task?.forkTasks||r.task.forkTasks.length===0)&&d.jsx(O.Handle,{type:"source",position:o,style:{background:"#fff"}}),p&&d.jsx(O.Handle,{type:"source",position:o,style:{background:"#fff"}})]})})});Ih.displayName="ForkNode";const Rh=q.memo(({id:e,data:r,selected:t})=>{const{layoutDirection:n,sourcePosition:o,targetPosition:a}=Ve(r),{execution:i,isRunning:s}=ir(r.taskReferenceName),l=oe(f=>f.viewMode),c=q.useMemo(()=>Ge.find(f=>f.type==="JOIN"),[])?.icon||Kr;return d.jsx(yr,{isHighlighted:r.isHighlighted,nodeId:e,selected:t,isError:r.isError,hasWarning:r.hasWarning,executionStatus:i?.status,simRunning:r.simRunning,simDone:r.simDone,children:d.jsxs("div",{style:{borderRadius:"8px",background:"var(--bg-secondary)",position:"relative"},children:[d.jsx(Jr,{icon:c,header:r.taskType==="EXCLUSIVE_JOIN"?"EXCLUSIVE JOIN":"JOIN",title:r.taskReferenceName,meta:xr(r.taskType,r,l,r.taskType==="EXCLUSIVE_JOIN"?"Wait for any task":"Wait for tasks"),color:Ch,status:i?.status,isRunning:s}),d.jsx(O.Handle,{type:"target",position:a,style:{background:"#fff"}}),n==="TB"&&d.jsxs(d.Fragment,{children:[d.jsx(O.Handle,{type:"target",position:O.Position.Left,id:"left",style:{background:"#fff"}}),d.jsx(O.Handle,{type:"target",position:O.Position.Right,id:"right",style:{background:"#fff"}})]}),n==="LR"&&d.jsxs(d.Fragment,{children:[d.jsx(O.Handle,{type:"target",position:O.Position.Top,id:"top",style:{background:"#fff"}}),d.jsx(O.Handle,{type:"target",position:O.Position.Bottom,id:"bottom",style:{background:"#fff"}})]}),d.jsx(O.Handle,{type:"source",position:o,style:{background:"#fff"}})]})})});Rh.displayName="JoinNode";const jh={ForkNode:Ih,JoinNode:Rh},ox=({id:e,data:r,selected:t})=>{const{sourcePosition:n,targetPosition:o}=Ve(r),{execution:a,isRunning:i}=ir(r.taskReferenceName),{executionData:s,selectTaskAction:l,mode:u,viewMode:c,removeNode:f}=oe(),[p,h]=q.useState(!1),g=r.task,v=g?.loopOver||[],x=q.useMemo(()=>Ge.find(w=>w.type==="DO_WHILE"),[])?.icon||Th,y=q.useMemo(()=>{if(!i||!s||v.length===0)return 0;let w=0;return v.forEach(I=>{const R=s[I.taskReferenceName];R?.totalIterations?w=Math.max(w,R.totalIterations):R?.attempts.some(B=>(B.iteration??0)>0)&&(w=Math.max(w,R.attempts.length))}),w},[i,s,v]),b=r.loopCondition||g?.loopCondition||"",k=q.useMemo(()=>{const w=b?b.length>35?b.slice(0,35)+"…":b:"循环直到条件满足";return xr("DO_WHILE",r,c,w)},[r,c,b]),S=a?.status==="COMPLETED"?"var(--status-completed)":a?.status==="FAILED"||a?.status==="FAILED_WITH_TERMINAL_ERROR"?"var(--status-failed)":a?.status==="IN_PROGRESS"||a?.status==="SCHEDULED"?"var(--status-in-progress)":"var(--color-accent)",C=t?`2px solid ${S}`:`1.5px dashed ${i&&a?.status?S:"var(--color-accent)"}`,N=u==="edit",A=c==="developer"&&b;return d.jsxs("div",{style:{width:"100%",height:"100%",border:C,borderRadius:"10px",background:"transparent",display:"flex",flexDirection:"column",position:"relative",overflow:"visible",boxSizing:"border-box",pointerEvents:"none"},children:[N&&d.jsx("button",{onClick:w=>{w.stopPropagation(),h(!0)},"aria-label":"删除循环任务",style:{position:"absolute",top:"-10px",right:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"2px solid white",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:100,boxShadow:"0 2px 8px rgba(0,0,0,0.2)",padding:0,pointerEvents:"auto"},title:"删除循环任务",children:"×"}),r.isError&&d.jsx("div",{style:{position:"absolute",top:"-10px",left:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"2px solid white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:101,boxShadow:"0 2px 8px rgba(0,0,0,0.2)",pointerEvents:"auto"},title:"此节点配置有误",children:"❗"}),!r.isError&&r.hasWarning&&d.jsx("div",{style:{position:"absolute",top:"-10px",left:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#f59e0b",color:"white",border:"2px solid white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:101,boxShadow:"0 2px 8px rgba(0,0,0,0.2)",pointerEvents:"auto"},title:"此节点有警告信息",children:"⚠️"}),d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",padding:"8px 12px",background:"var(--bg-tertiary)",borderBottom:"1px solid var(--border-primary)",borderRadius:"8px 8px 0 0",flexShrink:0,minHeight:"42px",pointerEvents:"auto"},children:[d.jsx("div",{style:{color:"var(--color-accent)",display:"flex",alignItems:"center",flexShrink:0},children:d.jsx(x,{size:14})}),d.jsxs("div",{style:{flex:1,minWidth:0},children:[d.jsx("div",{style:{fontSize:"9px",fontWeight:700,color:"var(--color-accent)",letterSpacing:"0.08em",textTransform:"uppercase"},children:"DO WHILE"}),d.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.taskReferenceName}),(c==="business"||c==="developer")&&k&&d.jsx("div",{style:{fontSize:"9px",color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:"1px",fontStyle:"italic"},children:k})]}),i&&y>0&&d.jsxs("div",{onClick:()=>l(g||null),style:{padding:"2px 8px",borderRadius:"12px",background:"var(--color-accent)",color:"#fff",fontSize:"10px",fontWeight:700,cursor:"pointer",flexShrink:0},children:["×",y]}),i&&a?.status&&d.jsx("div",{style:{width:"8px",height:"8px",borderRadius:"50%",background:S,flexShrink:0}})]}),A&&d.jsxs("div",{style:{padding:"3px 12px",fontSize:"9px",color:"var(--text-secondary)",background:"var(--bg-tertiary)",borderBottom:"1px solid var(--border-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flexShrink:0,pointerEvents:"auto"},children:["until: ",b]}),d.jsx("div",{style:{flex:1,position:"relative",background:"var(--loop-body-bg, rgba(99,102,241,0.04))",borderRadius:"0 0 8px 8px",pointerEvents:"none"}}),d.jsx(O.Handle,{type:"target",position:o,style:{background:"var(--color-accent)",zIndex:10}}),d.jsx(O.Handle,{type:"source",position:n,style:{background:"var(--color-accent)",zIndex:10}}),p&&d.jsx(Ur,{message:"确定要删除此循环任务吗?循环体内的任务也会一并删除。",onConfirm:()=>{f(e),h(!1)},onCancel:()=>h(!1)})]})},ix=q.memo(ox),sx="var(--color-accent)",cx=({id:e,data:r,selected:t})=>{const{sourcePosition:n,targetPosition:o}=Ve(r),{execution:a,isRunning:i}=ir(r.taskReferenceName),s=oe(p=>p.viewMode),u=q.useMemo(()=>Ge.find(p=>p.type==="SUB_WORKFLOW"),[])?.icon||Kr,c=r.task?.subWorkflowParam?.name||r.subWorkflowName||"Unknown",f=r.task?.subWorkflowParam?.version;return d.jsx(yr,{nodeId:e,selected:t,isError:r.isError,hasWarning:r.hasWarning,isHighlighted:r.isHighlighted,executionStatus:a?.status,simRunning:r.simRunning,simDone:r.simDone,children:d.jsxs("div",{style:{borderRadius:"8px",background:"var(--bg-secondary)",position:"relative"},children:[d.jsx(Jr,{icon:u,header:"SUB WORKFLOW",title:r.taskReferenceName,meta:xr("SUB_WORKFLOW",r,s,`Flow: ${c} (v${f})`),color:sx,status:a?.status,isRunning:i}),d.jsx(O.Handle,{type:"target",position:o,style:{background:"#fff"}}),d.jsx(O.Handle,{type:"source",position:n,style:{background:"#fff"}})]})})},ux=q.memo(cx),lx=({data:e})=>{const t=(e.layoutDirection||"TB")==="LR";return d.jsxs("div",{className:"plus-node-container",style:{width:"32px",height:"32px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",background:"var(--bg-secondary, #1e293b)",border:"2px dashed var(--color-accent, #3b82f6)",color:"var(--color-accent, #3b82f6)",cursor:"pointer",transition:"all 0.2s ease",padding:e.label&&e.label!=="+"?"0 12px":"0",minWidth:e.label&&e.label!=="+"?"80px":"32px",gap:"4px"},children:[d.jsx(Jy,{size:16}),e.label&&e.label!=="+"&&d.jsx("span",{style:{fontSize:"12px",fontWeight:500},children:e.label}),d.jsx(O.Handle,{type:"target",position:t?O.Position.Left:O.Position.Top,style:{opacity:0}}),d.jsx("style",{dangerouslySetInnerHTML:{__html:`
10
+ .plus-node-container:hover {
11
+ transform: scale(1.1);
12
+ background: var(--color-accent);
13
+ color: #fff;
14
+ border-style: solid;
15
+ box-shadow: 0 0 10px var(--color-accent);
16
+ }
17
+ `}})]})},dx=q.memo(lx),fx=({data:e})=>{const{sourcePosition:r,targetPosition:t}=Ve(e);return d.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:[d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[d.jsx(Hr,{size:14,style:{color:"var(--color-accent)"}}),d.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:"var(--color-accent)"},children:"动态分支"})]}),d.jsx("span",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:"运行时生成"}),d.jsx(O.Handle,{type:"target",position:t,style:{background:"var(--color-accent)",width:8,height:8}}),d.jsx(O.Handle,{type:"source",position:r,style:{background:"var(--color-accent)",width:8,height:8}})]})},px=q.memo(fx),hx=({onSelect:e,onCancel:r})=>{const[t,n]=q.useState("CORE");q.useEffect(()=>{const a=i=>{i.key==="Escape"&&r()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[r]);const o=Ge.filter(a=>a.category===t&&!a.hidden);return d.jsxs("div",{style:{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",backgroundColor:"rgba(0,0,0,0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:2e3,backdropFilter:"blur(4px)",animation:"fadeIn 0.2s ease-out"},onClick:r,children:[d.jsxs("div",{className:"glass-panel",style:{backgroundColor:"var(--glass-surface)",borderRadius:"16px",padding:"0",width:"600px",height:"500px",boxShadow:"0 20px 50px rgba(0,0,0,0.4)",border:"1px solid var(--glass-border)",display:"flex",flexDirection:"column",overflow:"hidden"},onClick:a=>a.stopPropagation(),children:[d.jsxs("div",{style:{padding:"20px 24px 0",borderBottom:"1px solid var(--border-primary)",backgroundColor:"var(--bg-secondary)"},children:[d.jsx("h3",{style:{marginTop:0,marginBottom:"16px",color:"var(--text-primary)",fontSize:"18px",fontWeight:"600"},children:"添加任务"}),d.jsx("div",{style:{display:"flex",gap:"24px"},children:Zy.map(a=>d.jsx("button",{onClick:()=>n(a.key),style:{background:"none",border:"none",padding:"0 0 12px 0",fontSize:"14px",fontWeight:t===a.key?"600":"500",color:t===a.key?"var(--color-accent)":"var(--text-secondary)",borderBottom:t===a.key?"2px solid var(--color-accent)":"2px solid transparent",cursor:"pointer",transition:"all 0.2s"},children:a.label},a.key))})]}),d.jsx("div",{style:{flex:1,overflowY:"auto",padding:"24px",backgroundColor:"var(--bg-primary)"},children:d.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"12px"},children:o.map(a=>{const i=a.icon;return d.jsxs("button",{onClick:()=>e(a.type),style:{display:"flex",alignItems:"flex-start",gap:"16px",padding:"16px",backgroundColor:"var(--bg-tertiary)",border:"1px solid var(--border-primary)",borderRadius:"12px",cursor:"pointer",textAlign:"left",transition:"all 0.2s",color:"var(--text-primary)",position:"relative",overflow:"hidden"},onMouseEnter:s=>{s.currentTarget.style.borderColor="var(--color-accent)",s.currentTarget.style.backgroundColor="var(--bg-highlight)",s.currentTarget.style.transform="translateY(-2px)",s.currentTarget.style.boxShadow="0 4px 12px rgba(0,0,0,0.1)"},onMouseLeave:s=>{s.currentTarget.style.borderColor="var(--border-primary)",s.currentTarget.style.backgroundColor="var(--bg-tertiary)",s.currentTarget.style.transform="translateY(0)",s.currentTarget.style.boxShadow="none"},children:[d.jsx("div",{style:{padding:"10px",borderRadius:"8px",backgroundColor:"var(--bg-secondary)",color:"var(--color-accent)",display:"flex",alignItems:"center",justifyContent:"center"},children:d.jsx(i,{size:24,strokeWidth:1.5})}),d.jsxs("div",{children:[d.jsx("div",{style:{fontWeight:"600",fontSize:"14px",marginBottom:"4px"},children:a.label}),d.jsx("div",{style:{fontSize:"12px",color:"var(--text-secondary)",lineHeight:"1.4"},children:a.description})]})]},a.type)})})}),d.jsx("div",{style:{padding:"16px 24px",borderTop:"1px solid var(--border-primary)",backgroundColor:"var(--bg-secondary)",display:"flex",justifyContent:"flex-end"},children:d.jsx("button",{onClick:r,style:{padding:"8px 24px",backgroundColor:"transparent",border:"1px solid var(--border-primary)",borderRadius:"6px",color:"var(--text-primary)",cursor:"pointer",fontSize:"13px",fontWeight:"500",transition:"all 0.2s"},onMouseEnter:a=>a.currentTarget.style.backgroundColor="var(--bg-tertiary)",onMouseLeave:a=>a.currentTarget.style.backgroundColor="transparent",children:"取消"})})]}),d.jsx("style",{children:`
7
18
  @keyframes fadeIn {
8
19
  from { opacity: 0; }
9
20
  to { opacity: 1; }
10
21
  }
11
- `})]})},dh=()=>{const{selectedTask:e,selectedTaskInstance:t,setSelectedTask:r,setSelectedTaskInstance:n,executionData:a,workflowInstance:i}=V(),[o,s]=D.useState("summary"),c=e?.taskReferenceName==="__workflow_global__",u=e?a?.[e.taskReferenceName]:null;if(!e||!u&&!c)return null;const d=u?.attempts||[],l=t||d[d.length-1],p=()=>{r(null),n(null)},h=(g,v)=>{if(!g)return"-";const b=(v||Date.now())-g;return b<1e3?`${b}ms`:`${(b/1e3).toFixed(2)}s`},m=g=>({COMPLETED:"var(--status-completed)",FAILED:"var(--status-failed)",IN_PROGRESS:"var(--status-in-progress)",SCHEDULED:"var(--status-scheduled)",TIMED_OUT:"var(--status-timed-out)",CANCELED:"var(--status-canceled)"})[g]||"var(--text-secondary)";return f.jsxs("div",{className:"execution-details-panel",children:[f.jsx("style",{children:`
12
- .execution-details-panel {
13
- position: fixed;
14
- right: 20px;
15
- top: 80px;
16
- width: 400px;
17
- max-height: calc(100vh - 120px);
18
- background: var(--glass-surface);
19
- backdrop-filter: blur(12px);
20
- border: 1px solid var(--glass-border);
21
- border-radius: 16px;
22
- box-shadow: 0 20px 50px rgba(0,0,0,0.3);
23
- z-index: 1000;
24
- display: flex;
25
- flex-direction: column;
26
- overflow: hidden;
27
- animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1);
28
- }
29
-
30
- @keyframes slideInRight {
31
- from { transform: translateX(50px); opacity: 0; }
32
- to { transform: translateX(0); opacity: 1; }
33
- }
34
-
35
- .panel-header {
36
- padding: 20px;
37
- border-bottom: 1px solid var(--border-primary);
38
- display: flex;
39
- justify-content: space-between;
40
- align-items: flex-start;
41
- }
42
-
43
- .task-title {
44
- margin: 0;
45
- font-size: 18px;
46
- font-weight: 700;
47
- color: var(--text-primary);
48
- }
49
-
50
- .task-ref {
51
- font-size: 12px;
52
- color: var(--text-secondary);
53
- margin-top: 4px;
54
- font-family: monospace;
55
- }
56
-
57
- .close-btn {
58
- background: none;
59
- border: none;
60
- color: var(--text-secondary);
61
- font-size: 20px;
62
- cursor: pointer;
63
- padding: 4px;
64
- }
65
-
66
- .panel-content {
67
- flex: 1;
68
- overflow-y: auto;
69
- padding: 20px;
70
- }
71
-
72
- .attempt-selector {
73
- margin-bottom: 20px;
74
- padding: 12px;
75
- background: var(--bg-tertiary);
76
- border-radius: 12px;
77
- }
78
-
79
- .selector-label {
80
- font-size: 12px;
81
- font-weight: 600;
82
- margin-bottom: 8px;
83
- color: var(--text-secondary);
84
- display: block;
85
- }
86
-
87
- .attempt-list {
88
- display: flex;
89
- gap: 8px;
90
- overflow-x: auto;
91
- padding-bottom: 4px;
92
- }
93
-
94
- .attempt-pill {
95
- padding: 6px 12px;
96
- border-radius: 20px;
97
- font-size: 12px;
98
- cursor: pointer;
99
- white-space: nowrap;
100
- transition: all 0.2s;
101
- border: 1px solid var(--border-primary);
102
- background: var(--bg-secondary);
103
- color: var(--text-primary);
104
- }
105
-
106
- .attempt-pill.active {
107
- background: var(--color-accent);
108
- color: #fff;
109
- border-color: var(--color-accent);
110
- }
111
-
112
- .info-grid {
113
- display: grid;
114
- grid-template-columns: 1fr 1fr;
115
- gap: 16px;
116
- margin-bottom: 24px;
117
- }
118
-
119
- .info-item label {
120
- font-size: 11px;
121
- color: var(--text-secondary);
122
- text-transform: uppercase;
123
- letter-spacing: 0.5px;
124
- display: block;
125
- margin-bottom: 4px;
126
- }
127
-
128
- .info-item span {
129
- font-weight: 600;
130
- color: var(--text-primary);
131
- }
132
-
133
- .status-badge {
134
- display: inline-flex;
135
- align-items: center;
136
- gap: 6px;
137
- padding: 4px 10px;
138
- border-radius: 6px;
139
- font-size: 12px;
140
- font-weight: 700;
141
- }
142
-
143
- .tabs {
144
- display: flex;
145
- border-bottom: 1px solid var(--border-primary);
146
- margin-bottom: 20px;
147
- }
148
-
149
- .tab-btn {
150
- padding: 10px 20px;
151
- background: none;
152
- border: none;
153
- border-bottom: 2px solid transparent;
154
- color: var(--text-secondary);
155
- cursor: pointer;
156
- font-size: 13px;
157
- transition: all 0.2s;
158
- }
159
-
160
- .tab-btn.active {
161
- color: var(--color-accent);
162
- border-bottom-color: var(--color-accent);
163
- font-weight: 600;
164
- }
165
-
166
- .json-block {
167
- background: var(--bg-tertiary);
168
- padding: 16px;
169
- border-radius: 12px;
170
- font-family: 'Fira Code', monospace;
171
- font-size: 12px;
172
- line-height: 1.5;
173
- overflow: auto;
174
- max-height: 300px;
175
- color: var(--text-primary);
176
- }
177
-
178
- .error-message {
179
- margin-top: 16px;
180
- padding: 12px;
181
- background: rgba(239, 68, 68, 0.1);
182
- border-left: 3px solid var(--status-failed);
183
- border-radius: 4px;
184
- font-size: 12px;
185
- color: var(--status-failed);
186
- }
187
- `}),f.jsxs("div",{className:"panel-header",children:[f.jsxs("div",{children:[f.jsx("h3",{className:"task-title",children:e.name}),f.jsx("div",{className:"task-ref",children:e.taskReferenceName})]}),f.jsx("button",{className:"close-btn",onClick:p,children:"✕"})]}),f.jsxs("div",{className:"panel-content",children:[d.length>1&&f.jsxs("div",{className:"attempt-selector",children:[f.jsxs("label",{className:"selector-label",children:["执行记录 (",d.length," 次尝试",d.some(g=>g.iteration)?" / 迭代":"",")"]}),f.jsx("div",{className:"attempt-list",children:d.map((g,v)=>f.jsx("div",{className:`attempt-pill ${l?.taskId===g.taskId?"active":""}`,onClick:()=>n(g),children:g.iteration?`迭代 ${g.iteration}`:`尝试 ${v+1}`},g.taskId))})]}),f.jsxs("div",{className:"tabs",children:[f.jsx("button",{className:`tab-btn ${o==="summary"?"active":""}`,onClick:()=>s("summary"),children:"概览"}),f.jsx("button",{className:`tab-btn ${o==="input"?"active":""}`,onClick:()=>s("input"),children:"输入 (JSON)"}),f.jsx("button",{className:`tab-btn ${o==="output"?"active":""}`,onClick:()=>s("output"),children:"输出 (JSON)"})]}),o==="summary"&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"info-grid",children:[f.jsxs("div",{className:"info-item",children:[f.jsx("label",{children:"执行状态"}),f.jsxs("div",{className:"status-badge",style:{background:`${m(c?i?.status:l?.status)}20`,color:m(c?i?.status:l?.status)},children:["● ",c?i?.status:l?.status]})]}),f.jsxs("div",{className:"info-item",children:[f.jsx("label",{children:"总耗时"}),f.jsx("span",{children:c?h(i?.startTime,i?.endTime):h(l?.startTime,l?.endTime)})]}),f.jsxs("div",{className:"info-item",children:[f.jsx("label",{children:"开始时间"}),f.jsx("span",{style:{fontSize:"12px"},children:(c?i?.startTime:l?.startTime)?new Date((c?i?.startTime:l?.startTime)||0).toLocaleTimeString():"-"})]}),f.jsxs("div",{className:"info-item",children:[f.jsx("label",{children:"结束时间"}),f.jsx("span",{style:{fontSize:"12px"},children:(c?i?.endTime:l?.endTime)?new Date((c?i?.endTime:l?.endTime)||0).toLocaleTimeString():"-"})]})]}),(c?i?.reasonForIncompletion:l?.reasonForIncompletion)&&f.jsxs("div",{className:"error-message",children:[f.jsx("strong",{children:"异常信息:"}),f.jsx("div",{style:{marginTop:"4px"},children:c?i?.reasonForIncompletion:l?.reasonForIncompletion})]}),f.jsxs("div",{className:"info-item",style:{marginTop:"20px"},children:[f.jsx("label",{children:c?"Workflow ID":"Task ID"}),f.jsx("span",{style:{fontSize:"11px",fontFamily:"monospace",opacity:.7},children:c?i?.workflowId:l?.taskId})]})]}),o==="input"&&f.jsx("div",{className:"json-block",children:f.jsx("pre",{children:JSON.stringify(c?i?.input:l?.inputData||{},null,2)})}),o==="output"&&f.jsx("div",{className:"json-block",children:f.jsx("pre",{children:JSON.stringify(c?i?.output:l?.outputData||{},null,2)})})]})]})},Dy=()=>{const{executionData:e,loadSampleExecution:t,importExecutionJSON:r,workflowInstance:n,setSelectedTask:a,nodes:i}=V(),{fitView:o}=q.useReactFlow(),s=m=>{const g=m.target.files?.[0];if(g){const v=new FileReader;v.onload=x=>{try{const b=JSON.parse(x.target?.result);r(b)}catch(b){console.error("Failed to parse execution JSON:",b)}},v.readAsText(g)}};if(!e)return f.jsxs("div",{className:"execution-status-bar",children:[f.jsx("input",{type:"file",id:"execution-json-upload",accept:".json",onChange:s,style:{display:"none"}}),f.jsx("div",{className:"status-item",children:f.jsx("span",{className:"status-label",children:"准备就绪"})}),f.jsxs("div",{style:{display:"flex",gap:"8px"},children:[f.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:"🚀 加载示例运行"}),f.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"),l=d.length,p=c.filter(m=>m.status==="IN_PROGRESS"||m.status==="SCHEDULED").length,h=D.useCallback(()=>{if(l===0)return;const m=new Set(d.map(v=>v.taskReferenceName)),g=i.filter(v=>m.has(v.data?.taskReferenceName)).map(v=>v.id);g.length>0&&o({nodes:g.map(v=>({id:v})),duration:500,padding:.3})},[d,i,o,l]);return f.jsxs("div",{className:"execution-status-bar",children:[n&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"status-item",children:[f.jsx("span",{className:"status-label",children:" Workflow ID:"}),f.jsx("span",{className:"status-value highlight",style:{color:"var(--text-primary)",opacity:.8},children:n.workflowId})]}),f.jsx("div",{className:"status-divider"})]}),f.jsxs("div",{className:"status-item",children:[f.jsx("span",{className:"status-label",children:"状态:"}),f.jsx("span",{className:"status-value highlight",style:{color:n?.status==="COMPLETED"?"var(--status-completed)":"var(--status-in-progress)"},children:n?.status||"运行中"})]}),f.jsx("div",{className:"status-divider"}),f.jsxs("div",{className:"status-item",children:[f.jsx("span",{className:"status-label",children:"已完成:"}),f.jsx("span",{className:"status-value",children:u})]}),f.jsxs("div",{className:"status-item",onClick:l>0?h:void 0,style:{cursor:l>0?"pointer":"default",borderRadius:"4px",padding:"2px 6px",transition:"background 0.2s",...l>0?{background:"rgba(239, 68, 68, 0.1)"}:{}},title:l>0?"点击聚焦失败节点":void 0,children:[f.jsx("span",{className:"status-label",style:{color:"var(--status-failed)"},children:"失败:"}),f.jsx("span",{className:"status-value",style:{color:"var(--status-failed)"},children:l})]}),f.jsxs("div",{className:"status-item",children:[f.jsx("span",{className:"status-label",style:{color:"var(--status-in-progress)"},children:"处理中:"}),f.jsx("span",{className:"status-value",style:{color:"var(--status-in-progress)"},children:p})]}),f.jsx("div",{className:"status-divider"}),f.jsx("div",{style:{display:"flex",gap:"8px"},children:f.jsx("button",{onClick:()=>{a({name:"Workflow Global Data",taskReferenceName:"__workflow_global__",type:"SIMPLE"})},style:{background:"rgba(255,255,255,0.05)",color:"var(--text-primary)",border:"1px solid var(--border-primary)",padding:"4px 10px",borderRadius:"6px",cursor:"pointer",fontSize:"11px",fontWeight:"600"},children:"🔍 全局 I/O"})})]})},lh=({isOpen:e,onClose:t,theme:r="dark",onTaskSelect:n})=>{const{validationResults:a,setSelectedTask:i,taskMap:o}=V(),{errors:s,warnings:c}=a||{errors:[],warnings:[]},u=m=>{if(m&&m!=="UNKNOWN"){const g=o[m];g&&(n?n(g):i(g))}},d="var(--glass-surface)",l="var(--text-primary)",p="var(--glass-border)",h="var(--text-secondary)";return e?f.jsxs("div",{style:{position:"absolute",top:"80px",right:"24px",width:"320px",maxHeight:"500px",backgroundColor:d,border:`1px solid ${p}`,borderRadius:"12px",boxShadow:"0 10px 25px rgba(0,0,0,0.2)",zIndex:1100,display:"flex",flexDirection:"column",overflow:"hidden",animation:"fadeInSlide 0.2s ease-out"},children:[f.jsx("style",{children:`
22
+ `})]})},gx=()=>{const{executionData:e,loadSampleExecution:r,importExecutionJSON:t,workflowInstance:n,setSelectedTask:o,nodes:a}=oe(),{fitView:i}=O.useReactFlow(),s=g=>{const v=g.target.files?.[0];if(v){const m=new FileReader;m.onload=x=>{try{const y=JSON.parse(x.target?.result);t(y)}catch(y){console.error("Failed to parse execution JSON:",y)}},m.readAsText(v)}};if(!e)return d.jsxs("div",{className:"execution-status-bar",children:[d.jsx("input",{type:"file",id:"execution-json-upload",accept:".json",onChange:s,style:{display:"none"}}),d.jsx("div",{className:"status-item",children:d.jsx("span",{className:"status-label",children:"准备就绪"})}),d.jsxs("div",{style:{display:"flex",gap:"8px"},children:[d.jsx("button",{onClick:r,style:{background:"var(--color-accent)",color:"#fff",border:"none",padding:"6px 14px",borderRadius:"8px",cursor:"pointer",fontSize:"13px",fontWeight:"600",boxShadow:"0 4px 12px rgba(0,0,0,0.2)",transition:"all 0.2s ease"},children:"🚀 加载示例运行"}),d.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 l=Object.values(e),u=l.filter(g=>g.status==="COMPLETED").length,c=l.filter(g=>g.status==="FAILED"||g.status==="FAILED_WITH_TERMINAL_ERROR"||g.status==="TIMED_OUT"),f=c.length,p=l.filter(g=>g.status==="IN_PROGRESS"||g.status==="SCHEDULED").length,h=q.useCallback(()=>{if(f===0)return;const g=new Set(c.map(m=>m.taskReferenceName)),v=a.filter(m=>g.has(m.data?.taskReferenceName)).map(m=>m.id);v.length>0&&i({nodes:v.map(m=>({id:m})),duration:500,padding:.3})},[c,a,i,f]);return d.jsxs("div",{className:"execution-status-bar",children:[n&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"status-item",children:[d.jsx("span",{className:"status-label",children:" Workflow ID:"}),d.jsx("span",{className:"status-value highlight",style:{color:"var(--text-primary)",opacity:.8},children:n.workflowId})]}),d.jsx("div",{className:"status-divider"})]}),d.jsxs("div",{className:"status-item",children:[d.jsx("span",{className:"status-label",children:"状态:"}),d.jsx("span",{className:"status-value highlight",style:{color:n?.status==="COMPLETED"?"var(--status-completed)":"var(--status-in-progress)"},children:n?.status||"运行中"})]}),d.jsx("div",{className:"status-divider"}),d.jsxs("div",{className:"status-item",children:[d.jsx("span",{className:"status-label",children:"已完成:"}),d.jsx("span",{className:"status-value",children:u})]}),d.jsxs("div",{className:"status-item",onClick:f>0?h:void 0,style:{cursor:f>0?"pointer":"default",borderRadius:"4px",padding:"2px 6px",transition:"background 0.2s",...f>0?{background:"rgba(239, 68, 68, 0.1)"}:{}},title:f>0?"点击聚焦失败节点":void 0,children:[d.jsx("span",{className:"status-label",style:{color:"var(--status-failed)"},children:"失败:"}),d.jsx("span",{className:"status-value",style:{color:"var(--status-failed)"},children:f})]}),d.jsxs("div",{className:"status-item",children:[d.jsx("span",{className:"status-label",style:{color:"var(--status-in-progress)"},children:"处理中:"}),d.jsx("span",{className:"status-value",style:{color:"var(--status-in-progress)"},children:p})]}),d.jsx("div",{className:"status-divider"}),d.jsx("div",{style:{display:"flex",gap:"8px"},children:d.jsx("button",{onClick:()=>{o({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"})})]})},Oh=({isOpen:e,onClose:r,theme:t="dark",onTaskSelect:n})=>{const{validationResults:o,setSelectedTask:a,taskMap:i}=oe(),{errors:s,warnings:l}=o||{errors:[],warnings:[]},u=g=>{if(g&&g!=="UNKNOWN"){const v=i[g];v&&(n?n(v):a(v))}},c="var(--glass-surface)",f="var(--text-primary)",p="var(--glass-border)",h="var(--text-secondary)";return e?d.jsxs("div",{style:{position:"absolute",top:"80px",right:"24px",width:"320px",maxHeight:"500px",backgroundColor:c,border:`1px solid ${p}`,borderRadius:"12px",boxShadow:"0 10px 25px rgba(0,0,0,0.2)",zIndex:1100,display:"flex",flexDirection:"column",overflow:"hidden",animation:"fadeInSlide 0.2s ease-out"},children:[d.jsx("style",{children:`
188
23
  @keyframes fadeInSlide {
189
24
  from { opacity: 0; transform: translateY(-10px); }
190
25
  to { opacity: 1; transform: translateY(0); }
191
26
  }
192
27
  .health-item:hover {
193
- background-color: ${r==="light"?"#f1f5f9":"rgba(255,255,255,0.05)"};
28
+ background-color: ${t==="light"?"#f1f5f9":"rgba(255,255,255,0.05)"};
194
29
  }
195
- `}),f.jsxs("div",{style:{padding:"16px",borderBottom:`1px solid ${p}`,display:"flex",justifyContent:"space-between",alignItems:"center",backgroundColor:"rgba(0,0,0,0.02)"},children:[f.jsxs("div",{style:{fontWeight:"bold",fontSize:"14px",display:"flex",alignItems:"center",gap:"8px"},children:[f.jsx("span",{children:"🩺"})," 工作流体检报告"]}),f.jsx("button",{onClick:t,style:{background:"none",border:"none",color:h,cursor:"pointer",fontSize:"18px"},children:"✕"})]}),f.jsx("div",{style:{flex:1,overflowY:"auto",padding:"8px"},children:s.length===0&&c.length===0?f.jsxs("div",{style:{padding:"32px 16px",textAlign:"center",color:"#10b981"},children:[f.jsx("div",{style:{fontSize:"32px",marginBottom:"12px"},children:"✅"}),f.jsx("div",{style:{fontWeight:"bold"},children:"未发现问题"}),f.jsx("div",{style:{fontSize:"12px",opacity:.7,marginTop:"4px"},children:"工作流逻辑看起来很完美"})]}):f.jsxs(f.Fragment,{children:[s.map((m,g)=>f.jsxs("div",{className:"health-item",role:"button",tabIndex:m.ref?0:void 0,onKeyDown:v=>{(v.key==="Enter"||v.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:[f.jsxs("div",{style:{fontSize:"12px",color:"#ef4444",fontWeight:"bold",marginBottom:"2px"},children:["ERROR ",m.ref!=="UNKNOWN"&&`[${m.ref}]`]}),f.jsx("div",{style:{fontSize:"13px",color:l},children:m.message})]},`err-${g}`)),c.map((m,g)=>f.jsxs("div",{className:"health-item",role:"button",tabIndex:m.ref?0:void 0,onKeyDown:v=>{(v.key==="Enter"||v.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:[f.jsxs("div",{style:{fontSize:"12px",color:"#f59e0b",fontWeight:"bold",marginBottom:"2px"},children:["WARNING ",m.ref!=="UNKNOWN"&&`[${m.ref}]`]}),f.jsx("div",{style:{fontSize:"13px",color:l},children:m.message})]},`warn-${g}`))]})}),f.jsxs("div",{style:{padding:"12px 16px",fontSize:"11px",color:h,borderTop:`1px solid ${p}`,backgroundColor:"rgba(0,0,0,0.02)",display:"flex",justifyContent:"space-between"},children:[f.jsxs("span",{children:["共 ",s.length," 个错误, ",c.length," 个警告"]}),s.length>0&&f.jsx("span",{style:{color:"#ef4444"},children:"无法保存/导出"})]})]}):null},My=({id:e,source:t,target:r,sourceX:n,sourceY:a,targetX:i,targetY:o,sourcePosition:s,targetPosition:c,style:u={},markerEnd:d,data:l})=>{const[p,h]=D.useState(!1),m=D.useRef(null),g=()=>{const E=l?.edgeType||"default",T={sourceX:n,sourceY:a,sourcePosition:s,targetX:i,targetY:o,targetPosition:c};switch(E){case"step":case"smoothstep":return q.getSmoothStepPath(T);case"straight":return q.getStraightPath(T);default:return q.getBezierPath(T)}},[v,x,b]=g(),_=E=>{E.stopPropagation(),E.preventDefault();const T=new CustomEvent("edgeAddNode",{detail:{id:e,source:t,target:r,edgeData:l}});window.dispatchEvent(T)},y=()=>{m.current&&clearTimeout(m.current),h(!0)},S=()=>{m.current=setTimeout(()=>{h(!1)},100)},w=l?.mode==="edit";return f.jsxs(f.Fragment,{children:[f.jsx(q.BaseEdge,{path:v,markerEnd:d,style:{...u,strokeWidth:p?4:2,stroke:p?"#fbbf24":u?.stroke,transition:"stroke 0.2s, stroke-width 0.2s",pointerEvents:"none"}}),f.jsx("path",{d:v,fill:"none",stroke:"transparent",strokeWidth:20,style:{cursor:w?"pointer":"default",pointerEvents:"all"},onMouseEnter:y,onMouseLeave:S}),w&&p&&f.jsx(q.EdgeLabelRenderer,{children:f.jsxs("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${x}px,${b}px)`,fontSize:12,pointerEvents:"all",zIndex:2e3,display:"flex",flexDirection:"column",alignItems:"center"},className:"nodrag nopan",onMouseEnter:y,onMouseLeave:S,children:[l?.label&&f.jsx("div",{style:{background:"var(--glass-bg-accent)",backdropFilter:"var(--glass-blur)",color:"var(--color-accent)",padding:"4px 10px",borderRadius:"6px",fontSize:"11px",fontWeight:"700",marginBottom:"8px",border:"1px solid var(--color-accent)",boxShadow:"0 4px 12px rgba(0,0,0,0.3)",whiteSpace:"nowrap",letterSpacing:"0.5px"},children:l.label}),f.jsx("button",{style:{width:"32px",height:"32px",backgroundColor:"var(--color-accent)",color:"#fff",border:"2px solid rgba(255,255,255,0.8)",borderRadius:"50%",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontWeight:"700",fontSize:"20px",boxShadow:"0 4px 15px rgba(var(--color-accent-rgb), 0.5)",transition:"all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275)",padding:0},className:"edge-add-button",onClick:_,onMouseDown:E=>E.stopPropagation(),title:"在此处添加任务",children:"+"})]})})]})},pe=({onClick:e,icon:t,label:r,title:n,disabled:a=!1,active:i=!1,variant:o="default",style:s})=>{let c="var(--bg-tertiary)",u="var(--text-primary)",d="1px solid var(--border-primary)";return o==="primary"?(c="var(--color-accent)",u="#fff",d="none"):o==="danger"?(c=a?"rgba(239, 68, 68, 0.1)":"var(--status-failed)",u=a?"var(--text-secondary)":"#fff",d="none"):i&&(c="var(--bg-secondary)",u="var(--color-accent)",d="1px solid var(--color-accent)"),f.jsxs("button",{onClick:e,disabled:a,title:n,"aria-label":n||r,"aria-pressed":i,"aria-disabled":a,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:r?"6px":"0",background:c,color:u,border:d,borderRadius:"6px",padding:r?"6px 12px":"8px",cursor:a?"not-allowed":"pointer",opacity:a?.5:1,fontSize:"13px",fontWeight:500,transition:"all 0.2s",minWidth:r?"auto":"32px",height:"32px",boxShadow:o==="default"?"0 1px 2px rgba(0,0,0,0.05)":"none",...s},children:[t&&f.jsx("span",{style:{fontSize:"14px",display:"flex"},children:t}),r&&f.jsx("span",{children:r})]})},By=()=>{const{zoomIn:e,zoomOut:t,fitView:r}=q.useReactFlow();return f.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"10px"},children:f.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:[f.jsx(pe,{icon:"➕",title:"放大",onClick:()=>e()}),f.jsx(pe,{icon:"➖",title:"缩小",onClick:()=>t()}),f.jsx(pe,{icon:"⤢",title:"适应屏幕",onClick:()=>r({duration:600})})]})})},Wy=({onShowHealthCheck:e,showHealthCheck:t,onShowSettings:r,executionActions:n})=>{const{mode:a,validationResults:i,workflowInstance:o,workflowDef:s}=V(),c=V.temporal,{undo:u,redo:d,pastStates:l,futureStates:p}=jr(c,v=>v),h=(i?.errors?.length||0)>0,m=o?.status,g=o?.workflowId??"";return f.jsxs("div",{className:"action-bar",style:{display:"flex",gap:"8px"},children:[a==="edit"&&f.jsxs(f.Fragment,{children:[f.jsx(pe,{icon:"↺",title:"撤销 (Cmd+Z)",onClick:()=>u(),disabled:l.length===0}),f.jsx(pe,{icon:"↻",title:"重做 (Cmd+Shift+Z)",onClick:()=>d(),disabled:p.length===0}),f.jsx("div",{style:{width:"1px",height:"20px",background:"var(--border-primary)",margin:"0 4px",alignSelf:"center"}}),f.jsx(pe,{icon:"🩺",label:h?`错误 (${i.errors.length})`:"诊断",title:"流程健康检查",onClick:e,active:t,variant:h?"danger":"secondary"}),f.jsx(pe,{icon:"⚙️",label:"配置",title:"工作流全局配置",onClick:()=>r?.()})]}),a==="run"&&o&&n&&f.jsx(f.Fragment,{children:m==="PAUSED"?n.onResume&&f.jsx(pe,{icon:"▶️",label:"恢复",title:"恢复执行",onClick:()=>n.onResume(g),variant:"primary"}):f.jsxs(f.Fragment,{children:[n.onPause&&m==="RUNNING"&&f.jsx(pe,{icon:"⏸️",label:"暂停",title:"暂停执行",onClick:()=>n.onPause(g)}),n.onTerminate&&m==="RUNNING"&&f.jsx(pe,{icon:"⏹️",label:"停止",title:"终止执行",onClick:()=>n.onTerminate(g),variant:"danger"}),n.onRetry&&(m==="FAILED"||m==="TIMED_OUT"||m==="TERMINATED")&&f.jsx(pe,{icon:"🔄",label:"重试",title:"重试执行",onClick:()=>n.onRetry(g),variant:"primary"}),n.onRestart&&s?.restartable===!0&&f.jsx(pe,{icon:"◀️",label:"重启",title:"重启执行",onClick:()=>n.onRestart(g)})]})})]})},Fy=[{id:"basic",label:"基本信息"},{id:"timeout",label:"超时与容错"},{id:"params",label:"参数配置"},{id:"advanced",label:"高级设置"}],$y=({isOpen:e,onClose:t})=>{const{workflowDef:r,updateWorkflowProperties:n,mode:a}=V(),[i,o]=D.useState(r),[s,c]=D.useState("basic"),u=a!=="edit";D.useEffect(()=>{r&&o(r)},[r,e]);const d=D.useCallback(N=>{N.key==="Escape"&&t()},[t]);if(D.useEffect(()=>{if(e)return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[e,d]),!e||!i)return null;const l="var(--text-primary)",p="var(--glass-border)",h="var(--bg-tertiary)",m="var(--text-secondary)",g=(N,M)=>{if(!i||u)return;const L={...i,[N]:M};o(L),n({[N]:M})},v=(N,M,L)=>{if(!i||u)return;const U={...i[N]||{},[M]:L};o(W=>({...W,[N]:U})),n({[N]:U})},x=(N,M)=>{if(!(!i||u))try{const L=JSON.parse(M),$={...i,[N]:L};o($),n({[N]:L})}catch{o(L=>({...L,[`_${N}_str`]:M}))}},b={width:"100%",padding:"10px 14px",borderRadius:"8px",border:`1px solid ${p}`,background:h,color:l,fontSize:"14px",outline:"none",boxSizing:"border-box"},_={display:"block",fontSize:"11px",color:m,marginBottom:"8px",fontWeight:600},y=(N,M,L="text",$)=>f.jsxs("div",{style:{marginBottom:"20px"},children:[f.jsx("label",{style:_,children:N.toUpperCase()}),f.jsx("input",{className:"wsp-input",type:L,value:i?.[M]??"",onChange:U=>g(M,L==="number"?U.target.value===""?0:parseInt(U.target.value):U.target.value),disabled:u||$?.readOnly,placeholder:$?.placeholder,style:{...b,opacity:u||$?.readOnly?.6:1}})]}),S=(N,M,L=!1,$=6)=>{const U=i?.[`_${M}_str`]!==void 0?i[`_${M}_str`]:typeof i?.[M]=="object"?JSON.stringify(i[M],null,2):i?.[M];return f.jsxs("div",{style:{marginBottom:"20px"},children:[f.jsxs("label",{style:_,children:[N.toUpperCase()," ",L&&"(JSON)"]}),f.jsx("textarea",{className:"wsp-input",value:U||"",onChange:W=>L?x(M,W.target.value):g(M,W.target.value),rows:$,disabled:u,style:{...b,fontSize:"13px",fontFamily:L?"var(--font-mono)":"inherit",resize:"vertical",opacity:u?.6:1}})]})},w=(N,M,L)=>f.jsxs("div",{style:{marginBottom:"20px"},children:[f.jsx("label",{style:_,children:N.toUpperCase()}),f.jsx("select",{className:"wsp-input",value:i?.[M]??L[0]?.value,onChange:$=>g(M,$.target.value),disabled:u,style:{...b,opacity:u?.6:1,cursor:u?"not-allowed":"pointer"},children:L.map($=>f.jsx("option",{value:$.value,children:$.label},$.value))})]}),E=(N,M)=>{const L=!!i?.[M];return f.jsxs("div",{style:{marginBottom:"20px",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[f.jsx("label",{style:{fontSize:"13px",color:l},children:N}),f.jsx("button",{type:"button",role:"switch","aria-checked":L,onClick:()=>!u&&g(M,!L),disabled:u,style:{width:"44px",height:"24px",borderRadius:"12px",border:"none",background:L?"var(--color-accent)":"var(--border-primary)",position:"relative",cursor:u?"not-allowed":"pointer",transition:"background 0.2s",opacity:u?.6:1,flexShrink:0},children:f.jsx("span",{style:{position:"absolute",top:"2px",left:L?"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)"}})})]})},T=()=>f.jsxs(f.Fragment,{children:[f.jsxs("div",{style:{display:"grid",gridTemplateColumns:"3fr 1fr",gap:"20px"},children:[y("工作流名称","name"),y("版本号","version","number")]}),S("描述信息","description",!1,3),y("负责人邮箱","ownerEmail","text",{placeholder:"owner@example.com"}),y("Schema 版本","schemaVersion","number",{readOnly:!0})]}),C=()=>f.jsxs(f.Fragment,{children:[w("超时策略","timeoutPolicy",[{value:"ALERT_ONLY",label:"ALERT_ONLY — 仅告警"},{value:"TIME_OUT_WF",label:"TIME_OUT_WF — 超时终止"}]),f.jsxs("div",{children:[y("超时秒数","timeoutSeconds","number",{placeholder:"0 表示不超时"}),i?.timeoutPolicy==="ALERT_ONLY"&&f.jsx("p",{style:{fontSize:"11px",color:m,marginTop:"-12px",marginBottom:"20px"},children:"当前策略为 ALERT_ONLY,超时仅触发告警,不会终止工作流。"})]}),y("失败补偿工作流","failureWorkflow","text",{placeholder:"输入补偿工作流名称"}),E("允许重启 (restartable)","restartable")]}),R=()=>f.jsxs(f.Fragment,{children:[S("输入参数声明 (inputParameters)","inputParameters",!0),S("输出参数映射 (outputParameters)","outputParameters",!0),S("默认输入模板 (inputTemplate)","inputTemplate",!0),S("工作流级变量 (variables)","variables",!0)]}),A=()=>f.jsxs(f.Fragment,{children:[E("启用状态监听 (workflowStatusListenerEnabled)","workflowStatusListenerEnabled"),i?.workflowStatusListenerEnabled&&y("状态事件目标 (Listener Sink)","workflowStatusListenerSink","text",{placeholder:"conductor:workflow_status_event"}),f.jsxs("div",{style:{borderTop:`1px solid ${p}`,marginTop:"8px",paddingTop:"20px"},children:[E("强制 Schema 校验 (enforceSchema)","enforceSchema"),i?.enforceSchema&&f.jsxs(f.Fragment,{children:[S("输入 Schema (inputSchema)","inputSchema",!0,4),S("输出 Schema (outputSchema)","outputSchema",!0,4)]})]}),f.jsxs("div",{style:{borderTop:`1px solid ${p}`,marginTop:"8px",paddingTop:"20px"},children:[f.jsx("label",{style:{..._,marginBottom:"16px"},children:"并发限流 (RATE LIMIT)"}),f.jsxs("div",{style:{display:"grid",gridTemplateColumns:"2fr 1fr",gap:"20px"},children:[f.jsxs("div",{children:[f.jsx("label",{style:_,children:"RATE LIMIT KEY"}),f.jsx("input",{className:"wsp-input",type:"text",value:i?.rateLimitConfig?.rateLimitKey??"",onChange:N=>v("rateLimitConfig","rateLimitKey",N.target.value),disabled:u,placeholder:"限流键",style:{...b,opacity:u?.6:1}})]}),f.jsxs("div",{children:[f.jsx("label",{style:_,children:"并发上限"}),f.jsx("input",{className:"wsp-input",type:"number",value:i?.rateLimitConfig?.concurrentExecLimit??"",onChange:N=>v("rateLimitConfig","concurrentExecLimit",N.target.value===""?0:parseInt(N.target.value)),disabled:u,placeholder:"0",style:{...b,opacity:u?.6:1}})]})]})]})]}),B=()=>{switch(s){case"basic":return T();case"timeout":return C();case"params":return R();case"advanced":return A()}};return f.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:f.jsxs("div",{onClick:N=>N.stopPropagation(),style:{width:"680px",maxHeight:"85vh",background:"var(--glass-surface)",borderRadius:"16px",boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.5)",display:"flex",flexDirection:"column",overflow:"hidden",animation:"slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1)",border:`1px solid ${p}`,backdropFilter:"blur(20px)"},children:[f.jsxs("div",{style:{padding:"24px 32px 0 32px",background:"var(--bg-highlight)"},children:[f.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px"},children:[f.jsxs("div",{children:[f.jsx("h2",{style:{margin:0,fontSize:"20px",color:l},children:"工作流全局配置"}),f.jsx("p",{style:{margin:"4px 0 0 0",fontSize:"12px",color:m},children:u?"当前为只读模式":"配置工作流级属性,所有更改将实时保存"})]}),f.jsx("button",{className:"wsp-close",onClick:t,"aria-label":"关闭",style:{background:"none",border:"none",color:l,fontSize:"24px",cursor:"pointer",opacity:.6},children:"✕"})]}),f.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${p}`},children:Fy.map(N=>f.jsx("button",{className:"wsp-tab",onClick:()=>c(N.id),style:{padding:"10px 20px",fontSize:"13px",fontWeight:s===N.id?600:400,color:s===N.id?"var(--color-accent)":m,background:"none",border:"none",borderBottom:s===N.id?"2px solid var(--color-accent)":"2px solid transparent",cursor:"pointer",transition:"all 0.2s",marginBottom:"-1px"},children:N.label},N.id))})]}),f.jsx("div",{style:{flex:1,overflowY:"auto",padding:"28px 32px"},children:B()}),f.jsx("div",{style:{padding:"20px 32px",borderTop:`1px solid ${p}`,background:"var(--bg-highlight)",display:"flex",justifyContent:"flex-end"},children:f.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:"完成并关闭"})})]})})},zy=({onRequestImport:e})=>{const{createBlankWorkflow:t}=V(),[r,n]=D.useState(""),a=()=>{t(r||void 0),V.temporal.getState().clear()},i=()=>{t(r||void 0),V.temporal.getState().clear(),window.dispatchEvent(new CustomEvent("open-ai-chat"))};return f.jsxs("div",{className:"empty-state-panel",children:[f.jsx("h2",{className:"empty-state-title",children:"创建新工作流"}),f.jsx("p",{className:"empty-state-subtitle",children:"从空白画布开始设计,或让 AI 帮你生成完整流程"}),f.jsx("input",{className:"empty-state-name-input",type:"text",placeholder:"工作流名称(可选)",value:r,onChange:o=>n(o.target.value),onKeyDown:o=>{o.key==="Enter"&&a()}}),f.jsxs("div",{className:"empty-state-actions",children:[f.jsxs("button",{className:"empty-state-btn primary",onClick:a,children:[f.jsx("span",{className:"empty-state-btn-icon",children:"📄"}),"空白工作流"]}),f.jsxs("button",{className:"empty-state-btn",onClick:i,children:[f.jsx("span",{className:"empty-state-btn-icon",children:"✨"}),"AI 生成"]}),e&&f.jsxs("button",{className:"empty-state-btn",onClick:e,children:[f.jsx("span",{className:"empty-state-btn-icon",children:"📤"}),"导入 JSON"]})]})]})},Hy={success:{bg:"#10b981",text:"#fff"},error:{bg:"#ef4444",text:"#fff"},info:{bg:"var(--color-accent)",text:"#fff"}},Gy=({messages:e,onDismiss:t})=>e.length===0?null:f.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=>f.jsx(Uy,{message:r,onDismiss:t},r.id))}),Uy=({message:e,onDismiss:t})=>{const r=Hy[e.type||"info"];return D.useEffect(()=>{const n=setTimeout(()=>t(e.id),2500);return()=>clearTimeout(n)},[e.id,t]),f.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})},fh=["shift","alt","meta","mod","ctrl","control"],Ky={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 Ee(e){return(Ky[e.trim()]||e.trim()).toLowerCase().replace(/key|digit|numpad/,"")}function ph(e){return fh.includes(e)}function bs(e,t=","){return e.toLowerCase().split(t)}function xs(e,t="+",r=">",n=!1,a){let i=[],o=!1;e=e.trim(),e.includes(r)?(o=!0,i=e.toLocaleLowerCase().split(r).map(u=>Ee(u))):i=e.toLocaleLowerCase().split(t).map(u=>Ee(u));const s={alt:i.includes("alt"),ctrl:i.includes("ctrl")||i.includes("control"),shift:i.includes("shift"),meta:i.includes("meta"),mod:i.includes("mod"),useKey:n},c=i.filter(u=>!fh.includes(u));return{...s,keys:c,description:a,isSequence:o,hotkey:e}}typeof document<"u"&&(document.addEventListener("keydown",e=>{e.code!==void 0&&hh([Ee(e.code)])}),document.addEventListener("keyup",e=>{e.code!==void 0&&vh([Ee(e.code)])})),typeof window<"u"&&(window.addEventListener("blur",()=>{ke.clear()}),window.addEventListener("contextmenu",()=>{setTimeout(()=>{ke.clear()},0)}));const ke=new Set;function _s(e){return Array.isArray(e)}function Jy(e,t=","){return(_s(e)?e:e.split(t)).every(r=>ke.has(r.trim().toLowerCase()))}function hh(e){const t=Array.isArray(e)?e:[e];ke.has("meta")&&ke.forEach(r=>!ph(r)&&ke.delete(r.toLowerCase())),t.forEach(r=>ke.add(r.toLowerCase()))}function vh(e){const t=Array.isArray(e)?e:[e];e==="meta"?ke.clear():t.forEach(r=>ke.delete(r.toLowerCase()))}function Vy(e,t,r){(typeof r=="function"&&r(e,t)||r===!0)&&e.preventDefault()}function Yy(e,t,r){return typeof r=="function"?r(e,t):r===!0||r===void 0}const Xy=["input","textarea","select","searchbox","slider","spinbutton","menuitem","menuitemcheckbox","menuitemradio","option","radio","textbox"];function Zy(e){return gh(e,Xy)}function gh(e,t=!1){const{target:r,composed:n}=e;let a,i;return Qy(r)&&n?(a=e.composedPath()[0]&&e.composedPath()[0].tagName,i=e.composedPath()[0]&&e.composedPath()[0].role):(a=r&&r.tagName,i=r&&r.role),_s(t)?!!(a&&t&&t.some(o=>o.toLowerCase()===a.toLowerCase()||o===i)):!!(a&&t&&t)}function Qy(e){return!!e.tagName&&!e.tagName.startsWith("-")&&e.tagName.includes("-")}function eb(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 rb=(e,t,r=!1)=>{const{alt:n,meta:a,mod:i,shift:o,ctrl:s,keys:c,useKey:u}=t,{code:d,key:l,ctrlKey:p,metaKey:h,shiftKey:m,altKey:g}=e,v=Ee(d);if(u&&c?.length===1&&c.includes(l))return!0;if(!c?.includes(v)&&!["ctrl","control","unknown","meta","alt","shift","os"].includes(v))return!1;if(!r){if(n!==g&&v!=="alt"||o!==m&&v!=="shift")return!1;if(i){if(!h&&!p)return!1}else if(a!==h&&v!=="meta"&&v!=="os"||s!==p&&v!=="ctrl"&&v!=="control")return!1}return c&&c.length===1&&c.includes(v)?!0:c?Jy(c):!c},tb=D.createContext(void 0),nb=()=>D.useContext(tb);function mh(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&&mh(e[n],t[n]),!0):e===t}const ab=D.createContext({hotkeys:[],activeScopes:[],toggleScope:()=>{},enableScope:()=>{},disableScope:()=>{}}),ib=()=>D.useContext(ab);function ob(e){const t=D.useRef(void 0);return mh(t.current,e)||(t.current=e),t.current}const yh=e=>{e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation()},sb=typeof window<"u"?D.useLayoutEffect:D.useEffect;function ze(e,t,r,n){const a=D.useRef(null),i=D.useRef(!1),o=Array.isArray(r)?Array.isArray(n)?void 0:n:r,s=_s(e)?e.join(o?.delimiter):e,c=Array.isArray(r)?r:Array.isArray(n)?n:void 0,u=D.useCallback(t,c??[]),d=D.useRef(u);c?d.current=u:d.current=t;const l=ob(o),{activeScopes:p}=ib(),h=nb();return sb(()=>{if(l?.enabled===!1||!eb(p,l?.scopes))return;let m=[],g;const v=(y,S=!1)=>{if(!(Zy(y)&&!gh(y,l?.enableOnFormTags))){if(a.current!==null){const w=a.current.getRootNode();if((w instanceof Document||w instanceof ShadowRoot)&&w.activeElement!==a.current&&!a.current.contains(w.activeElement)){yh(y);return}}y.target?.isContentEditable&&!l?.enableOnContentEditable||bs(s,l?.delimiter).forEach(w=>{if(w.includes(l?.splitKey??"+")&&w.includes(l?.sequenceSplitKey??">")){console.warn(`Hotkey ${w} contains both ${l?.splitKey??"+"} and ${l?.sequenceSplitKey??">"} which is not supported.`);return}const E=xs(w,l?.splitKey,l?.sequenceSplitKey,l?.useKey,l?.description);if(E.isSequence){g=setTimeout(()=>{m=[]},l?.sequenceTimeoutMs??1e3);const T=E.useKey?y.key:Ee(y.code);if(ph(T.toLowerCase()))return;m.push(T);const C=E.keys?.[m.length-1];if(T!==C){m=[],g&&clearTimeout(g);return}m.length===E.keys?.length&&(d.current(y,E),g&&clearTimeout(g),m=[])}else if(rb(y,E,l?.ignoreModifiers)||E.keys?.includes("*")){if(l?.ignoreEventWhen?.(y)||S&&i.current)return;if(Vy(y,E,l?.preventDefault),!Yy(y,E,l?.enabled)){yh(y);return}d.current(y,E),S||(i.current=!0)}})}},x=y=>{y.code!==void 0&&(hh(Ee(y.code)),(l?.keydown===void 0&&l?.keyup!==!0||l?.keydown)&&v(y))},b=y=>{y.code!==void 0&&(vh(Ee(y.code)),i.current=!1,l?.keyup&&v(y,!0))},_=a.current||o?.document||document;return _.addEventListener("keyup",b,o?.eventListenerOptions),_.addEventListener("keydown",x,o?.eventListenerOptions),h&&bs(s,l?.delimiter).forEach(y=>h.addHotkey(xs(y,l?.splitKey,l?.sequenceSplitKey,l?.useKey,l?.description))),()=>{_.removeEventListener("keyup",b,o?.eventListenerOptions),_.removeEventListener("keydown",x,o?.eventListenerOptions),h&&bs(s,l?.delimiter).forEach(y=>h.removeHotkey(xs(y,l?.splitKey,l?.sequenceSplitKey,l?.useKey,l?.description))),m=[],g&&clearTimeout(g)}},[s,l,p]),a}const ub=e=>{const{mode:t,removeNode:r,selectedTask:n,pasteTask:a}=V(),i=V.temporal,{undo:o,redo:s}=jr(i,p=>p),c=e?.confirm||(p=>Promise.resolve(window.confirm(p))),u=e?.showToast,d=p=>{const h=p.target;return h.tagName==="INPUT"||h.tagName==="TEXTAREA"||h.isContentEditable},l=()=>{requestAnimationFrame(()=>{const p=V.getState(),{nodes:h,edges:m}=ae(p.nodes,p.edges,{direction:p.layoutDirection,mode:p.mode});V.setState({nodes:h,edges:m})})};return ze("mod+z",p=>{t==="edit"&&(d(p)||(p.preventDefault(),o(),l()))},[t,o]),ze(["mod+shift+z","mod+y"],p=>{t==="edit"&&(d(p)||(p.preventDefault(),s(),l()))},[t,s]),ze("delete, backspace",p=>{t!=="edit"||!n||d(p)||(p.preventDefault(),c("确定要删除此任务吗?").then(h=>{h&&r(n.taskReferenceName)}))},[t,n,r,c]),ze("mod+c",p=>{if(!(t!=="edit"||!n)&&!d(p)){if(n.type==="JOIN"){u?.("JOIN 任务不能独立复制","error");return}p.preventDefault();try{localStorage.setItem("conductor-clipboard",JSON.stringify(n)),u?.("任务已复制","success")}catch{u?.("复制失败","error")}}},[t,n,u]),ze("mod+v",p=>{if(t==="edit"&&!d(p)){p.preventDefault();try{const h=localStorage.getItem("conductor-clipboard");if(h){const m=JSON.parse(h);a(m),u?.("任务已粘贴","success")}}catch{u?.("粘贴失败","error")}}},[t,a,u]),ze("mod+s",p=>{p.preventDefault();const h=V.getState().workflowDef;h&&e?.onSave&&e.onSave(h)},[e?.onSave]),{}},cb=()=>{const[e,t]=D.useState(null),r=D.useCallback(i=>new Promise(o=>{t({message:i,resolve:o})}),[]),n=D.useCallback(()=>{e?.resolve(!0),t(null)},[e]),a=D.useCallback(()=>{e?.resolve(!1),t(null)},[e]);return{confirm:r,confirmState:e,handleConfirm:n,handleCancel:a}},db=()=>{const[e,t]=D.useState([]),r=D.useCallback((a,i="info")=>{const o=Date.now().toString();t(s=>[...s,{id:o,text:a,type:i}])},[]),n=D.useCallback(a=>{t(i=>i.filter(o=>o.id!==a))},[]);return{toasts:e,showToast:r,dismissToast:n}},lb={taskNode:Cy,decisionNode:Ry,forkNode:ch.ForkNode,joinNode:ch.JoinNode,loopNode:Oy,subWorkflowNode:Ay},fb={addableEdge:My},pb=({onNodeClick:e,searchQuery:t="",onSave:r,onRequestImport:n,executionActions:a})=>{const{nodes:i,edges:o,onNodesChange:s,onEdgesChange:c,onConnect:u,mode:d,selectedTask:l,setSelectedTask:p,theme:h,edgeType:m,addNode:g,nodesLocked:v,executionData:x,validationResults:b,setIsDetailPanelOpen:_,workflowDef:y}=V(),{fitView:S}=q.useReactFlow(),[w,E]=D.useState(!1),[T,C]=D.useState(null),[R,A]=D.useState(!1),[B,N]=D.useState(!1),{confirm:M,confirmState:L,handleConfirm:$,handleCancel:U}=cb(),{toasts:W,showToast:z,dismissToast:K}=db();ub({confirm:M,showToast:z,onSave:r}),D.useEffect(()=>{if(l){const k=i.find(I=>I.data.taskReferenceName===l.taskReferenceName);k&&S({nodes:[k],duration:800,padding:.5})}},[l?.taskReferenceName,S]),D.useEffect(()=>{const k=()=>{S({duration:800})};return window.addEventListener("workflow-zoom-to-fit",k),()=>window.removeEventListener("workflow-zoom-to-fit",k)},[S]),D.useEffect(()=>{const k=O=>{e&&O.detail&&O.detail.task&&e(O.detail.task)},I=O=>{d==="edit"&&(C({sourceId:O.detail.loopId,edgeData:{isLoopAdd:!0}}),E(!0))},P=O=>{d==="edit"&&(C({sourceId:O.detail.source,targetId:O.detail.target,edgeId:O.detail.id,edgeData:O.detail.edgeData}),E(!0))};return document.addEventListener("miniTaskClick",k),document.addEventListener("loopAddNodeRequested",I),window.addEventListener("edgeAddNode",P),()=>{document.removeEventListener("miniTaskClick",k),document.removeEventListener("loopAddNodeRequested",I),window.removeEventListener("edgeAddNode",P)}},[d,e]);const j=D.useCallback(k=>{if(T){const{sourceId:I,targetId:P,edgeId:O,edgeData:H}=T;g({data:{label:`New ${k}`,taskReferenceName:`${k.toLowerCase()}_${Date.now()}`,taskType:k}},I,P,O,H)}E(!1),C(null)},[T,g]),F=D.useMemo(()=>o.map(k=>{const I=k.id.includes("loop-back");let O={...{...k.style,stroke:h==="light"?"#475569":"#64748b",strokeWidth:2,strokeDasharray:I?"5,5":void 0}},H=!I;if(d==="run"&&x){const Z=x[k.source]?.status,ee=x[k.target]?.status,ce=Z==="COMPLETED"||k.source==="start";ce&&ee==="COMPLETED"?(O={...O,stroke:"var(--status-completed)",strokeWidth:4},H=!1):ce&&ee==="IN_PROGRESS"&&(O={...O,stroke:"var(--status-in-progress)",strokeWidth:4},H=!0)}return{...k,type:d==="edit"&&!I?"addableEdge":m,data:{...k.data,mode:d,edgeType:m,label:k.label},markerEnd:{type:q.MarkerType.ArrowClosed,width:20,height:20,color:O.stroke},style:O,animated:H}}),[o,m,h,d,x]);return f.jsxs("div",{style:{width:"100%",height:"100%",position:"relative",background:"var(--bg-secondary)"},children:[f.jsxs(q,{nodes:D.useMemo(()=>{const k=new Set(b.errors.filter(O=>O.type==="TASK").map(O=>O.ref)),I=new Set(b.warnings.filter(O=>O.type==="TASK").map(O=>O.ref)),P=t.toLowerCase();return i.map(O=>{const H=O.data.taskReferenceName;return{...O,selected:l?.taskReferenceName===H,data:{...O.data,isError:k.has(H),hasWarning:I.has(H),isHighlighted:t?O.data.label.toLowerCase().includes(P)||O.data.taskReferenceName.toLowerCase().includes(P):!1}}})},[i,b,t,l]),edges:F,onNodesChange:s,onEdgesChange:c,onConnect:u,nodeTypes:lb,edgeTypes:fb,onNodeClick:(k,I)=>{const P=I.data.task||null;p(P),e&&e(P)},onPaneClick:()=>{p(null),d!=="run"&&_(!1)},fitView:!0,nodesDraggable:!v,nodesConnectable:!v,elementsSelectable:!0,minZoom:.2,maxZoom:2,children:[f.jsx(q.Background,{color:"var(--border-primary)",gap:20}),f.jsx(q.Panel,{position:"bottom-left",style:{marginBottom:"20px",marginLeft:"20px",zIndex:1e3},children:f.jsx(By,{})}),d==="run"&&f.jsx(q.Panel,{position:"bottom-center",children:f.jsx(Dy,{})}),d==="run"&&f.jsx(dh,{}),f.jsx(lh,{isOpen:R,onClose:()=>A(!1),theme:h,onTaskSelect:k=>{p(k)}}),f.jsx("div",{style:{position:"absolute",top:20,right:20,zIndex:1e3},children:f.jsx(Wy,{onShowHealthCheck:()=>A(!R),showHealthCheck:R,onShowSettings:()=>N(!0),executionActions:a})})]}),!y&&f.jsx(zy,{onRequestImport:n}),w&&f.jsx(Ly,{theme:h,onSelect:j,onCancel:()=>E(!1)}),f.jsx($y,{isOpen:B,onClose:()=>N(!1)}),L&&f.jsx(Qp,{message:L.message,onConfirm:$,onCancel:U}),f.jsx(Gy,{messages:W,onDismiss:K})]})},bh={apiKey:"",baseUrl:"https://api.openai.com/v1",model:"gpt-4o"},hb=async(e,t={},r)=>{const n={...bh,...t};if(!n.apiKey)throw new Error("Please configure AI API Key in settings.");const a=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(!a.ok){const o=await a.json();throw new Error(o.error?.message||"AI request failed")}return(await a.json()).choices[0].message.content},vb=async(e,t={},r,n,a)=>{const i={...bh,...t};if(!i.apiKey)throw new Error("Please configure AI API Key in settings.");const o=await fetch(`${i.baseUrl}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i.apiKey}`},body:JSON.stringify({model:i.model,messages:e,temperature:.7,stream:!0}),signal:a});if(!o.ok){const d=await o.json();throw new Error(d.error?.message||"AI request failed")}const s=o.body?.getReader();if(!s)throw new Error("ReadableStream not supported");const c=new TextDecoder;let u="";for(;;){const{done:d,value:l}=await s.read();if(d)break;const h=c.decode(l,{stream:!0}).split(`
196
- `).filter(m=>m.trim()!=="");for(const m of h)if(m.startsWith("data: ")){const g=m.slice(6);if(g==="[DONE]")return u;try{const x=JSON.parse(g).choices?.[0]?.delta?.content;x&&(u+=x,r(x))}catch{console.warn("[AI SSE] malformed chunk:",g)}}}return u},gb=`
30
+ `}),d.jsxs("div",{style:{padding:"16px",borderBottom:`1px solid ${p}`,display:"flex",justifyContent:"space-between",alignItems:"center",backgroundColor:"rgba(0,0,0,0.02)"},children:[d.jsxs("div",{style:{fontWeight:"bold",fontSize:"14px",display:"flex",alignItems:"center",gap:"8px"},children:[d.jsx("span",{children:"🩺"})," 工作流体检报告"]}),d.jsx("button",{onClick:r,style:{background:"none",border:"none",color:h,cursor:"pointer",fontSize:"18px"},children:"✕"})]}),d.jsx("div",{style:{flex:1,overflowY:"auto",padding:"8px"},children:s.length===0&&l.length===0?d.jsxs("div",{style:{padding:"32px 16px",textAlign:"center",color:"#10b981"},children:[d.jsx("div",{style:{fontSize:"32px",marginBottom:"12px"},children:"✅"}),d.jsx("div",{style:{fontWeight:"bold"},children:"未发现问题"}),d.jsx("div",{style:{fontSize:"12px",opacity:.7,marginTop:"4px"},children:"工作流逻辑看起来很完美"})]}):d.jsxs(d.Fragment,{children:[s.map((g,v)=>d.jsxs("div",{className:"health-item",role:"button",tabIndex:g.ref?0:void 0,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&u(g.ref)},onClick:()=>u(g.ref),style:{padding:"12px",borderRadius:"8px",marginBottom:"4px",cursor:g.ref?"pointer":"default",borderLeft:"4px solid #ef4444",transition:"background 0.2s"},children:[d.jsxs("div",{style:{fontSize:"12px",color:"#ef4444",fontWeight:"bold",marginBottom:"2px"},children:["ERROR ",g.ref!=="UNKNOWN"&&`[${g.ref}]`]}),d.jsx("div",{style:{fontSize:"13px",color:f},children:g.message})]},`err-${v}`)),l.map((g,v)=>d.jsxs("div",{className:"health-item",role:"button",tabIndex:g.ref?0:void 0,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&u(g.ref)},onClick:()=>u(g.ref),style:{padding:"12px",borderRadius:"8px",marginBottom:"4px",cursor:g.ref?"pointer":"default",borderLeft:"4px solid #f59e0b",transition:"background 0.2s"},children:[d.jsxs("div",{style:{fontSize:"12px",color:"#f59e0b",fontWeight:"bold",marginBottom:"2px"},children:["WARNING ",g.ref!=="UNKNOWN"&&`[${g.ref}]`]}),d.jsx("div",{style:{fontSize:"13px",color:f},children:g.message})]},`warn-${v}`))]})}),d.jsxs("div",{style:{padding:"12px 16px",fontSize:"11px",color:h,borderTop:`1px solid ${p}`,backgroundColor:"rgba(0,0,0,0.02)",display:"flex",justifyContent:"space-between"},children:[d.jsxs("span",{children:["共 ",s.length," 个错误, ",l.length," 个警告"]}),s.length>0&&d.jsx("span",{style:{color:"#ef4444"},children:"无法保存/导出"})]})]}):null},vx=({id:e,source:r,target:t,sourceX:n,sourceY:o,targetX:a,targetY:i,sourcePosition:s,targetPosition:l,style:u={},markerEnd:c,data:f})=>{const[p,h]=q.useState(!1),g=q.useRef(null),v=()=>{const N=f?.edgeType||"default",A={sourceX:n,sourceY:o,sourcePosition:s,targetX:a,targetY:i,targetPosition:l};switch(N){case"step":case"smoothstep":return O.getSmoothStepPath(A);case"straight":return O.getStraightPath(A);default:return O.getBezierPath(A)}},[m,x,y]=v(),b=N=>{N.stopPropagation(),N.preventDefault();const A=new CustomEvent("edgeAddNode",{detail:{id:e,source:r,target:t,edgeData:f}});window.dispatchEvent(A)},k=()=>{g.current&&clearTimeout(g.current),h(!0)},S=()=>{g.current=setTimeout(()=>{h(!1)},100)},C=f?.mode==="edit";return d.jsxs(d.Fragment,{children:[d.jsx(O.BaseEdge,{path:m,markerEnd:c,style:{...u,strokeWidth:p?4:2,stroke:p?"#fbbf24":u?.stroke,transition:"stroke 0.2s, stroke-width 0.2s",pointerEvents:"none"}}),d.jsx("path",{d:m,fill:"none",stroke:"transparent",strokeWidth:20,style:{cursor:C?"pointer":"default",pointerEvents:"all"},onMouseEnter:k,onMouseLeave:S}),C&&p&&d.jsx(O.EdgeLabelRenderer,{children:d.jsxs("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${x}px,${y}px)`,fontSize:12,pointerEvents:"all",zIndex:2e3,display:"flex",flexDirection:"column",alignItems:"center"},className:"nodrag nopan",onMouseEnter:k,onMouseLeave:S,children:[f?.label&&d.jsx("div",{style:{background:"var(--glass-bg-accent)",backdropFilter:"var(--glass-blur)",color:"var(--color-accent)",padding:"4px 10px",borderRadius:"6px",fontSize:"11px",fontWeight:"700",marginBottom:"8px",border:"1px solid var(--color-accent)",boxShadow:"0 4px 12px rgba(0,0,0,0.3)",whiteSpace:"nowrap",letterSpacing:"0.5px"},children:f.label}),d.jsx("button",{style:{width:"32px",height:"32px",backgroundColor:"var(--color-accent)",color:"#fff",border:"2px solid rgba(255,255,255,0.8)",borderRadius:"50%",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontWeight:"700",fontSize:"20px",boxShadow:"0 4px 15px rgba(var(--color-accent-rgb), 0.5)",transition:"all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275)",padding:0},className:"edge-add-button",onClick:b,onMouseDown:N=>N.stopPropagation(),title:"在此处添加任务",children:"+"})]})})]})},Pe=({onClick:e,icon:r,label:t,title:n,disabled:o=!1,active:a=!1,variant:i="default",style:s})=>{let l="var(--bg-tertiary)",u="var(--text-primary)",c="1px solid var(--border-primary)";return i==="primary"?(l="var(--color-accent)",u="#fff",c="none"):i==="danger"?(l=o?"rgba(239, 68, 68, 0.1)":"var(--status-failed)",u=o?"var(--text-secondary)":"#fff",c="none"):a&&(l="var(--bg-secondary)",u="var(--color-accent)",c="1px solid var(--color-accent)"),d.jsxs("button",{onClick:e,disabled:o,title:n,"aria-label":n||t,"aria-pressed":a,"aria-disabled":o,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:t?"6px":"0",background:l,color:u,border:c,borderRadius:"6px",padding:t?"6px 12px":"8px",cursor:o?"not-allowed":"pointer",opacity:o?.5:1,fontSize:"13px",fontWeight:500,transition:"all 0.2s",minWidth:t?"auto":"32px",height:"32px",boxShadow:i==="default"?"0 1px 2px rgba(0,0,0,0.05)":"none",...s},children:[r&&d.jsx("span",{style:{fontSize:"14px",display:"flex"},children:r}),t&&d.jsx("span",{children:t})]})},mx=()=>{const{zoomIn:e,zoomOut:r,fitView:t}=O.useReactFlow();return d.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"10px"},children:d.jsxs("div",{style:{display:"flex",background:"var(--bg-tertiary)",padding:"4px",borderRadius:"8px",border:"1px solid var(--border-primary)",gap:"4px",boxShadow:"0 2px 5px rgba(0,0,0,0.05)"},children:[d.jsx(Pe,{icon:"➕",title:"放大",onClick:()=>e()}),d.jsx(Pe,{icon:"➖",title:"缩小",onClick:()=>r()}),d.jsx(Pe,{icon:"⤢",title:"适应屏幕",onClick:()=>t({duration:600})})]})})},yx=({onShowHealthCheck:e,showHealthCheck:r,onShowSettings:t,executionActions:n})=>{const{mode:o,validationResults:a,workflowInstance:i,workflowDef:s}=oe(),l=oe.temporal,{undo:u,redo:c,pastStates:f,futureStates:p}=Vr(l,w=>w),[h,g]=q.useState(!1),v=q.useRef(null);q.useEffect(()=>{if(!h)return;const w=I=>{v.current&&!v.current.contains(I.target)&&g(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[h]);const m=(a?.errors?.length||0)>0,x=i?.status,y=i?.workflowId??"",b=x==="RUNNING",k=x==="PAUSED",S=x==="FAILED"||x==="TIMED_OUT"||x==="TERMINATED",C=x==="COMPLETED",N=s?.restartable===!0&&(S||C),A=n?.allowOperations!==!1;return d.jsxs("div",{className:"action-bar",style:{display:"flex",gap:"8px",alignItems:"center"},children:[o==="edit"&&d.jsxs(d.Fragment,{children:[d.jsx(Pe,{icon:"↺",title:"撤销 (Cmd+Z)",onClick:()=>u(),disabled:f.length===0}),d.jsx(Pe,{icon:"↻",title:"重做 (Cmd+Shift+Z)",onClick:()=>c(),disabled:p.length===0}),d.jsx("div",{style:{width:"1px",height:"20px",background:"var(--border-primary)",margin:"0 4px",alignSelf:"center"}}),d.jsx(Pe,{icon:"🩺",label:m?`错误 (${a.errors.length})`:"诊断",title:"流程健康检查",onClick:e,active:r,variant:m?"danger":"secondary"}),d.jsx(Pe,{icon:"⚙️",label:"配置",title:"工作流全局配置",onClick:()=>t?.()})]}),o==="run"&&i&&n&&d.jsxs(d.Fragment,{children:[k&&n.onResume&&d.jsx(Pe,{icon:d.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:d.jsx("path",{d:"M4 3l9 5-9 5z"})}),label:"继续",title:A?"继续执行工作流":"操作权限受限",onClick:()=>A&&n.onResume(y),disabled:!A,variant:"primary"}),b&&n.onPause&&d.jsx(Pe,{icon:d.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:[d.jsx("rect",{x:"4",y:"3",width:"3",height:"10",rx:"1"}),d.jsx("rect",{x:"9",y:"3",width:"3",height:"10",rx:"1"})]}),label:"暂停",title:A?"暂停工作流执行":"操作权限受限",onClick:()=>A&&n.onPause(y),disabled:!A}),(b||k)&&n.onTerminate&&d.jsx(Pe,{icon:d.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:d.jsx("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"})}),label:"终止",title:A?"终止工作流执行":"操作权限受限",onClick:()=>A&&n.onTerminate(y),disabled:!A,variant:"danger"}),S&&n.onRetry&&d.jsx(Pe,{icon:d.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[d.jsx("path",{d:"M13 2v4h-4"}),d.jsx("path",{d:"M13 6A7 7 0 1 1 9.5 2.5"})]}),label:"重试",title:A?"重试失败的工作流":"操作权限受限",onClick:()=>A&&n.onRetry(y),disabled:!A,variant:"primary"}),N&&n.onRestart&&d.jsxs("div",{ref:v,style:{position:"relative",display:"flex"},children:[d.jsxs("button",{disabled:!A,onClick:()=>A&&n.onRestart(y,{useLatestDef:!0}),title:A?"使用当前最新定义版本重新运行":"操作权限受限",style:{display:"flex",alignItems:"center",gap:"6px",background:"var(--bg-tertiary)",color:"var(--text-primary)",border:"1px solid var(--border-primary)",borderRight:"none",borderRadius:"6px 0 0 6px",padding:"6px 10px",cursor:A?"pointer":"not-allowed",opacity:A?1:.5,fontSize:"13px",fontWeight:500,height:"32px"},children:[d.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[d.jsx("path",{d:"M3 14v-4h4"}),d.jsx("path",{d:"M3 10A7 7 0 1 1 6.5 13.5"})]}),"重启"]}),d.jsx("button",{disabled:!A,onClick:()=>A&&g(w=>!w),title:A?"展开重启版本选项":"操作权限受限",style:{display:"flex",alignItems:"center",justifyContent:"center",background:A&&h?"var(--bg-secondary)":"var(--bg-tertiary)",color:"var(--text-secondary)",border:"1px solid var(--border-primary)",borderRadius:"0 6px 6px 0",padding:"6px 6px",cursor:A?"pointer":"not-allowed",opacity:A?1:.5,height:"32px",width:"22px",fontSize:"10px"},children:d.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",children:d.jsx("path",{d:"M1 3l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",fill:"none"})})}),h&&d.jsxs("div",{style:{position:"absolute",top:"36px",right:0,background:"var(--glass-surface)",backdropFilter:"blur(12px)",border:"1px solid var(--glass-border)",borderRadius:"10px",boxShadow:"0 8px 24px rgba(0,0,0,0.25)",zIndex:2e3,minWidth:"180px",overflow:"hidden"},children:[d.jsx("div",{style:{padding:"6px 12px 4px",fontSize:"11px",color:"var(--text-secondary)",fontWeight:600,letterSpacing:"0.5px",textTransform:"uppercase"},children:"选择版本"}),d.jsxs("button",{onClick:()=>{n.onRestart(y,{useLatestDef:!0}),g(!1)},style:Ph,onMouseEnter:w=>w.currentTarget.style.background="var(--bg-secondary)",onMouseLeave:w=>w.currentTarget.style.background="transparent",children:[d.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[d.jsx("circle",{cx:"8",cy:"8",r:"6"}),d.jsx("path",{d:"M8 5v3l2 1"})]}),d.jsxs("div",{children:[d.jsx("div",{style:{fontWeight:600,fontSize:"13px"},children:"当前版本"}),d.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:"使用最新工作流定义"})]})]}),d.jsxs("button",{onClick:()=>{n.onRestart(y,{useLatestDef:!1}),g(!1)},style:Ph,onMouseEnter:w=>w.currentTarget.style.background="var(--bg-secondary)",onMouseLeave:w=>w.currentTarget.style.background="transparent",children:[d.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[d.jsx("rect",{x:"3",y:"2",width:"10",height:"12",rx:"1"}),d.jsx("path",{d:"M6 6h4M6 9h3"})]}),d.jsxs("div",{children:[d.jsx("div",{style:{fontWeight:600,fontSize:"13px"},children:"执行版本"}),d.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:"使用本次运行时的定义"})]})]})]})]})]})]})},Ph={display:"flex",alignItems:"center",gap:"10px",width:"100%",padding:"8px 12px",background:"transparent",border:"none",cursor:"pointer",textAlign:"left",color:"var(--text-primary)",transition:"background 0.15s"},xx=[{id:"basic",label:"基本信息"},{id:"timeout",label:"超时与容错"},{id:"params",label:"参数配置"},{id:"advanced",label:"高级设置"}],bx=({isOpen:e,onClose:r})=>{const{workflowDef:t,updateWorkflowProperties:n,mode:o}=oe(),[a,i]=q.useState(t),[s,l]=q.useState("basic"),u=o!=="edit";q.useEffect(()=>{t&&i(t)},[t,e]);const c=q.useCallback(D=>{D.key==="Escape"&&r()},[r]);if(q.useEffect(()=>{if(e)return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[e,c]),!e||!a)return null;const f="var(--text-primary)",p="var(--glass-border)",h="var(--bg-tertiary)",g="var(--text-secondary)",v=(D,L)=>{if(!a||u)return;const F={...a,[D]:L};i(F),n({[D]:L})},m=(D,L,F)=>{if(!a||u)return;const V={...a[D]||{},[L]:F};i(Z=>({...Z,[D]:V})),n({[D]:V})},x=(D,L)=>{if(!(!a||u))try{const F=JSON.parse(L),W={...a,[D]:F};i(W),n({[D]:F})}catch{i(F=>({...F,[`_${D}_str`]:L}))}},y={width:"100%",padding:"10px 14px",borderRadius:"8px",border:`1px solid ${p}`,background:h,color:f,fontSize:"14px",outline:"none",boxSizing:"border-box"},b={display:"block",fontSize:"11px",color:g,marginBottom:"8px",fontWeight:600},k=(D,L,F="text",W)=>d.jsxs("div",{style:{marginBottom:"20px"},children:[d.jsx("label",{style:b,children:D.toUpperCase()}),d.jsx("input",{className:"wsp-input",type:F,value:a?.[L]??"",onChange:V=>v(L,F==="number"?V.target.value===""?0:parseInt(V.target.value):V.target.value),disabled:u||W?.readOnly,placeholder:W?.placeholder,style:{...y,opacity:u||W?.readOnly?.6:1}})]}),S=(D,L,F=!1,W=6)=>{const V=a?.[`_${L}_str`]!==void 0?a[`_${L}_str`]:typeof a?.[L]=="object"?JSON.stringify(a[L],null,2):a?.[L];return d.jsxs("div",{style:{marginBottom:"20px"},children:[d.jsxs("label",{style:b,children:[D.toUpperCase()," ",F&&"(JSON)"]}),d.jsx("textarea",{className:"wsp-input",value:V||"",onChange:Z=>F?x(L,Z.target.value):v(L,Z.target.value),rows:W,disabled:u,style:{...y,fontSize:"13px",fontFamily:F?"var(--font-mono)":"inherit",resize:"vertical",opacity:u?.6:1}})]})},C=(D,L,F)=>d.jsxs("div",{style:{marginBottom:"20px"},children:[d.jsx("label",{style:b,children:D.toUpperCase()}),d.jsx("select",{className:"wsp-input",value:a?.[L]??F[0]?.value,onChange:W=>v(L,W.target.value),disabled:u,style:{...y,opacity:u?.6:1,cursor:u?"not-allowed":"pointer"},children:F.map(W=>d.jsx("option",{value:W.value,children:W.label},W.value))})]}),N=(D,L)=>{const F=!!a?.[L];return d.jsxs("div",{style:{marginBottom:"20px",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[d.jsx("label",{style:{fontSize:"13px",color:f},children:D}),d.jsx("button",{type:"button",role:"switch","aria-checked":F,onClick:()=>!u&&v(L,!F),disabled:u,style:{width:"44px",height:"24px",borderRadius:"12px",border:"none",background:F?"var(--color-accent)":"var(--border-primary)",position:"relative",cursor:u?"not-allowed":"pointer",transition:"background 0.2s",opacity:u?.6:1,flexShrink:0},children:d.jsx("span",{style:{position:"absolute",top:"2px",left:F?"22px":"2px",width:"20px",height:"20px",borderRadius:"50%",background:"var(--text-inverse)",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)"}})})]})},A=()=>d.jsxs(d.Fragment,{children:[d.jsxs("div",{style:{display:"grid",gridTemplateColumns:"3fr 1fr",gap:"20px"},children:[k("工作流名称","name"),k("版本号","version","number")]}),S("描述信息","description",!1,3),k("负责人邮箱","ownerEmail","text",{placeholder:"owner@example.com"}),k("Schema 版本","schemaVersion","number",{readOnly:!0})]}),w=()=>d.jsxs(d.Fragment,{children:[C("超时策略","timeoutPolicy",[{value:"ALERT_ONLY",label:"ALERT_ONLY — 仅告警"},{value:"TIME_OUT_WF",label:"TIME_OUT_WF — 超时终止"}]),d.jsxs("div",{children:[k("超时秒数","timeoutSeconds","number",{placeholder:"0 表示不超时"}),a?.timeoutPolicy==="ALERT_ONLY"&&d.jsx("p",{style:{fontSize:"11px",color:g,marginTop:"-12px",marginBottom:"20px"},children:"当前策略为 ALERT_ONLY,超时仅触发告警,不会终止工作流。"})]}),k("失败补偿工作流","failureWorkflow","text",{placeholder:"输入补偿工作流名称"}),N("允许重启 (restartable)","restartable")]}),I=()=>d.jsxs(d.Fragment,{children:[S("输入参数声明 (inputParameters)","inputParameters",!0),S("输出参数映射 (outputParameters)","outputParameters",!0),S("默认输入模板 (inputTemplate)","inputTemplate",!0),S("工作流级变量 (variables)","variables",!0)]}),R=()=>d.jsxs(d.Fragment,{children:[N("启用状态监听 (workflowStatusListenerEnabled)","workflowStatusListenerEnabled"),a?.workflowStatusListenerEnabled&&k("状态事件目标 (Listener Sink)","workflowStatusListenerSink","text",{placeholder:"conductor:workflow_status_event"}),d.jsxs("div",{style:{borderTop:`1px solid ${p}`,marginTop:"8px",paddingTop:"20px"},children:[N("强制 Schema 校验 (enforceSchema)","enforceSchema"),a?.enforceSchema&&d.jsxs(d.Fragment,{children:[S("输入 Schema (inputSchema)","inputSchema",!0,4),S("输出 Schema (outputSchema)","outputSchema",!0,4)]})]}),d.jsxs("div",{style:{borderTop:`1px solid ${p}`,marginTop:"8px",paddingTop:"20px"},children:[d.jsx("label",{style:{...b,marginBottom:"16px"},children:"并发限流 (RATE LIMIT)"}),d.jsxs("div",{style:{display:"grid",gridTemplateColumns:"2fr 1fr",gap:"20px"},children:[d.jsxs("div",{children:[d.jsx("label",{style:b,children:"RATE LIMIT KEY"}),d.jsx("input",{className:"wsp-input",type:"text",value:a?.rateLimitConfig?.rateLimitKey??"",onChange:D=>m("rateLimitConfig","rateLimitKey",D.target.value),disabled:u,placeholder:"限流键",style:{...y,opacity:u?.6:1}})]}),d.jsxs("div",{children:[d.jsx("label",{style:b,children:"并发上限"}),d.jsx("input",{className:"wsp-input",type:"number",value:a?.rateLimitConfig?.concurrentExecLimit??"",onChange:D=>m("rateLimitConfig","concurrentExecLimit",D.target.value===""?0:parseInt(D.target.value)),disabled:u,placeholder:"0",style:{...y,opacity:u?.6:1}})]})]})]})]}),B=()=>{switch(s){case"basic":return A();case"timeout":return w();case"params":return I();case"advanced":return R()}};return d.jsx("div",{role:"dialog","aria-modal":"true","aria-label":"工作流全局配置",onClick:r,style:{position:"fixed",left:0,top:0,width:"100vw",height:"100vh",backgroundColor:"rgba(0,0,0,0.5)",zIndex:1300,display:"flex",justifyContent:"center",alignItems:"center",backdropFilter:"blur(4px)",animation:"fadeIn 0.2s ease"},children:d.jsxs("div",{onClick:D=>D.stopPropagation(),style:{width:"680px",maxHeight:"85vh",background:"var(--glass-surface)",borderRadius:"16px",boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.5)",display:"flex",flexDirection:"column",overflow:"hidden",animation:"slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1)",border:`1px solid ${p}`,backdropFilter:"blur(20px)"},children:[d.jsxs("div",{style:{padding:"24px 32px 0 32px",background:"var(--bg-highlight)"},children:[d.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px"},children:[d.jsxs("div",{children:[d.jsx("h2",{style:{margin:0,fontSize:"20px",color:f},children:"工作流全局配置"}),d.jsx("p",{style:{margin:"4px 0 0 0",fontSize:"12px",color:g},children:u?"当前为只读模式":"配置工作流级属性,所有更改将实时保存"})]}),d.jsx("button",{className:"wsp-close",onClick:r,"aria-label":"关闭",style:{background:"none",border:"none",color:f,fontSize:"24px",cursor:"pointer",opacity:.6},children:"✕"})]}),d.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${p}`},children:xx.map(D=>d.jsx("button",{className:"wsp-tab",onClick:()=>l(D.id),style:{padding:"10px 20px",fontSize:"13px",fontWeight:s===D.id?600:400,color:s===D.id?"var(--color-accent)":g,background:"none",border:"none",borderBottom:s===D.id?"2px solid var(--color-accent)":"2px solid transparent",cursor:"pointer",transition:"all 0.2s",marginBottom:"-1px"},children:D.label},D.id))})]}),d.jsx("div",{style:{flex:1,overflowY:"auto",padding:"28px 32px"},children:B()}),d.jsx("div",{style:{padding:"20px 32px",borderTop:`1px solid ${p}`,background:"var(--bg-highlight)",display:"flex",justifyContent:"flex-end"},children:d.jsx("button",{className:"wsp-footer-btn",onClick:r,style:{padding:"12px 32px",background:"var(--color-accent)",color:"var(--text-inverse)",border:"none",borderRadius:"12px",fontWeight:"bold",cursor:"pointer",boxShadow:"0 4px 12px var(--color-accent-bg)"},children:"完成并关闭"})})]})})},kx=({onRequestImport:e})=>{const{createBlankWorkflow:r}=oe(),[t,n]=q.useState(""),o=()=>{r(t||void 0),oe.temporal.getState().clear()},a=()=>{r(t||void 0),oe.temporal.getState().clear(),window.dispatchEvent(new CustomEvent("open-ai-chat"))};return d.jsxs("div",{className:"empty-state-panel",children:[d.jsx("h2",{className:"empty-state-title",children:"创建新工作流"}),d.jsx("p",{className:"empty-state-subtitle",children:"从空白画布开始设计,或让 AI 帮你生成完整流程"}),d.jsx("input",{className:"empty-state-name-input",type:"text",placeholder:"工作流名称(可选)",value:t,onChange:i=>n(i.target.value),onKeyDown:i=>{i.key==="Enter"&&o()}}),d.jsxs("div",{className:"empty-state-actions",children:[d.jsxs("button",{className:"empty-state-btn primary",onClick:o,children:[d.jsx("span",{className:"empty-state-btn-icon",children:"📄"}),"空白工作流"]}),d.jsxs("button",{className:"empty-state-btn",onClick:a,children:[d.jsx("span",{className:"empty-state-btn-icon",children:"✨"}),"AI 生成"]}),e&&d.jsxs("button",{className:"empty-state-btn",onClick:e,children:[d.jsx("span",{className:"empty-state-btn-icon",children:"📤"}),"导入 JSON"]})]})]})},_x={success:{bg:"#10b981",text:"#fff"},error:{bg:"#ef4444",text:"#fff"},info:{bg:"var(--color-accent)",text:"#fff"}},Sx=({messages:e,onDismiss:r})=>e.length===0?null:d.jsx("div",{style:{position:"fixed",bottom:"24px",left:"50%",transform:"translateX(-50%)",zIndex:3e3,display:"flex",flexDirection:"column",gap:"8px",pointerEvents:"none"},children:e.map(t=>d.jsx(wx,{message:t,onDismiss:r},t.id))}),wx=({message:e,onDismiss:r})=>{const t=_x[e.type||"info"];return q.useEffect(()=>{const n=setTimeout(()=>r(e.id),2500);return()=>clearTimeout(n)},[e.id,r]),d.jsx("div",{role:"status","aria-live":"polite",style:{backgroundColor:t.bg,color:t.text,padding:"10px 20px",borderRadius:"8px",fontSize:"13px",fontWeight:500,boxShadow:"0 4px 16px rgba(0,0,0,0.2)",animation:"toastSlideUp 0.3s ease-out",pointerEvents:"auto",cursor:"pointer",whiteSpace:"nowrap"},onClick:()=>r(e.id),children:e.text})},Ah=["shift","alt","meta","mod","ctrl","control"],Tx={esc:"escape",return:"enter",left:"arrowleft",right:"arrowright",up:"arrowup",down:"arrowdown",ShiftLeft:"shift",ShiftRight:"shift",AltLeft:"alt",AltRight:"alt",MetaLeft:"meta",MetaRight:"meta",OSLeft:"meta",OSRight:"meta",ControlLeft:"ctrl",ControlRight:"ctrl"};function ze(e){return(Tx[e.trim()]||e.trim()).toLowerCase().replace(/key|digit|numpad/,"")}function qh(e){return Ah.includes(e)}function Ws(e,r=","){return e.toLowerCase().split(r)}function Bs(e,r="+",t=">",n=!1,o){let a=[],i=!1;e=e.trim(),e.includes(t)?(i=!0,a=e.toLocaleLowerCase().split(t).map(u=>ze(u))):a=e.toLocaleLowerCase().split(r).map(u=>ze(u));const s={alt:a.includes("alt"),ctrl:a.includes("ctrl")||a.includes("control"),shift:a.includes("shift"),meta:a.includes("meta"),mod:a.includes("mod"),useKey:n},l=a.filter(u=>!Ah.includes(u));return{...s,keys:l,description:o,isSequence:i,hotkey:e}}typeof document<"u"&&(document.addEventListener("keydown",e=>{e.code!==void 0&&Lh([ze(e.code)])}),document.addEventListener("keyup",e=>{e.code!==void 0&&Dh([ze(e.code)])})),typeof window<"u"&&(window.addEventListener("blur",()=>{We.clear()}),window.addEventListener("contextmenu",()=>{setTimeout(()=>{We.clear()},0)}));const We=new Set;function Fs(e){return Array.isArray(e)}function Ex(e,r=","){return(Fs(e)?e:e.split(r)).every(t=>We.has(t.trim().toLowerCase()))}function Lh(e){const r=Array.isArray(e)?e:[e];We.has("meta")&&We.forEach(t=>!qh(t)&&We.delete(t.toLowerCase())),r.forEach(t=>We.add(t.toLowerCase()))}function Dh(e){const r=Array.isArray(e)?e:[e];e==="meta"?We.clear():r.forEach(t=>We.delete(t.toLowerCase()))}function Nx(e,r,t){(typeof t=="function"&&t(e,r)||t===!0)&&e.preventDefault()}function Cx(e,r,t){return typeof t=="function"?t(e,r):t===!0||t===void 0}const Ix=["input","textarea","select","searchbox","slider","spinbutton","menuitem","menuitemcheckbox","menuitemradio","option","radio","textbox"];function Rx(e){return Mh(e,Ix)}function Mh(e,r=!1){const{target:t,composed:n}=e;let o,a;return jx(t)&&n?(o=e.composedPath()[0]&&e.composedPath()[0].tagName,a=e.composedPath()[0]&&e.composedPath()[0].role):(o=t&&t.tagName,a=t&&t.role),Fs(r)?!!(o&&r&&r.some(i=>i.toLowerCase()===o.toLowerCase()||i===a)):!!(o&&r&&r)}function jx(e){return!!e.tagName&&!e.tagName.startsWith("-")&&e.tagName.includes("-")}function Ox(e,r){return e.length===0&&r?(console.warn('A hotkey has the "scopes" option set, however no active scopes were found. If you want to use the global scopes feature, you need to wrap your app in a <HotkeysProvider>'),!0):r?e.some(t=>r.includes(t))||e.includes("*"):!0}const Px=(e,r,t=!1)=>{const{alt:n,meta:o,mod:a,shift:i,ctrl:s,keys:l,useKey:u}=r,{code:c,key:f,ctrlKey:p,metaKey:h,shiftKey:g,altKey:v}=e,m=ze(c);if(u&&l?.length===1&&l.includes(f))return!0;if(!l?.includes(m)&&!["ctrl","control","unknown","meta","alt","shift","os"].includes(m))return!1;if(!t){if(n!==v&&m!=="alt"||i!==g&&m!=="shift")return!1;if(a){if(!h&&!p)return!1}else if(o!==h&&m!=="meta"&&m!=="os"||s!==p&&m!=="ctrl"&&m!=="control")return!1}return l&&l.length===1&&l.includes(m)?!0:l?Ex(l):!l},Ax=q.createContext(void 0),qx=()=>q.useContext(Ax);function Wh(e,r){return e&&r&&typeof e=="object"&&typeof r=="object"?Object.keys(e).length===Object.keys(r).length&&Object.keys(e).reduce((t,n)=>t&&Wh(e[n],r[n]),!0):e===r}const Lx=q.createContext({hotkeys:[],activeScopes:[],toggleScope:()=>{},enableScope:()=>{},disableScope:()=>{}}),Dx=()=>q.useContext(Lx);function Mx(e){const r=q.useRef(void 0);return Wh(r.current,e)||(r.current=e),r.current}const Bh=e=>{e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation()},Wx=typeof window<"u"?q.useLayoutEffect:q.useEffect;function sr(e,r,t,n){const o=q.useRef(null),a=q.useRef(!1),i=Array.isArray(t)?Array.isArray(n)?void 0:n:t,s=Fs(e)?e.join(i?.delimiter):e,l=Array.isArray(t)?t:Array.isArray(n)?n:void 0,u=q.useCallback(r,l??[]),c=q.useRef(u);l?c.current=u:c.current=r;const f=Mx(i),{activeScopes:p}=Dx(),h=qx();return Wx(()=>{if(f?.enabled===!1||!Ox(p,f?.scopes))return;let g=[],v;const m=(k,S=!1)=>{if(!(Rx(k)&&!Mh(k,f?.enableOnFormTags))){if(o.current!==null){const C=o.current.getRootNode();if((C instanceof Document||C instanceof ShadowRoot)&&C.activeElement!==o.current&&!o.current.contains(C.activeElement)){Bh(k);return}}k.target?.isContentEditable&&!f?.enableOnContentEditable||Ws(s,f?.delimiter).forEach(C=>{if(C.includes(f?.splitKey??"+")&&C.includes(f?.sequenceSplitKey??">")){console.warn(`Hotkey ${C} contains both ${f?.splitKey??"+"} and ${f?.sequenceSplitKey??">"} which is not supported.`);return}const N=Bs(C,f?.splitKey,f?.sequenceSplitKey,f?.useKey,f?.description);if(N.isSequence){v=setTimeout(()=>{g=[]},f?.sequenceTimeoutMs??1e3);const A=N.useKey?k.key:ze(k.code);if(qh(A.toLowerCase()))return;g.push(A);const w=N.keys?.[g.length-1];if(A!==w){g=[],v&&clearTimeout(v);return}g.length===N.keys?.length&&(c.current(k,N),v&&clearTimeout(v),g=[])}else if(Px(k,N,f?.ignoreModifiers)||N.keys?.includes("*")){if(f?.ignoreEventWhen?.(k)||S&&a.current)return;if(Nx(k,N,f?.preventDefault),!Cx(k,N,f?.enabled)){Bh(k);return}c.current(k,N),S||(a.current=!0)}})}},x=k=>{k.code!==void 0&&(Lh(ze(k.code)),(f?.keydown===void 0&&f?.keyup!==!0||f?.keydown)&&m(k))},y=k=>{k.code!==void 0&&(Dh(ze(k.code)),a.current=!1,f?.keyup&&m(k,!0))},b=o.current||i?.document||document;return b.addEventListener("keyup",y,i?.eventListenerOptions),b.addEventListener("keydown",x,i?.eventListenerOptions),h&&Ws(s,f?.delimiter).forEach(k=>h.addHotkey(Bs(k,f?.splitKey,f?.sequenceSplitKey,f?.useKey,f?.description))),()=>{b.removeEventListener("keyup",y,i?.eventListenerOptions),b.removeEventListener("keydown",x,i?.eventListenerOptions),h&&Ws(s,f?.delimiter).forEach(k=>h.removeHotkey(Bs(k,f?.splitKey,f?.sequenceSplitKey,f?.useKey,f?.description))),g=[],v&&clearTimeout(v)}},[s,f,p]),o}const Bx=e=>{const{mode:r,removeNode:t,selectedTask:n,pasteTask:o}=oe(),a=oe.temporal,{undo:i,redo:s}=Vr(a,p=>p),l=e?.confirm||(p=>Promise.resolve(window.confirm(p))),u=e?.showToast,c=p=>{const h=p.target;return h.tagName==="INPUT"||h.tagName==="TEXTAREA"||h.isContentEditable},f=()=>{requestAnimationFrame(()=>{const p=oe.getState(),{nodes:h,edges:g}=be(p.nodes,p.edges,{direction:p.layoutDirection,mode:p.mode});oe.setState({nodes:h,edges:g})})};return sr("mod+z",p=>{r==="edit"&&(c(p)||(p.preventDefault(),i(),f()))},[r,i]),sr(["mod+shift+z","mod+y"],p=>{r==="edit"&&(c(p)||(p.preventDefault(),s(),f()))},[r,s]),sr("delete, backspace",p=>{r!=="edit"||!n||c(p)||(p.preventDefault(),l("确定要删除此任务吗?").then(h=>{h&&t(n.taskReferenceName)}))},[r,n,t,l]),sr("mod+c",p=>{if(!(r!=="edit"||!n)&&!c(p)){if(n.type==="JOIN"){u?.("JOIN 任务不能独立复制","error");return}p.preventDefault();try{localStorage.setItem("conductor-clipboard",JSON.stringify(n)),u?.("任务已复制","success")}catch{u?.("复制失败","error")}}},[r,n,u]),sr("mod+v",p=>{if(r==="edit"&&!c(p)){p.preventDefault();try{const h=localStorage.getItem("conductor-clipboard");if(h){const g=JSON.parse(h);o(g),u?.("任务已粘贴","success")}}catch{u?.("粘贴失败","error")}}},[r,o,u]),sr("mod+s",p=>{p.preventDefault();const h=oe.getState().workflowDef;h&&e?.onSave&&e.onSave(h)},[e?.onSave]),{}},Fx=()=>{const[e,r]=q.useState(null),t=q.useCallback(a=>new Promise(i=>{r({message:a,resolve:i})}),[]),n=q.useCallback(()=>{e?.resolve(!0),r(null)},[e]),o=q.useCallback(()=>{e?.resolve(!1),r(null)},[e]);return{confirm:t,confirmState:e,handleConfirm:n,handleCancel:o}},zx=()=>{const[e,r]=q.useState([]),t=q.useCallback((o,a="info")=>{const i=Date.now().toString();r(s=>[...s,{id:i,text:o,type:a}])},[]),n=q.useCallback(o=>{r(a=>a.filter(i=>i.id!==o))},[]);return{toasts:e,showToast:t,dismissToast:n}},$x={taskNode:tx,decisionNode:ax,forkNode:jh.ForkNode,joinNode:jh.JoinNode,loopNode:ix,subWorkflowNode:ux,plusNode:dx,dynamicPlaceholderNode:px},Hx={addableEdge:vx},Kx=({onNodeClick:e,searchQuery:r="",onSave:t,onRequestImport:n,executionActions:o})=>{const{nodes:a,edges:i,onNodesChange:s,onEdgesChange:l,onConnect:u,mode:c,viewMode:f,selectedTask:p,setSelectedTask:h,theme:g,edgeType:v,addNode:m,nodesLocked:x,executionData:y,validationResults:b,setIsDetailPanelOpen:k,workflowDef:S,dynamicRuntimeTasksByFork:C,layoutDirection:N,simState:A,workflowLoadKey:w}=oe(),I=q.useMemo(()=>{if(c==="run"||c==="edit")return new Set(a.map(J=>J.id));const ne=Xy[f],G=new Set;return a.forEach(J=>{if(J.type==="plusNode"||J.type==="dynamicPlaceholderNode"){G.add(J.id);return}if(J.parentId)return;const $=Ge.find(X=>X.type===J.data.taskType)?.viewCategory??"business";ne.includes($)&&G.add(J.id)}),a.forEach(J=>{J.parentId&&G.has(J.parentId)&&G.add(J.id)}),G},[a,f,c]),R=q.useCallback(ne=>{if(I.size===a.length)return ne;const G={};ne.forEach($=>{G[$.source]||(G[$.source]=[]),G[$.source].push($)});const J=[],H=new Set;return ne.forEach($=>{if(!I.has($.source))return;if(I.has($.target)){const ue=`${$.source}->${$.target}`;H.has(ue)||(H.add(ue),J.push($));return}const X=[{to:$.target,label:$.label}],de=new Set;for(;X.length;){const ue=X.shift();if(!de.has(ue.to)){if(de.add(ue.to),I.has(ue.to)){const he=`${$.source}->${ue.to}`;H.has(he)||(H.add(he),J.push({...$,id:he,target:ue.to,label:ue.label??$.label}));continue}(G[ue.to]??[]).forEach(he=>X.push({to:he.target,label:ue.label??he.label}))}}}),J},[I,a.length]),{fitView:B}=O.useReactFlow(),[D,L]=q.useState(!1),[F,W]=q.useState(null),[V,Z]=q.useState(!1),[le,se]=q.useState(!1),{confirm:_,confirmState:Y,handleConfirm:K,handleCancel:E}=Fx(),{toasts:j,showToast:M,dismissToast:P}=zx();Bx({confirm:_,showToast:M,onSave:t}),q.useEffect(()=>{if(p){const ne=a.find(G=>G.data.taskReferenceName===p.taskReferenceName);ne&&B({nodes:[ne],duration:800,padding:.5})}},[p?.taskReferenceName,B]),q.useEffect(()=>{const ne=()=>{B({duration:800})};return window.addEventListener("workflow-zoom-to-fit",ne),()=>window.removeEventListener("workflow-zoom-to-fit",ne)},[B]),q.useEffect(()=>{if(w===0)return;const ne=setTimeout(()=>{B({duration:600,padding:.12})},50);return()=>clearTimeout(ne)},[w,B]),q.useEffect(()=>{const ne=H=>{e&&H.detail&&H.detail.task&&e(H.detail.task)},G=H=>{if(c==="edit"){const{loopId:$,afterRef:X}=H.detail;W(X?{sourceId:X,edgeData:{}}:{sourceId:$,edgeData:{isLoopAdd:!0}}),L(!0)}},J=H=>{c==="edit"&&(W({sourceId:H.detail.source,targetId:H.detail.target,edgeId:H.detail.id,edgeData:H.detail.edgeData}),L(!0))};return document.addEventListener("miniTaskClick",ne),document.addEventListener("loopAddNodeRequested",G),window.addEventListener("edgeAddNode",J),()=>{document.removeEventListener("miniTaskClick",ne),document.removeEventListener("loopAddNodeRequested",G),window.removeEventListener("edgeAddNode",J)}},[c,e]);const z=q.useCallback(ne=>{if(F){const{sourceId:G,targetId:J,edgeId:H,edgeData:$}=F;m({data:{label:`New ${ne}`,taskReferenceName:`${ne.toLowerCase()}_${Date.now()}`,taskType:ne}},G,J,H,$)}L(!1),W(null)},[F,m]),ee=q.useMemo(()=>{const ne={extraNodes:[],extraEdges:[],removedEdgeIds:new Set,removedNodeIds:new Set};if(c!=="run")return ne;const G=a.filter(U=>U.type==="forkNode"&&U.data.taskType==="FORK_JOIN_DYNAMIC");if(!G.length)return ne;const J=[],H=[],$=new Set,X=new Set,de=N==="LR",ue=47,he=120,T={animated:!0,style:{stroke:"#10b981",strokeDasharray:"4,4"},markerEnd:{type:O.MarkerType.ArrowClosed,color:"#10b981"}};for(const U of G){const Q=C[U.id]||[],te=`${U.id}_dynamic_placeholder`,re=a.find(fe=>fe.id===te),ge=i.find(fe=>fe.target===te),ve=i.find(fe=>fe.source===te);let ce,ye;if(ve)ce=ve.target,ye=a.find(fe=>fe.id===ce);else{const fe=a.indexOf(U);if(ye=a.slice(fe).find(Ie=>Ie.type==="joinNode"),!ye)continue;ce=ye.id}if(!ye||(ve&&$.add(ve.id),ge&&$.add(ge.id),X.add(te),!Q.length))continue;const $e=Q.length,Ce=re?re.position.x+110:(U.position.x+ye.position.x)/2,Xe=re?re.position.y+35:(U.position.y+ye.position.y)/2;Q.forEach((fe,Ie)=>{const kr=`dynamic_rt_${fe.referenceTaskName}`,pb=de?Ce-he:U.position.x+(Ie-($e-1)/2)*280,hb=de?Xe-ue+(Ie-($e-1)/2)*110:Xe-ue;J.push({id:kr,type:"taskNode",data:{label:fe.referenceTaskName,task:{name:fe.referenceTaskName,taskReferenceName:fe.referenceTaskName,type:fe.taskType||"SIMPLE"},taskReferenceName:fe.referenceTaskName,taskType:fe.taskType||"SIMPLE",isDynamicRuntime:!0,layoutDirection:N},position:{x:pb,y:hb}}),H.push({id:`e-${U.id}-${kr}`,source:U.id,target:kr,...T}),H.push({id:`e-${kr}-${ce}`,source:kr,target:ce,...T})})}return{extraNodes:J,extraEdges:H,removedEdgeIds:$,removedNodeIds:X}},[c,C,a,i,N]),ae=q.useMemo(()=>[...R(i.filter(J=>!ee.removedEdgeIds.has(J.id))).map(J=>{const H=J.id.includes("loop-back"),$=g==="light"?"#64748b":"#94a3b8";let de={...{...J.style,stroke:$,strokeWidth:2,strokeDasharray:H?"5,5":void 0}},ue=!1;if(c==="run"&&y){const Q=y[J.source]?.status,te=y[J.target]?.status,re=Q==="COMPLETED";re&&te==="COMPLETED"?(de={...de,stroke:"var(--status-completed)",strokeWidth:4},ue=!1):re&&te==="IN_PROGRESS"&&(de={...de,stroke:"var(--status-in-progress)",strokeWidth:4},ue=!0)}const he=J.source.endsWith("_dynamic_placeholder")||J.target.endsWith("_dynamic_placeholder"),T=J.source==="__workflow_start__"||J.source.startsWith("__loop_start__");return{...J,type:c==="edit"&&!H&&!he&&!T?"addableEdge":v,data:{...J.data,mode:c,edgeType:v,label:J.label},markerEnd:{type:O.MarkerType.ArrowClosed,width:20,height:20,color:de.stroke},style:de,animated:ue}}),...ee.extraEdges],[i,v,g,c,y,ee,R]);return d.jsxs("div",{style:{width:"100%",height:"100%",position:"relative",background:"var(--bg-secondary)"},children:[d.jsxs(O,{nodes:q.useMemo(()=>{const ne=new Set(b.errors.filter($=>$.type==="TASK").map($=>$.ref)),G=new Set(b.warnings.filter($=>$.type==="TASK").map($=>$.ref)),J=r.toLowerCase();return a.filter($=>!ee.removedNodeIds.has($.id)&&I.has($.id)).map($=>{const X=$.data.taskReferenceName,de=A[X];return{...$,selected:p?.taskReferenceName===X,data:{...$.data,isError:c==="edit"&&ne.has(X),hasWarning:c==="edit"&&G.has(X),isHighlighted:r?$.data.label.toLowerCase().includes(J)||$.data.taskReferenceName.toLowerCase().includes(J):!1,simRunning:de==="running",simDone:de==="done"}}}).concat(ee.extraNodes.map($=>({...$,data:{...$.data,isError:!1,hasWarning:!1,isHighlighted:!1}})))},[a,b,r,p,ee,I,A,c]),edges:ae,onNodesChange:s,onEdgesChange:l,onConnect:u,nodeTypes:$x,edgeTypes:Hx,onNodeClick:(ne,G)=>{if(G.type==="plusNode"){W({sourceId:G.data.parentRef,edgeData:G.data.edgeData||{}}),L(!0);return}if(G.type==="loopNode"){const H=G.data.task||null;h(H),e&&e(H);return}const J=G.data.task||null;h(J),e&&e(J)},onPaneClick:()=>{h(null),c!=="run"&&k(!1)},fitView:!0,nodesDraggable:!x,nodesConnectable:!x,elementsSelectable:!0,minZoom:.2,maxZoom:2,children:[d.jsx(O.Background,{color:"var(--border-primary)",gap:20}),d.jsx(O.Panel,{position:"bottom-left",style:{marginBottom:"20px",marginLeft:"20px",zIndex:1e3},children:d.jsx(mx,{})}),c==="run"&&d.jsx(O.Panel,{position:"bottom-center",children:d.jsx(gx,{})}),d.jsx(Oh,{isOpen:V,onClose:()=>Z(!1),theme:g,onTaskSelect:ne=>{h(ne)}}),d.jsx("div",{style:{position:"absolute",top:20,right:20,zIndex:1e3},children:d.jsx(yx,{onShowHealthCheck:()=>Z(!V),showHealthCheck:V,onShowSettings:()=>se(!0),executionActions:o})})]}),!S&&d.jsx(kx,{onRequestImport:n}),S&&a.length===0&&c==="edit"&&d.jsx("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:10,display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:d.jsxs("button",{className:"empty-state-btn primary",style:{padding:"12px 24px",borderRadius:"8px",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",fontSize:"16px",fontWeight:500,boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1)"},onClick:()=>{W({sourceId:"start",targetId:"end",edgeId:"new",edgeData:{}}),L(!0)},children:[d.jsx("span",{style:{fontSize:"20px",lineHeight:1},children:"+"}),"添加第一个任务"]})}),D&&d.jsx(hx,{theme:g,onSelect:z,onCancel:()=>L(!1)}),d.jsx(bx,{isOpen:le,onClose:()=>se(!1)}),Y&&d.jsx(Ur,{message:Y.message,onConfirm:K,onCancel:E}),d.jsx(Sx,{messages:j,onDismiss:P})]})},Fh={apiKey:"",baseUrl:"https://api.openai.com/v1",model:"gpt-4o"},Ux=async(e,r={},t)=>{const n={...Fh,...r};if(!n.apiKey)throw new Error("Please configure AI API Key in settings.");const o=await fetch(`${n.baseUrl}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n.apiKey}`},body:JSON.stringify({model:n.model,messages:e,temperature:.7,stream:!1}),signal:t});if(!o.ok){const i=await o.json();throw new Error(i.error?.message||"AI request failed")}return(await o.json()).choices[0].message.content},Jx=async(e,r={},t,n,o)=>{const a={...Fh,...r};if(!a.apiKey)throw new Error("Please configure AI API Key in settings.");const i=await fetch(`${a.baseUrl}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a.apiKey}`},body:JSON.stringify({model:a.model,messages:e,temperature:.7,stream:!0}),signal:o});if(!i.ok){const c=await i.json();throw new Error(c.error?.message||"AI request failed")}const s=i.body?.getReader();if(!s)throw new Error("ReadableStream not supported");const l=new TextDecoder;let u="";for(;;){const{done:c,value:f}=await s.read();if(c)break;const h=l.decode(f,{stream:!0}).split(`
31
+ `).filter(g=>g.trim()!=="");for(const g of h)if(g.startsWith("data: ")){const v=g.slice(6);if(v==="[DONE]")return u;try{const x=JSON.parse(v).choices?.[0]?.delta?.content;x&&(u+=x,t(x))}catch{console.warn("[AI SSE] malformed chunk:",v)}}}return u},Gx=`
197
32
  You are an expert in Netflix Conductor Workflow modeling.
198
33
  Your goal is to help users design JSON-based workflows.
199
34
 
@@ -205,25 +40,48 @@ CONSTRANTS:
205
40
  5. For FORK_JOIN, ensure a corresponding JOIN task follows.
206
41
 
207
42
  Provide clear, enterprise-grade logic with proper error handling paths.
208
- `,mb=(e,t)=>{const r=t?`Current Workflow State:
209
- ${JSON.stringify(t,null,2)}`:"Initial state: No workflow defined yet.";return`
210
- User Request: ${e}
211
-
212
- ${r}
213
-
214
- Please provide a JSON suggestion that fulfills the user's request.
215
- If modifying the current workflow, return the ENTIRE updated JSON.
216
- Wrap the JSON in triple backticks with 'json' label.
217
- `},yb=(e,t)=>`
43
+ `,Vx=(e,r)=>{const t=r?`当前工作流(JSON):
44
+ ${JSON.stringify({name:r.name,tasks:r.tasks.map(n=>({ref:n.taskReferenceName,type:n.type,name:n.name}))},null,2)}`:"当前工作流:尚未定义。";return`
45
+ 用户请求:${e}
46
+
47
+ ${t}
48
+
49
+ 请用中文回答,简明说明你将做什么修改,并在回答末尾(如果有工作流变更)输出一个结构化 diff 块,格式如下:
50
+
51
+ \`\`\`diff-json
52
+ {
53
+ "kind": "mod",
54
+ "summary": "一句话描述变更",
55
+ "rows": [
56
+ { "kind": "add", "desc": "新增 xxx 任务" },
57
+ { "kind": "mod", "desc": "修改 yyy 属性" }
58
+ ],
59
+ "patch": [
60
+ { "op": "patchTask", "ref": "task_ref", "set": { "retryCount": 3 } }
61
+ ]
62
+ }
63
+ \`\`\`
64
+
65
+ 支持的 patch 操作:
66
+ - patchTask: { "op": "patchTask", "ref": "taskRef", "set": { ...fields } }
67
+ - insertAfter: { "op": "insertAfter", "after": "refA", "edgeTo": "refB", "task": {...} }
68
+ - insertBefore: { "op": "insertBefore", "before": "refA", "task": {...} }
69
+ - addTask: { "op": "addTask", "task": {...}, "extraEdges": [{...}] }
70
+ - removeTask: { "op": "removeTask", "ref": "taskRef" }
71
+
72
+ 如果是全量生成新工作流,使用 kind="replace" 并在 diff-json 中加入 "payload": {...完整工作流JSON...}。
73
+ 如果不涉及工作流变更(仅解释/回答),则不需要输出 diff-json 块。
74
+ `},Yx=(e,r)=>`
218
75
  Context: I am configuring a Conductor task in a workflow.
219
76
  Task Reference Name: ${e.taskReferenceName}
220
77
  Task Type: ${e.type}
221
78
 
222
79
  Full Workflow Structure for reference:
223
- ${JSON.stringify(t,null,2)}
80
+ ${JSON.stringify(r,null,2)}
224
81
 
225
82
  Requirement: Suggest 3 meaningful 'inputParameters' or JSONPath expressions for this task based on the workflow context.
226
83
  Return the suggestions as a JSON array of objects with { label, value, description }.
227
- `,bb=({isOpen:e,onClose:t,onSelect:r,suggestions:n,anchorRect:a})=>{if(!e||!a)return null;const i={position:"fixed",top:a.bottom+8,left:Math.max(a.left-200,20),width:"280px",zIndex:3e3};return f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"suggester-overlay",onClick:t}),f.jsxs("div",{className:"parameter-suggester-popover glass-panel",style:i,children:[f.jsxs("div",{className:"suggester-header",children:[f.jsx("span",{className:"sparkle-icon",children:"✨"}),"AI Suggestions"]}),f.jsx("div",{className:"suggester-list",children:n.length===0?f.jsxs("div",{className:"suggester-loading",children:[f.jsx("div",{className:"suggester-skeleton-line",style:{width:"85%"}}),f.jsx("div",{className:"suggester-skeleton-line",style:{width:"65%"}}),f.jsx("div",{className:"suggester-skeleton-line",style:{width:"75%"}})]}):n.map((o,s)=>f.jsxs("div",{className:"suggestion-item",onClick:()=>{r(o.value),t()},children:[f.jsx("div",{className:"suggestion-label",children:o.label}),f.jsx("div",{className:"suggestion-value",children:o.value}),f.jsx("div",{className:"suggestion-desc",children:o.description})]},s))})]})]})},xb=({task:e,isOpen:t=!0,onClose:r,aiConfig:n})=>{const{mode:a,updateTask:i,checkTaskRefUniqueness:o}=V(),[s,c]=D.useState(e),[u,d]=D.useState(!1),[l,p]=D.useState(),[h,m]=D.useState([]),[g,v]=D.useState(()=>()=>{}),x=[{label:"引用工作流输入",value:"${workflow.input.data}",description:"引用工作流启动时传入的原始数据"},{label:"引用前序任务输出",value:"${previous_task.output.result}",description:"引用上一个节点的计算结果"},{label:"环境变量",value:"${workflow.variables.api_key}",description:"引用工作流定义的全局变量"}],b=async(W,z)=>{const K=W.currentTarget.getBoundingClientRect();p(K),v(()=>z),m([]),d(!0);const j=n?.apiKey||localStorage.getItem("AI_API_KEY")||"";if(!j){m(x);return}try{const F=n?.baseUrl||localStorage.getItem("AI_BASE_URL")||"",G=n?.model||localStorage.getItem("AI_MODEL")||"",k={apiKey:j};F&&(k.baseUrl=F),G&&(k.model=G);const{workflowDef:I}=V.getState(),P=yb(_,I),H=(await hb([{role:"system",content:"You are a Conductor workflow expert. Return only valid JSON."},{role:"user",content:P}],k)).match(/\[[\s\S]*\]/);if(H){const J=JSON.parse(H[0]);m(J)}else m(x)}catch(F){console.warn("[AI ParameterSuggester] fallback to mock:",F),m(x)}};if(D.useEffect(()=>{e&&c(e)},[e]),!e&&!s)return null;const _=e||s,y=s&&e&&s.taskReferenceName===e.taskReferenceName?s:_,S=t&&e?"panel-enter-active":"panel-exit",w=a==="edit",E="var(--text-primary)",T="var(--glass-border)",C="var(--bg-tertiary)",R="var(--text-secondary)",A=(W,z)=>{const K={...y,[W]:z};c(K),i(y.taskReferenceName,{[W]:z})},B=(W,z,K)=>{const F={...y[W]||{},[z]:K},G={...y,[W]:F};c(G),i(y.taskReferenceName,{[W]:F})},N=(W,z)=>{const K=y.inputParameters||{},F={...K.http_request||y.httpRequest||{},[W]:z},k={inputParameters:{...K,http_request:F}};y.httpRequest&&(k.httpRequest=F);const I={...y,...k};c(I),i(y.taskReferenceName,k)},M=(W,z)=>{const j={inputParameters:{...y.inputParameters,[W]:z}},F={...y,...j};c(F),i(y.taskReferenceName,j)},L=(W,z,K,j)=>f.jsxs("div",{style:{marginBottom:"24px",padding:"16px",borderRadius:"12px",background:`${K}10`,border:`1px solid ${K}30`,boxShadow:"0 4px 12px rgba(0,0,0,0.05)"},children:[f.jsxs("div",{style:{fontSize:"12px",fontWeight:"bold",marginBottom:"16px",color:K,display:"flex",alignItems:"center",gap:"8px"},children:[f.jsx("span",{children:z})," ",W]}),j]}),$=(W,z,K="text")=>{const j=z==="taskReferenceName",F=j&&!o(y[z],y.taskReferenceName);return f.jsxs("div",{style:{marginBottom:"16px"},children:[f.jsxs("label",{style:{display:"block",fontSize:"11px",color:R,marginBottom:"6px",fontWeight:"600",textTransform:"uppercase"},children:[W,j&&F&&f.jsx("span",{style:{color:"#ef4444",marginLeft:"8px",textTransform:"none"},children:"⚠️ 已存在相同引用名"})]}),f.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center"},children:[f.jsx("input",{type:K,value:y[z]||"",onChange:G=>A(z,G.target.value),disabled:!w||j&&!w,style:{width:"100%",padding:`8px ${w&&!j?"32px":"12px"} 8px 12px`,borderRadius:"6px",border:`1px solid ${F?"#ef4444":T}`,background:C,color:E,fontSize:"13px",outline:"none",opacity:w?1:.8,fontFamily:j?"monospace":"inherit"}}),w&&!j&&f.jsx("button",{className:"ai-hint-trigger",onClick:G=>b(G,k=>A(z,k)),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:"✨"})]})]})},U=(W,z,K=!1)=>{const j=typeof y[z]=="object"?JSON.stringify(y[z],null,2):y[z];return f.jsxs("div",{style:{marginBottom:"16px"},children:[f.jsxs("label",{style:{display:"block",fontSize:"11px",color:R,marginBottom:"6px",fontWeight:"600",textTransform:"uppercase"},children:[W," ",K&&f.jsx("span",{style:{opacity:.5,fontWeight:"normal"},children:"(JSON)"})]}),f.jsx("textarea",{value:j||"",onChange:F=>{let G=F.target.value;if(K)try{G=JSON.parse(F.target.value)}catch{c(I=>({...I,[z]:F.target.value}));return}A(z,G)},disabled:!w,rows:z==="description"?3:5,style:{width:"100%",padding:"8px 12px",borderRadius:"6px",border:`1px solid ${T}`,background:C,color:E,fontSize:"12px",fontFamily:"monospace",outline:"none",resize:"vertical"}})]})};return f.jsxs("div",{className:`detail-panel-container ${S}`,style:{position:"absolute",right:0,top:0,bottom:0,width:"450px",zIndex:1200,display:"flex",flexDirection:"column",background:"var(--bg-primary)",borderLeft:`1px solid ${T}`,boxShadow:"-10px 0 30px rgba(0, 0, 0, 0.2)",overflowY:"hidden"},children:[f.jsxs("div",{style:{padding:"24px",borderBottom:`1px solid ${T}`,background:"var(--bg-secondary)",flexShrink:0},children:[f.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[f.jsx("div",{style:{background:"var(--color-accent)",color:"#fff",padding:"2px 8px",borderRadius:"4px",fontSize:"10px",fontWeight:"bold",letterSpacing:"1px"},children:y.type||"TASK"}),f.jsx("button",{onClick:r,style:{background:"none",border:"none",color:E,cursor:"pointer",fontSize:"20px"},children:"✕"})]}),w?f.jsx("input",{value:y.name||"",onChange:W=>A("name",W.target.value),placeholder:"任务名称",style:{display:"block",width:"100%",fontSize:"22px",fontWeight:"bold",background:"transparent",border:"none",color:E,outline:"none",borderBottom:"2px dashed var(--color-accent)"}}):f.jsx("div",{style:{fontSize:"22px",fontWeight:"bold"},children:y.name}),f.jsxs("div",{style:{fontSize:"12px",color:R,marginTop:"8px",fontFamily:"monospace",opacity:.8},children:["REF: ",y.taskReferenceName]})]}),f.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"24px",background:"var(--bg-primary)"},children:[y.type==="HTTP"&&L("HTTP 请求配置","🌐","var(--color-accent)",f.jsxs(f.Fragment,{children:[f.jsxs("div",{style:{display:"flex",gap:"8px",marginBottom:"12px"},children:[f.jsx("select",{value:y.inputParameters?.http_request?.method||y.httpRequest?.method||"GET",onChange:W=>N("method",W.target.value),disabled:!w,style:{width:"90px",padding:"10px",borderRadius:"8px",background:C,color:E,border:`1px solid ${T}`,cursor:"pointer"},children:["GET","POST","PUT","DELETE","PATCH"].map(W=>f.jsx("option",{value:W,children:W},W))}),f.jsx("input",{placeholder:"URI (支持 ${workflow.input.uri})",value:y.inputParameters?.http_request?.uri||y.httpRequest?.uri||"",onChange:W=>N("uri",W.target.value),disabled:!w,style:{flex:1,padding:"10px",borderRadius:"8px",background:C,color:E,border:`1px solid ${T}`}})]}),f.jsxs("div",{style:{marginBottom:"12px"},children:[f.jsx("label",{style:{display:"block",fontSize:"10px",color:R,marginBottom:"4px"},children:"HEADERS (JSON)"}),f.jsx("textarea",{value:typeof(y.inputParameters?.http_request?.headers||y.httpRequest?.headers)=="object"?JSON.stringify(y.inputParameters?.http_request?.headers||y.httpRequest?.headers,null,2):"{}",onChange:W=>{try{N("headers",JSON.parse(W.target.value))}catch{}},disabled:!w,rows:3,style:{width:"100%",padding:"8px",borderRadius:"8px",background:C,color:E,border:`1px solid ${T}`,fontSize:"11px",fontFamily:"monospace"}})]}),f.jsx("label",{style:{display:"block",fontSize:"10px",color:R,marginBottom:"4px"},children:"BODY (RAW/JSON)"}),f.jsx("textarea",{value:typeof(y.inputParameters?.http_request?.body||y.httpRequest?.body)=="object"?JSON.stringify(y.inputParameters?.http_request?.body||y.httpRequest?.body,null,2):y.inputParameters?.http_request?.body||y.httpRequest?.body||"",onChange:W=>{let z=W.target.value;try{z=JSON.parse(W.target.value)}catch{}N("body",z)},disabled:!w,rows:4,style:{width:"100%",padding:"8px",borderRadius:"8px",background:C,color:E,border:`1px solid ${T}`,fontSize:"11px",fontFamily:"monospace"}})]})),y.type==="LAMBDA"&&L("Lambda 脚本配置","📜","var(--color-accent)",f.jsxs(f.Fragment,{children:[f.jsx("label",{style:{display:"block",fontSize:"10px",color:R,marginBottom:"4px"},children:"SCRIPT EXPRESSION (JS)"}),f.jsx("textarea",{value:y.inputParameters?.scriptExpression||"",onChange:W=>M("scriptExpression",W.target.value),disabled:!w,rows:10,style:{width:"100%",padding:"12px",borderRadius:"8px",background:"#000",color:"var(--color-accent)",border:"1px solid var(--color-accent)",fontSize:"12px",fontFamily:"monospace",lineHeight:"1.5"}}),f.jsx("div",{style:{marginTop:"8px",fontSize:"10px",color:R,fontStyle:"italic"},children:"提示: 使用 `$.input.key` 访问参数,返回值为节点输出。"})]})),y.type==="JSON_JQ_TRANSFORM"&&L("JQ 数据转换","🔍","var(--color-accent)",f.jsxs(f.Fragment,{children:[f.jsx("label",{style:{display:"block",fontSize:"10px",color:R,marginBottom:"4px"},children:"JQ QUERY"}),f.jsx("textarea",{value:y.inputParameters?.queryExpression||"",onChange:W=>M("queryExpression",W.target.value),disabled:!w,rows:6,style:{width:"100%",padding:"12px",borderRadius:"8px",background:C,color:"var(--color-accent)",border:`1px solid ${T}`,fontSize:"12px",fontFamily:"monospace",lineHeight:"1.5"}})]})),y.type==="SUB_WORKFLOW"&&L("子工作流配置","🏗️","var(--color-accent)",f.jsxs(f.Fragment,{children:[f.jsxs("div",{style:{marginBottom:"12px"},children:[f.jsx("label",{style:{display:"block",fontSize:"10px",color:R,marginBottom:"4px"},children:"WORKFLOW NAME"}),f.jsx("input",{value:y.subWorkflowParam?.name||"",onChange:W=>B("subWorkflowParam","name",W.target.value),disabled:!w,style:{width:"100%",padding:"10px",borderRadius:"8px",background:C,color:E,border:`1px solid ${T}`}})]}),f.jsx("label",{style:{display:"block",fontSize:"10px",color:R,marginBottom:"4px"},children:"VERSION"}),f.jsx("input",{type:"number",value:y.subWorkflowParam?.version||1,onChange:W=>B("subWorkflowParam","version",parseInt(W.target.value)),disabled:!w,style:{width:"100px",padding:"10px",borderRadius:"8px",background:C,color:E,border:`1px solid ${T}`}})]})),y.type==="TERMINATE"&&L("终止状态配置","⏹️","var(--color-accent)",f.jsxs(f.Fragment,{children:[f.jsx("label",{style:{display:"block",fontSize:"10px",color:R,marginBottom:"4px"},children:"TERMINATION STATUS"}),f.jsx("div",{style:{display:"flex",gap:"8px",marginBottom:"16px"},children:["COMPLETED","FAILED"].map(W=>f.jsx("button",{onClick:()=>M("terminationStatus",W),disabled:!w,style:{flex:1,padding:"8px",borderRadius:"6px",cursor:"pointer",background:(y.inputParameters?.terminationStatus||"COMPLETED")===W?"var(--color-accent)":C,color:(y.inputParameters?.terminationStatus||"COMPLETED")===W?"#fff":E,border:`1px solid ${T}`,fontWeight:"bold",fontSize:"11px"},children:W},W))}),f.jsx("label",{style:{display:"block",fontSize:"10px",color:R,marginBottom:"4px"},children:"TERMINATION REASON"}),f.jsx("input",{placeholder:"终止原因...",value:y.inputParameters?.terminationReason||"",onChange:W=>M("terminationReason",W.target.value),disabled:!w,style:{width:"100%",padding:"10px",borderRadius:"8px",background:C,color:E,border:`1px solid ${T}`}})]})),y.type==="EVENT"&&L("事件发送配置","✉️","var(--color-accent)",f.jsxs(f.Fragment,{children:[f.jsx("label",{style:{display:"block",fontSize:"10px",color:R,marginBottom:"4px"},children:"EVENT SINK (地址/队列名)"}),f.jsx("input",{placeholder:"e.g. sqs:queue_name or conductor",value:y.sink||"",onChange:W=>A("sink",W.target.value),disabled:!w,style:{width:"100%",padding:"10px",borderRadius:"8px",background:C,color:E,border:`1px solid ${T}`}})]})),y.type==="WAIT"&&L("等待状态配置","⏳","var(--color-accent)",f.jsxs("div",{style:{fontSize:"12px",color:R,lineHeight:"1.6"},children:["此任务将使工作流进入 ",f.jsx("b",{children:"IN_PROGRESS"})," 状态,直到外部信号触发更新或达到超时时间。",f.jsx("br",{}),f.jsx("br",{}),"您可以在下方设置超时限制。"]})),(y.type==="DECISION"||y.type==="SWITCH")&&L("决策条件配置","⚖️","var(--color-accent)",f.jsxs(f.Fragment,{children:[$("判断参数名","caseValueParam"),U("JS 表达式","caseExpression")]})),y.type==="DO_WHILE"&&L("循环逻辑配置","🔄","var(--color-accent)",f.jsx(f.Fragment,{children:U("循环结束条件 (JS)","loopCondition")})),f.jsxs("div",{style:{marginTop:"32px",borderTop:`1px solid ${T}`,paddingTop:"24px"},children:[f.jsx("div",{style:{fontSize:"11px",fontWeight:"bold",marginBottom:"16px",opacity:.6,textTransform:"uppercase",letterSpacing:"1px"},children:"通用参数与属性"}),$("任务唯一引用名 (Reference Name)","taskReferenceName"),$("任务描述","description"),U("输入参数 (inputParameters)","inputParameters",!0),f.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px",marginTop:"16px"},children:[$("重试次数","retryCount","number"),$("超时限制 (秒)","timeoutSeconds","number")]})]}),f.jsx("div",{style:{marginTop:"48px",opacity:.6},children:f.jsxs("details",{children:[f.jsx("summary",{style:{fontSize:"11px",cursor:"pointer",marginBottom:"8px"},children:"查看完整 JSON (只读)"}),f.jsx("pre",{style:{background:"rgba(0,0,0,0.2)",padding:"16px",borderRadius:"8px",fontSize:"10px",overflow:"auto",border:`1px solid ${T}`,color:R},children:JSON.stringify(y,null,2)})]})})]}),w&&f.jsxs("div",{style:{padding:"24px",borderTop:`1px solid ${T}`,background:"var(--bg-secondary)",display:"flex",gap:"12px",flexShrink:0},children:[f.jsx("div",{style:{flex:1,fontSize:"11px",color:R,display:"flex",alignItems:"center"},children:"✅ 所有修改已实时同步"}),f.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:"完成退出"})]}),f.jsx(bb,{isOpen:u,onClose:()=>d(!1),onSelect:g,suggestions:h,anchorRect:l})]})},_b=D.memo(xb),xh={id:"1",role:"ai",content:"你好!我是您的流程助手。我可以帮你生成工作流框架、优化逻辑或提供参数配置建议。你想实现什么样的流程?",type:"text"},_h=e=>e.split(/(```[\s\S]*?```)/).map((r,n)=>{if(r.startsWith("```")&&r.endsWith("```")){const a=r.slice(3,-3),i=a.indexOf(`
228
- `),o=i>=0?a.slice(i+1):a;return f.jsx("pre",{children:f.jsx("code",{children:o})},n)}return f.jsx("span",{children:kb(r)},n)}),kb=e=>{const t=[],r=/(\*\*[^*]+\*\*|`[^`]+`|\n)/g;let n=0,a;for(;(a=r.exec(e))!==null;){a.index>n&&t.push(e.slice(n,a.index));const i=a[0];i.startsWith("**")&&i.endsWith("**")?t.push(f.jsx("strong",{children:i.slice(2,-2)},a.index)):i.startsWith("`")&&i.endsWith("`")?t.push(f.jsx("code",{children:i.slice(1,-1)},a.index)):i===`
229
- `&&t.push(f.jsx("br",{},a.index)),n=a.index+i.length}return n<e.length&&t.push(e.slice(n)),t},Sb=({aiConfig:e})=>{const{workflowDef:t,applyAIGeneratedWorkflow:r}=V(),[n,a]=D.useState(!1),[i,o]=D.useState(""),[s,c]=D.useState(!1),[u,d]=D.useState([xh]),[l,p]=D.useState(""),[h,m]=D.useState(null),g=D.useRef(null),v=D.useRef(null),x=D.useRef(null),b=()=>{const N=v.current;N&&(N.style.height="auto",N.style.height=Math.min(N.scrollHeight,120)+"px")},_=()=>{const N=v.current;N&&(N.style.height="auto")};D.useEffect(()=>()=>{x.current?.abort()},[]),D.useEffect(()=>{const N=()=>a(!0);return window.addEventListener("open-ai-chat",N),()=>window.removeEventListener("open-ai-chat",N)},[]);const y=()=>{g.current?.scrollIntoView({behavior:"smooth"})};D.useEffect(()=>{n&&y()},[u,n,l]);const S=D.useCallback(N=>{const M=[{role:"system",content:gb}];for(const $ of u)$.role==="user"?M.push({role:"user",content:$.content}):$.role==="ai"&&!$.error&&M.push({role:"assistant",content:$.content});const L=mb(N,t);return M.push({role:"user",content:L}),M},[u,t]),w=async N=>{const M=N||i.trim();if(!M||s)return;x.current?.abort();const L=new AbortController;x.current=L;const $={id:Date.now().toString(),role:"user",content:M,type:"text"};N||(d(U=>[...U,$]),o(""),_()),c(!0),p("");try{const U=e?.apiKey||localStorage.getItem("AI_API_KEY")||"",W=e?.baseUrl||localStorage.getItem("AI_BASE_URL")||"",z=e?.model||localStorage.getItem("AI_MODEL")||"";if(!U){setTimeout(()=>{if(L.signal.aborted)return;const P={id:(Date.now()+1).toString(),role:"ai",content:"由于未检测到 API Key,我为您模拟了一个简单的审批流程:",type:"change_suggestion",payload:{name:"demo_approval",tasks:[{name:"submit_request",taskReferenceName:"submit_1",type:"SIMPLE"},{name:"manager_approve",taskReferenceName:"approve_1",type:"SIMPLE"}]}};d(O=>[...O,P]),c(!1)},1e3);return}const K={apiKey:U};W&&(K.baseUrl=W),z&&(K.model=z);const j=S(M),F=await vb(j,K,P=>{p(O=>O+P)},()=>{},L.signal),G=F.match(/```json\n([\s\S]*?)\n```/),k=G?JSON.parse(G[1]):null,I={id:(Date.now()+1).toString(),role:"ai",content:F,type:k?"change_suggestion":"text",payload:k};d(P=>[...P,I]),p("")}catch(U){if(U.name==="AbortError")p(W=>{if(W){const z={id:(Date.now()+1).toString(),role:"ai",content:W,type:"text"};d(K=>[...K,z])}return""});else{const W={id:Date.now().toString(),role:"ai",content:`抱歉,目前无法连接到 AI 服务: ${U.message}`,error:!0};d(z=>[...z,W]),p("")}}finally{c(!1)}},E=()=>{x.current?.abort()},T=()=>{x.current?.abort(),d([xh]),p(""),c(!1)},C=N=>{navigator.clipboard.writeText(N.content),m(N.id),setTimeout(()=>m(null),1500)},R=()=>{const N=[...u].reverse().find(M=>M.role==="user");N&&(d(M=>M[M.length-1]?.error?M.slice(0,-1):M),w(N.content))},A=N=>{r(N)},B=N=>{N.nativeEvent.isComposing||N.keyCode===229||N.key==="Enter"&&!N.shiftKey&&(N.preventDefault(),w())};return n?f.jsxs("div",{className:"ai-chat-panel",children:[f.jsxs("div",{className:"ai-header",children:[f.jsxs("div",{className:"ai-title",children:[f.jsx("span",{className:"ai-sparkles",children:"✨"}),"AI 助手"]}),f.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[f.jsx("button",{className:"ai-close",onClick:T,title:"清空对话",children:"🗑"}),f.jsx("button",{className:"ai-close",onClick:()=>a(!1),children:"×"})]})]}),f.jsxs("div",{className:"ai-messages",children:[u.map(N=>f.jsxs("div",{className:`message ${N.role}${N.error?" error":""}`,children:[f.jsx("div",{className:"message-content",children:N.role==="ai"?_h(N.content):N.content}),N.type==="change_suggestion"&&N.payload&&f.jsxs("div",{className:"change-card",children:[f.jsx("div",{className:"card-header",children:"工作流修改建议"}),f.jsxs("div",{className:"card-actions",children:[f.jsx("button",{className:"card-btn",children:"预览"}),f.jsx("button",{className:"card-btn apply",onClick:()=>A(N.payload),children:"应用"})]})]}),N.role==="ai"&&!N.error&&f.jsx("button",{className:"copy-btn",onClick:()=>C(N),title:"复制",children:h===N.id?"✓":"📋"}),N.error&&f.jsx("button",{className:"retry-btn",onClick:R,children:"重试"})]},N.id)),s&&l&&f.jsxs("div",{className:"message ai",style:{opacity:.9},children:[f.jsx("div",{className:"message-content",children:_h(l)}),f.jsx("span",{className:"streaming-cursor",children:"▊"})]}),s&&!l&&f.jsxs("div",{className:"message ai thinking-skeleton",children:[f.jsx("div",{className:"skeleton-line",style:{width:"80%"}}),f.jsx("div",{className:"skeleton-line",style:{width:"60%"}}),f.jsx("div",{className:"skeleton-line",style:{width:"70%"}})]}),f.jsx("div",{ref:g})]}),f.jsx("div",{className:"ai-input-area",children:f.jsxs("div",{className:"ai-input-container",children:[f.jsx("textarea",{ref:v,className:"ai-input",placeholder:s?"AI 正在响应...":"描述您的需求…(Shift+Enter 换行)",value:i,onChange:N=>o(N.target.value),onInput:b,onKeyDown:B,disabled:s,rows:2}),s?f.jsx("button",{className:"ai-send stop",onClick:E,title:"停止生成",children:"⏹"}):f.jsx("button",{className:"ai-send",onClick:()=>w(),title:"发送",children:"🚀"})]})})]}):f.jsx("div",{className:"ai-chat-panel collapsed",onClick:()=>a(!0),children:f.jsx("div",{className:"ai-header",style:{borderBottom:"none"},children:f.jsxs("div",{className:"ai-title",children:[f.jsx("span",{className:"ai-sparkles",children:"✨"}),"AI 助手"]})})})},kh=D.forwardRef(({workflowDef:e,readOnly:t=!1,theme:r="dark",themeColor:n="blue",layoutDirection:a="LR",searchQuery:i="",workflowExecution:o,onRequestImport:s,executionActions:c,aiConfig:u,onSave:d,onWorkflowChange:l,height:p="100%"},h)=>{const{setWorkflow:m,setTheme:g,setThemeColor:v,setLayoutDirection:x,setNodesLocked:b,selectedTask:_,setSelectedTask:y,edgeType:S,importExecutionJSON:w,setMode:E,isDetailPanelOpen:T,setIsDetailPanelOpen:C,selectTaskAction:R}=V(),[A,B]=D.useState(!1);D.useEffect(()=>{g(r),v(n),x(a),b(t||!!o)},[r,n,a,t,o,g,v,x,b]),D.useEffect(()=>{e&&(m(e,a),V.temporal.getState().clear())},[e,m,a]),D.useEffect(()=>{o?w(o):E(t?"view":"edit")},[o,w,E,t]),D.useImperativeHandle(h,()=>({getWorkflowDef:()=>V.getState().workflowDef,getValidationResults:()=>V.getState().validationResults,save:()=>{const M=V.getState().workflowDef;M&&d&&d(M)},createBlankWorkflow:M=>{V.getState().createBlankWorkflow(M),V.temporal.getState().clear()}}),[d]),D.useEffect(()=>{if(!l)return;let M=!0,L=V.getState().workflowDef;return V.subscribe(U=>{const W=U.workflowDef;if(W!==L){if(L=W,M){M=!1;return}W&&l(W)}})},[l]);const N=M=>{o?y(M):R(M,!0)};return f.jsxs("div",{className:`workflow-ide ${r==="light"?"light-theme":""}`,"data-mode":r,"data-brand":n,style:{width:"100%",height:p,display:"flex",position:"relative",overflow:"hidden"},children:[f.jsxs("div",{className:"workflow-viewer",style:{flex:1,position:"relative"},children:[f.jsx(q.ReactFlowProvider,{children:f.jsx(pb,{onNodeClick:N,edgeType:S,theme:r,nodesLocked:t||!!o,searchQuery:i,onSave:d,onRequestImport:s,executionActions:c})}),f.jsx("div",{style:{position:"absolute",top:10,right:10,zIndex:10,display:"flex",gap:8}})]}),f.jsx(_b,{task:_,isOpen:T,onClose:()=>C(!1),theme:r,aiConfig:u}),f.jsx(lh,{isOpen:A,onClose:()=>B(!1),theme:r,onTaskSelect:M=>{R(M,!0)}}),o&&f.jsx(dh,{}),f.jsx(Sb,{aiConfig:u})]})});kh.displayName="WorkflowIDE",Se.WorkflowIDE=kh,Object.defineProperty(Se,Symbol.toStringTag,{value:"Module"})}));
84
+ `,Xx=({isOpen:e,onClose:r,onSelect:t,suggestions:n,anchorRect:o})=>{if(!e||!o)return null;const a={position:"fixed",top:o.bottom+8,left:Math.max(o.left-200,20),width:"280px",zIndex:3e3};return d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"suggester-overlay",onClick:r}),d.jsxs("div",{className:"parameter-suggester-popover glass-panel",style:a,children:[d.jsxs("div",{className:"suggester-header",children:[d.jsx("span",{className:"sparkle-icon",children:"✨"}),"AI Suggestions"]}),d.jsx("div",{className:"suggester-list",children:n.length===0?d.jsxs("div",{className:"suggester-loading",children:[d.jsx("div",{className:"suggester-skeleton-line",style:{width:"85%"}}),d.jsx("div",{className:"suggester-skeleton-line",style:{width:"65%"}}),d.jsx("div",{className:"suggester-skeleton-line",style:{width:"75%"}})]}):n.map((i,s)=>d.jsxs("div",{className:"suggestion-item",onClick:()=>{t(i.value),r()},children:[d.jsx("div",{className:"suggestion-label",children:i.label}),d.jsx("div",{className:"suggestion-value",children:i.value}),d.jsx("div",{className:"suggestion-desc",children:i.description})]},s))})]})]})},Zx=({title:e,value:r,language:t="text",placeholder:n="",onSave:o,onClose:a})=>{const{theme:i,themeColor:s}=oe(),[l,u]=q.useState(r),c=q.useRef(null);q.useEffect(()=>{c.current?.focus();const h=g=>{g.key==="Escape"&&(g.stopPropagation(),a()),(g.ctrlKey||g.metaKey)&&g.key==="s"&&(g.preventDefault(),g.stopPropagation(),o(l))};return window.addEventListener("keydown",h,!0),()=>window.removeEventListener("keydown",h,!0)},[l,o,a]);const p={javascript:"#f7df1e",js:"#f7df1e",json:"#89b4fa",jq:"#a6e3a1",groovy:"#4ec994",python:"#3572A5",text:"var(--text-secondary)"}[t.toLowerCase()]??"var(--text-secondary)";return Gr.createPortal(d.jsxs("div",{"data-mode":i,"data-brand":s,style:{position:"fixed",inset:0,zIndex:3e3,display:"flex",flexDirection:"column",background:"var(--bg-primary)"},onClick:h=>h.stopPropagation(),children:[d.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:[d.jsx("span",{style:{fontSize:"11px",fontWeight:700,color:p,background:`${p}18`,border:`1px solid ${p}44`,padding:"2px 8px",borderRadius:"4px",fontFamily:"monospace",letterSpacing:"0.5px",textTransform:"uppercase",flexShrink:0},children:t}),d.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:"var(--text-primary)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e}),d.jsx("span",{style:{fontSize:"11px",color:"var(--text-secondary)",flexShrink:0},children:"Ctrl+S 保存 · Esc 取消"}),d.jsx("button",{onClick:a,style:{padding:"6px 14px",background:"var(--bg-tertiary)",border:"1px solid var(--glass-border)",borderRadius:"6px",color:"var(--text-primary)",cursor:"pointer",fontSize:"12px",fontWeight:500,flexShrink:0},children:"取消"}),d.jsx("button",{onClick:()=>o(l),style:{padding:"6px 16px",background:"var(--color-accent)",border:"none",borderRadius:"6px",color:"#fff",cursor:"pointer",fontSize:"12px",fontWeight:600,flexShrink:0},children:"应用"})]}),d.jsx("textarea",{ref:c,value:l,placeholder:n,onChange:h=>u(h.target.value),onKeyDown:h=>h.stopPropagation(),spellCheck:!1,style:{flex:1,width:"100%",padding:"20px 24px",background:"var(--bg-primary)",color:t==="javascript"||t==="js"||t==="groovy"?"var(--color-accent)":"var(--text-primary)",border:"none",outline:"none",resize:"none",fontFamily:'var(--font-mono, "Fira Code", "Cascadia Code", Consolas, monospace)',fontSize:"14px",lineHeight:"1.7",boxSizing:"border-box",caretColor:"var(--color-accent)"}}),d.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:[d.jsxs("span",{children:[l.split(`
85
+ `).length," 行"]}),d.jsxs("span",{children:[l.length," 字符"]}),l!==r&&d.jsx("span",{style:{color:"#f59e0b",fontWeight:600},children:"● 未保存"})]})]}),document.body)},Qx=[{label:"工作流输入",value:"${workflow.input.fieldName}",desc:"引用工作流启动时传入的参数"},{label:"上游任务输出",value:"${taskRef.output.result}",desc:"引用上游任务的输出字段"},{label:"工作流变量",value:"${workflow.variables.varName}",desc:"引用 SET_VARIABLE 设置的变量"},{label:"工作流 ID",value:"${workflow.workflowId}",desc:"当前工作流实例 ID"},{label:"关联 ID",value:"${workflow.correlationId}",desc:"工作流关联 ID"},{label:"工作流状态",value:"${workflow.status}",desc:"当前工作流状态"}],eb=({task:e,isOpen:r=!0,onClose:t,aiConfig:n})=>{const{mode:o,updateTask:a,checkTaskRefUniqueness:i}=oe(),[s,l]=q.useState(e),[u,c]=q.useState(e?.taskReferenceName??null),[f,p]=q.useState(null),[h,g]=q.useState(!1),[v,m]=q.useState(null),[x,y]=q.useState(()=>e?.type==="WAIT"&&e.inputParameters?.until?"until":"duration"),[b,k]=q.useState(()=>e?.type==="DO_WHILE"&&e.inputParameters?.items?"items":"condition"),[S,C]=q.useState(()=>!e||e.type!=="FORK_JOIN_DYNAMIC"?"classic":e.forkTaskWorkflow?"workflow":e.forkTaskType?"task":"classic"),[N,A]=q.useState(!1),[w,I]=q.useState(),[R,B]=q.useState([]),[D,L]=q.useState(()=>()=>{}),[F,W]=q.useState(null),V=(T,U,Q,te)=>{W({title:T,value:U,language:Q,onSave:te})},Z=[{label:"引用工作流输入",value:"${workflow.input.data}",description:"引用工作流启动时传入的原始数据"},{label:"引用前序任务输出",value:"${previous_task.output.result}",description:"引用上一个节点的计算结果"},{label:"环境变量",value:"${workflow.variables.api_key}",description:"引用工作流定义的全局变量"}],le=async(T,U)=>{const Q=T.currentTarget.getBoundingClientRect();I(Q),L(()=>U),B([]),A(!0);const te=n?.apiKey||localStorage.getItem("AI_API_KEY")||"";if(!te){B(Z);return}try{const re=n?.baseUrl||localStorage.getItem("AI_BASE_URL")||"",ge=n?.model||localStorage.getItem("AI_MODEL")||"",ve={apiKey:te};re&&(ve.baseUrl=re),ge&&(ve.model=ge);const{workflowDef:ce}=oe.getState(),ye=Yx(se,ce),Ce=(await Ux([{role:"system",content:"You are a Conductor workflow expert. Return only valid JSON."},{role:"user",content:ye}],ve)).match(/\[[\s\S]*\]/);if(Ce){const Xe=JSON.parse(Ce[0]);B(Xe)}else B(Z)}catch{B(Z)}};if(q.useEffect(()=>{e&&(l(e),c(e.taskReferenceName),p(null),e.type==="WAIT"&&y(e.inputParameters?.until?"until":"duration"),e.type==="DO_WHILE"&&k(e.inputParameters?.items?"items":"condition"),e.type==="FORK_JOIN_DYNAMIC"&&(e.forkTaskWorkflow?C("workflow"):e.forkTaskType?C("task"):C("classic")))},[e]),!e&&!s)return null;const se=e||s,_=s&&e&&u===e.taskReferenceName?s:se,Y=r&&e?"panel-enter-active":"panel-exit",K=o==="edit",E="var(--text-primary)",j="var(--glass-border)",M="var(--bg-tertiary)",P="var(--text-secondary)",z=(T,U)=>{const Q={..._,[T]:U};l(Q),a(_.taskReferenceName,{[T]:U})},ee=(T,U,Q)=>{const re={..._[T]||{},[U]:Q},ge={..._,[T]:re};l(ge),a(_.taskReferenceName,{[T]:re})},ae=(T,U)=>{const Q=_.inputParameters||{},re={...Q.http_request||_.httpRequest||{},[T]:U},ve={inputParameters:{...Q,http_request:re}};_.httpRequest&&(ve.httpRequest=re);const ce={..._,...ve};l(ce),a(_.taskReferenceName,ve)},ie=(T,U)=>{const te={inputParameters:{..._.inputParameters,[T]:U}},re={..._,...te};l(re),a(_.taskReferenceName,te)},ne=T=>{if(!v)return;const U=v.selectionStart??0,Q=v.selectionEnd??0,te=v.value,re=te.substring(0,U)+T+te.substring(Q),ge=v.getAttribute("data-field");ge&&z(ge,re),g(!1)},G=(T,U,Q,te)=>d.jsxs("div",{style:{marginBottom:"24px",padding:"16px",borderRadius:"12px",background:`${Q}10`,border:`1px solid ${Q}30`,boxShadow:"0 4px 12px rgba(0,0,0,0.05)"},children:[d.jsxs("div",{style:{fontSize:"12px",fontWeight:"bold",marginBottom:"16px",color:Q,display:"flex",alignItems:"center",gap:"8px"},children:[d.jsx("span",{children:U})," ",T]}),te]}),J=(T,U,Q="text",te)=>{const re=U==="taskReferenceName",ge=re&&f!==null?f:_[U]??"",ve=re&&!i(ge,_.taskReferenceName);return d.jsxs("div",{style:{marginBottom:"16px"},children:[d.jsxs("label",{style:{display:"block",fontSize:"11px",color:P,marginBottom:"6px",fontWeight:"600",textTransform:"uppercase"},children:[T,re&&ve&&d.jsx("span",{style:{color:"#ef4444",marginLeft:"8px",textTransform:"none"},children:"⚠️ 已存在相同引用名"})]}),d.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center"},children:[d.jsx("input",{type:Q,value:ge,placeholder:te,onChange:ce=>{re?p(ce.target.value):z(U,Q==="number"?ce.target.value===""?void 0:Number(ce.target.value):ce.target.value)},onFocus:re?()=>{f===null&&p(_.taskReferenceName??"")}:void 0,onBlur:re?ce=>{const ye=ce.target.value.trim();p(null),ye&&ye!==_.taskReferenceName&&z("taskReferenceName",ye)}:void 0,onKeyDown:re?ce=>{ce.key==="Enter"&&ce.currentTarget.blur(),ce.stopPropagation()}:void 0,disabled:!K,style:{width:"100%",padding:`8px ${K&&!re?"32px":"12px"} 8px 12px`,borderRadius:"6px",border:`1px solid ${ve?"#ef4444":j}`,background:M,color:E,fontSize:"13px",outline:"none",opacity:K?1:.8,fontFamily:re?"monospace":"inherit"}}),K&&!re&&d.jsx("button",{className:"ai-hint-trigger",onClick:ce=>le(ce,ye=>z(U,ye)),title:"AI 智能提示",style:{position:"absolute",right:"8px",background:"none",border:"none",cursor:"pointer",fontSize:"14px",padding:"4px",opacity:.6,display:"flex",alignItems:"center",justifyContent:"center"},children:"✨"})]})]})},H=(T,U,Q,te={})=>{const{rows:re=5,language:ge="text",style:ve,placeholder:ce,"data-field":ye}=te,$e={width:"100%",padding:"12px",borderRadius:"8px",border:`1px solid ${j}`,background:M,color:E,fontSize:"12px",fontFamily:"monospace",lineHeight:"1.5",resize:"vertical",...ve};return d.jsxs("div",{style:{marginBottom:"8px"},children:[d.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"4px"},children:[d.jsx("label",{style:{fontSize:"10px",color:P},children:T}),K&&d.jsx("button",{onClick:()=>V(T,U,ge,Ce=>{Q(Ce),W(null)}),title:"全屏编辑",style:{background:"none",border:"none",cursor:"pointer",fontSize:"14px",padding:"2px 4px",color:"var(--text-secondary)",opacity:.7,lineHeight:1},children:"⛶"})]}),d.jsx("textarea",{value:U,placeholder:ce,onChange:Ce=>Q(Ce.target.value),disabled:!K,rows:re,"data-field":ye,onFocus:Ce=>m(Ce.currentTarget),style:$e})]})},$=(T,U,Q,te="text",re)=>d.jsxs("div",{style:{marginBottom:"12px"},children:[d.jsx("label",{style:{display:"block",fontSize:"10px",color:P,marginBottom:"4px"},children:T}),d.jsx("input",{type:te,value:U??"",placeholder:re,onChange:ge=>Q(te==="number"?ge.target.value===""?void 0:Number(ge.target.value):ge.target.value),disabled:!K,style:{width:"100%",padding:"8px 10px",borderRadius:"6px",border:`1px solid ${j}`,background:M,color:E,fontSize:"12px",outline:"none"}})]}),X=(T,U,Q,te)=>d.jsxs("div",{style:{marginBottom:"12px"},children:[d.jsx("label",{style:{display:"block",fontSize:"10px",color:P,marginBottom:"4px"},children:T}),d.jsx("select",{value:Q,onChange:re=>te(re.target.value),disabled:!K,style:{width:"100%",padding:"8px 10px",borderRadius:"6px",border:`1px solid ${j}`,background:M,color:E,fontSize:"12px",outline:"none",cursor:"pointer"},children:U.map(re=>d.jsx("option",{value:re,children:re},re))})]}),de=(T,U,Q)=>d.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},children:[d.jsx("span",{style:{fontSize:"11px",color:P},children:T}),d.jsx("button",{onClick:()=>Q(!U),disabled:!K,style:{width:"36px",height:"20px",borderRadius:"10px",border:"none",cursor:"pointer",background:U?"var(--color-accent)":j,position:"relative",transition:"background 0.2s"},children:d.jsx("span",{style:{position:"absolute",top:"2px",left:U?"18px":"2px",width:"16px",height:"16px",borderRadius:"50%",background:"#fff",transition:"left 0.2s"}})})]}),ue=(T,U,Q)=>d.jsx("div",{style:{display:"flex",gap:"6px",marginBottom:"12px"},children:T.map(te=>d.jsx("button",{onClick:()=>Q(te.key),disabled:!K,style:{flex:1,padding:"6px",borderRadius:"6px",border:`1px solid ${j}`,cursor:"pointer",fontSize:"11px",fontWeight:U===te.key?"bold":"normal",background:U===te.key?"var(--color-accent)":M,color:U===te.key?"#fff":E},children:te.label},te.key))}),he=_.inputParameters?.http_request||_.httpRequest||{};return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:`detail-panel-container ${Y}`,style:{position:"absolute",right:0,top:0,bottom:0,width:"450px",zIndex:1200,display:"flex",flexDirection:"column",background:"var(--bg-primary)",borderLeft:`1px solid ${j}`,boxShadow:"-10px 0 30px rgba(0, 0, 0, 0.2)",overflowY:"hidden"},children:[d.jsxs("div",{style:{padding:"24px",borderBottom:`1px solid ${j}`,background:"var(--bg-secondary)",flexShrink:0},children:[d.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[d.jsx("div",{style:{background:"var(--color-accent)",color:"#fff",padding:"2px 8px",borderRadius:"4px",fontSize:"10px",fontWeight:"bold",letterSpacing:"1px"},children:_.type||"TASK"}),d.jsx("button",{onClick:t,style:{background:"none",border:"none",color:E,cursor:"pointer",fontSize:"20px"},children:"✕"})]}),K?d.jsx("input",{value:_.name||"",onChange:T=>z("name",T.target.value),placeholder:"任务名称",style:{display:"block",width:"100%",fontSize:"22px",fontWeight:"bold",background:"transparent",border:"none",color:E,outline:"none",borderBottom:"2px dashed var(--color-accent)"}}):d.jsx("div",{style:{fontSize:"22px",fontWeight:"bold"},children:_.name}),d.jsxs("div",{style:{fontSize:"12px",color:P,marginTop:"8px",fontFamily:"monospace",opacity:.8},children:["REF: ",_.taskReferenceName]})]}),d.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"24px",background:"var(--bg-primary)"},children:[_.type==="HTTP"&&G("HTTP 请求配置","🌐","var(--color-accent)",d.jsxs(d.Fragment,{children:[d.jsxs("div",{style:{display:"flex",gap:"8px",marginBottom:"12px"},children:[d.jsx("select",{value:he.method||"GET",onChange:T=>ae("method",T.target.value),disabled:!K,style:{width:"90px",padding:"10px",borderRadius:"8px",background:M,color:E,border:`1px solid ${j}`,cursor:"pointer"},children:["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"].map(T=>d.jsx("option",{value:T,children:T},T))}),d.jsx("input",{placeholder:"URI (支持 ${workflow.input.uri})",value:he.uri||"",onChange:T=>ae("uri",T.target.value),disabled:!K,style:{flex:1,padding:"10px",borderRadius:"8px",background:M,color:E,border:`1px solid ${j}`}})]}),d.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px",marginBottom:"12px"},children:[d.jsxs("div",{children:[d.jsx("label",{style:{display:"block",fontSize:"10px",color:P,marginBottom:"4px"},children:"CONTENT-TYPE"}),d.jsx("input",{placeholder:"application/json",value:he.contentType||"",onChange:T=>ae("contentType",T.target.value),disabled:!K,style:{width:"100%",padding:"8px",borderRadius:"6px",background:M,color:E,border:`1px solid ${j}`,fontSize:"12px"}})]}),d.jsxs("div",{children:[d.jsx("label",{style:{display:"block",fontSize:"10px",color:P,marginBottom:"4px"},children:"ACCEPT"}),d.jsx("input",{placeholder:"application/json",value:he.accept||"",onChange:T=>ae("accept",T.target.value),disabled:!K,style:{width:"100%",padding:"8px",borderRadius:"6px",background:M,color:E,border:`1px solid ${j}`,fontSize:"12px"}})]})]}),d.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px",marginBottom:"12px"},children:[d.jsxs("div",{children:[d.jsx("label",{style:{display:"block",fontSize:"10px",color:P,marginBottom:"4px"},children:"连接超时 (ms)"}),d.jsx("input",{type:"number",placeholder:"3000",value:he.connectionTimeOut??"",onChange:T=>ae("connectionTimeOut",T.target.value===""?void 0:Number(T.target.value)),disabled:!K,style:{width:"100%",padding:"8px",borderRadius:"6px",background:M,color:E,border:`1px solid ${j}`,fontSize:"12px"}})]}),d.jsxs("div",{children:[d.jsx("label",{style:{display:"block",fontSize:"10px",color:P,marginBottom:"4px"},children:"读取超时 (ms)"}),d.jsx("input",{type:"number",placeholder:"3000",value:he.readTimeOut??"",onChange:T=>ae("readTimeOut",T.target.value===""?void 0:Number(T.target.value)),disabled:!K,style:{width:"100%",padding:"8px",borderRadius:"6px",background:M,color:E,border:`1px solid ${j}`,fontSize:"12px"}})]})]}),d.jsxs("div",{style:{marginBottom:"12px"},children:[d.jsx("label",{style:{display:"block",fontSize:"10px",color:P,marginBottom:"4px"},children:"HEADERS (JSON)"}),d.jsx("textarea",{value:typeof he.headers=="object"?JSON.stringify(he.headers,null,2):"{}",onChange:T=>{try{ae("headers",JSON.parse(T.target.value))}catch{}},disabled:!K,rows:3,style:{width:"100%",padding:"8px",borderRadius:"8px",background:M,color:E,border:`1px solid ${j}`,fontSize:"11px",fontFamily:"monospace"}})]}),d.jsx("label",{style:{display:"block",fontSize:"10px",color:P,marginBottom:"4px"},children:"BODY (RAW/JSON)"}),d.jsx("textarea",{value:typeof he.body=="object"?JSON.stringify(he.body,null,2):he.body||"",onChange:T=>{let U=T.target.value;try{U=JSON.parse(T.target.value)}catch{}ae("body",U)},disabled:!K,rows:4,style:{width:"100%",padding:"8px",borderRadius:"8px",background:M,color:E,border:`1px solid ${j}`,fontSize:"11px",fontFamily:"monospace"}})]})),(_.type==="INLINE"||_.type==="LAMBDA")&&G("内联脚本配置 (Inline)","📜","var(--color-accent)",d.jsxs(d.Fragment,{children:[X("脚本引擎",["graaljs","javascript","value-param","python"],_.evaluatorType||"graaljs",T=>z("evaluatorType",T)),H(`EXPRESSION ${_.evaluatorType==="value-param"?"(值引用)":"(脚本)"}`,_.inputParameters?.expression||_.inputParameters?.scriptExpression||"",T=>{const U=_.inputParameters?.scriptExpression!==void 0?"scriptExpression":"expression";ie(U,T)},{rows:10,language:_.evaluatorType||"javascript",style:{background:"#000",color:"var(--color-accent)",border:"1px solid var(--color-accent)"}}),d.jsx("div",{style:{marginTop:"8px",fontSize:"10px",color:P,fontStyle:"italic"},children:"提示: 使用 $.input.key 访问输入参数,返回值作为任务输出。"})]})),_.type==="JSON_JQ_TRANSFORM"&&G("JQ 数据转换","🔍","var(--color-accent)",d.jsxs(d.Fragment,{children:[H("JQ QUERY EXPRESSION",_.inputParameters?.queryExpression||"",T=>ie("queryExpression",T),{rows:6,language:"jq",style:{color:"var(--color-accent)"}}),d.jsx("div",{style:{marginTop:"8px",fontSize:"10px",color:P},children:"输出字段: result(首个结果)、resultList(完整列表)"})]})),_.type==="SUB_WORKFLOW"&&G("子工作流配置","🏗️","var(--color-accent)",d.jsxs(d.Fragment,{children:[$("WORKFLOW NAME *",_.subWorkflowParam?.name||"",T=>ee("subWorkflowParam","name",T),"text","e.g. my_workflow"),$("VERSION",_.subWorkflowParam?.version??"",T=>ee("subWorkflowParam","version",T?parseInt(T):void 0),"number","1"),H("INPUT PARAMETERS MAPPING (JSON)",typeof _.inputParameters=="object"&&_.inputParameters!==null?JSON.stringify(_.inputParameters,null,2):"{}",T=>{try{z("inputParameters",JSON.parse(T))}catch{}},{rows:5,language:"json"}),d.jsxs("div",{style:{fontSize:"10px",color:P,marginTop:"4px"},children:["传递给子工作流的参数,支持 ","${workflow.input.xxx}"," 表达式"]})]})),_.type==="START_WORKFLOW"&&G("启动工作流配置","▶️","var(--color-accent)",d.jsxs(d.Fragment,{children:[d.jsxs("div",{style:{fontSize:"11px",color:P,marginBottom:"12px",padding:"8px",borderRadius:"6px",background:"rgba(255,165,0,0.1)",border:"1px solid rgba(255,165,0,0.3)"},children:["⚡ 注意:此任务启动目标工作流后立即继续,",d.jsx("b",{children:"不等待"}),"目标工作流完成。"]}),$("WORKFLOW NAME *",_.inputParameters?.startWorkflow?.name||"",T=>{const U={..._.inputParameters?.startWorkflow||{},name:T};ie("startWorkflow",U)},"text","e.g. target_workflow"),$("VERSION",_.inputParameters?.startWorkflow?.version??"",T=>{const U={..._.inputParameters?.startWorkflow||{},version:T?parseInt(T):void 0};ie("startWorkflow",U)},"number","1"),$("CORRELATION ID",_.inputParameters?.startWorkflow?.correlationId||"",T=>{const U={..._.inputParameters?.startWorkflow||{},correlationId:T};ie("startWorkflow",U)},"text","${workflow.correlationId}"),H("WORKFLOW INPUT (JSON)",typeof _.inputParameters?.startWorkflow?.input=="object"?JSON.stringify(_.inputParameters.startWorkflow.input,null,2):"{}",T=>{try{const U={..._.inputParameters?.startWorkflow||{},input:JSON.parse(T)};ie("startWorkflow",U)}catch{}},{rows:4,language:"json"})]})),_.type==="TERMINATE"&&G("终止状态配置","⏹️","var(--color-accent)",d.jsxs(d.Fragment,{children:[d.jsx("label",{style:{display:"block",fontSize:"10px",color:P,marginBottom:"4px"},children:"TERMINATION STATUS"}),d.jsx("div",{style:{display:"flex",gap:"8px",marginBottom:"16px"},children:["COMPLETED","FAILED"].map(T=>d.jsx("button",{onClick:()=>ie("terminationStatus",T),disabled:!K,style:{flex:1,padding:"8px",borderRadius:"6px",cursor:"pointer",background:(_.inputParameters?.terminationStatus||"COMPLETED")===T?"var(--color-accent)":M,color:(_.inputParameters?.terminationStatus||"COMPLETED")===T?"#fff":E,border:`1px solid ${j}`,fontWeight:"bold",fontSize:"11px"},children:T},T))}),$("TERMINATION REASON",_.inputParameters?.terminationReason||"",T=>ie("terminationReason",T),"text","终止原因..."),H("WORKFLOW OUTPUT (JSON)",typeof _.inputParameters?.workflowOutput=="object"?JSON.stringify(_.inputParameters.workflowOutput,null,2):"{}",T=>{try{ie("workflowOutput",JSON.parse(T))}catch{}},{rows:3,language:"json"})]})),_.type==="EVENT"&&G("事件发送配置","✉️","var(--color-accent)",d.jsxs(d.Fragment,{children:[$("EVENT SINK *",_.sink||"",T=>z("sink",T),"text","e.g. sqs:queue_name 或 conductor"),d.jsx("div",{style:{fontSize:"10px",color:P,marginTop:"4px",marginBottom:"8px"},children:"支持前缀: conductor | sqs | kafka | amqp | nats"}),de("异步完成 (asyncComplete)",!!_.asyncComplete,T=>z("asyncComplete",T))]})),_.type==="WAIT"&&G("等待状态配置","⏳","var(--color-accent)",d.jsxs(d.Fragment,{children:[ue([{key:"duration",label:"等待时长"},{key:"until",label:"等待到指定时间"}],x,T=>y(T)),x==="duration"?$("DURATION",_.inputParameters?.duration||"",T=>ie("duration",T),"text","e.g. 30s, 10m, 2 hours"):$("UNTIL (时间点)",_.inputParameters?.until||"",T=>ie("until",T),"text","e.g. 2025-06-15 09:00 GMT+00:00"),d.jsxs("div",{style:{fontSize:"11px",color:P,lineHeight:"1.6",marginTop:"8px"},children:["此任务会使工作流进入 ",d.jsx("b",{children:"IN_PROGRESS"})," 状态,直到时间满足或外部 API 触发完成。"]})]})),(_.type==="DECISION"||_.type==="SWITCH")&&G("条件分支配置","⚖️","var(--color-accent)",d.jsxs(d.Fragment,{children:[X("评估模式 (evaluatorType)",["value-param","javascript"],_.evaluatorType||"value-param",T=>z("evaluatorType",T)),(_.evaluatorType||"value-param")==="value-param"?$("CASE VALUE PARAM (参数名)",_.caseValueParam||"",T=>z("caseValueParam",T),"text","e.g. status"):d.jsx(d.Fragment,{children:H("CASE EXPRESSION (JS)",_.caseExpression||"",T=>z("caseExpression",T),{rows:4,language:"javascript",style:{color:"var(--color-accent)"}})}),d.jsx("div",{style:{fontSize:"10px",color:P,marginTop:"8px"},children:'分支可在图中通过右键节点→"添加分支"进行管理'})]})),_.type==="DO_WHILE"&&G("循环逻辑配置","🔄","var(--color-accent)",d.jsxs(d.Fragment,{children:[ue([{key:"condition",label:"条件循环"},{key:"items",label:"列表迭代"}],b,T=>k(T)),b==="condition"?d.jsxs(d.Fragment,{children:[H("LOOP CONDITION (JS) *",_.loopCondition||"",T=>z("loopCondition",T),{rows:4,language:"javascript",style:{color:"var(--color-accent)"}}),d.jsx("div",{style:{fontSize:"10px",color:P,marginTop:"4px"},children:"条件为 true 时继续循环,false 时退出"})]}):d.jsxs(d.Fragment,{children:[d.jsx("label",{style:{display:"block",fontSize:"10px",color:P,marginBottom:"4px"},children:"ITEMS (列表表达式)"}),d.jsx("input",{value:_.inputParameters?.items||"",onChange:T=>ie("items",T.target.value),disabled:!K,placeholder:"${workflow.input.myList}",style:{width:"100%",padding:"8px",borderRadius:"6px",border:`1px solid ${j}`,background:M,color:E,fontSize:"12px",outline:"none"}}),d.jsx("div",{style:{fontSize:"10px",color:P,marginTop:"4px"},children:"引用一个数组,对每个元素执行一次循环体"})]}),d.jsx("div",{style:{marginTop:"12px"},children:$("KEEP LAST N 次迭代",_.keepLastN??"",T=>z("keepLastN",T?parseInt(T):void 0),"number","0 = 保留全部")})]})),_.type==="FORK_JOIN_DYNAMIC"&&G("动态并行配置","⚡","var(--color-accent)",d.jsxs(d.Fragment,{children:[ue([{key:"classic",label:"经典模式"},{key:"task",label:"任务简化"},{key:"workflow",label:"工作流简化"}],S,T=>C(T)),S==="classic"&&d.jsxs(d.Fragment,{children:[$("DYNAMIC_FORK_TASKS_PARAM",_.dynamicForkTasksParam||"",T=>z("dynamicForkTasksParam",T),"text","e.g. dynamic_tasks"),$("DYNAMIC_FORK_TASKS_INPUT_PARAM",_.dynamicForkTasksInputParamName||"",T=>z("dynamicForkTasksInputParamName",T),"text","e.g. input"),d.jsx("div",{style:{fontSize:"10px",color:P},children:"经典模式:通过 inputParameters 传入 dynamicTasks 数组和 dynamicTasksInput 映射"})]}),S==="task"&&d.jsxs(d.Fragment,{children:[$("FORK TASK TYPE *",_.forkTaskType||"",T=>z("forkTaskType",T),"text","e.g. HTTP"),$("FORK TASK NAME (仅 SIMPLE 任务)",_.forkTaskName||"",T=>z("forkTaskName",T),"text","e.g. my_task"),$("FORK TASK INPUTS PARAM",_.forkTaskInputs||"",T=>z("forkTaskInputs",T),"text","e.g. inputs"),d.jsx("div",{style:{fontSize:"10px",color:P},children:"所有分支执行相同任务类型,每个元素作为一个分支输入"})]}),S==="workflow"&&d.jsxs(d.Fragment,{children:[$("FORK WORKFLOW NAME *",_.forkTaskWorkflow||"",T=>z("forkTaskWorkflow",T),"text","e.g. sub_workflow"),$("WORKFLOW VERSION",_.forkTaskWorkflowVersion||"",T=>z("forkTaskWorkflowVersion",T),"text","1"),$("FORK TASK INPUTS PARAM",_.forkTaskInputs||"",T=>z("forkTaskInputs",T),"text","e.g. inputs"),d.jsx("div",{style:{fontSize:"10px",color:P},children:"所有分支执行相同子工作流,每个元素作为一个子工作流输入"})]})]})),_.type==="DYNAMIC"&&G("动态任务配置","🎯","var(--color-accent)",d.jsxs(d.Fragment,{children:[$("DYNAMIC TASK NAME PARAM *",_.dynamicTaskNameParam||"",T=>z("dynamicTaskNameParam",T),"text","e.g. taskToExecute"),d.jsx("div",{style:{fontSize:"10px",color:P,marginTop:"4px"},children:'运行时从 inputParameters 的指定键中读取实际任务类型名(如 "HTTP"、"SIMPLE")'})]})),_.type==="HUMAN"&&G("人工审批配置","👤","var(--color-accent)",d.jsxs(d.Fragment,{children:[$("表单模板名 (userFormTemplate)",_.humanTaskDef?.userFormTemplate||"",T=>ee("humanTaskDef","userFormTemplate",T),"text","e.g. approval_form"),X("分配策略 (assignmentCompletionStrategy)",["LEAVE_OPEN","TERMINATE"],_.humanTaskDef?.assignmentCompletionStrategy||"LEAVE_OPEN",T=>ee("humanTaskDef","assignmentCompletionStrategy",T)),$("显示名称 (displayName)",_.humanTaskDef?.displayName||"",T=>ee("humanTaskDef","displayName",T),"text","审批任务")]})),_.type==="KAFKA_PUBLISH"&&G("Kafka 推送配置","📨","var(--color-accent)",d.jsxs(d.Fragment,{children:[$("BOOTSTRAP SERVERS *",_.inputParameters?.bootStrapServers||"",T=>ie("bootStrapServers",T),"text","localhost:9092"),$("TOPIC *",_.inputParameters?.topic||"",T=>ie("topic",T),"text","my_topic"),$("KEY (消息分区键)",_.inputParameters?.key||"",T=>ie("key",T),"text",""),H("VALUE (消息内容)",typeof _.inputParameters?.value=="object"?JSON.stringify(_.inputParameters.value,null,2):_.inputParameters?.value||"",T=>{let U=T;try{U=JSON.parse(T)}catch{}ie("value",U)},{rows:4,language:"json"}),H("HEADERS (JSON)",typeof _.inputParameters?.headers=="object"?JSON.stringify(_.inputParameters.headers,null,2):"{}",T=>{try{ie("headers",JSON.parse(T))}catch{}},{rows:3,language:"json"})]})),_.type==="SET_VARIABLE"&&G("变量配置","📦","var(--color-accent)",d.jsxs(d.Fragment,{children:[d.jsxs("div",{style:{fontSize:"11px",color:P,marginBottom:"12px"},children:["在 inputParameters 中定义要设置的变量名和值,后续任务通过 ","${workflow.variables.varName}"," 访问。"]}),H("VARIABLES (JSON)",typeof _.inputParameters=="object"&&_.inputParameters!==null?JSON.stringify(_.inputParameters,null,2):"{}",T=>{try{z("inputParameters",JSON.parse(T))}catch{}},{rows:6,language:"json"})]})),d.jsxs("div",{style:{marginTop:"32px",borderTop:`1px solid ${j}`,paddingTop:"24px"},children:[d.jsx("div",{style:{fontSize:"11px",fontWeight:"bold",marginBottom:"16px",opacity:.6,textTransform:"uppercase",letterSpacing:"1px"},children:"通用参数与属性"}),J("任务唯一引用名 (Reference Name)","taskReferenceName"),J("任务描述","description"),d.jsxs("div",{style:{marginBottom:"16px"},children:[d.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"},children:[d.jsxs("label",{style:{fontSize:"11px",color:P,fontWeight:"600",textTransform:"uppercase"},children:["输入参数 (inputParameters) ",d.jsx("span",{style:{opacity:.5,fontWeight:"normal"},children:"(JSON)"})]}),K&&d.jsxs("button",{onClick:()=>g(!h),title:"快捷表达式",style:{fontSize:"11px",background:h?"var(--color-accent)":"none",border:`1px solid ${j}`,borderRadius:"4px",padding:"2px 6px",cursor:"pointer",color:h?"#fff":P},children:["{}"," 快捷片段"]})]}),h&&d.jsx("div",{style:{marginBottom:"8px",padding:"8px",borderRadius:"6px",border:`1px solid ${j}`,background:"var(--bg-secondary)",display:"flex",flexWrap:"wrap",gap:"6px"},children:Qx.map(T=>d.jsx("button",{onClick:()=>ne(T.value),title:T.desc,style:{fontSize:"10px",padding:"3px 8px",borderRadius:"4px",border:`1px solid ${j}`,background:M,color:E,cursor:"pointer",fontFamily:"monospace"},children:T.label},T.value))}),H("",typeof _.inputParameters=="object"&&_.inputParameters!==null?JSON.stringify(_.inputParameters,null,2):_.inputParameters??"",T=>{try{z("inputParameters",JSON.parse(T))}catch{l(U=>({...U,inputParameters:T}))}},{rows:5,language:"json","data-field":"inputParameters",style:{outline:"none"}})]}),d.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[J("重试次数","retryCount","number"),J("超时限制 (秒)","timeoutSeconds","number")]}),d.jsxs("details",{style:{marginTop:"16px"},children:[d.jsx("summary",{style:{fontSize:"11px",cursor:"pointer",color:P,userSelect:"none",fontWeight:"600"},children:"▸ 执行控制(高级)"}),d.jsxs("div",{style:{marginTop:"12px"},children:[X("重试策略 (retryLogic)",["FIXED","EXPONENTIAL_BACKOFF","LINEAR_BACKOFF"],_.retryLogic||"FIXED",T=>z("retryLogic",T)),$("重试延迟 (秒)",_.retryDelaySeconds??"",T=>z("retryDelaySeconds",T?parseInt(T):void 0),"number","0"),X("超时策略 (timeoutPolicy)",["TIME_OUT_WF","ALERT_ONLY","RETRY","FAIL_WORKFLOW"],_.timeoutPolicy||"TIME_OUT_WF",T=>z("timeoutPolicy",T)),$("启动延迟 (秒)",_.startDelay??"",T=>z("startDelay",T?parseInt(T):void 0),"number","0"),de("可选任务 (optional) — 失败不影响工作流",!!_.optional,T=>z("optional",T)),de("异步完成 (asyncComplete)",!!_.asyncComplete,T=>z("asyncComplete",T))]})]})]}),d.jsx("div",{style:{marginTop:"48px",opacity:.6},children:d.jsxs("details",{children:[d.jsx("summary",{style:{fontSize:"11px",cursor:"pointer",marginBottom:"8px"},children:"查看完整 JSON (只读)"}),d.jsx("pre",{style:{background:"rgba(0,0,0,0.2)",padding:"16px",borderRadius:"8px",fontSize:"10px",overflow:"auto",border:`1px solid ${j}`,color:P},children:JSON.stringify(_,null,2)})]})})]}),K&&d.jsxs("div",{style:{padding:"24px",borderTop:`1px solid ${j}`,background:"var(--bg-secondary)",display:"flex",gap:"12px",flexShrink:0},children:[d.jsx("div",{style:{flex:1,fontSize:"11px",color:P,display:"flex",alignItems:"center"},children:"✅ 所有修改已实时同步"}),d.jsx("button",{onClick:t,style:{padding:"10px 24px",background:"var(--color-accent)",color:"#fff",border:"none",borderRadius:"8px",fontWeight:"bold",cursor:"pointer",boxShadow:"0 4px 12px var(--color-accent-bg)"},children:"完成退出"})]}),d.jsx(Xx,{isOpen:N,onClose:()=>A(!1),onSelect:D,suggestions:R,anchorRect:w})]}),F&&d.jsx(Zx,{title:F.title,value:F.value,language:F.language,onSave:F.onSave,onClose:()=>W(null)})]})},rb=q.memo(eb),tb={COMPLETED:"var(--status-completed)",FAILED:"var(--status-failed)",FAILED_WITH_TERMINAL_ERROR:"var(--status-failed-terminal)",IN_PROGRESS:"var(--status-in-progress)",SCHEDULED:"var(--status-scheduled)",TIMED_OUT:"var(--status-timed-out)",CANCELED:"var(--status-canceled)",SKIPPED:"var(--status-skipped)"},br=e=>tb[e??""]??"var(--text-secondary)",nb=(e,r)=>{if(!e)return"-";const t=(r??Date.now())-e;return t<1e3?`${t}ms`:`${(t/1e3).toFixed(2)}s`},zh=e=>e?new Date(e).toLocaleTimeString():"-",ab=({executionActions:e})=>{const{selectedTask:r,selectedTaskInstance:t,setSelectedTask:n,setSelectedTaskInstance:o,executionData:a,workflowInstance:i}=oe(),[s,l]=q.useState("summary"),u=q.useRef(null);q.useEffect(()=>{u.current?.scrollTo({top:0})},[s,r?.taskReferenceName]),q.useEffect(()=>{l("summary")},[r?.taskReferenceName]);const c=r?.taskReferenceName==="__workflow_global__",f=r?a?.[r.taskReferenceName]:null;if(!r||!f&&!c)return null;const p=f?.attempts??[],h=t??p[p.length-1],g=i?.workflowId??"",v=i?.status,m=f?.status,x=c?v:h?.status??m,y=c?i?.startTime:h?.startTime,b=c?i?.endTime:h?.endTime,k=c?i?.reasonForIncompletion:h?.reasonForIncompletion,S=c?i?.workflowId:h?.taskId,C=c?i?.input:h?.inputData,N=c?i?.output:h?.outputData,A=!c&&e?.onSkipTask&&(m==="SCHEDULED"||m==="IN_PROGRESS")&&(v==="RUNNING"||v==="PAUSED"),w=!c&&e?.onRerunFromTask&&(v==="FAILED"||v==="TERMINATED"||v==="COMPLETED"||v==="TIMED_OUT"),I=A||w,R=e?.allowOperations!==!1,B=()=>{n(null),o(null)},D="var(--glass-border)",L="var(--text-secondary)",F="var(--bg-tertiary)";return d.jsxs("div",{className:"detail-panel-container panel-enter-active",style:{position:"absolute",right:0,top:0,bottom:0,width:450,zIndex:1200,display:"flex",flexDirection:"column",background:"var(--bg-primary)",borderLeft:`1px solid ${D}`,boxShadow:"-10px 0 30px rgba(0,0,0,0.2)",overflow:"hidden"},children:[d.jsxs("div",{style:{padding:"20px 24px",borderBottom:`1px solid ${D}`,background:"var(--bg-secondary)",flexShrink:0},children:[d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[d.jsx("div",{style:{background:"var(--color-accent)",color:"#fff",padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:"bold",letterSpacing:"1px",flexShrink:0},children:c?"WORKFLOW":r.type||"TASK"}),x&&d.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:5,padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:700,background:`${br(x)}18`,color:br(x),letterSpacing:"0.5px",flexShrink:0},children:["● ",x]}),d.jsx("div",{style:{flex:1}}),d.jsx("button",{onClick:B,style:{background:"none",border:"none",color:L,cursor:"pointer",fontSize:20,lineHeight:1,padding:4},children:"✕"})]}),d.jsx("div",{style:{fontSize:20,fontWeight:700,color:"var(--text-primary)",lineHeight:1.3},children:c?"工作流全局数据":r.name}),d.jsxs("div",{style:{fontSize:12,color:L,marginTop:6,fontFamily:"monospace",opacity:.8},children:["REF: ",r.taskReferenceName]})]}),p.length>1&&d.jsxs("div",{style:{padding:"12px 24px",borderBottom:`1px solid ${D}`,background:"var(--bg-secondary)",flexShrink:0},children:[d.jsxs("div",{style:{fontSize:11,fontWeight:600,color:L,marginBottom:8,textTransform:"uppercase",letterSpacing:"0.5px"},children:["执行记录(",p.length," 次",p.some(W=>W.iteration)?" / 迭代":"尝试",")"]}),d.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:p.map((W,V)=>{const Z=h?.taskId===W.taskId;return d.jsx("button",{onClick:()=>o(W),style:{padding:"4px 12px",borderRadius:20,fontSize:12,cursor:"pointer",border:`1px solid ${Z?"var(--color-accent)":D}`,background:Z?"var(--color-accent)":"var(--bg-tertiary)",color:Z?"#fff":"var(--text-primary)",fontFamily:"inherit",transition:"all 0.15s"},children:W.iteration?`迭代 ${W.iteration}`:`尝试 ${V+1}`},W.taskId)})})]}),d.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${D}`,background:"var(--bg-secondary)",flexShrink:0},children:["summary","input","output"].map(W=>{const V={summary:"概览",input:"输入 JSON",output:"输出 JSON"},Z=s===W;return d.jsx("button",{onClick:()=>l(W),style:{padding:"10px 20px",background:"none",border:"none",borderBottom:`2px solid ${Z?"var(--color-accent)":"transparent"}`,color:Z?"var(--color-accent)":L,cursor:"pointer",fontSize:13,fontWeight:Z?600:400,fontFamily:"inherit",transition:"all 0.15s"},children:V[W]},W)})}),d.jsxs("div",{ref:u,style:{flex:1,overflowY:"auto",padding:24,background:"var(--bg-primary)"},children:[s==="summary"&&d.jsxs(d.Fragment,{children:[d.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,marginBottom:24},children:[{label:"总耗时",value:nb(y,b)},{label:"开始时间",value:zh(y)},{label:"结束时间",value:zh(b)},{label:c?"Workflow ID":"Task ID",value:d.jsx("span",{style:{fontSize:10,fontFamily:"monospace",opacity:.7,wordBreak:"break-all"},children:S??"-"})}].map(({label:W,value:V})=>d.jsxs("div",{style:{padding:"12px 14px",background:F,borderRadius:10,border:`1px solid ${D}`},children:[d.jsx("div",{style:{fontSize:10,color:L,textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:6,fontWeight:600},children:W}),d.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",fontSize:13},children:V})]},W))}),p.length>1&&d.jsxs("div",{style:{marginBottom:20,padding:"10px 14px",background:`${br(m)}10`,border:`1px solid ${br(m)}30`,borderRadius:8,fontSize:12,color:br(m),display:"flex",alignItems:"center",gap:8},children:[d.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[d.jsx("path",{d:"M13 2v4h-4"}),d.jsx("path",{d:"M13 6A7 7 0 1 1 9.5 2.5"})]}),"已重试 ",p.length-1," 次,共 ",p.length," 次尝试"]}),!c&&h?.workerId&&d.jsxs("div",{style:{marginBottom:20},children:[d.jsx("div",{style:{fontSize:10,color:L,textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:4,fontWeight:600},children:"Worker"}),d.jsx("div",{style:{fontSize:12,fontFamily:"monospace",color:"var(--text-primary)",opacity:.8},children:h.workerId})]}),k&&d.jsxs("div",{style:{padding:14,background:"rgba(239,68,68,0.08)",borderLeft:"3px solid var(--status-failed)",borderRadius:"0 8px 8px 0",fontSize:12,color:"var(--status-failed)",lineHeight:1.6},children:[d.jsx("strong",{children:"异常信息"}),d.jsx("div",{style:{marginTop:6,opacity:.9},children:k})]}),I&&d.jsxs("div",{style:{marginTop:24,paddingTop:20,borderTop:`1px solid ${D}`},children:[d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[d.jsx("div",{style:{fontSize:11,fontWeight:600,color:L,textTransform:"uppercase",letterSpacing:"0.5px"},children:"任务操作"}),!R&&d.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 7px",borderRadius:4,background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.25)",color:"var(--status-failed)",fontSize:10,fontWeight:600},children:[d.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[d.jsx("circle",{cx:"8",cy:"8",r:"6"}),d.jsx("path",{d:"M8 5v3M8 11v.5"})]}),"操作权限受限"]})]}),d.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[w&&d.jsxs("button",{disabled:!R,onClick:()=>R&&e.onRerunFromTask(g,r.taskReferenceName,h?.taskId),title:R?`从任务 ${r.taskReferenceName} 处重新运行工作流`:"操作权限受限",style:R?Ye:Hh,onMouseEnter:W=>!R||Object.assign(W.currentTarget.style,ob),onMouseLeave:W=>!R||Object.assign(W.currentTarget.style,Ye),children:[d.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[d.jsx("path",{d:"M3 14v-4h4"}),d.jsx("path",{d:"M3 10A7 7 0 1 1 6.5 13.5"})]}),"从此处重新运行"]}),A&&d.jsxs("button",{disabled:!R,onClick:()=>R&&e.onSkipTask(g,r.taskReferenceName,h?.taskId),title:R?`跳过任务 ${r.taskReferenceName}`:"操作权限受限",style:R?Ye:Hh,onMouseEnter:W=>!R||Object.assign(W.currentTarget.style,ib),onMouseLeave:W=>!R||Object.assign(W.currentTarget.style,Ye),children:[d.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:d.jsx("path",{d:"M4 4l8 8M12 4l-8 8"})}),"跳过此任务"]})]})]})]}),s==="input"&&d.jsx($h,{data:C}),s==="output"&&d.jsx($h,{data:N})]})]})},$h=({data:e})=>d.jsx("div",{style:{background:"var(--bg-tertiary)",padding:16,borderRadius:10,border:"1px solid var(--glass-border)",fontFamily:"'Fira Code', monospace",fontSize:12,lineHeight:1.6,color:"var(--text-primary)",wordBreak:"break-all",whiteSpace:"pre-wrap"},children:JSON.stringify(e??{},null,2)}),Ye={display:"inline-flex",alignItems:"center",gap:6,padding:"7px 14px",borderRadius:8,fontSize:12,fontWeight:500,cursor:"pointer",border:"1px solid var(--border-primary)",background:"var(--bg-secondary)",color:"var(--text-primary)",fontFamily:"inherit",transition:"all 0.15s"},ob={...Ye,borderColor:"var(--color-accent)",color:"var(--color-accent)",background:"var(--bg-primary)"},ib={...Ye,borderColor:"var(--status-failed)",color:"var(--status-failed)",background:"rgba(239,68,68,0.08)"},Hh={...Ye,opacity:.45,cursor:"not-allowed",border:"1px solid var(--border-primary)",background:"var(--bg-secondary)",color:"var(--text-secondary)"},sb={add:"新增",mod:"修改",del:"删除",replace:"替换"},cb={add:"+",mod:"~",del:"−"};function ub({diff:e,applied:r,onApply:t,onUndo:n}){const o=e.kind==="replace"?"add":e.kind;return d.jsxs("div",{className:"diff-card",children:[d.jsxs("div",{className:"diff-head",children:[d.jsx("span",{className:`diff-badge ${o}`,children:sb[e.kind]??e.kind}),d.jsx("span",{className:"diff-summary",children:e.summary})]}),e.rows&&e.rows.length>0&&d.jsx("div",{className:"diff-list",children:e.rows.map((a,i)=>d.jsxs("div",{className:`diff-row ${a.kind}`,children:[d.jsx("div",{className:"diff-marker",children:cb[a.kind]??"·"}),d.jsx("div",{className:"diff-desc",children:a.desc})]},i))}),d.jsx("div",{className:"diff-actions",children:r?d.jsxs(d.Fragment,{children:[d.jsxs("button",{className:"diff-btn applied",disabled:!0,children:[d.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:d.jsx("path",{d:"M3 8l3.5 3.5L13 5",strokeLinecap:"round",strokeLinejoin:"round"})}),"已应用"]}),d.jsxs("button",{className:"diff-btn undo",onClick:n,children:[d.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[d.jsx("path",{d:"M3.5 8a4.5 4.5 0 1 1 1.4 3.3",strokeLinecap:"round"}),d.jsx("path",{d:"M3 4.5L4.5 8L7 6.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),"撤销"]})]}):d.jsxs("button",{className:"diff-btn apply",onClick:t,children:[d.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:d.jsx("path",{d:"M3 8l3.5 3.5L13 5",strokeLinecap:"round",strokeLinejoin:"round"})}),"应用更改"]})})]})}function Kh(e,r){const t=JSON.parse(JSON.stringify(e));if(r.kind==="replace"&&r.payload)return{next:JSON.parse(JSON.stringify(r.payload)),inverse:{kind:"replace",summary:"撤销替换",rows:[],payload:e}};if(r.kind==="add"&&r.payload)return{next:JSON.parse(JSON.stringify(r.payload)),inverse:{kind:"replace",summary:"撤销生成",rows:[],payload:e}};if(!r.patch)return{next:t,inverse:{kind:r.kind,summary:"(无变更)",rows:[]}};const n=[],o=[];for(const a of r.patch)if(a.op==="patchTask"){const i=t.tasks.find(l=>l.taskReferenceName===a.ref);if(!i)continue;const s={};for(const l of Object.keys(a.set))s[l]=i[l];Object.assign(i,a.set),n.push({op:"patchTask",ref:a.ref,set:s}),o.push({kind:"mod",desc:`还原 ${a.ref} 属性`})}else if(a.op==="addEdge")t.edges=t.edges??[],t.edges.push({from:a.from,to:a.to,label:a.label}),n.push({op:"removeEdge",from:a.from,to:a.to}),o.push({kind:"del",desc:`移除边 ${a.from} → ${a.to}`});else if(a.op==="removeEdge")t.edges=(t.edges??[]).filter(i=>!(i.from===a.from&&i.to===a.to)),n.push({op:"addEdge",from:a.from,to:a.to}),o.push({kind:"add",desc:`恢复边 ${a.from} → ${a.to}`});else if(a.op==="addTask")t.tasks.push(a.task),t.edges=t.edges??[],a.removeEdges&&a.removeEdges.forEach(i=>{t.edges=t.edges.filter(s=>!(s.from===i.from&&s.to===i.to))}),a.extraEdges&&a.extraEdges.forEach(i=>t.edges.push(i)),n.push({op:"removeTask",ref:a.task.taskReferenceName}),o.push({kind:"del",desc:`移除 ${a.task.taskReferenceName}`});else if(a.op==="removeTask"){const i=t.tasks.findIndex(u=>u.taskReferenceName===a.ref);if(i<0)continue;const[s]=t.tasks.splice(i,1),l=(t.edges??[]).filter(u=>u.from===a.ref||u.to===a.ref);t.edges=(t.edges??[]).filter(u=>u.from!==a.ref&&u.to!==a.ref),n.push({op:"addTask",task:s,extraEdges:l}),o.push({kind:"add",desc:`恢复 ${a.ref}`})}else if(a.op==="insertAfter"){t.tasks.push(a.task),t.edges=t.edges??[];const i=t.edges.findIndex(s=>s.from===a.after&&s.to===a.edgeTo);i>=0&&t.edges.splice(i,1),t.edges.push({from:a.after,to:a.task.taskReferenceName}),t.edges.push({from:a.task.taskReferenceName,to:a.edgeTo}),n.push({op:"removeTask",ref:a.task.taskReferenceName}),o.push({kind:"del",desc:`移除 ${a.task.taskReferenceName}(恢复直连边)`})}else if(a.op==="insertBefore"){t.tasks.push(a.task),t.edges=t.edges??[];const i=t.edges.filter(s=>s.to===a.before);t.edges=t.edges.filter(s=>s.to!==a.before),i.forEach(s=>t.edges.push({from:s.from,to:a.task.taskReferenceName,label:s.label})),t.edges.push({from:a.task.taskReferenceName,to:a.before}),n.push({op:"removeTask",ref:a.task.taskReferenceName}),o.push({kind:"del",desc:`移除 ${a.task.taskReferenceName}(恢复原有入边)`})}return{next:t,inverse:{kind:r.kind,summary:`撤销:${r.summary}`,rows:o,patch:n.reverse()}}}function lb(e){const r=e.match(/```diff-json\n([\s\S]*?)\n```/);if(!r)return null;try{const t=JSON.parse(r[1]);return!t.kind||!t.summary?null:t}catch{return null}}const Uh={id:"1",role:"ai",content:"你好!我是您的流程助手。我可以帮你生成工作流框架、优化逻辑或提供参数配置建议。你想实现什么样的流程?"},Jh=e=>e.split(/(```[\s\S]*?```)/).map((t,n)=>{if(t.startsWith("```")&&t.endsWith("```")){const o=t.slice(3,-3),a=o.indexOf(`
86
+ `),i=a>=0?o.slice(a+1):o;return d.jsx("pre",{children:d.jsx("code",{children:i})},n)}return d.jsx("span",{children:db(t)},n)}),db=e=>{const r=[],t=/(\*\*[^*]+\*\*|`[^`]+`|\n)/g;let n=0,o;for(;(o=t.exec(e))!==null;){o.index>n&&r.push(e.slice(n,o.index));const a=o[0];a.startsWith("**")&&a.endsWith("**")?r.push(d.jsx("strong",{children:a.slice(2,-2)},o.index)):a.startsWith("`")&&a.endsWith("`")?r.push(d.jsx("code",{children:a.slice(1,-1)},o.index)):a===`
87
+ `&&r.push(d.jsx("br",{},o.index)),n=o.index+a.length}return n<e.length&&r.push(e.slice(n)),r},fb=({aiConfig:e})=>{const{workflowDef:r,setWorkflow:t,mode:n}=oe(),[o,a]=q.useState(!1),[i,s]=q.useState(""),[l,u]=q.useState(!1),[c,f]=q.useState([Uh]),[p,h]=q.useState(""),[g,v]=q.useState(null),m=q.useRef(null),x=q.useRef(null),y=q.useRef(null),b=q.useCallback(L=>{if(!L.diff||L.applied||!r)return;const{next:F,inverse:W}=Kh(r,L.diff);t(F),f(V=>V.map(Z=>Z.id===L.id?{...Z,applied:!0,inverse:W}:Z))},[r,t]),k=q.useCallback(L=>{if(!L.inverse||!L.applied||!r)return;const{next:F}=Kh(r,L.inverse);t(F),f(W=>W.map(V=>V.id===L.id?{...V,applied:!1,inverse:void 0}:V))},[r,t]),S=()=>{const L=x.current;L&&(L.style.height="auto",L.style.height=Math.min(L.scrollHeight,120)+"px")},C=()=>{const L=x.current;L&&(L.style.height="auto")};q.useEffect(()=>()=>{y.current?.abort()},[]),q.useEffect(()=>{const L=()=>a(!0);return window.addEventListener("open-ai-chat",L),()=>window.removeEventListener("open-ai-chat",L)},[]);const N=()=>{m.current?.scrollIntoView({behavior:"smooth"})};q.useEffect(()=>{o&&N()},[c,o,p]);const A=q.useCallback(L=>{const F=[{role:"system",content:Gx}];for(const V of c)V.role==="user"&&V.content?F.push({role:"user",content:V.content}):V.role==="ai"&&V.content&&!V.thinking&&F.push({role:"assistant",content:V.content});const W=Vx(L,r);return F.push({role:"user",content:W}),F},[c,r]),w=async L=>{const F=i.trim();if(!F||l)return;y.current?.abort();const W=new AbortController;y.current=W;const V={id:Date.now().toString(),role:"user",content:F};f(Z=>[...Z,V]),s(""),C(),u(!0),h("");try{const Z=e?.apiKey||localStorage.getItem("AI_API_KEY")||"",le=e?.baseUrl||localStorage.getItem("AI_BASE_URL")||"",se=e?.model||localStorage.getItem("AI_MODEL")||"";if(!Z){setTimeout(()=>{if(W.signal.aborted)return;const P={name:"demo_approval_workflow",description:"演示审批流程",tasks:[{name:"submit_request",taskReferenceName:"submit_request",type:"SIMPLE",inputParameters:{}},{name:"human_approval",taskReferenceName:"human_approval",type:"HUMAN",inputParameters:{}},{name:"process_result",taskReferenceName:"process_result",type:"SIMPLE",inputParameters:{}}]},z={id:(Date.now()+1).toString(),role:"ai",content:"**演示模式**:未检测到 API Key,以下是一个示例审批流程供体验。请在标题栏 🤖 按钮中配置真实 API Key 以启用 AI 功能。",diff:{kind:"replace",summary:"生成三步审批流程(演示)",rows:[{kind:"add",desc:"submit_request — 提交申请任务"},{kind:"add",desc:"human_approval — 人工审批任务"},{kind:"add",desc:"process_result — 处理审批结果"}],payload:P}};f(ee=>[...ee,z]),u(!1)},800);return}const _={apiKey:Z};le&&(_.baseUrl=le),se&&(_.model=se);const Y=A(F),K=await Jx(Y,_,P=>{h(z=>z+P)},()=>{},W.signal);let j=lb(K);if(!j){const P=K.match(/```json\n([\s\S]*?)\n```/);if(P)try{const z=JSON.parse(P[1]);j={kind:"replace",summary:"应用 AI 生成的工作流",rows:[{kind:"add",desc:"全量替换为 AI 生成的工作流定义"}],payload:z}}catch{}}const M={id:(Date.now()+1).toString(),role:"ai",content:K,diff:j??void 0,applied:!1};f(P=>[...P,M]),h("")}catch(Z){if(Z.name==="AbortError")h(le=>{if(le){const se={id:(Date.now()+1).toString(),role:"ai",content:le};f(_=>[..._,se])}return""});else{const le={id:Date.now().toString(),role:"ai",content:`抱歉,目前无法连接到 AI 服务: ${Z.message}`};f(se=>[...se,le]),h("")}}finally{u(!1)}},I=()=>{y.current?.abort()},R=()=>{y.current?.abort(),f([Uh]),h(""),u(!1)},B=L=>{navigator.clipboard.writeText(L.content??""),v(L.id),setTimeout(()=>v(null),1500)},D=L=>{L.nativeEvent.isComposing||L.keyCode===229||L.key==="Enter"&&!L.shiftKey&&(L.preventDefault(),w())};return n!=="edit"?null:o?d.jsxs("div",{className:"ai-chat-panel",children:[d.jsxs("div",{className:"ai-header",children:[d.jsxs("div",{className:"ai-title",children:[d.jsx("span",{className:"ai-sparkles",children:"✨"}),"AI 助手"]}),d.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[d.jsx("button",{className:"ai-close",onClick:R,title:"清空对话",children:"🗑"}),d.jsx("button",{className:"ai-close",onClick:()=>a(!1),children:"×"})]})]}),d.jsxs("div",{className:"ai-messages",children:[c.map(L=>d.jsxs("div",{className:`message ${L.role}`,children:[d.jsx("div",{className:"message-content",children:L.thinking?d.jsxs("div",{className:"thinking-skeleton",children:[d.jsx("div",{className:"skeleton-line",style:{width:"80%"}}),d.jsx("div",{className:"skeleton-line",style:{width:"60%"}})]}):L.role==="ai"?Jh(L.content??""):L.content}),L.diff&&!L.thinking&&d.jsx(ub,{diff:L.diff,applied:L.applied??!1,onApply:()=>b(L),onUndo:()=>k(L)}),L.role==="ai"&&L.content&&d.jsx("button",{className:"copy-btn",onClick:()=>B(L),title:"复制",children:g===L.id?"✓":"📋"})]},L.id)),l&&p&&d.jsxs("div",{className:"message ai",style:{opacity:.9},children:[d.jsx("div",{className:"message-content",children:Jh(p)}),d.jsx("span",{className:"streaming-cursor",children:"▊"})]}),l&&!p&&d.jsxs("div",{className:"message ai thinking-skeleton",children:[d.jsx("div",{className:"skeleton-line",style:{width:"80%"}}),d.jsx("div",{className:"skeleton-line",style:{width:"60%"}}),d.jsx("div",{className:"skeleton-line",style:{width:"70%"}})]}),d.jsx("div",{ref:m})]}),d.jsx("div",{className:"ai-input-area",children:d.jsxs("div",{className:"ai-input-container",children:[d.jsx("textarea",{ref:x,className:"ai-input",placeholder:l?"AI 正在响应...":"描述您的需求…(Shift+Enter 换行)",value:i,onChange:L=>s(L.target.value),onInput:S,onKeyDown:D,disabled:l,rows:2}),l?d.jsx("button",{className:"ai-send stop",onClick:I,title:"停止生成",children:"⏹"}):d.jsx("button",{className:"ai-send",onClick:()=>w(),title:"发送",children:"🚀"})]})})]}):d.jsx("div",{className:"ai-chat-panel collapsed",onClick:()=>a(!0),children:d.jsx("div",{className:"ai-header",style:{borderBottom:"none"},children:d.jsxs("div",{className:"ai-title",children:[d.jsx("span",{className:"ai-sparkles",children:"✨"}),"AI 助手"]})})})},Gh=q.forwardRef(({workflowDef:e,readOnly:r=!1,theme:t="dark",themeColor:n="blue",layoutDirection:o="LR",searchQuery:a="",workflowExecution:i,onRequestImport:s,executionActions:l,aiConfig:u,viewMode:c="developer",onSave:f,onWorkflowChange:p,height:h="100%"},g)=>{const{setWorkflow:v,setTheme:m,setThemeColor:x,setLayoutDirection:y,setNodesLocked:b,selectedTask:k,setSelectedTask:S,edgeType:C,importExecutionJSON:N,setMode:A,setViewMode:w,isDetailPanelOpen:I,setIsDetailPanelOpen:R,selectTaskAction:B,workflowDef:D,isSimRunning:L,startSimulation:F,stopSimulation:W,mode:V}=oe(),[Z,le]=q.useState(!1),se=q.useCallback(()=>{if(!D)return;const K=new Blob([JSON.stringify(D,null,2)],{type:"application/json"}),E=URL.createObjectURL(K),j=document.createElement("a");j.href=E,j.download=`${D.name||"workflow"}.json`,j.click(),URL.revokeObjectURL(E)},[D]),_=q.useCallback(()=>{D&&navigator.clipboard.writeText(JSON.stringify(D,null,2))},[D]);q.useEffect(()=>{m(t),x(n),y(o),b(r||!!i)},[t,n,o,r,i,m,x,y,b]),q.useEffect(()=>{w(i?"developer":c)},[c,i,w]),q.useEffect(()=>{e&&(v(e,o),oe.temporal.getState().clear())},[e,v,o]),q.useEffect(()=>{i?N(i):A(r?"view":"edit")},[i,N,A,r]),q.useImperativeHandle(g,()=>({getWorkflowDef:()=>oe.getState().workflowDef,getValidationResults:()=>oe.getState().validationResults,save:()=>{const K=oe.getState().workflowDef;K&&f&&f(K)},createBlankWorkflow:K=>{oe.getState().createBlankWorkflow(K),oe.temporal.getState().clear()}}),[f]),q.useEffect(()=>{if(!p)return;let K=!0,E=oe.getState().workflowDef;return oe.subscribe(M=>{const P=M.workflowDef;if(P!==E){if(E=P,K){K=!1;return}P&&p(P)}})},[p]);const Y=K=>{i?S(K):B(K,!0)};return d.jsxs("div",{className:`workflow-ide ${t==="light"?"light-theme":""}`,"data-mode":t,"data-brand":n,style:{width:"100%",height:h,display:"flex",flexDirection:"column",position:"relative",overflow:"hidden"},children:[d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 12px",borderBottom:"1px solid var(--border)",background:"var(--bg-primary)",flexShrink:0,flexWrap:"wrap"},children:[d.jsx("div",{style:{flex:1}}),V!=="run"&&D&&(L?d.jsxs("button",{onClick:W,style:{height:28,padding:"0 10px",background:"color-mix(in srgb, var(--status-failed) 15%, transparent)",color:"var(--status-failed)",border:"1px solid color-mix(in srgb, var(--status-failed) 30%, transparent)",borderRadius:6,cursor:"pointer",fontSize:12,fontWeight:500,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"停止模拟",children:[d.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"currentColor",children:d.jsx("rect",{x:"4",y:"4",width:"8",height:"8",rx:"1"})}),"停止"]}):d.jsxs("button",{onClick:F,style:{height:28,padding:"0 10px",background:"color-mix(in srgb, var(--status-completed) 15%, transparent)",color:"var(--status-completed)",border:"1px solid color-mix(in srgb, var(--status-completed) 30%, transparent)",borderRadius:6,cursor:"pointer",fontSize:12,fontWeight:500,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"模拟执行工作流",children:[d.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"currentColor",children:d.jsx("path",{d:"M4 3l9 5-9 5z"})}),"模拟运行"]})),D&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{onClick:se,style:{height:28,padding:"0 10px",background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-strong)",borderRadius:6,cursor:"pointer",fontSize:12,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"导出工作流 JSON 文件",children:[d.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:d.jsx("path",{d:"M3 10v2.5a.5.5 0 0 0 .5.5h9a.5.5 0 0 0 .5-.5V10M5 7l3 3 3-3M8 2v8",strokeLinecap:"round",strokeLinejoin:"round"})}),"导出 JSON"]}),d.jsxs("button",{onClick:_,style:{height:28,padding:"0 10px",background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-strong)",borderRadius:6,cursor:"pointer",fontSize:12,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"复制 Conductor DSL 到剪贴板",children:[d.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[d.jsx("rect",{x:"4",y:"4",width:"9",height:"10",rx:"1"}),d.jsx("path",{d:"M2 10V3a1 1 0 0 1 1-1h7",strokeLinecap:"round"})]}),"复制 DSL"]})]})]}),d.jsx("div",{className:"workflow-viewer",style:{flex:1,position:"relative",overflow:"hidden"},children:d.jsx(O.ReactFlowProvider,{children:d.jsx(Kx,{onNodeClick:Y,edgeType:C,theme:t,nodesLocked:r||!!i,searchQuery:a,onSave:f,onRequestImport:s,executionActions:l})})}),d.jsx(rb,{task:k,isOpen:I,onClose:()=>R(!1),theme:t,aiConfig:u}),d.jsx(Oh,{isOpen:Z,onClose:()=>le(!1),theme:t,onTaskSelect:K=>{B(K,!0)}}),i&&d.jsx(ab,{executionActions:l}),d.jsx(fb,{aiConfig:u})]})});Gh.displayName="WorkflowIDE",Le.WorkflowIDE=Gh,Object.defineProperty(Le,Symbol.toStringTag,{value:"Module"})}));