@blueking/flow-canvas 0.0.8 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";var We=Object.create;var Ce=Object.defineProperty;var Xe=Object.getOwnPropertyDescriptor;var Ke=Object.getOwnPropertyNames;var Ze=Object.getPrototypeOf,Ye=Object.prototype.hasOwnProperty;var Qe=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ke(e))!Ye.call(r,n)&&n!==t&&Ce(r,n,{get:()=>e[n],enumerable:!(s=Xe(e,n))||s.enumerable});return r};var me=(r,e,t)=>(t=r!=null?We(Ze(r)):{},Qe(e||!r||!r.__esModule?Ce(t,"default",{value:r,enumerable:!0}):t,r));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("vue"),Je=require("@antv/x6"),et=require("@antv/x6-vue-shape"),tt=require("@antv/x6-plugin-selection"),ot=require("@antv/x6-plugin-minimap");function nt(){return{version:"1.0",nodes:{},edges:{}}}class oe extends Error{constructor(e){super(e),this.name="CanvasConstraintError"}}class Le extends Error{constructor(e){super(e),this.name="CanvasSchemaError"}}function fe(r,e,t){if(e.length===0){if(t===void 0)return;if(typeof t!="object"||t===null||Array.isArray(t))throw new Error("Root value of payload/extensions/meta must be an object or undefined");return t}const s=r?{...r}:{};let n=s;for(let a=0;a<e.length-1;a++){const c=e[a],l=n[c];l&&typeof l=="object"&&!Array.isArray(l)?n[c]={...l}:n[c]={},n=n[c]}const i=e[e.length-1];return t===void 0?delete n[i]:n[i]=t,s}function be(r,e){switch(e.type){case"node.add":return st(r,e.node);case"node.move":return rt(r,e.nodeId,e.position);case"node.remove":return it(r,e.nodeId);case"node.update":return at(r,e.nodeId,e.patch);case"node.set-payload":return lt(r,e.nodeId,e.path,e.value);case"node.set-extensions":return ct(r,e.nodeId,e.path,e.value);case"edge.add":return dt(r,e.edge);case"edge.remove":return ut(r,e.edgeId);case"edge.reconnect":return ft(r,e.edgeId,e.source,e.target);case"edge.update":return pt(r,e.edgeId,e.patch);case"edge.set-payload":return gt(r,e.edgeId,e.path,e.value);case"edge.label.update":return ht(r,e.edgeId,e.labelId,e.patch);case"model.set-meta":return vt(r,e.path,e.value);default:throw new oe(`Unknown command type: ${e.type}`)}}function ce(r,e){const t=r.nodes[e];if(!t)throw new oe(`Node "${e}" does not exist`);return t}function de(r,e){const t=r.edges[e];if(!t)throw new oe(`Edge "${e}" does not exist`);return t}function le(r,e,t){const s=r.nodes[e.nodeId];if(!s)throw new oe(`${t} node "${e.nodeId}" does not exist`);if(e.portId&&s.ports&&!s.ports.some(i=>i.id===e.portId))throw new oe(`${t} port "${e.portId}" not found on node "${e.nodeId}"`)}function pe(r,e,t){return{...r,nodes:{...r.nodes,[e]:t}}}function ge(r,e,t){return{...r,edges:{...r.edges,[e]:t}}}function st(r,e){if(r.nodes[e.id])throw new oe(`Node id "${e.id}" already exists`);return{...r,nodes:{...r.nodes,[e.id]:e}}}function rt(r,e,t){const s=ce(r,e);return pe(r,e,{...s,position:t})}function it(r,e){ce(r,e);const{[e]:t,...s}=r.nodes,n={};for(const[i,a]of Object.entries(r.edges))a.source.nodeId!==e&&a.target.nodeId!==e&&(n[i]=a);return{...r,nodes:s,edges:n}}function at(r,e,t){const s=ce(r,e);return pe(r,e,{...s,...t,id:s.id})}function lt(r,e,t,s){const n=ce(r,e),i=fe(n.payload,t,s);return pe(r,e,{...n,payload:i})}function ct(r,e,t,s){const n=ce(r,e),i=fe(n.extensions,t,s);return pe(r,e,{...n,extensions:i})}function dt(r,e){if(r.edges[e.id])throw new oe(`Edge id "${e.id}" already exists`);if(le(r,e.source,"Source"),le(r,e.target,"Target"),e.labels){const t=new Set;for(const s of e.labels){if(t.has(s.id))throw new oe(`Duplicate label id "${s.id}" in edge "${e.id}"`);t.add(s.id)}}return{...r,edges:{...r.edges,[e.id]:e}}}function ut(r,e){de(r,e);const{[e]:t,...s}=r.edges;return{...r,edges:s}}function ft(r,e,t,s){const n=de(r,e),i=t??n.source,a=s??n.target;return le(r,i,"Source"),le(r,a,"Target"),ge(r,e,{...n,source:i,target:a})}function pt(r,e,t){const s=de(r,e),n={...s,...t,id:s.id};return t.source&&le(r,n.source,"Source"),t.target&&le(r,n.target,"Target"),ge(r,e,n)}function gt(r,e,t,s){const n=de(r,e),i=fe(n.payload,t,s);return ge(r,e,{...n,payload:i})}function ht(r,e,t,s){const n=de(r,e);if(!n.labels)throw new oe(`Edge "${e}" has no labels`);const i=n.labels.findIndex(c=>c.id===t);if(i===-1)throw new oe(`Label "${t}" not found in edge "${e}"`);const a=[...n.labels];return a[i]={...a[i],...s,id:t},ge(r,e,{...n,labels:a})}function vt(r,e,t){const s=fe(r.meta,e,t);return{...r,meta:s}}function Oe(r,e){const t=e?.maxHistorySize??100,s=o.ref(r),n=[],i=[],a=o.ref(!1),c=o.ref(!1);function l(){a.value=n.length>0,c.value=i.length>0}function v(I){const D=s.value;let P=D;for(const A of I.commands)P=be(P,A);if(!I.skipHistory){const A=e?.excludeCommandFromHistory,O=A?I.commands.filter(q=>!A(q)):I.commands;if(O.length>0){const q=O.length<I.commands.length?{...I,commands:O}:I;n.push({snapshot:D,envelope:q}),n.length>t&&n.shift(),i.length=0}}return s.value=P,l(),P}function f(){const I=n.pop();if(!I)return null;i.push({snapshot:s.value,envelope:I.envelope});const D=e?.preserveMetaOnUndoRedo?{...I.snapshot,meta:s.value.meta}:I.snapshot;return s.value=D,l(),D}function h(){const I=i.pop();if(!I)return null;n.push({snapshot:s.value,envelope:I.envelope});const D=e?.preserveMetaOnUndoRedo?{...I.snapshot,meta:s.value.meta}:I.snapshot;return s.value=D,l(),D}function g(){n.length=0,i.length=0,l()}function k(){return s.value}function w(I){s.value=I,g()}return{currentFlowModel:s,execute:v,undo:f,redo:h,canUndo:a,canRedo:c,get undoStack(){return n.map(I=>I.envelope)},get redoStack(){return i.map(I=>I.envelope)},clear:g,createSnapshot:k,replaceFlowModel:w}}function mt(r){return r!==null&&typeof r=="object"&&r.rejected===!0}class yt{plugins=[];editorContext=null;runtimeCtx=null;runtimeVersion=0;install(e,t){this.plugins=[...e].sort((s,n)=>(s.priority??100)-(n.priority??100)),this.editorContext=t;for(const s of this.plugins)s.install?.(t)}attachRuntime(e){const t=++this.runtimeVersion;this.runtimeCtx=e;const s=this.createSafeRuntimeContext(e,t);for(const n of this.plugins)n.attachRuntime?.(s)}detachRuntime(){for(const e of[...this.plugins].reverse())e.detachRuntime?.();this.runtimeCtx=null}createSafeRuntimeContext(e,t){const s=this,n=new Proxy(e.graph,{get(i,a,c){const l=Reflect.get(i,a,c);return a==="use"&&typeof l=="function"?function(...f){if(s.runtimeVersion===t)return l.apply(i,f)}:l}});return{...e,graph:n}}dispose(){for(const e of[...this.plugins].reverse())e.dispose?.();this.plugins=[],this.editorContext=null,this.runtimeCtx=null}transformCommand(e){if(!this.editorContext)return{envelope:e};let t=e;for(const s of this.plugins){if(!s.transformCommand)continue;const n=this.createPreview(t),i=s.transformCommand(t,n,this.editorContext);if(i===null)return{rejected:!0,error:{code:"plugin_rejected",reason:"",source:s.name}};if(mt(i))return{rejected:!0,error:{code:i.code??"plugin_rejected",reason:i.reason,source:s.name}};t=i}return{envelope:t}}afterCommand(e,t,s){if(this.editorContext)for(const n of this.plugins)n.afterCommand?.(e,t,s,this.editorContext)}dispatchUiEvent(e){if(this.runtimeCtx)for(const t of this.plugins)t.onUiEvent?.(e,this.runtimeCtx)}dispatchSelectionChange(e){if(this.runtimeCtx)for(const t of this.plugins)t.onSelectionChange?.(e,this.runtimeCtx)}dispatchKeyboardShortcut(e){if(!this.runtimeCtx)return!1;for(const t of this.plugins)if(t.onKeyboardShortcut?.(e,this.runtimeCtx))return!0;return!1}collectContextMenuItems(e){if(!this.runtimeCtx)return[];const t=[];for(const s of this.plugins){const n=s.onBlankContextMenu?.(e,this.runtimeCtx);n&&t.push(...n)}return t}collectToolbarItems(){if(!this.editorContext)return[];const e=new Map;for(const t of this.plugins){const s=t.provideToolbarItems?.(this.editorContext);if(s)for(const n of s)e.set(n.id,n)}return[...e.values()].sort((t,s)=>(t.order??0)-(s.order??0))}collectNodeDecorations(e){if(!this.editorContext)return;let t;for(const s of this.plugins){const n=s.decorateNode?.(e,this.editorContext);n&&(t=t?{...t,...n}:n)}return t}collectEdgeDecorations(e){if(!this.editorContext)return;let t;for(const s of this.plugins){const n=s.decorateEdge?.(e,this.editorContext);n&&(t=t?{...t,...n}:n)}return t}collectExtendedApi(){if(!this.runtimeCtx)return{};const e={};for(const t of this.plugins){const s=t.extendApi?.(this.runtimeCtx.api,this.runtimeCtx);s&&Object.assign(e,s)}return e}createPreview(e){const t=this.editorContext;return{previewFlowModel(s){const n=s??e.commands;let i=t.flowModel.value;for(const a of n)i=be(i,a);return i}}}}let wt=0;function K(){const r=Date.now().toString(36),e=Math.random().toString(36).substring(2,8);return`${r}-${e}-${++wt}`}const Ee=()=>K();function bt(r){const{schema:e,plugins:t=[],historyOptions:s}=r,n=r.idGenerator??Ee,i={version:"1.0",...r.initialFlowModel},a=Oe(i,s),c=o.ref(r.mode??"edit"),l=o.ref(!1),v=o.ref(null),f=o.ref([]),h={},g=new yt;function k(P,A,O,q="user:toolbar"){const R={id:`history-${Date.now()}`,source:q,label:P,timestamp:Date.now(),commands:[]};g.afterCommand(R,A,O),f.value=g.collectToolbarItems(),r.onCommandResult?.({status:"applied",envelope:R,flowModel:O}),r.onFlowModelChange?.({flowModel:O,prevFlowModel:A,envelope:R,source:q})}const w={execute:a.execute,undo(){const P=a.currentFlowModel.value,A=a.undo();return A&&k("撤销",P,A),A},redo(){const P=a.currentFlowModel.value,A=a.redo();return A&&k("重做",P,A),A},get canUndo(){return a.canUndo},get canRedo(){return a.canRedo},get undoStack(){return a.undoStack},get redoStack(){return a.redoStack},clear:a.clear,createSnapshot:a.createSnapshot,replaceFlowModel(P){const A=a.currentFlowModel.value;a.replaceFlowModel(P),k("替换 FlowModel",A,P,"system:replace")}},I={flowModel:o.computed(()=>a.currentFlowModel.value),history:w,schema:e,mode:c,idGenerator:n,executeCommand:D,replaceFlowModel(P){w.replaceFlowModel(P)},setMode(P){c.value=P},selectionMode:l,setSelectionMode(P){l.value=P},api:v,toolbarItems:f,extendedApi:h,_pluginManager:g,_emitUiEvent:P=>{g.dispatchUiEvent(P)}};g.install(t,{flowModel:I.flowModel,history:w,schema:e,mode:c,idGenerator:n,executeCommand:D}),f.value=g.collectToolbarItems(),o.onScopeDispose(()=>{g.dispose()});function D(P){const A=g.transformCommand(P);if("rejected"in A){const R={status:"rejected",envelope:P,error:A.error};return r.onCommandResult?.(R),R}const O=A.envelope,q=a.currentFlowModel.value;try{const R=a.execute(O),z={status:"applied",envelope:O,flowModel:R};return g.afterCommand(O,q,R),f.value=g.collectToolbarItems(),r.onCommandResult?.(z),r.onFlowModelChange?.({flowModel:R,prevFlowModel:q,envelope:O,source:O.source}),z}catch(R){if(R instanceof oe){const z={status:"invalid",envelope:O,error:{code:"constraint_violated",reason:R.message,source:"engine"}};return r.onCommandResult?.(z),z}throw R}}return I}const Et=["top","right","bottom","left"];function $e(){return Et.map(r=>({id:r,group:r}))}function ke(r,e){return e?.(r)??r.ports??$e()}const ye=-1,kt="flow-canvas-node-ring-target",xe="flow-canvas-node-ring-target--decorated",Ie="flow-canvas-node-ring-target--pulse",Ct="linear-gradient(135deg, #cadcfa 0%, #cee0ff 100%)";class xt{graph;schema;shapeRegistry;resolveNodeDecoration;resolveEdgeDecoration;resolveCanvasContext;knownNodeIds=new Set;knownEdgeIds=new Set;syncing=!1;prevNodeDecorationClasses=new Map;prevNodeDecorationColors=new Set;prevEdgeDecorationClasses=new Map;prevEdgeDecorationColors=new Set;highlightedNodeIds=new Set;highlightedEdgeIds=new Set;hoveredEdgeId=null;defaultHighlightedNodeIds=new Set;defaultHighlightedEdgeIds=new Set;prevEdgeStyleIds=new Set;nodeDefaultAttrs=new Map;edgeDefaultAttrs=new Map;lastModel=null;pendingDecorationRAFs=new Map;constructor(e,t,s,n,i,a){this.graph=e,this.schema=t,this.shapeRegistry=s,this.resolveNodeDecoration=n,this.resolveEdgeDecoration=i,this.resolveCanvasContext=a}syncFlowModel(e){if(!this.syncing){this.syncing=!0,this.lastModel=e;try{const t=this.resolveNodes(e),s=this.resolveEdges(e);this.syncNodes(t),this.syncEdges(s,e)}finally{this.syncing=!1}}}get isSyncing(){return this.syncing}saveNodeDefaultAttrs(e,t){const n=t.x6CellConfig?.attrs?.body;if(!n)return;const i={};let a=!1;n.stroke!==void 0&&(i.stroke=n.stroke,a=!0),n.strokeWidth!==void 0&&(i.strokeWidth=n.strokeWidth,a=!0),a&&this.nodeDefaultAttrs.set(e,i)}saveEdgeDefaultAttrs(e,t){const n=t?.x6EdgeConfig?.attrs?.line;if(!n)return;const i={};let a=!1;n.stroke!==void 0&&(i.stroke=n.stroke,a=!0),n.strokeWidth!==void 0&&(i.strokeWidth=n.strokeWidth,a=!0),n.strokeDasharray!==void 0&&(i.strokeDasharray=n.strokeDasharray,a=!0),a&&this.edgeDefaultAttrs.set(e,i)}restoreNodeAttr(e,t,s){const n=this.nodeDefaultAttrs.get(e.id)?.[s];if(n!==void 0)e.setAttrByPath(t,n);else{const i=s==="stroke"?"none":0;e.setAttrByPath(t,i)}}restoreEdgeAttr(e,t,s){const n=this.edgeDefaultAttrs.get(e.id)?.[s];n!==void 0?this.setEdgeAttrIfChanged(e,t,n):e.attr(t)!==void 0&&e.removeAttrByPath(t)}setEdgeAttrIfChanged(e,t,s){e.attr(t)!==s&&e.setAttrByPath(t,s)}getNodeRingTarget(e){return e?e.querySelector(".flow-canvas-highlight-target")??e.querySelector(".flow-canvas-node-surface > :first-child"):null}syncEdgeMarker(e,t,s){const i=t?.x6EdgeConfig?.attrs?.line?.[s],a=`line/${s}`;e.removeAttrByPath(a),i!==void 0&&e.setAttrByPath(a,i)}dispose(){for(const e of this.pendingDecorationRAFs.values())cancelAnimationFrame(e);this.pendingDecorationRAFs.clear(),this.knownNodeIds.clear(),this.knownEdgeIds.clear()}resolveNodes(e){const t=new Map;for(const[s,n]of Object.entries(e.nodes)){const i=this.schema.nodeTypes[n.type];if(!i)throw new Le(`Unknown node type "${n.type}" for node "${s}". Registered types: [${Object.keys(this.schema.nodeTypes).join(", ")}]. Register the type in CanvasSchema.nodeTypes before using it in a FlowModel.`);const a=this.shapeRegistry.registerNodeType(n.type,i.component),c=i.getSize(n),l=ke(n,i.getPorts);t.set(s,{model:n,definition:i,shapeName:a,size:c,ports:l})}return t}resolveEdges(e){const t=new Map;for(const[s,n]of Object.entries(e.edges)){const i=n.type??this.schema.defaultEdgeType??"default",a=this.schema.edgeTypes?.[i];t.set(s,{model:n,definition:a})}return t}syncNodes(e){const t=new Set(e.keys());for(const s of this.knownNodeIds)if(!t.has(s)){const n=this.graph.getCellById(s);n&&this.graph.removeCell(n),this.knownNodeIds.delete(s),this.defaultHighlightedNodeIds.delete(s),this.prevNodeDecorationClasses.delete(s),this.prevNodeDecorationColors.delete(s),this.nodeDefaultAttrs.delete(s);const i=this.pendingDecorationRAFs.get(s);i&&(cancelAnimationFrame(i),this.pendingDecorationRAFs.delete(s))}for(const[s,n]of e){const i=this.graph.getCellById(s);i?this.updateExistingNode(i,n):this.addNewNode(s,n)}}updateExistingNode(e,t){const{model:s,size:n,ports:i,definition:a}=t;if(e.getData()?.type!==s.type){this.graph.removeCell(e),this.addNewNode(e.id,t);return}const l=e.getPosition();(l.x!==s.position.x||l.y!==s.position.y)&&e.setPosition(s.position.x,s.position.y);const v=e.getSize();(v.width!==n.width||v.height!==n.height)&&e.setSize(n.width,n.height,{silent:!0}),this.syncNodePorts(e,i),e.setData({...s}),this.applyNodeBehavior(e,s,a),this.applyNodeHighlightAndDecoration(e,s)}syncNodePorts(e,t){const s=e.getPorts(),n=new Set(t.map(a=>a.id)),i=new Set(s.map(a=>a.id));for(const a of s)a.id&&!n.has(a.id)&&e.removePort(a.id);for(const a of t)i.has(a.id)||e.addPort({id:a.id,group:a.group,...a.x6PortConfig})}addNewNode(e,t){const{model:s,shapeName:n,size:i,ports:a,definition:c}=t,l={id:s.id,shape:n,x:s.position.x,y:s.position.y,width:i.width,height:i.height,data:{...s},ports:{groups:{top:{position:"top",attrs:{circle:{r:6,magnet:!0,fill:"#3a84ff",stroke:"#fff",strokeWidth:1,visibility:"hidden"}}},right:{position:"right",attrs:{circle:{r:6,magnet:!0,fill:"#3a84ff",stroke:"#fff",strokeWidth:1,visibility:"hidden"}}},bottom:{position:"bottom",attrs:{circle:{r:6,magnet:!0,fill:"#3a84ff",stroke:"#fff",strokeWidth:1,visibility:"hidden"}}},left:{position:"left",attrs:{circle:{r:6,magnet:!0,fill:"#3a84ff",stroke:"#fff",strokeWidth:1,visibility:"hidden"}}}},items:a.map(f=>({id:f.id,group:f.group,...f.x6PortConfig}))},...c.x6CellConfig};this.graph.addNode(l),this.knownNodeIds.add(e),this.saveNodeDefaultAttrs(e,c);const v=this.graph.getCellById(e);v&&(this.applyNodeBehavior(v,s,c),this.applyNodeHighlightAndDecoration(v,s),this.scheduleDecorationRetryIfNeeded(v,s))}scheduleDecorationRetryIfNeeded(e,t){const s=this.graph.findViewByCell(e)?.container;if(this.getNodeRingTarget(s))return;const n=e.id,i=this.pendingDecorationRAFs.get(n);i&&cancelAnimationFrame(i);const a=requestAnimationFrame(()=>{if(this.pendingDecorationRAFs.delete(n),!this.knownNodeIds.has(n))return;const c=this.lastModel?.nodes[n];if(!c)return;const l=this.graph.getCellById(n);l?.isNode()&&this.applyNodeHighlightAndDecoration(l,c)});this.pendingDecorationRAFs.set(n,a)}applyNodeBehavior(e,t,s){if(!s.getBehavior)return;const n=this.resolveCanvasContext?.();if(!n)return;const i=s.getBehavior(t,n);if(i.draggable!==void 0&&e.setProp("draggable",i.draggable,{silent:!0}),i.connectable!==void 0){const c=i.connectable?!0:i.targetable===!1?!1:"passive";for(const l of e.getPorts())e.setPortProp(l.id,"attrs/circle/magnet",c,{silent:!0})}if(i.showPorts!==void 0){const c=i.showPorts;for(const l of e.getPorts())e.setPortProp(l.id,"attrs/circle/visibility",c?"visible":"hidden",{silent:!0})}const a=e.getData()??{};i.deletable!==void 0&&a._deletable!==i.deletable&&e.setData({...a,_deletable:i.deletable},{silent:!0}),i.selectable!==void 0&&a._selectable!==i.selectable&&e.setData({...e.getData(),_selectable:i.selectable},{silent:!0})}syncEdges(e,t){const s=new Set(e.keys());for(const n of this.knownEdgeIds)if(!s.has(n)){const i=this.graph.getCellById(n);i&&this.graph.removeCell(i),this.knownEdgeIds.delete(n),this.defaultHighlightedEdgeIds.delete(n),this.prevEdgeDecorationClasses.delete(n),this.prevEdgeDecorationColors.delete(n),this.prevEdgeStyleIds.delete(n),this.edgeDefaultAttrs.delete(n)}for(const[n,i]of e){const a=this.graph.getCellById(n),{model:c,definition:l}=i;a?(this.updateExistingEdge(a,c,l,t),this.knownEdgeIds.has(n)||(this.knownEdgeIds.add(n),this.saveEdgeDefaultAttrs(n,l))):this.addNewEdge(n,c,l)}}updateExistingEdge(e,t,s,n){const i=e.getSource(),a=e.getTarget(),c=i.cell!==t.source.nodeId||i.port!==t.source.portId,l=a.cell!==t.target.nodeId||a.port!==t.target.portId;c&&e.setSource({cell:t.source.nodeId,port:t.source.portId}),l&&e.setTarget({cell:t.target.nodeId,port:t.target.portId});const f=(e.getData()?.type??void 0)!==(t.type??void 0);if(f){if(s?.router){const h=typeof s.router=="string"?{name:s.router}:s.router;e.setRouter(h)}if(s?.connector){const h=typeof s.connector=="string"?{name:s.connector}:s.connector;e.setConnector(h)}}(f||c||l)&&(this.syncEdgeMarker(e,s,"sourceMarker"),this.syncEdgeMarker(e,s,"targetMarker")),this.syncEdgeLabels(e,t),e.getZIndex()!==ye&&e.setZIndex(ye),e.setData({...t},{silent:!0}),this.applyEdgeStyleAndDecoration(e,t,s)}syncEdgeLabels(e,t){if(!t.labels?.length){e.getLabels().length>0&&e.setLabels([]);return}const s=t.labels.map(n=>({attrs:{label:{text:n.text??""}},position:n.position!=null?{distance:n.position}:void 0}));e.setLabels(s)}addNewEdge(e,t,s){const n={id:t.id,source:{cell:t.source.nodeId,port:t.source.portId},target:{cell:t.target.nodeId,port:t.target.portId},data:{...t},zIndex:ye};s?.router&&(n.router=typeof s.router=="string"?{name:s.router}:s.router),s?.connector&&(n.connector=typeof s.connector=="string"?{name:s.connector}:s.connector),s?.x6EdgeConfig&&Object.assign(n,s.x6EdgeConfig),t.labels?.length&&(n.labels=t.labels.map(a=>({attrs:{label:{text:a.text??""}},position:a.position!=null?{distance:a.position}:void 0}))),this.graph.addEdge(n),this.knownEdgeIds.add(e),this.saveEdgeDefaultAttrs(e,s);const i=this.graph.getCellById(e);i&&this.applyEdgeStyleAndDecoration(i,t,s)}refreshEdgeStyles(){if(this.lastModel)for(const[e,t]of Object.entries(this.lastModel.edges)){const s=this.graph.getCellById(e);if(!s?.isEdge())continue;const n=t.type??this.schema.defaultEdgeType??"default",i=this.schema.edgeTypes?.[n];this.applyEdgeStyleAndDecoration(s,t,i)}}refreshSingleEdgeStyle(e){if(!this.lastModel)return;const t=this.lastModel.edges[e];if(!t)return;const s=this.graph.getCellById(e);if(!s?.isEdge())return;const n=t.type??this.schema.defaultEdgeType??"default",i=this.schema.edgeTypes?.[n];this.applyEdgeStyleAndDecoration(s,t,i)}refreshNodeHighlights(){if(this.lastModel)for(const[e,t]of Object.entries(this.lastModel.nodes)){const s=this.graph.getCellById(e);s?.isNode()&&this.applyNodeHighlightAndDecoration(s,t)}}applyNodeHighlightAndDecoration(e,t){const s=this.highlightedNodeIds.has(e.id),n=this.resolveNodeDecoration?.(t),i=this.graph.findViewByCell(e)?.container,a=this.getNodeRingTarget(i),c=this.prevNodeDecorationClasses.get(e.id);c&&(i?.classList.remove(c),this.prevNodeDecorationClasses.delete(e.id)),n?.className&&(i?.classList.add(n.className),this.prevNodeDecorationClasses.set(e.id,n.className));const l=n?.borderColor,f=l??(s?"#3a84ff":void 0),h=this.prevNodeDecorationColors.has(e.id)||this.defaultHighlightedNodeIds.has(e.id);f?(e.setAttrByPath("body/stroke",f),e.setAttrByPath("body/strokeWidth",2)):h&&(this.restoreNodeAttr(e,"body/stroke","stroke"),this.restoreNodeAttr(e,"body/strokeWidth","strokeWidth")),a&&(a.classList.add(kt),l?(a.classList.add(xe),a.style.setProperty("--flow-canvas-node-decoration-ring-background",l),a.style.setProperty("--flow-canvas-node-decoration-ring-opacity","0.95")):(a.classList.remove(xe),a.style.removeProperty("--flow-canvas-node-decoration-ring-background"),a.style.removeProperty("--flow-canvas-node-decoration-ring-opacity")),s?(a.classList.add(Ie),a.style.setProperty("--flow-canvas-node-pulse-ring-background",l??Ct),a.style.setProperty("--flow-canvas-node-pulse-ring-opacity","0.95")):(a.classList.remove(Ie),a.style.removeProperty("--flow-canvas-node-pulse-ring-background"),a.style.removeProperty("--flow-canvas-node-pulse-ring-opacity"))),l?this.prevNodeDecorationColors.add(e.id):this.prevNodeDecorationColors.delete(e.id),s&&!l?this.defaultHighlightedNodeIds.add(e.id):this.defaultHighlightedNodeIds.delete(e.id)}getHoveredEdgeId(){return this.hoveredEdgeId}setHoveredEdge(e){this.hoveredEdgeId=e}setHighlightedNodes(e){this.highlightedNodeIds=new Set(e)}setHighlightedEdges(e){const t=this.highlightedEdgeIds;return this.highlightedEdgeIds=new Set(e),t}applyEdgeStyleAndDecoration(e,t,s){const n=this.highlightedEdgeIds.has(e.id),i=this.resolveEdgeDecoration?.(t),a=this.prevEdgeDecorationClasses.get(e.id);a&&(this.graph.findViewByCell(e)?.container?.classList.remove(a),this.prevEdgeDecorationClasses.delete(e.id)),i?.className&&(this.graph.findViewByCell(e)?.container?.classList.add(i.className),this.prevEdgeDecorationClasses.set(e.id,i.className));let c,l,v;if(s?.style){const w=this.graph.isSelected?.(e)??!1,I=this.hoveredEdgeId===e.id,D=s.style(t,{selected:w,highlighted:n,hovered:I});c=D.stroke,l=D.strokeWidth,v=D.strokeDasharray}const f=!s?.style&&n?"#3a84ff":void 0,h=i?.strokeColor,g=h??c??f,k=!!s?.style||this.prevEdgeDecorationColors.has(e.id)||this.defaultHighlightedEdgeIds.has(e.id)||this.prevEdgeStyleIds.has(e.id);g?this.setEdgeAttrIfChanged(e,"line/stroke",g):k&&this.restoreEdgeAttr(e,"line/stroke","stroke"),s?.style?(this.prevEdgeStyleIds.add(e.id),l?this.setEdgeAttrIfChanged(e,"line/strokeWidth",l):this.restoreEdgeAttr(e,"line/strokeWidth","strokeWidth"),v?this.setEdgeAttrIfChanged(e,"line/strokeDasharray",v):this.restoreEdgeAttr(e,"line/strokeDasharray","strokeDasharray")):this.prevEdgeStyleIds.has(e.id)&&(this.restoreEdgeAttr(e,"line/strokeWidth","strokeWidth"),this.restoreEdgeAttr(e,"line/strokeDasharray","strokeDasharray"),this.prevEdgeStyleIds.delete(e.id)),h?this.prevEdgeDecorationColors.add(e.id):this.prevEdgeDecorationColors.delete(e.id),f?this.defaultHighlightedEdgeIds.add(e.id):this.defaultHighlightedEdgeIds.delete(e.id)}}class It{instanceId=K();registeredShapes=new Map;wrappedComponents=new Map;getShapeName(e){let t=this.registeredShapes.get(e);return t||(t=`flow-node-${this.instanceId}-${e}`,this.registeredShapes.set(e,t)),t}registerNodeType(e,t){const s=this.getShapeName(e);let n=this.wrappedComponents.get(e);return n||(n=o.defineComponent({name:`FlowCanvasNodeShape${e.replace(/(^|[-_])(\w)/g,(i,a,c)=>c.toUpperCase())}`,setup(){return()=>o.h("div",{class:"flow-canvas-node-surface"},[o.h(t)])}}),this.wrappedComponents.set(e,n)),et.register({shape:s,component:n,width:100,height:40}),s}dispose(){this.registeredShapes.clear(),this.wrappedComponents.clear()}}class Nt{graph;onUiEvent;onCommand;flowModelRef;idGenerator;disposers=[];constructor(e,t,s,n,i){this.graph=e,this.onUiEvent=t,this.onCommand=s,this.flowModelRef=n,this.idGenerator=i??Ee,this.bindEvents()}dispose(){for(const e of this.disposers)e();this.disposers=[]}bindEvents(){this.on("node:click",({node:e})=>{this.onUiEvent({type:"node.click",nodeId:e.id})}),this.on("node:dblclick",({node:e})=>{this.onUiEvent({type:"node.dblclick",nodeId:e.id})}),this.on("node:contextmenu",({node:e,e:t})=>{this.onUiEvent({type:"node.contextmenu",nodeId:e.id,position:{x:t.clientX,y:t.clientY}})}),this.on("edge:click",({edge:e,e:t})=>{const n=t.target?.closest?.(".x6-edge-label");if(n){const a=e.getData?.()?.labels??[],c=n.parentElement?.querySelectorAll(".x6-edge-label"),l=c?Array.from(c).indexOf(n):0,v=a[Math.max(0,l)];this.onUiEvent({type:"edge.label.click",edgeId:e.id,labelId:v?.id??`label-${l}`});return}this.onUiEvent({type:"edge.click",edgeId:e.id})}),this.on("blank:click",({e})=>{const t=this.graph.clientToLocal(e.clientX,e.clientY);this.onUiEvent({type:"blank.click",position:{x:t.x,y:t.y}})}),this.on("blank:contextmenu",({e})=>{this.onUiEvent({type:"blank.contextmenu",position:{x:e.clientX,y:e.clientY}})}),this.on("node:moved",({node:e})=>{const t=e.getPosition();this.onCommand({id:K(),source:"user:drag",label:"移动节点",timestamp:Date.now(),commands:[{type:"node.move",nodeId:e.id,position:{x:t.x,y:t.y}}]})}),this.on("edge:connected",({edge:e,isNew:t})=>{const s=e.getSourceCell(),n=e.getTargetCell();if(!s||!n)return;const i=e.getSourcePortId(),a=e.getTargetPortId(),c=e.id in this.flowModelRef.value.edges;t&&!c?(this.graph.removeCell(e),this.onCommand({id:K(),source:"user:drag",label:"连线",timestamp:Date.now(),commands:[{type:"edge.add",edge:{id:this.idGenerator("edge"),source:{nodeId:s.id,portId:i??void 0},target:{nodeId:n.id,portId:a??void 0}}}]})):this.onCommand({id:K(),source:"user:drag",label:"重连",timestamp:Date.now(),commands:[{type:"edge.reconnect",edgeId:e.id,source:{nodeId:s.id,portId:i??void 0},target:{nodeId:n.id,portId:a??void 0}}]})}),this.on("edge:change:labels",({edge:e,current:t})=>{const n=e.getData?.()?.labels??[];if(!n.length||!t?.length)return;const i=[];for(let a=0;a<Math.min(n.length,t.length);a++){const c=t[a],l=n[a];if(!l?.id)continue;const v=typeof c.position=="object"?c.position?.distance:c.position;v!=null&&i.push({type:"edge.label.update",edgeId:e.id,labelId:l.id,patch:{position:v}})}i.length&&this.onCommand({id:K(),source:"user:drag",label:"拖动标签",timestamp:Date.now(),commands:i})})}on(e,t){this.graph.on(e,t),this.disposers.push(()=>this.graph.off(e,t))}}function St(r){function e(t){const s=r.getCellById(t);if(!s||!s.isNode())return null;const n=s,i=n.getPosition(),a=n.getSize(),c={x:i.x,y:i.y,width:a.width,height:a.height},l=r.localToGraph(c);return new DOMRect(l.x,l.y,l.width,l.height)}return{getNodeScreenRect:e}}function Fe(r){return{nodeIds:r.filter(e=>e.isNode()).map(e=>e.id),edgeIds:r.filter(e=>e.isEdge()).map(e=>e.id)}}function Dt(r,e){const t=[...e.nodeIds.map(i=>r.getCellById(i)),...e.edgeIds.map(i=>r.getCellById(i))].filter(i=>!!i);if(t.length===0)return null;const s=r.getCellsBBox(t);if(!s)return null;const n=r.localToGraph(s);return new DOMRect(n.x,n.y,n.width,n.height)}function Ve(r,e,t){const s=r.nodeIds.filter(a=>{const c=e.nodes[a];if(!c)return!1;const l=t(c);return l.deletable!==!1&&l.deleteDisabled!==!0}),n=new Set(s),i=r.edgeIds.filter(a=>{const c=e.edges[a];return c?!n.has(c.source.nodeId)&&!n.has(c.target.nodeId):!1});return{nodeIds:s,edgeIds:i}}function Mt(r){return[...r.edgeIds.map(e=>({type:"edge.remove",edgeId:e})),...r.nodeIds.map(e=>({type:"node.remove",nodeId:e}))]}const _t=100;function At({graph:r,overlayManager:e,executeCommand:t,schema:s,flowModel:n,getNodeBehavior:i,idGenerator:a,defaultInsertGap:c,getContextMenuItems:l,onHighlightChange:v,resolveNodeShape:f}){const h=a??Ee;let g=[],k=[],w=null,I=!1,D=null;async function P(){if(I)return w;I=!0;try{const p=await import("@antv/x6-plugin-dnd"),d=p.Dnd??p.default;return d?(w=new d({target:r,scaled:!0,animation:!0,getDragNode:u=>u.clone(),getDropNode:u=>u.clone()}),w):null}catch{return console.warn("[flow-canvas] @antv/x6-plugin-dnd not available, add it to your dependencies"),null}}function A(){return new Promise(p=>{requestAnimationFrame(()=>requestAnimationFrame(()=>p()))})}const O=({node:p})=>{const d=p.getData?.();if(!d?._dndSessionId||d._dndSessionId!==D)return;D=null;const u=p.getPosition();r.removeNode(p.id);const{_dndSessionId:m,...E}=d,C=E.id||h("node");t({id:K(),source:"user:drag",label:"拖入节点",timestamp:Date.now(),commands:[{type:"node.add",node:{...E,id:C,position:{x:u.x,y:u.y}}}]})};r.on("node:added",O);function q(p){const d=s.nodeTypes[p.type];return ke(p,d?.getPorts)}function R(p){return p??Fe(r.getSelectedCells?.()??[])}function z(p,d,u,m,E){switch(p){case"left":return{x:d.position.x-E-m.width,y:d.position.y+(u.height-m.height)/2};case"top":return{x:d.position.x+(u.width-m.width)/2,y:d.position.y-E-m.height};case"bottom":return{x:d.position.x+(u.width-m.width)/2,y:d.position.y+u.height+E};default:return{x:d.position.x+u.width+E,y:d.position.y+(u.height-m.height)/2}}}function H(p,d,u){switch(p){case"left":return{x:-(d.width+u),y:0};case"top":return{x:0,y:-(d.height+u)};case"bottom":return{x:0,y:d.height+u};default:return{x:d.width+u,y:0}}}function M(p){switch(p){case"left":return"right";case"top":return"bottom";case"bottom":return"top";default:return"left"}}const y={zoomIn(){r.zoom(.1)},zoomOut(){r.zoom(-.1)},zoomTo(p){r.zoomTo(p)},zoomToFit(){r.zoomToFit({padding:40,maxScale:1.5})},getZoom(){return r.zoom()},centerContent(){r.centerContent()},scrollToOrigin(){r.translate(0,0)},scrollToNode(p){const d=r.getCellById(p);d&&r.centerCell(d)},getSelection(){return R()},getSelectionBounds(p){return Dt(r,R(p))},selectNodes(p){const d=p.map(u=>r.getCellById(u)).filter(Boolean);r.select?.(d)},selectEdges(p){const d=p.map(u=>r.getCellById(u)).filter(Boolean);r.select?.(d)},clearSelection(){const p=r.getSelectedCells?.();p?.length&&r.unselect?.(p)},deleteSelection(p){const d=R(p?.selection),u=Ve(d,n.value,i??(()=>({}))),m=Mt(u);if(m.length===0)return null;const E=t({id:K(),source:p?.source??"user:toolbar",label:p?.label??"删除选中",timestamp:Date.now(),commands:m});return E.status==="applied"&&p?.clearSelectionAfterApply!==!1&&y.clearSelection(),E},registerDndSource(p,d){const u=async m=>{const E=await P();if(!E)return;const C=K();D=C;const $=d(),U=f?.($.type),N=r.createNode({width:U?.width??154,height:U?.height??54,shape:U?.shapeName??"rect",data:{...$,_dndSessionId:C}});E.start(N,m)};return p.addEventListener("mousedown",u),()=>{p.removeEventListener("mousedown",u)}},startConnection(p,d){const u=r.getCellById(p);if(!u?.isNode())return;const m=u,E=r.findViewByCell(m);if(!E)return;const C=E.findPortElem(d,"circle")??E.findPortElem(d);if(!C)return;const U=(C.matches?.("[magnet]")?C:C.querySelector?.("[magnet]"))??C,N=U.getBoundingClientRect(),T=N.left+N.width/2,b=N.top+N.height/2,B=new MouseEvent("mousedown",{clientX:T,clientY:b,button:0,buttons:1,bubbles:!0,cancelable:!0});U.dispatchEvent(B)},async exportAsImage(p){const{domToBlob:d}=await import("modern-screenshot"),u=p?.padding??20,m=p?.backgroundColor??r.options.background?.color??"#ffffff",E=r.zoom(),C=r.translate(),$=r.getContentBBox(),U=$.width/E,N=$.height/E;if(U===0||N===0)return new Blob;const T=($.x-C.tx)/E,b=($.y-C.ty)/E,B=Math.ceil(U+u*2),F=Math.ceil(N+u*2),j=document.createElement("div");j.style.cssText="position:fixed;left:-99999px;top:0;pointer-events:none;";const G=r.container.cloneNode(!0);G.style.width=`${B}px`,G.style.height=`${F}px`,G.style.overflow="visible";const Z=G.querySelector("svg");Z&&(Z.setAttribute("width",String(B)),Z.setAttribute("height",String(F)),Z.style.width=`${B}px`,Z.style.height=`${F}px`),G.querySelector(".x6-graph-svg-viewport")?.setAttribute("transform",`matrix(1,0,0,1,${-T+u},${-b+u})`),j.appendChild(G),document.body.appendChild(j);try{return await A(),await d(G,{width:B,height:F,backgroundColor:m,scale:p?.scale??window.devicePixelRatio,filter:Y=>{if(Y instanceof Element){const J=Y.getAttribute("class")??"";if(J.includes("x6-widget-selection")||J.includes("x6-widget-transform")||J.includes("x6-graph-grid")||J.includes("x6-graph-background"))return!1}return!0}})}catch(Y){return console.warn("[flow-canvas] Export failed:",Y),new Blob}finally{j.remove()}},highlightNodes(p){g=p,v?.(g,k)},highlightEdges(p){k=p,v?.(g,k)},clearHighlight(){g=[],k=[],v?.([],[])},overlay:e,getContextMenuItems(p){return l?.(p)??[]},insertNodeToRight(p,d,u){const m=n.value,E=m.nodes[p];if(!E)return{status:"invalid",envelope:{id:"",source:"user:toolbar",timestamp:Date.now(),commands:[]},error:{code:"constraint_violated",reason:`Source node "${p}" not found`,source:"api"}};const C=u?.gap??c??_t,$=u?.direction??"right",U=s.nodeTypes[E.type],N=s.nodeTypes[d.type],T=U?.getSize(E)??{width:154,height:54},b=N?.getSize({...d,position:{x:0,y:0}})??{width:154,height:54},B=z($,E,T,b,C),F=d.id||h("node"),j={...d,id:F,position:B},G=[{type:"node.add",node:j}],Z=H($,b,C),W={x:B.x,y:B.y,width:b.width,height:b.height};for(const[J,Q]of Object.entries(m.nodes)){if(J===p||J===F)continue;const x=s.nodeTypes[Q.type]?.getSize(Q)??{width:154,height:54},_=W.x<Q.position.x+x.width&&W.x+W.width>Q.position.x,V=W.y<Q.position.y+x.height&&W.y+W.height>Q.position.y;_&&V&&G.push({type:"node.move",nodeId:J,position:{x:Q.position.x+Z.x,y:Q.position.y+Z.y}})}if(u?.autoWireEdges){const J=q(E),Q=q(j),S=$,x=M($),_=J.find(X=>X.group===S),V=Q.find(X=>X.group===x),te=Q.find(X=>X.group===S),ne=_?Object.values(m.edges).find(X=>X.source.nodeId===p&&X.source.portId===_.id):Object.values(m.edges).find(X=>X.source.nodeId===p);if(ne){const X=ne.target;G.push({type:"edge.remove",edgeId:ne.id}),G.push({type:"edge.add",edge:{id:h("edge"),source:{nodeId:p,portId:_?.id},target:{nodeId:F,portId:V?.id}}}),G.push({type:"edge.add",edge:{id:h("edge"),source:{nodeId:F,portId:te?.id},target:X}})}else G.push({type:"edge.add",edge:{id:h("edge"),source:{nodeId:p,portId:_?.id},target:{nodeId:F,portId:V?.id}}})}const Y={id:K(),source:u?.source??"user:toolbar",label:u?.label??"插入节点",timestamp:Date.now(),commands:G};return t(Y)},onGraphEvent(p,d){return r.on(p,d),()=>r.off(p,d)},unsafeGetGraph(){return r}};return y}function Bt(){const r=o.ref(null),e=o.ref(!1);let t=null,s=!1;function n(h){t&&(clearTimeout(t),t=null),r.value=h}function i(h=100){s||(t&&clearTimeout(t),t=setTimeout(()=>{r.value=null,t=null},h))}function a(){s=!0,t&&(clearTimeout(t),t=null)}function c(h=100){s=!1,i(h)}function l(){t&&(clearTimeout(t),t=null)}function v(){l(),s=!1,r.value=null}function f(){t&&clearTimeout(t)}return{hoveredNodeId:r,isDraggingNode:e,enter:n,leave:i,enterOverlay:a,leaveOverlay:c,cancelLeave:l,reset:v,cleanup:f}}const Ne=10,ue=12;function Se(r,e){const t=r.getTotalLength();if(t===0)return{...e,length:0,totalLength:0};let s=r.getPointAtLength(0),n=1/0;const i=50,a=t/i;let c=0;for(let h=0;h<=i;h++){const g=h*a,k=r.getPointAtLength(g),w=(k.x-e.x)**2+(k.y-e.y)**2;w<n&&(n=w,s=k,c=g)}const l=Math.max(0,c-a),v=Math.min(t,c+a),f=(v-l)/20;for(let h=l;h<=v;h+=f){const g=r.getPointAtLength(h),k=(g.x-e.x)**2+(g.y-e.y)**2;k<n&&(n=k,s=g,c=h)}return{x:s.x,y:s.y,length:c,totalLength:t}}function De(r,e){return r<Ne||r>e-Ne}function Me(r,e,t){const s=r.querySelectorAll(".x6-edge-label");for(const n of s){const i=n.getBoundingClientRect();if(e>=i.left-ue&&e<=i.right+ue&&t>=i.top-ue&&t<=i.bottom+ue)return!0}return!1}function _e(){const r="http://www.w3.org/2000/svg",e=document.createElementNS(r,"g");e.setAttribute("class","flow-canvas-edge-delete-tool"),e.style.cursor="pointer";const t=document.createElementNS(r,"rect");t.setAttribute("width","20"),t.setAttribute("height","20"),t.setAttribute("x","-10"),t.setAttribute("y","-10"),t.setAttribute("rx","4"),t.setAttribute("ry","4"),t.setAttribute("fill","#3a84ff"),e.appendChild(t);const s=document.createElementNS(r,"text");return s.setAttribute("font-family","flow-canvas"),s.setAttribute("font-size","16"),s.setAttribute("fill","#ffffff"),s.setAttribute("text-anchor","middle"),s.setAttribute("dominant-baseline","central"),s.textContent="",e.appendChild(s),e}function Pt(r){let e=null,t=null;function s(c,l){if(i(),t=c,l.target?.closest?.(".x6-edge-label"))return;const f=r.getCellById(c);if(!f?.isEdge())return;const h=r.findViewByCell(f);if(!h)return;const g=h.container.querySelector("path");if(!g)return;const k=r.clientToLocal(l.clientX,l.clientY),w=Se(g,k);if(De(w.length,w.totalLength)||Me(h.container,l.clientX,l.clientY))return;const I=_e();I.setAttribute("transform",`translate(${w.x}, ${w.y})`),h.container.appendChild(I),e=I}function n(c){if(!t)return;if(c.target?.closest?.(".x6-edge-label")){e&&e.setAttribute("display","none");return}const v=r.getCellById(t);if(!v?.isEdge())return;const f=r.findViewByCell(v);if(!f)return;const h=f.container.querySelector("path");if(!h)return;const g=r.clientToLocal(c.clientX,c.clientY),k=Se(h,g);if(De(k.length,k.totalLength)||Me(f.container,c.clientX,c.clientY))e&&e.setAttribute("display","none");else if(e)e.removeAttribute("display"),e.setAttribute("transform",`translate(${k.x}, ${k.y})`);else{const w=_e();w.setAttribute("transform",`translate(${k.x}, ${k.y})`),f.container.appendChild(w),e=w}}function i(){e&&(e.remove(),e=null),t=null}function a(c){c===t&&(e=null,t=null)}return{show:s,move:n,remove:i,handleEdgeRemoved:a}}function Tt(r){let e=null,t=0;function s(f){const h=f?"visible":"hidden";for(const g of r.getNodes())for(const k of g.getPorts())g.setPortProp(k.id,"attrs/circle/visibility",h)}function n(f){if(!e)for(const h of f.getPorts())f.setPortProp(h.id,"attrs/circle/visibility","visible")}function i(f){if(!e)for(const h of f.getPorts())f.setPortProp(h.id,"attrs/circle/visibility","hidden")}function a(f,h){if(!f.getTargetCell())if(e=f.id,h?.size)for(const g of r.getNodes()){const k=h.has(g.id)?"hidden":"visible";for(const w of g.getPorts())g.setPortProp(w.id,"attrs/circle/visibility",k)}else s(!0)}function c(){e=null,s(!1),t=Date.now()+300}function l(f){f===e&&(e=null,s(!1))}function v(){return!e&&Date.now()>=t}return{showNodePorts:n,hideNodePorts:i,handleEdgeAdded:a,handleEdgeConnected:c,handleEdgeRemoved:l,canShowEdgeTool:v}}function Ae(r){return r==="top"||r==="right"||r==="bottom"||r==="left"}function Rt(r){const{editor:e,nodeHover:t,isSelectionModeActive:s,viewportVersion:n,getNodeBehavior:i,getInsertGap:a}=r,{isDraggingNode:c}=r,l=o.ref(null),v=o.ref(!1);let f=null,h=null,g=null;const k=o.computed(()=>({enabled:!0,portGroup:"right",...r.quickAddProp.value}));function w(){f&&(clearTimeout(f),f=null)}function I(){f&&clearTimeout(f),f=setTimeout(()=>{l.value=null,f=null},150)}function D(N){return v.value?!0:(w(),y(N)?(l.value=N,!0):(l.value=null,!1))}function P(){w(),t.enterOverlay()}function A(){I(),t.leaveOverlay()}function O(N){const T=e.schema.nodeTypes[N.type];return ke(N,T?.getPorts)}function q(N,T){const b=k.value.getPort?.(N,T);if(!b)return null;const B=typeof b=="string"?b:b.id;return T.find(F=>F.id===B)??null}function R(N,T){const b=e.api.value?.overlay.getNodeScreenRect(N);if(!b)return null;switch(T){case"top":return{x:b.x+b.width/2,y:b.y};case"bottom":return{x:b.x+b.width/2,y:b.y+b.height};case"left":return{x:b.x,y:b.y+b.height/2};case"right":return{x:b.x+b.width,y:b.y+b.height/2};default:return null}}function z(N,T,b){if(!h)return R(N,b);const B=h.getCellById(N);if(B?.isNode()){const F=B,j=h.findViewByCell(F),G=j?.findPortElem(T,"circle")??j?.findPortElem(T);if(G){const Z=h.container.getBoundingClientRect(),W=G.getBoundingClientRect();return{x:W.left-Z.left+W.width/2,y:W.top-Z.top+W.height/2}}}return R(N,b)}function H(N){const T=O(N),b=q(N,T)??T.find(F=>F.group===k.value.portGroup)??null;if(!b)return null;const B=z(N.id,b.id,b.group);return B?{portId:b.id,portGroup:b.group,portPosition:B}:null}function M(N){const T=H(N),b=k.value.insertDirection;if(typeof b=="function"){const B=b(N,T?{id:T.portId,group:T.portGroup}:null);if(B)return B}else if(b)return b;return T&&Ae(T.portGroup)?T.portGroup:Ae(k.value.portGroup)?k.value.portGroup:"right"}function y(N){if(!k.value.enabled||e.mode.value!=="edit")return!1;const b=e.flowModel.value.nodes[N];return!b||i(b).quickAddEnabled===!1?!1:!!H(b)}const p=o.computed(()=>{if(n.value,!k.value.enabled)return null;const N=l.value;if(!N||c.value||!e.api.value||e.mode.value!=="edit"||s.value)return null;const b=e.flowModel.value.nodes[N];if(!b)return null;const B=i(b);if(B.quickAddEnabled===!1)return null;const F=H(b);return F?{node:b,...F,behavior:B}:null});function d(N){v.value=!0,p.value&&e._emitUiEvent({type:"node.quick-add",nodeId:N,position:p.value.portPosition})}function u(){v.value=!1}function m(N){const T=e.api.value;if(!T)return;const b=e.flowModel.value.nodes[N];if(!b)return;const B=H(b);B&&T.startConnection(N,B.portId)}function E(N,T){const b=e.api.value;if(!b)return;const B=T.id||e.idGenerator("node"),F={...T,id:B},j=e.flowModel.value.nodes[N];if(!j)return;b.insertNodeToRight(N,F,{autoWireEdges:!0,direction:M(j),gap:a(),source:"user:quick-add",label:"快捷插入节点"}).status==="applied"&&e._emitUiEvent({type:"node.action.quick-insert",sourceNodeId:N,newNodeId:B}),r.closePopover()}function C(N){if(!h)return;const T=h.getCellById(N);if(!T?.isNode())return;const b=T,B=e.flowModel.value.nodes[N];if(!B)return;const F=H(B);let j=!0;i(B).hidePortForQuickAdd===!1&&(j=!1);const Z=j&&!c.value&&!!F&&y(N);for(const W of b.getPorts()){const Y=Z&&W.id===F?.portId?"hidden":"visible";b.setPortProp(W.id,"attrs/circle/visibility",Y)}}function $(N,T){g?.(),h=N,g=o.watch([l,c],([b],[B])=>{if(B&&B!==b){const F=N.getCellById(B);F?.isNode()&&T(F)}b&&C(b)},{flush:"sync"})}o.watch(p,N=>{N||(v.value=!1)});function U(){f&&clearTimeout(f),g?.(),g=null,h=null}return{quickAddNodeId:l,quickAddPopoverOpen:v,mergedConfig:k,data:p,enter:D,leave:I,cancelLeave:w,handleOverlayEnter:P,handleOverlayLeave:A,handleOpen:d,handleClose:u,handleStartDrag:m,handleInsert:E,isActiveForNode:y,syncNodePorts:C,attachRuntime:$,cleanup:U}}const Lt=15,Ot=10;function $t(r){const{editor:e}=r;let t=null,s=null,n=null,i=null;const a=[];let c=null;const l=o.computed(()=>({enabled:!1,bufferMargin:Lt,incomingPortGroup:"left",outgoingPortGroup:"right",...r.edgeDropProp.value}));function v(y){if(!t)return null;const p=t.getCellById(y);if(!p?.isEdge())return null;const d=t.findViewByCell(p)?.container;if(!d)return null;const u=d.querySelectorAll("path");for(const m of u)if(m.getAttribute("stroke")!=="transparent")return m;return null}function f(y){const p=v(y);p&&(p.style.stroke="#3a84ff",i=y)}function h(){if(!i)return;const y=v(i);y&&(y.style.stroke=""),i=null}function g(y,p,d){if(t){const u=t.getCellById(y);if(u?.isNode()){const m=u.getPorts().find(E=>E.group===d);if(m?.id)return m.id}}if(p.ports?.length){const u=p.ports.find(m=>m.group===d);if(u)return u.id}return d}function k(y){const p=y.getTotalLength();if(p===0)return[];const d=[];for(let m=0;m<=p;m+=Ot){const E=y.getPointAtLength(m);d.push({x:E.x,y:E.y})}const u=y.getPointAtLength(p);return d.push({x:u.x,y:u.y}),d}function w(y,p,d){if(!t)return null;const u=l.value,m=u.bufferMargin,E={x:y.x+m,y:y.y+m,width:Math.max(0,y.width-m*2),height:Math.max(0,y.height-m*2)};if(E.width<=0||E.height<=0)return null;const C=E.x+E.width,$=E.y+E.height;let U=null;const N=y.x+y.width/2,T=y.y+y.height/2;for(const b of t.getEdges()){const B=p.edges[b.id];if(!B||d&&(B.source.nodeId===d||B.target.nodeId===d)||u.isEdgeDropTarget&&!u.isEdgeDropTarget(B,p))continue;const F=t.findViewByCell(b);if(!F)continue;const j=F.findOne?.("path");if(!j||typeof j.getTotalLength!="function")continue;const G=k(j);if(!G.length)continue;let Z=!1,W=1/0;for(const Y of G)if(Y.x>=E.x&&Y.x<=C&&Y.y>=E.y&&Y.y<=$){const J=Y.x-N,Q=Y.y-T,S=J*J+Q*Q;S<W&&(W=S),Z=!0}Z&&(!U||W<U.distSq)&&(U={edgeId:b.id,edge:B,distSq:W})}return U?{edgeId:U.edgeId,edge:U.edge}:null}function I(y,p){if(!l.value.enabled)return;const u=e.flowModel.value,m=w(y,u,p);m?s!==m.edgeId&&(h(),s=m.edgeId,f(m.edgeId)):s&&(h(),s=null)}let D=!0;function P({node:y}){if(s=null,!l.value.enabled)return;const p=e.flowModel.value,d=p.nodes[y.id];if(!d){D=!1;return}const u=l.value;D=!u.isNodeInsertable||u.isNodeInsertable(d,p)}function A({node:y}){!l.value.enabled||!D||n===null&&(n=requestAnimationFrame(()=>{if(n=null,!t)return;const p=y.getPosition(),d=y.getSize();I({x:p.x,y:p.y,width:d.width,height:d.height},y.id)}))}function O(){n!==null&&(cancelAnimationFrame(n),n=null),h(),D=!0}function q(){if(!t)return;let y=!1;c=()=>{if(!l.value.enabled)return;const p=document.querySelector(".x6-widget-dnd");if(!p){y&&(y=!1,h(),s=null);return}y=!0,n===null&&(n=requestAnimationFrame(()=>{if(n=null,!t)return;const d=p.getBoundingClientRect(),u=t.clientToLocal(d.left,d.top),m=t.clientToLocal(d.right,d.bottom),E={x:u.x,y:u.y,width:m.x-u.x,height:m.y-u.y};I(E)}))},document.addEventListener("mousemove",c),a.push(()=>{c&&(document.removeEventListener("mousemove",c),c=null)})}function R(){h(),s=null,n!==null&&(cancelAnimationFrame(n),n=null)}function z(y){if(!s||y.source!=="user:drag")return y;const p=s;s=null,h();const d=e.flowModel.value,u=d.edges[p];if(!u)return y;const m=y.commands.find(F=>F.type==="node.add"||F.type==="node.move");if(!m)return y;const E=m.type==="node.add"?m.node.id:m.nodeId,C=m.type==="node.add"?m.node:d.nodes[m.nodeId];if(!C)return y;const $=l.value;if($.isNodeInsertable&&!$.isNodeInsertable(C,d))return y;const U=g(E,C,$.incomingPortGroup),N=g(E,C,$.outgoingPortGroup),T=e.idGenerator("edge"),b=e.idGenerator("edge"),B=[{type:"edge.remove",edgeId:p},{type:"edge.add",edge:{id:T,type:u.type,source:{nodeId:u.source.nodeId,portId:u.source.portId},target:{nodeId:E,portId:U}}},{type:"edge.add",edge:{id:b,type:u.type,source:{nodeId:E,portId:N},target:{nodeId:u.target.nodeId,portId:u.target.portId}}}];return{...y,source:"user:edge-drop",commands:[...y.commands,...B]}}function H(y){t=y;const p=(d,u)=>{y.on(d,u),a.push(()=>y.off(d,u))};p("node:move",P),p("node:change:position",A),p("node:moved",O),q()}function M(){R();for(const y of a)y();a.length=0,t=null,D=!0}return{attachRuntime:H,tryExpandForEdgeDrop:z,cleanup:M}}function Ft(r){function e(n){return{id:r.idGenerator("node"),type:n.type,label:n.label,ports:n.ports?JSON.parse(JSON.stringify(n.ports)):void 0,payload:n.payload?JSON.parse(JSON.stringify(n.payload)):void 0,extensions:n.extensions?JSON.parse(JSON.stringify(n.extensions)):void 0}}function t(n,i,a){const c=r.api.value;switch(n){case"delete":return r.executeCommand({id:K(),source:"user:toolbar",label:"删除节点",timestamp:Date.now(),commands:[{type:"node.remove",nodeId:i}]}),r._emitUiEvent({type:"node.action.delete",nodeId:i}),!0;case"copy":{if(!c)break;const l=r.flowModel.value.nodes[i];if(!l)break;const v=e(l);c.insertNodeToRight(i,v,{autoWireEdges:!1,gap:a,label:"复制节点"}),r._emitUiEvent({type:"node.action.copy",sourceNodeId:i,newNodeId:v.id});break}case"copy-insert":{if(!c)break;const l=r.flowModel.value.nodes[i];if(!l)break;const v=e(l);c.insertNodeToRight(i,v,{autoWireEdges:!0,gap:a,label:"复制并插入节点"}),r._emitUiEvent({type:"node.action.copy-insert",sourceNodeId:i,newNodeId:v.id});break}case"disconnect":{const l=r.flowModel.value,v=Object.entries(l.edges).filter(([,f])=>{const h=f;return h.source.nodeId===i||h.target.nodeId===i}).map(([f])=>f);if(v.length===0)break;r.executeCommand({id:K(),source:"user:toolbar",label:"断开连线",timestamp:Date.now(),commands:v.map(f=>({type:"edge.remove",edgeId:f}))}),r._emitUiEvent({type:"node.action.disconnect",nodeId:i,edgeIds:v});break}case"debug":{r._emitUiEvent({type:"node.action.debug",nodeId:i});break}}return!1}function s(n){r.api.value?.deleteSelection({selection:n,source:"user:toolbar",label:"批量删除选中"})}return{handleNodeAction:t,deleteSelection:s}}function Vt(){return{refX:0,children:[{tagName:"path",d:"M -16 -5 L -8 0 L -16 5 Z",transform:"rotate(0)"},{tagName:"circle",cx:0,cy:0,r:8,fill:"#3a84ff",stroke:"#3a84ff",transform:"rotate(0)"}]}}function Ht(r,e){const t=e.defaultEdgeType??"default",s=e.edgeTypes?.[t],n={zIndex:-1,attrs:{line:{stroke:"#abb5cc",strokeWidth:2,targetMarker:{name:"block",width:8,height:8}}}};s?.router&&(n.router=typeof s.router=="string"?{name:s.router}:s.router),s?.connector&&(n.connector=typeof s.connector=="string"?{name:s.connector}:s.connector),s?.x6EdgeConfig&&Object.assign(n,s.x6EdgeConfig);const i=n.attrs??{},a=i.line??{};return n.attrs={...i,line:{...a,targetMarker:Vt()}},r.createEdge(n)}const zt={class:"flow-canvas-node-actions__bar"},qt=o.defineComponent({__name:"node-actions-toolbar",props:{node:{},position:{},config:{},behavior:{},actionsOffset:{}},emits:["action"],setup(r,{emit:e}){const t=r,s=o.computed(()=>{const h=t.actionsOffset?.x??0,g=t.actionsOffset?.y??0,k=h!==0||g!==0;return{left:`${t.position.x}px`,top:`${t.position.y}px`,transform:k?`translate(${h}px, ${g}px)`:"translateX(-100%)"}}),n=e,i=o.computed(()=>({debug:{visible:t.config.showDebug&&t.behavior.debuggable!==!1,disabled:t.behavior.debugDisabled===!0},delete:{visible:t.config.showDelete&&t.behavior.deletable!==!1,disabled:t.behavior.deleteDisabled===!0},copy:{visible:t.config.showCopy&&t.behavior.copyable!==!1,disabled:t.behavior.copyDisabled===!0},copyInsert:{visible:t.config.showCopyInsert&&t.behavior.copyable!==!1,disabled:t.behavior.copyInsertDisabled===!0},disconnect:{visible:t.config.showDisconnect&&t.behavior.disconnectable!==!1,disabled:t.behavior.disconnectDisabled===!0}})),a=o.computed(()=>i.value.copy.visible||i.value.copyInsert.visible||i.value.disconnect.visible),c=o.ref(!1);let l=null;function v(){l&&(clearTimeout(l),l=null),c.value=!0}function f(){l=setTimeout(()=>{c.value=!1,l=null},100)}return o.onBeforeUnmount(()=>{l&&clearTimeout(l)}),(h,g)=>(o.openBlock(),o.createElementBlock("div",{class:"flow-canvas-node-actions",style:o.normalizeStyle(s.value)},[o.createElementVNode("div",zt,[i.value.debug.visible?(o.openBlock(),o.createElementBlock("i",{key:0,class:o.normalizeClass(["flow-canvas-icon canvas-debug flow-canvas-node-actions__icon",{"is-disabled":i.value.debug.disabled}]),onClick:g[0]||(g[0]=k=>!i.value.debug.disabled&&n("action","debug",r.node.id))},null,2)):o.createCommentVNode("",!0),i.value.delete.visible?(o.openBlock(),o.createElementBlock("i",{key:1,class:o.normalizeClass(["flow-canvas-icon canvas-shanchu flow-canvas-node-actions__icon",{"is-disabled":i.value.delete.disabled}]),onClick:g[1]||(g[1]=k=>!i.value.delete.disabled&&n("action","delete",r.node.id))},null,2)):o.createCommentVNode("",!0),a.value?(o.openBlock(),o.createElementBlock("div",{key:2,class:"flow-canvas-node-actions__more-wrapper",onMouseenter:v,onMouseleave:f},[...g[5]||(g[5]=[o.createElementVNode("i",{class:"flow-canvas-icon canvas-gengduo flow-canvas-node-actions__icon"},null,-1)])],32)):o.createCommentVNode("",!0)]),o.createVNode(o.Transition,{name:"flow-canvas-fade"},{default:o.withCtx(()=>[c.value&&a.value?(o.openBlock(),o.createElementBlock("div",{key:0,class:"flow-canvas-node-actions__dropdown",onMouseenter:v,onMouseleave:f},[i.value.copy.visible?(o.openBlock(),o.createElementBlock("div",{key:0,class:o.normalizeClass(["flow-canvas-node-actions__dropdown-item",{"is-disabled":i.value.copy.disabled}]),onClick:g[2]||(g[2]=k=>!i.value.copy.disabled&&n("action","copy",r.node.id))},[...g[6]||(g[6]=[o.createElementVNode("i",{class:"flow-canvas-icon canvas-copy-fuzhi-2"},null,-1),o.createElementVNode("span",null,"复制",-1)])],2)):o.createCommentVNode("",!0),i.value.copyInsert.visible?(o.openBlock(),o.createElementBlock("div",{key:1,class:o.normalizeClass(["flow-canvas-node-actions__dropdown-item",{"is-disabled":i.value.copyInsert.disabled}]),onClick:g[3]||(g[3]=k=>!i.value.copyInsert.disabled&&n("action","copy-insert",r.node.id))},[...g[7]||(g[7]=[o.createElementVNode("i",{class:"flow-canvas-icon canvas-fuzhibingcharu"},null,-1),o.createElementVNode("span",null,"复制并插入",-1)])],2)):o.createCommentVNode("",!0),i.value.disconnect.visible?(o.openBlock(),o.createElementBlock("div",{key:2,class:o.normalizeClass(["flow-canvas-node-actions__dropdown-item",{"is-disabled":i.value.disconnect.disabled}]),onClick:g[4]||(g[4]=k=>!i.value.disconnect.disabled&&n("action","disconnect",r.node.id))},[...g[8]||(g[8]=[o.createElementVNode("i",{class:"flow-canvas-icon canvas-unlock-jiebang"},null,-1),o.createElementVNode("span",null,"断开连线",-1)])],2)):o.createCommentVNode("",!0)],32)):o.createCommentVNode("",!0)]),_:1})],4))}}),re=(r,e)=>{const t=r.__vccOpts||r;for(const[s,n]of e)t[s]=n;return t},He=re(qt,[["__scopeId","data-v-3b39dab5"]]),Gt={key:0,class:"flow-canvas-quick-add__tooltip"},Ut=5,jt=o.defineComponent({__name:"node-quick-add-popover",props:{node:{},portPosition:{}},emits:["open","close","start-drag","mouseenter","mouseleave"],setup(r,{expose:e,emit:t}){const s=r,n=t,i=o.ref(),a=o.ref(),c=o.ref(!1),l=o.ref(!1);let v=null,f=!1,h=null;function g(H){H.preventDefault(),H.stopPropagation(),v={x:H.clientX,y:H.clientY},f=!1,document.addEventListener("mousemove",k),document.addEventListener("mouseup",w)}function k(H){if(!v)return;const M=H.clientX-v.x,y=H.clientY-v.y;Math.sqrt(M*M+y*y)>=Ut&&(f=!0,I(),n("start-drag",s.node.id))}function w(){I(),f||D(),v=null,f=!1}function I(){document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",w)}function D(){l.value?A():P()}function P(){l.value=!0,n("open",s.node.id),requestAnimationFrame(()=>{document.addEventListener("mousedown",O)})}function A(){l.value=!1,n("close"),document.removeEventListener("mousedown",O)}function O(H){const M=H.target;i.value?.contains(M)||a.value?.contains(M)||A()}function q(){l.value||n("mouseleave")}function R(){h&&(clearTimeout(h),h=null),n("mouseenter")}function z(){h=setTimeout(()=>{A(),n("mouseleave"),h=null},150)}return o.onBeforeUnmount(()=>{I(),h&&clearTimeout(h),document.removeEventListener("mousedown",O)}),e({closePopover:A}),(H,M)=>(o.openBlock(),o.createElementBlock("div",{class:"flow-canvas-quick-add",style:o.normalizeStyle({left:`${r.portPosition.x}px`,top:`${r.portPosition.y}px`}),onMouseenter:M[2]||(M[2]=y=>n("mouseenter")),onMouseleave:q,onClick:M[3]||(M[3]=o.withModifiers(()=>{},["stop"]))},[o.createElementVNode("div",{ref_key:"btnRef",ref:i,class:o.normalizeClass(["flow-canvas-quick-add__btn",{"is-hovered":c.value,"is-active":l.value}]),onMouseenter:M[0]||(M[0]=y=>c.value=!0),onMouseleave:M[1]||(M[1]=y=>c.value=!1),onMousedown:g},[...M[4]||(M[4]=[o.createElementVNode("i",{class:"flow-canvas-icon canvas-zoom-add"},null,-1)])],34),c.value&&!l.value?(o.openBlock(),o.createElementBlock("div",Gt,[...M[5]||(M[5]=[o.createElementVNode("div",null,[o.createElementVNode("b",null,"点击"),o.createTextVNode(" 添加节点")],-1),o.createElementVNode("div",null,[o.createElementVNode("b",null,"拖拽"),o.createTextVNode(" 连接节点")],-1)])])):o.createCommentVNode("",!0),o.createVNode(o.Transition,{name:"flow-canvas-fade"},{default:o.withCtx(()=>[l.value?(o.openBlock(),o.createElementBlock("div",{key:0,ref_key:"popoverRef",ref:a,class:"flow-canvas-quick-add__popover",onMouseenter:R,onMouseleave:z},[o.renderSlot(H.$slots,"default",{},()=>[M[6]||(M[6]=o.createElementVNode("div",{class:"flow-canvas-quick-add__default-content"},"节点快捷操作面板",-1))],!0)],544)):o.createCommentVNode("",!0)]),_:3})],36))}}),ze=re(jt,[["__scopeId","data-v-336cc3b4"]]),Wt={class:"flow-canvas-selection-actions__bar"},Xt=o.defineComponent({__name:"selection-actions-toolbar",props:{position:{},canDelete:{type:Boolean}},emits:["action"],setup(r,{emit:e}){const t=r,s=e,n=o.computed(()=>({left:`${t.position.x}px`,top:`${t.position.y}px`,transform:"translateX(-100%)"}));return(i,a)=>(o.openBlock(),o.createElementBlock("div",{class:"flow-canvas-selection-actions",style:o.normalizeStyle(n.value)},[o.createElementVNode("div",Wt,[o.createElementVNode("i",{class:o.normalizeClass(["flow-canvas-icon canvas-shanchu flow-canvas-selection-actions__icon",{"is-disabled":!r.canDelete}]),onClick:a[0]||(a[0]=c=>r.canDelete&&s("action","delete"))},null,2)])],4))}}),Kt=re(Xt,[["__scopeId","data-v-25eb8b79"]]),Zt={class:"flow-canvas-runtime-core__overlay"},Yt=o.defineComponent({__name:"canvas-runtime-core",props:{editor:{},graphOptions:{},nodeActions:{},quickAdd:{},edgeDrop:{},getConnectionExcludedNodeIds:{type:Function},toolbarInclude:{}},emits:["ui-event"],setup(r,{emit:e}){const t=r,s=e,n=o.ref(),i=o.ref();let a,c,l,v,f=null,h=null,g=null,k=null;const w=Bt(),{hoveredNodeId:I,isDraggingNode:D}=w,P=w.enterOverlay,A=()=>w.leaveOverlay(),O=o.ref(0),q=o.ref({nodeIds:[],edgeIds:[]});function R(S){const x=t.editor.api.value;return x?t.editor.schema.nodeTypes[S.type]?.getBehavior?.(S,{api:x,flowModel:t.editor.flowModel.value,history:t.editor.history,mode:t.editor.mode.value})??{}:{}}const z=o.computed(()=>t.editor.mode.value==="edit"&&t.editor.selectionMode.value),H=o.computed(()=>({showDebug:!1,showDelete:!0,showCopy:!0,showCopyInsert:!0,showDisconnect:!0,insertGap:100,...t.nodeActions})),M=o.computed(()=>{if(O.value,!t.editor.api.value)return[];const S=t.editor.flowModel.value,x=t.editor.api.value.overlay,_=[];for(const[V,te]of Object.entries(S.nodes)){const ne=t.editor._pluginManager.collectNodeDecorations(te);if(!ne?.badge)continue;const X=x.getNodeScreenRect(V);X&&_.push({nodeId:V,x:X.x+X.width-4,y:X.y-8,badge:ne.badge})}return _}),y=o.computed(()=>{O.value;const S=I.value;if(!S||D.value||!t.editor.api.value||t.editor.mode.value!=="edit"||z.value)return null;const _=t.editor.flowModel.value.nodes[S];if(!_)return null;const V=t.editor.api.value.overlay.getNodeScreenRect(S);if(!V)return null;const te=R(_);return te.showActions===!1?null:{node:_,position:{x:V.x+V.width,y:V.y+V.height+4},behavior:te}}),p=o.computed(()=>{if(O.value,!t.editor.api.value||t.editor.mode.value!=="edit")return null;const S=q.value;if(S.nodeIds.length+S.edgeIds.length<=1)return null;const x=t.editor.api.value.getSelectionBounds(S);if(!x)return null;const _=Ve(S,t.editor.flowModel.value,R);return{position:{x:x.x+x.width,y:x.y+x.height+4},canDelete:_.nodeIds.length>0||_.edgeIds.length>0}}),d=o.ref(),u=Rt({editor:t.editor,quickAddProp:o.computed(()=>t.quickAdd),isDraggingNode:D,nodeHover:w,isSelectionModeActive:z,viewportVersion:O,getNodeBehavior:R,getInsertGap:()=>H.value.insertGap,closePopover:()=>d.value?.closePopover()}),m=u.data,E=u.handleOpen,C=u.handleClose,$=u.handleStartDrag,U=u.handleOverlayEnter,N=u.handleOverlayLeave,T=u.handleInsert,b=$t({editor:t.editor,edgeDropProp:o.computed(()=>t.edgeDrop)}),B=Ft(t.editor);function F(S,x){B.handleNodeAction(S,x,H.value.insertGap)&&(I.value=null)}function j(S){S==="delete"&&B.deleteSelection(q.value)}function G(S){if(t.editor.mode.value!=="edit")return;if((S.metaKey||S.ctrlKey)&&(S.key==="z"||S.key==="Z")){if(S.shiftKey){if(!t.toolbarInclude?.includes("redo"))return;t.editor.history.redo()}else{if(!t.toolbarInclude?.includes("undo"))return;t.editor.history.undo()}S.preventDefault();return}t.editor._pluginManager.dispatchKeyboardShortcut(S)&&(S.preventDefault(),S.stopPropagation())}function Z(S,x){const _=a,V=te=>{const ne=_.isRubberbandEnabled?.()??!1;ne&&_.disableRubberband?.(),te?a.enablePanning():a.disablePanning(),ne&&_.enableRubberband?.()};S&&x?(_.enableSelection?.(),w.reset(),u.quickAddNodeId.value=null,u.quickAddPopoverOpen.value=!1,f?.remove(),V(!1),_.enableRubberband?.()):(_.disableRubberband?.(),V(!0),_.disableSelection?.(),_.cleanSelection?.())}function W(S){a.on("node:move",({node:x})=>{D.value=!0;const _=t.editor.flowModel.value.nodes[x.id];_&&R(_).bringToFrontOnDrag===!1||x.toFront?.()}),a.on("node:moved",()=>{D.value=!1}),a.on("node:mouseenter",({node:x})=>{if(z.value){I.value=null,u.quickAddNodeId.value=null,S.hideNodePorts(x);return}w.enter(x.id);const _=t.editor.flowModel.value.nodes[x.id];if(_&&R(_).showPorts===!1){u.mergedConfig.value.enabled&&u.enter(x.id);return}u.mergedConfig.value.enabled&&u.enter(x.id)||S.showNodePorts(x)}),a.on("node:mouseleave",({node:x})=>{if(z.value){S.hideNodePorts(x);return}const _=t.editor.flowModel.value.nodes[x.id];let V=100;_&&R(_).actionsOffset&&(V=300),w.leave(V),u.mergedConfig.value.enabled?u.quickAddNodeId.value===x.id&&!u.quickAddPopoverOpen.value?u.leave():u.quickAddNodeId.value!==x.id&&S.hideNodePorts(x):S.hideNodePorts(x)})}function Y(S){a.on("edge:added",({edge:x})=>{let _;if(t.getConnectionExcludedNodeIds&&!x.getTargetCell()){const V=x.getSourceCell();if(V){const te=t.getConnectionExcludedNodeIds(V.id);_=te instanceof Set?te:new Set(te)}}S.handleEdgeAdded(x,_)}),a.on("edge:connected",()=>{S.handleEdgeConnected()}),a.on("edge:removed",({edge:x})=>{S.handleEdgeRemoved(x.id),f.handleEdgeRemoved(x.id)}),a.on("edge:mouseenter",({edge:x,e:_})=>{const V=c.getHoveredEdgeId();c.setHoveredEdge(x.id),V&&V!==x.id&&c.refreshSingleEdgeStyle(V),c.refreshSingleEdgeStyle(x.id),t.editor.mode.value==="edit"&&!z.value&&S.canShowEdgeTool()&&f.show(x.id,_)}),a.on("edge:mouseleave",({edge:x})=>{c.setHoveredEdge(null),c.refreshSingleEdgeStyle(x.id),f.remove()}),a.on("edge:click",({edge:x,e:_})=>{_.target?.closest?.(".flow-canvas-edge-delete-tool")&&t.editor.mode.value==="edit"&&(f.remove(),t.editor.executeCommand({id:K(),source:"user:toolbar",label:"删除连线",timestamp:Date.now(),commands:[{type:"edge.remove",edgeId:x.id}]}))}),h=x=>f.move(x),a.container.addEventListener("mousemove",h)}function J(){g=S=>{if(!I.value&&!u.quickAddNodeId.value)return;const x=S.target;if(x?.closest?.(".x6-node")||x?.closest?.(".flow-canvas-node-actions")||x?.closest?.(".flow-canvas-quick-add")){w.cancelLeave(),u.cancelLeave();return}w.leave(180),u.quickAddPopoverOpen.value||u.leave()},n.value?.addEventListener("mousemove",g),k=()=>{w.reset(),u.quickAddPopoverOpen.value||(u.quickAddNodeId.value=null)},n.value?.addEventListener("mouseleave",k),n.value?.addEventListener("keydown",G)}function Q(){o.watch(()=>t.editor.flowModel.value,S=>c.syncFlowModel(S)),o.watch([()=>t.editor.mode.value,()=>t.editor.selectionMode.value],([S,x])=>{Z(S==="edit",x)},{immediate:!0})}return o.onMounted(()=>{if(!i.value)return;const S=new Set(["model","container"]),x={};if(t.graphOptions)for(const[L,ee]of Object.entries(t.graphOptions)){if(S.has(L)){console.warn(`[flow-canvas] graphOptions.${L} is managed by the engine and will be ignored`);continue}x[L]=ee}a=new Je.Graph({container:i.value,autoResize:!0,background:{color:"#edf2fc"},grid:{visible:!0,size:20,type:"dot"},highlighting:{magnetAdsorbed:{name:"className",args:{className:"flow-canvas-magnet-adsorbed"}}},panning:{enabled:!0},mousewheel:{enabled:!0,modifiers:["ctrl","meta"]},interacting:{nodeMovable(L){return L.cell.getProp("draggable")!==!1}},connecting:{allowBlank:!1,allowMulti:!0,allowLoop:!1,allowNode:!1,allowEdge:!1,highlight:!0,anchor:"center",connectionPoint:"anchor",snap:{radius:30},createEdge(){return Ht(this,t.editor.schema)}},...x}),l=new It,c=new xt(a,t.editor.schema,l,L=>t.editor._pluginManager.collectNodeDecorations(L),L=>t.editor._pluginManager.collectEdgeDecorations(L),()=>t.editor.api.value?{api:t.editor.api.value,flowModel:t.editor.flowModel.value,history:t.editor.history,mode:t.editor.mode.value}:null);const _=St(a),V=At({graph:a,overlayManager:_,executeCommand:L=>t.editor.executeCommand(b.tryExpandForEdgeDrop(L)),schema:t.editor.schema,flowModel:t.editor.flowModel,getNodeBehavior:R,idGenerator:t.editor.idGenerator,defaultInsertGap:t.nodeActions?.insertGap,getContextMenuItems:L=>t.editor._pluginManager.collectContextMenuItems(L),onHighlightChange:(L,ee)=>{c.setHighlightedNodes(L);const se=c.setHighlightedEdges(ee);c.refreshNodeHighlights();const ie=new Set(ee);for(const ae of se)ie.has(ae)||c.refreshSingleEdgeStyle(ae);for(const ae of ie)se.has(ae)||c.refreshSingleEdgeStyle(ae)},resolveNodeShape:L=>{const ee=t.editor.schema.nodeTypes[L];if(!ee)return null;const se=l.registerNodeType(L,ee.component),ie=ee.getSize({id:"",type:L,position:{x:0,y:0}});return{shapeName:se,width:ie.width,height:ie.height}}});t.editor.api.value=V;const te={flowModel:t.editor.flowModel,history:t.editor.history,schema:t.editor.schema,mode:t.editor.mode,idGenerator:t.editor.idGenerator,executeCommand:t.editor.executeCommand,selectionMode:t.editor.selectionMode,api:V,overlay:_,graph:a};t.editor._pluginManager.attachRuntime(te);const ne=t.editor._pluginManager.collectExtendedApi();Object.assign(t.editor.extendedApi,ne),t.editor._emitUiEvent=L=>{t.editor._pluginManager.dispatchUiEvent(L),s("ui-event",L)},v=new Nt(a,L=>{(L.type==="node.click"||L.type==="node.dblclick"||L.type==="node.contextmenu")&&w.enter(L.nodeId),t.editor._emitUiEvent(L)},L=>{if(c.isSyncing)return;const ee=b.tryExpandForEdgeDrop(L);if(t.editor.executeCommand(ee).status!=="applied"){for(const ie of ee.commands)if(ie.type==="edge.add"){const ae=a.getCellById(ie.edge.id);ae&&a.removeCell(ae)}}},t.editor.flowModel,t.editor.idGenerator),f=Pt(a);const X=Tt(a);u.attachRuntime(a,L=>X.hideNodePorts(L)),b.attachRuntime(a),W(X),Y(X);let he=new Set;a.on("selection:changed",()=>{const L=Fe(a.getSelectedCells?.()??[]);q.value=L,t.editor._pluginManager.dispatchSelectionChange(L),s("ui-event",{type:"selection.change",nodeIds:L.nodeIds,edgeIds:L.edgeIds}),c.refreshNodeHighlights();const ee=new Set(L.edgeIds);for(const se of he)ee.has(se)||c.refreshSingleEdgeStyle(se);for(const se of ee)he.has(se)||c.refreshSingleEdgeStyle(se);he=ee});const ve=()=>{O.value++};a.on("translate",ve),a.on("scale",ve),a.on("resize",ve),J(),c.syncFlowModel(t.editor.flowModel.value),Q()}),o.onBeforeUnmount(()=>{w.cleanup(),u.cleanup(),b.cleanup(),f?.remove(),h&&a?.container?.removeEventListener("mousemove",h),g&&n.value?.removeEventListener("mousemove",g),k&&n.value?.removeEventListener("mouseleave",k),n.value?.removeEventListener("keydown",G),t.editor._pluginManager.detachRuntime(),t.editor.api.value=null;for(const S of Object.keys(t.editor.extendedApi))delete t.editor.extendedApi[S];v?.dispose(),c?.dispose(),l?.dispose(),a?.dispose()}),(S,x)=>(o.openBlock(),o.createElementBlock("div",{ref_key:"rootRef",ref:n,class:o.normalizeClass(["flow-canvas-runtime-core",{"flow-canvas-runtime-core--selection-mode":z.value}]),tabindex:"0"},[o.createElementVNode("div",{ref_key:"containerRef",ref:i,class:"flow-canvas-runtime-core__graph"},null,512),o.createElementVNode("div",Zt,[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(M.value,_=>(o.openBlock(),o.createElementBlock("div",{key:`badge-${_.nodeId}`,class:"flow-canvas-runtime-core__badge",style:o.normalizeStyle({left:`${_.x}px`,top:`${_.y}px`,backgroundColor:_.badge.color})},o.toDisplayString(_.badge.text),5))),128)),o.unref(m)?(o.openBlock(),o.createBlock(ze,{key:0,ref_key:"quickAddPopoverRef",ref:d,node:o.unref(m).node,"port-position":o.unref(m).portPosition,onOpen:o.unref(E),onClose:o.unref(C),onStartDrag:o.unref($),onMouseenter:o.unref(U),onMouseleave:o.unref(N)},{default:o.withCtx(()=>[o.renderSlot(S.$slots,"quick-add-panel",{node:o.unref(m).node,api:r.editor.api.value,insertNodeToRight:_=>o.unref(T)(o.unref(m).node.id,_),closePopover:()=>d.value?.closePopover()},void 0,!0)]),_:3},8,["node","port-position","onOpen","onClose","onStartDrag","onMouseenter","onMouseleave"])):o.createCommentVNode("",!0),y.value?(o.openBlock(),o.createBlock(He,{key:1,node:y.value.node,position:y.value.position,config:H.value,behavior:y.value.behavior,"actions-offset":y.value.behavior.actionsOffset,onAction:F,onMouseenter:o.unref(P),onMouseleave:A},null,8,["node","position","config","behavior","actions-offset","onMouseenter"])):o.createCommentVNode("",!0),p.value?(o.openBlock(),o.createBlock(Kt,{key:2,position:p.value.position,"can-delete":p.value.canDelete,onAction:j},null,8,["position","can-delete"])):o.createCommentVNode("",!0)])],2))}}),Qt=re(Yt,[["__scopeId","data-v-cd58116b"]]),Jt={class:"flow-canvas-node-palette"},eo=["data-node-type"],to={class:"flow-canvas-node-palette__item-label"},oo=o.defineComponent({__name:"canvas-node-palette",props:{editor:{},items:{}},setup(r){const e=r,t=o.ref(),s=o.computed(()=>e.items?e.items:Object.keys(e.editor.schema.nodeTypes).map(n=>({type:n,label:n.charAt(0).toUpperCase()+n.slice(1)})));return o.watch([()=>e.editor.api.value,s,t],([n,i,a],c,l)=>{if(!n||!a)return;const v=[];for(const f of i){const h=a.querySelector(`[data-node-type="${f.type}"]`);if(!h)continue;const g=n.registerDndSource(h,()=>({id:K(),type:f.type,label:f.label,position:{x:0,y:0}}));v.push(g)}l(()=>{for(const f of v)f()})},{flush:"post"}),(n,i)=>(o.openBlock(),o.createElementBlock("div",Jt,[o.createElementVNode("div",{ref_key:"listRef",ref:t,class:"flow-canvas-node-palette__list"},[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(s.value,a=>(o.openBlock(),o.createElementBlock("div",{key:a.type,class:"flow-canvas-node-palette__item","data-node-type":a.type},[a.icon?(o.openBlock(),o.createElementBlock("i",{key:0,class:o.normalizeClass([a.icon,"flow-canvas-node-palette__item-icon"])},null,2)):o.createCommentVNode("",!0),o.createElementVNode("span",to,o.toDisplayString(a.label),1)],8,eo))),128))],512)]))}}),qe=re(oo,[["__scopeId","data-v-300314b7"]]),no={class:"flow-canvas-layout"},so={class:"flow-canvas-layout__main"},ro={class:"flow-canvas-layout__content"},io={key:0,class:"flow-canvas-layout__footer"},ao=o.defineComponent({__name:"canvas-layout",props:{sidebarCollapsed:{type:Boolean,default:!1},sidebarWidth:{default:260},hideSidebar:{type:Boolean,default:!1},hideFooter:{type:Boolean,default:!1},editor:{default:void 0},paletteItems:{default:void 0}},emits:["update:sidebarCollapsed"],setup(r){return(e,t)=>(o.openBlock(),o.createElementBlock("div",no,[!r.hideSidebar&&(e.$slots.sidebar||r.editor)?(o.openBlock(),o.createElementBlock("aside",{key:0,class:o.normalizeClass(["flow-canvas-layout__sidebar",{"is-collapsed":r.sidebarCollapsed}]),style:o.normalizeStyle({width:r.sidebarCollapsed?"0px":`${r.sidebarWidth}px`})},[o.renderSlot(e.$slots,"sidebar",{},()=>[r.editor?(o.openBlock(),o.createBlock(qe,{key:0,editor:r.editor,items:r.paletteItems},null,8,["editor","items"])):o.createCommentVNode("",!0)],!0)],6)):o.createCommentVNode("",!0),o.createElementVNode("div",so,[o.createElementVNode("div",ro,[o.renderSlot(e.$slots,"default",{},void 0,!0)]),!r.hideFooter&&e.$slots.footer?(o.openBlock(),o.createElementBlock("div",io,[o.renderSlot(e.$slots,"footer",{},void 0,!0)])):o.createCommentVNode("",!0)])]))}}),lo=re(ao,[["__scopeId","data-v-26f35b6b"]]),Be=typeof navigator<"u"&&/Mac|iPod|iPhone|iPad/.test(navigator.platform??navigator.userAgent),co=["undo","redo"];function Ge(r){const e=new Set(r?.include),t=new Set(co.filter(l=>!e.has(l))),s=[{id:"undo",type:"undo",group:"history",icon:"flow-canvas-icon canvas-undo",description:"撤销",shortcut:Be?["⌘","Z"]:["Ctrl","Z"],order:10},{id:"redo",type:"redo",group:"history",icon:"flow-canvas-icon canvas-redo",description:"重做",shortcut:Be?["⇧","⌘","Z"]:["Ctrl","Shift","Z"],order:11}],n=[{id:"select",type:"select",group:"tools",icon:"flow-canvas-icon canvas-kuangxuan",description:"框选模式",order:20},{id:"auto-layout",type:"auto-layout",group:"tools",icon:"flow-canvas-icon canvas-beautify",description:"自动排版",order:21},{id:"export",type:"export",group:"tools",icon:"flow-canvas-icon canvas-xiazai",description:"下载",order:24}],i=[{id:"zoom-out",type:"zoom-out",group:"zoom",icon:"flow-canvas-icon canvas-zoom-minus",description:"缩小画布",order:30},{id:"zoom-display",type:"zoom-display",group:"zoom",order:31},{id:"zoom-in",type:"zoom-in",group:"zoom",icon:"flow-canvas-icon canvas-zoom-add",description:"放大画布",order:32}],a=[{id:"reset",type:"reset",group:"reset",icon:"flow-canvas-icon canvas-reset-1_1",description:"重置视图",order:40}];return[...[...s,...n].filter(l=>!t.has(l.type)),...i,...a]}const uo={class:"flow-canvas-toolbar"},fo={key:0,class:"flow-canvas-toolbar__separator"},po={class:"flow-canvas-toolbar__group"},go={key:0,class:"flow-canvas-toolbar__zoom-display"},ho=["data-toolbar-id","data-toolbar-type","disabled","onClick","onMouseenter"],vo=["textContent"],mo={key:0,class:"flow-canvas-toolbar-tooltip__kbd"},yo=o.defineComponent({__name:"canvas-toolbar",props:{items:{},exclude:{},include:{},editor:{}},setup(r){const e=new Set(["undo","redo","select","auto-layout","search","minimap","export"]),t=new Set(["select","search","minimap"]);function s(d){return d.id.startsWith("plugin:")||d.type==="custom"}function n(d){return d!=="custom"&&t.has(d)}const i=r,a=o.computed(()=>{if(i.items)return i.items;const d=Ge({include:i.include}),u=i.editor.toolbarItems.value,m=new Set(i.exclude??[]),E=new Map;for(const C of d)E.set(C.id,C);for(const C of u){const $=E.get(C.id);$?E.set(C.id,{...$,...C,order:$.order,group:$.group}):s(C)&&E.set(C.id,C)}return[...E.values()].filter(C=>C.type==="custom"||!e.has(C.type)?!0:!m.has(C.type)).sort((C,$)=>(C.order??0)-($.order??0))}),c=o.ref(1),l=o.ref(null),v=o.ref(null),f=o.ref(!1);let h=null;o.watch(()=>i.editor.api.value,d=>{h?.(),h=null,d&&(c.value=d.getZoom(),h=d.onGraphEvent("scale",()=>{c.value=d.getZoom()}))},{immediate:!0});const g=o.reactive({visible:!1,text:"",shortcut:[],x:0,y:0});function k(d,u){if(!u.description)return;const E=d.currentTarget.getBoundingClientRect();g.text=u.description,g.shortcut=u.shortcut??[],g.visible=!0,o.nextTick(()=>{const C=l.value?.offsetWidth??0,$=l.value?.offsetHeight??0;g.x=E.left+E.width/2-C/2,g.y=E.top-$-6})}function w(){g.visible=!1,l.value=null}o.onScopeDispose(()=>{h?.()});const I=o.computed(()=>`${Math.round(c.value*100)}%`),D=o.computed(()=>i.editor.api.value?{api:i.editor.api.value,flowModel:i.editor.flowModel.value,history:i.editor.history,mode:i.editor.mode.value}:null);function P(d){return d.visible===!1?!1:typeof d.visible=="function"?D.value?d.visible(D.value):!1:!0}function A(d){return typeof d.active=="function"?D.value?d.active(D.value):!1:d.active!==void 0?d.active:d.type==="select"?i.editor.selectionMode.value:!1}const O=o.computed(()=>{const d=y.value.filter(m=>n(m.type)&&A(m));if(d.length===0)return null;const u=v.value;return u&&d.some(m=>m.type===u)?u:d[0]?.type??null});function q(d){return n(d.type)?O.value===d.type:A(d)}function R(d){return!D.value||d.disabled===!0?!0:typeof d.disabled=="function"?d.disabled(D.value):d.type==="undo"?!i.editor.history.canUndo.value:d.type==="redo"?!i.editor.history.canRedo.value:d.type==="export"?f.value:!1}function z(d){if(!(!D.value||!n(d.type)||!A(d))){if(d.type==="select"){i.editor.setSelectionMode(!1);return}d.onClick?.(D.value)}}function H(d){if(n(d.type))for(const u of y.value)!n(u.type)||u.id===d.id||z(u)}function M(d){if(!D.value||R(d))return;if(n(d.type)&&(v.value=d.type,H(d)),d.onClick){d.onClick(D.value);return}const{api:u}=D.value;switch(d.type){case"undo":i.editor.history.undo();break;case"redo":i.editor.history.redo();break;case"zoom-in":u.zoomIn(),c.value=u.getZoom();break;case"zoom-out":u.zoomOut(),c.value=u.getZoom();break;case"fit":u.zoomToFit();break;case"reset":u.zoomTo(1),u.scrollToOrigin(),c.value=1;break;case"export":if(f.value)break;f.value=!0,u.exportAsImage().then(m=>{const E=URL.createObjectURL(m),C=document.createElement("a");C.href=E,C.download="canvas-export.png",C.click(),URL.revokeObjectURL(E)}).catch(m=>{console.warn("[flow-canvas] Export failed:",m)}).finally(()=>{f.value=!1});break;case"select":i.editor.setSelectionMode(!i.editor.selectionMode.value);break;case"auto-layout":i.editor._emitUiEvent({type:"toolbar.auto-layout"});break;case"search":case"minimap":console.warn(`[flow-canvas] "${d.type}" toolbar item has no built-in handler. Provide an onClick callback.`);break;default:d.type!=="custom"&&console.warn(`[flow-canvas] No default handler for toolbar type "${d.type}". Provide an onClick handler.`);break}}const y=o.computed(()=>a.value.filter(P)),p=o.computed(()=>{const d=new Map,u=[];for(const m of y.value){const E=m.group??"default";d.has(E)||(d.set(E,[]),u.push(E)),d.get(E).push(m)}return u.map(m=>({name:m,items:d.get(m)})).filter(m=>m.items.length>0)});return(d,u)=>(o.openBlock(),o.createElementBlock("div",uo,[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(p.value,(m,E)=>(o.openBlock(),o.createElementBlock(o.Fragment,{key:m.name},[E>0?(o.openBlock(),o.createElementBlock("div",fo)):o.createCommentVNode("",!0),o.createElementVNode("div",po,[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(m.items,C=>(o.openBlock(),o.createElementBlock(o.Fragment,{key:C.id},[C.type==="zoom-display"?(o.openBlock(),o.createElementBlock("span",go,o.toDisplayString(I.value),1)):(o.openBlock(),o.createElementBlock("button",{key:1,type:"button",class:o.normalizeClass(["flow-canvas-toolbar__btn",{"is-disabled":R(C),"is-active":q(C),"is-exporting":C.type==="export"&&f.value}]),"data-toolbar-id":C.id,"data-toolbar-type":C.type,disabled:R(C),onClick:$=>M(C),onMouseenter:$=>k($,C),onMouseleave:w},[C.component?(o.openBlock(),o.createBlock(o.resolveDynamicComponent(C.component),{key:0})):C.icon?(o.openBlock(),o.createElementBlock("i",{key:1,class:o.normalizeClass(C.icon)},null,2)):(o.openBlock(),o.createElementBlock("span",{key:2,class:"flow-canvas-toolbar__text",textContent:o.toDisplayString(C.text??C.description??C.id)},null,8,vo))],42,ho))],64))),128))])],64))),128)),(o.openBlock(),o.createBlock(o.Teleport,{to:"body"},[g.visible?(o.openBlock(),o.createElementBlock("div",{key:0,ref_key:"tooltipRef",ref:l,class:"flow-canvas-toolbar-tooltip",style:o.normalizeStyle({left:`${g.x}px`,top:`${g.y}px`})},[o.createElementVNode("span",null,o.toDisplayString(g.text),1),g.shortcut.length?(o.openBlock(),o.createElementBlock("kbd",mo,[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(g.shortcut,(m,E)=>(o.openBlock(),o.createElementBlock("span",{key:E},o.toDisplayString(m),1))),128))])):o.createCommentVNode("",!0),u[0]||(u[0]=o.createElementVNode("div",{class:"flow-canvas-toolbar-tooltip__arrow"},null,-1))],4)):o.createCommentVNode("",!0)]))]))}}),wo=re(yo,[["__scopeId","data-v-904248f4"]]),bo={class:"flow-canvas-default-node__ep-label"},Eo={key:1,class:"flow-canvas-default-node__diamond flow-canvas-highlight-target"},ko={key:2,class:"flow-canvas-default-node__task-label"},Co=o.defineComponent({__name:"default-node",setup(r){const t=o.inject("getNode")?.(),s=o.computed(()=>t?.getData?.()??null),n=o.computed(()=>s.value?.label||s.value?.type||""),i={start:"canvas-kaishi",end:"canvas-stop","parallel-gateway":"canvas-bingxingwangguan","branch-gateway":"canvas-fenzhiwangguan","converge-gateway":"canvas-huijuwangguan","conditional-parallel-gateway":"canvas-tiaojianbingxingwangguan"},a=new Set(["start","end"]),c=new Set(["parallel-gateway","branch-gateway","converge-gateway","conditional-parallel-gateway"]),l=o.computed(()=>{const f=s.value?.type??"";return a.has(f)?"endpoint":c.has(f)?"gateway":"task"}),v=o.computed(()=>i[s.value?.type??""]??"");return(f,h)=>(o.openBlock(),o.createElementBlock("div",{class:o.normalizeClass(["flow-canvas-default-node",[`is-${l.value}`,{"flow-canvas-highlight-target":l.value!=="gateway"}]])},[l.value==="endpoint"?(o.openBlock(),o.createElementBlock(o.Fragment,{key:0},[v.value?(o.openBlock(),o.createElementBlock("i",{key:0,class:o.normalizeClass([["flow-canvas-icon",v.value],"flow-canvas-default-node__ep-icon"])},null,2)):o.createCommentVNode("",!0),o.createElementVNode("span",bo,o.toDisplayString(n.value),1)],64)):l.value==="gateway"?(o.openBlock(),o.createElementBlock("div",Eo,[v.value?(o.openBlock(),o.createElementBlock("i",{key:0,class:o.normalizeClass([["flow-canvas-icon",v.value],"flow-canvas-default-node__gw-icon"])},null,2)):o.createCommentVNode("",!0)])):(o.openBlock(),o.createElementBlock("span",ko,o.toDisplayString(n.value),1))],2))}}),Ue=re(Co,[["__scopeId","data-v-f0e24a9f"]]),xo={start:{label:"开始",icon:"flow-canvas-icon canvas-kaishi",width:88,height:40},end:{label:"结束",icon:"flow-canvas-icon canvas-stop",width:88,height:40},empty:{label:"空节点",icon:"flow-canvas-icon canvas-jiedi",width:240,height:48},"parallel-gateway":{label:"并行网关",icon:"flow-canvas-icon canvas-bingxingwangguan",width:64,height:64},"branch-gateway":{label:"分支网关",icon:"flow-canvas-icon canvas-fenzhiwangguan",width:64,height:64},"converge-gateway":{label:"汇聚网关",icon:"flow-canvas-icon canvas-huijuwangguan",width:64,height:64},"conditional-parallel-gateway":{label:"条件并行网关",icon:"flow-canvas-icon canvas-tiaojianbingxingwangguan",width:64,height:64}},Pe=(r,e)=>({stroke:e.hovered?"#3a84ff":"#abb5cc",strokeWidth:2});function Te(){return{attrs:{line:{stroke:"#abb5cc",strokeWidth:2,targetMarker:{name:"block",width:8,height:8}}}}}function je(){return{manhattan:{router:{name:"manhattan",args:{padding:10,maxDirectionChange:90}},connector:{name:"rounded",args:{radius:8}},style:Pe,x6EdgeConfig:Te()},bezier:{connector:{name:"smooth"},style:Pe,x6EdgeConfig:Te()}}}function Io(r){const e=r?.nodeTypes??xo,t={},s=[];for(const[a,c]of Object.entries(e)){const l=c.width??150,v=c.height??50;t[a]={component:Ue,getSize:()=>({width:l,height:v}),getPorts:()=>$e()},s.push({type:a,label:c.label??a,icon:c.icon})}const n={...je(),...r?.edgeTypes},i=r?.defaultEdgeType??"manhattan";return{schema:{nodeTypes:t,defaultEdgeType:i,edgeTypes:n},paletteItems:s}}function No(r){return{name:"connection-validator",priority:10,transformCommand(e,t,s){const n=new Set;for(const i of e.commands)i.type==="edge.remove"&&n.add(i.edgeId);for(const i of e.commands){if(i.type!=="edge.add"&&i.type!=="edge.reconnect")continue;const a=s.flowModel.value,c=i.type==="edge.add"?i.edge.source.nodeId:i.source?.nodeId,l=i.type==="edge.add"?i.edge.target.nodeId:i.target?.nodeId;if(!c||!l)continue;const v=a.nodes[c],f=a.nodes[l];if(!v||!f)continue;const h=i.type==="edge.add"?i.edge.source.portId:i.source?.portId,g=i.type==="edge.add"?i.edge.target.portId:i.target?.portId,k=h?v.ports?.find(A=>A.id===h):void 0,w=g?f.ports?.find(A=>A.id===g):void 0,I=i.type==="edge.reconnect"?i.edgeId:void 0,D=Object.values(a.edges).filter(A=>A.id!==I&&!n.has(A.id)),P=r({flowModel:a,sourceNode:v,targetNode:f,sourcePort:k,targetPort:w,existingEdges:D});if(!P.valid)return{rejected:!0,reason:P.reason??"Connection validation failed",code:"validation_failed"}}return e}}}function So(r){const{rubberband:e=!0,multiple:t=!0,movable:s=!0}=r??{};return{name:"selection",priority:90,attachRuntime(n){n.graph.use(new tt.Selection({enabled:!0,rubberband:e,multiple:t,movable:s,pointerEvents:"none",showNodeSelectionBox:!0,filter:i=>!(i.isNode()&&(i.getData?.()??{})._selectable===!1)}))}}}function Do(r){const{tolerance:e=10,color:t="#3a84ff"}=r??{};let s=null;return{name:"snapline",priority:90,async attachRuntime(n){const{Snapline:i}=await import("@antv/x6-plugin-snapline");n.graph.use(new i({enabled:!0,tolerance:e,className:"flow-canvas-snapline"})),s=document.createElement("style"),s.textContent=`.flow-canvas-snapline line { stroke: ${t} !important; }`,document.head.appendChild(s)},detachRuntime(){s?.remove(),s=null}}}const Mo={class:"flow-canvas-search-popover__input"},_o=["value","placeholder"],Ao=["onMouseenter","onClick"],Bo={class:"flow-canvas-search-popover__item-label"},Po={key:0,class:"flow-canvas-search-popover__item-subtitle"},To={key:1,class:"flow-canvas-search-popover__empty"},Ro=o.defineComponent({__name:"search-popover",props:{open:{type:Boolean},position:{},query:{},results:{},placeholder:{default:"搜索节点名称"},emptyText:{default:"暂无匹配节点"},isAnchorTarget:{type:Function,default:void 0}},emits:["update:query","select","close"],setup(r,{emit:e}){const t=r,s=e,n=o.ref(null),i=o.ref(null),a=o.ref(-1);o.watch(()=>t.open,w=>{w&&(a.value=-1,o.nextTick(()=>{n.value?.focus(),n.value?.select()}))}),o.watch(()=>t.query,()=>{a.value=-1}),o.watch(()=>t.results.length,w=>{if(!w){a.value=-1;return}a.value>=w&&(a.value=-1)});function c(w){s("update:query",w.target.value)}function l(w){a.value=w}function v(){a.value=-1}function f(){s("update:query",""),o.nextTick(()=>{n.value?.focus()})}function h(){const w=t.results[a.value]??t.results[0];w&&s("select",w.id)}function g(w){if(w.key==="Escape"){w.preventDefault(),s("close");return}if(w.key==="ArrowDown"){if(w.preventDefault(),!t.results.length)return;a.value=a.value<t.results.length-1?a.value+1:0;return}if(w.key==="ArrowUp"){if(w.preventDefault(),!t.results.length)return;a.value=a.value>0?a.value-1:t.results.length-1;return}w.key==="Enter"&&(w.preventDefault(),h())}function k(w){if(!t.open)return;const I=w.target;I&&i.value?.contains(I)||t.isAnchorTarget?.(w.target)||s("close")}return o.onMounted(()=>{document.addEventListener("mousedown",k)}),o.onBeforeUnmount(()=>{document.removeEventListener("mousedown",k)}),(w,I)=>r.open?(o.openBlock(),o.createElementBlock("div",{key:0,ref_key:"panelRef",ref:i,class:"flow-canvas-search-popover",style:o.normalizeStyle({left:`${r.position.x}px`,top:`${r.position.y}px`,width:`${r.position.width}px`})},[o.createElementVNode("div",Mo,[I[1]||(I[1]=o.createElementVNode("i",{class:"flow-canvas-icon canvas-search"},null,-1)),o.createElementVNode("input",{ref_key:"inputRef",ref:n,value:r.query,placeholder:r.placeholder,onInput:c,onKeydown:g},null,40,_o),r.query?(o.openBlock(),o.createElementBlock("button",{key:0,type:"button",class:"flow-canvas-search-popover__clear","aria-label":"清空搜索",onClick:f},[...I[0]||(I[0]=[o.createElementVNode("i",{class:"flow-canvas-icon canvas-close-circle-shape"},null,-1)])])):o.createCommentVNode("",!0)]),r.results.length?(o.openBlock(),o.createElementBlock("div",{key:0,class:"flow-canvas-search-popover__list",onMouseleave:v},[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(r.results,(D,P)=>(o.openBlock(),o.createElementBlock("button",{key:D.id,type:"button",class:o.normalizeClass(["flow-canvas-search-popover__item",{"is-active":P===a.value}]),onMouseenter:A=>l(P),onClick:A=>s("select",D.id)},[o.createElementVNode("span",Bo,o.toDisplayString(D.label),1),D.subtitle?(o.openBlock(),o.createElementBlock("span",Po,o.toDisplayString(D.subtitle),1)):o.createCommentVNode("",!0)],42,Ao))),128))],32)):(o.openBlock(),o.createElementBlock("div",To,o.toDisplayString(r.emptyText),1))],4)):o.createCommentVNode("",!0)}}),Lo=re(Ro,[["__scopeId","data-v-c80f6b26"]]),Re=282,Oo=4,$o=300,Fo=360,we=100,Vo=Fo*4-we;function Ho(r){return r!==null}function zo(r){const e=new Set;return r.map(t=>t?.trim()).filter(t=>!!t).filter(t=>{const s=t.toLowerCase();return e.has(s)?!1:(e.add(s),!0)})}function qo(r,e){const t=Math.max(8,window.innerWidth-e-8);return Math.min(Math.max(8,r),t)}function Go(r,e){const t=e?.getNodeMeta?.(r);if(t===null)return null;const s=t?.label?.trim()||r.label?.trim()||r.id,n=t?.subtitle?.trim()||void 0,i=zo(t?.keywords??[r.label,n]);return i.length?{id:r.id,label:s,subtitle:n,keywords:i}:null}function Uo(r){let e=null,t=null,s=null,n=null,i=null,a=[];const c=o.ref(!1),l=o.ref(""),v=o.ref({x:0,y:0,width:Re}),f=o.computed(()=>e?Object.values(e.flowModel.value.nodes).map(M=>Go(M,r)).filter(Ho):[]),h=o.computed(()=>{const M=l.value.trim().toLowerCase(),y=Math.max(1,r?.maxResults??$o);return M?f.value.filter(p=>p.keywords.some(d=>d.toLowerCase().includes(M))).slice(0,y):f.value.slice(0,y)});function g(){return s?.querySelector('.flow-canvas-toolbar__btn[data-toolbar-type="search"]')}function k(){return g()?.closest(".flow-canvas-toolbar")}function w(){const M=k(),y=s?.getBoundingClientRect(),p=M?.getBoundingClientRect()??y;if(!p)return;const d=Math.max(Re,Math.round(p.width));v.value={x:qo(p.left,d),y:p.bottom+Oo,width:d}}function I(){a.forEach(M=>clearTimeout(M)),a=[],t?.api.clearHighlight()}function D(M){I();const y=setTimeout(()=>{t?.api.highlightNodes([M])},we),p=setTimeout(()=>{t?.api.clearHighlight(),a=[]},we+Vo);a.push(y,p)}function P(M){t&&(t.api.scrollToNode(M),D(M))}function A(){t&&(c.value=!0,w(),requestAnimationFrame(()=>w()))}function O(){c.value=!1,l.value=""}function q(){if(c.value){O();return}A()}function R(M){const y=g();return!!(y&&M instanceof Node&&y.contains(M))}function z(){c.value&&w()}const H=o.defineComponent({name:"FlowCanvasSearchHost",setup(){return()=>o.h(Lo,{open:c.value,position:v.value,query:l.value,results:h.value,placeholder:r?.placeholder??"搜索节点名称",emptyText:r?.emptyText??"暂无匹配节点",isAnchorTarget:R,"onUpdate:query":M=>{l.value=M},onSelect:P,onClose:O})}});return{name:"search",priority:90,install(M){e=M},attachRuntime(M){t=M,s=M.graph.container.closest(".flow-canvas-layout__content")??M.graph.container.parentElement,n=document.createElement("div"),n.className="flow-canvas-search-host",document.body.append(n),i=o.createApp(H),i.mount(n),window.addEventListener("resize",z),window.addEventListener("scroll",z,!0)},detachRuntime(){O(),I(),window.removeEventListener("resize",z),window.removeEventListener("scroll",z,!0),i?.unmount(),i=null,n?.remove(),n=null,s=null,t=null},dispose(){O(),I(),e=null},provideToolbarItems(){return[{id:"plugin:search",type:"search",icon:"flow-canvas-icon canvas-search",description:"搜索",group:"tools",order:22,active:()=>c.value,onClick:q}]}}}const jo=52,Wo=16,Xo=40;function Ko(r){const e=document.createElement("div");e.className="flow-canvas-minimap",r.floating!==!1&&e.classList.add("flow-canvas-minimap--floating");const t=document.createElement("div");t.className="flow-canvas-minimap__host",e.append(t),Object.assign(e.style,{width:`${r.width}px`,height:`${r.height}px`}),r.floating!==!1&&Object.assign(e.style,{top:`${jo}px`,left:`${Wo}px`});let s=null,n=r.defaultOpen??!1,i=null;function a(){!r.onClickOutside||i||(i=g=>{const k=g.target;k&&e.contains(k)||g.target?.closest('[data-toolbar-type="minimap"]')||r.onClickOutside()},document.addEventListener("mousedown",i))}function c(){i&&(document.removeEventListener("mousedown",i),i=null)}function l(){s||(s=new ot.MiniMap({container:t,width:r.width,height:r.height,padding:r.contentPadding??Xo,scalable:!1}),r.sourceGraph.use(s))}function v(g){n=g,e.style.display=n?"":"none",n?(l(),a()):c()}function f(){v(n),r.mountTarget.appendChild(e)}function h(){c(),s?.dispose(),s=null,e.remove()}return f(),{element:e,isOpen:()=>n,setOpen:v,toggle(){const g=!n;return v(g),g},destroy:h}}function Zo(r){let e=null;const t=o.ref(!1);function s(i){e?.setOpen(i),t.value=i}function n(){e&&(t.value=e.toggle())}return{name:"minimap",priority:90,attachRuntime(i){const a=r?.width??334,c=r?.height??180,l=r?.container??i.graph.container.closest(".flow-canvas-layout__content")??i.graph.container.parentElement;l&&(e=Ko({sourceGraph:i.graph,mountTarget:l,width:a,height:c,floating:!r?.container,defaultOpen:!1,onClickOutside:()=>s(!1)}),s(!1))},detachRuntime(){e?.destroy(),e=null,t.value=!1},provideToolbarItems(){return[{id:"plugin:minimap",type:"minimap",icon:"flow-canvas-icon canvas-map",description:"小地图",group:"tools",order:23,active:()=>t.value,onClick:n}]}}}function Yo(){let r=null,e=0;return{name:"clipboard",priority:90,onKeyboardShortcut(t,s){const n=t.metaKey||t.ctrlKey;if(n&&t.key==="c"){const i=s.graph.getSelectedCells?.()??[];if(!i.length)return!1;const a=s.flowModel.value,c=new Set(i.filter(f=>f.isNode()).map(f=>f.id)),l=[...c].map(f=>a.nodes[f]).filter(Boolean);if(!l.length)return!1;const v=Object.values(a.edges).filter(f=>c.has(f.source.nodeId)&&c.has(f.target.nodeId));return r={nodes:l,edges:v},e=0,!0}if(n&&t.key==="v"){if(!r?.nodes.length)return!1;e++;const i=e*30,a=new Map,c=[];for(const l of r.nodes){const v=`${l.id}_cp${K().slice(0,6)}`;a.set(l.id,v),c.push({type:"node.add",node:{...l,id:v,position:{x:l.position.x+i,y:l.position.y+i},payload:l.payload?{...l.payload}:{},extensions:l.extensions?{...l.extensions}:void 0}})}for(const l of r.edges){const v=a.get(l.source.nodeId),f=a.get(l.target.nodeId);!v||!f||c.push({type:"edge.add",edge:{...l,id:`${l.id}_cp${K().slice(0,6)}`,source:{...l.source,nodeId:v},target:{...l.target,nodeId:f},labels:l.labels?.map(h=>({...h,id:`${h.id}_cp${K().slice(0,6)}`})),payload:l.payload?{...l.payload}:{}}})}return c.length&&s.executeCommand({id:K(),source:"user:keyboard",label:"粘贴",timestamp:Date.now(),commands:c}),!0}return!1}}}exports.CanvasConstraintError=oe;exports.CanvasLayout=lo;exports.CanvasNodePalette=qe;exports.CanvasRuntime=Qt;exports.CanvasSchemaError=Le;exports.CanvasToolbar=wo;exports.DefaultNode=Ue;exports.NodeActionsToolbar=He;exports.NodeQuickAddPopover=ze;exports.applyCanvasCommand=be;exports.clipboardPlugin=Yo;exports.connectionValidatorPlugin=No;exports.createBuiltinEdgeTypes=je;exports.createCanvasHistory=Oe;exports.createDefaultSchema=Io;exports.createDefaultToolbarItems=Ge;exports.createEmptyFlowModel=nt;exports.generateId=K;exports.minimapPlugin=Zo;exports.searchPlugin=Uo;exports.selectionPlugin=So;exports.snaplinePlugin=Do;exports.useCanvasEditor=bt;
1
+ "use strict";var tt=Object.create;var Me=Object.defineProperty;var ot=Object.getOwnPropertyDescriptor;var nt=Object.getOwnPropertyNames;var rt=Object.getPrototypeOf,st=Object.prototype.hasOwnProperty;var it=(n,e,o,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of nt(e))!st.call(n,r)&&r!==o&&Me(n,r,{get:()=>e[r],enumerable:!(t=ot(e,r))||t.enumerable});return n};var Ce=(n,e,o)=>(o=n!=null?tt(rt(n)):{},it(e||!n||!n.__esModule?Me(o,"default",{value:n,enumerable:!0}):o,n));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("vue"),at=require("@antv/x6"),lt=require("@antv/x6-vue-shape"),ct=require("@antv/x6-plugin-selection"),dt=require("@antv/x6-plugin-minimap");function ut(){return{version:"1.0",nodes:{},edges:{}}}class te extends Error{constructor(e){super(e),this.name="CanvasConstraintError"}}class He extends Error{constructor(e){super(e),this.name="CanvasSchemaError"}}function ye(n,e,o){if(e.length===0){if(o===void 0)return;if(typeof o!="object"||o===null||Array.isArray(o))throw new Error("Root value of payload/extensions/meta must be an object or undefined");return o}const t=n?{...n}:{};let r=t;for(let a=0;a<e.length-1;a++){const c=e[a],l=r[c];l&&typeof l=="object"&&!Array.isArray(l)?r[c]={...l}:r[c]={},r=r[c]}const i=e[e.length-1];return o===void 0?delete r[i]:r[i]=o,t}function Ie(n,e){switch(e.type){case"node.add":return ft(n,e.node);case"node.move":return gt(n,e.nodeId,e.position);case"node.remove":return pt(n,e.nodeId);case"node.update":return ht(n,e.nodeId,e.patch);case"node.set-payload":return vt(n,e.nodeId,e.path,e.value);case"node.set-extensions":return mt(n,e.nodeId,e.path,e.value);case"edge.add":return yt(n,e.edge);case"edge.remove":return wt(n,e.edgeId);case"edge.reconnect":return bt(n,e.edgeId,e.source,e.target);case"edge.update":return Et(n,e.edgeId,e.patch);case"edge.set-payload":return kt(n,e.edgeId,e.path,e.value);case"edge.label.update":return Ct(n,e.edgeId,e.labelId,e.patch);case"model.set-meta":return xt(n,e.path,e.value);default:throw new te(`Unknown command type: ${e.type}`)}}function ge(n,e){const o=n.nodes[e];if(!o)throw new te(`Node "${e}" does not exist`);return o}function pe(n,e){const o=n.edges[e];if(!o)throw new te(`Edge "${e}" does not exist`);return o}function ue(n,e,o){const t=n.nodes[e.nodeId];if(!t)throw new te(`${o} node "${e.nodeId}" does not exist`);if(e.portId&&t.ports&&!t.ports.some(i=>i.id===e.portId))throw new te(`${o} port "${e.portId}" not found on node "${e.nodeId}"`)}function we(n,e,o){return{...n,nodes:{...n.nodes,[e]:o}}}function be(n,e,o){return{...n,edges:{...n.edges,[e]:o}}}function ft(n,e){if(n.nodes[e.id])throw new te(`Node id "${e.id}" already exists`);return{...n,nodes:{...n.nodes,[e.id]:e}}}function gt(n,e,o){const t=ge(n,e);return we(n,e,{...t,position:o})}function pt(n,e){ge(n,e);const{[e]:o,...t}=n.nodes,r={};for(const[i,a]of Object.entries(n.edges))a.source.nodeId!==e&&a.target.nodeId!==e&&(r[i]=a);return{...n,nodes:t,edges:r}}function ht(n,e,o){const t=ge(n,e);return we(n,e,{...t,...o,id:t.id})}function vt(n,e,o,t){const r=ge(n,e),i=ye(r.payload,o,t);return we(n,e,{...r,payload:i})}function mt(n,e,o,t){const r=ge(n,e),i=ye(r.extensions,o,t);return we(n,e,{...r,extensions:i})}function yt(n,e){if(n.edges[e.id])throw new te(`Edge id "${e.id}" already exists`);if(ue(n,e.source,"Source"),ue(n,e.target,"Target"),e.labels){const o=new Set;for(const t of e.labels){if(o.has(t.id))throw new te(`Duplicate label id "${t.id}" in edge "${e.id}"`);o.add(t.id)}}return{...n,edges:{...n.edges,[e.id]:e}}}function wt(n,e){pe(n,e);const{[e]:o,...t}=n.edges;return{...n,edges:t}}function bt(n,e,o,t){const r=pe(n,e),i=o??r.source,a=t??r.target;return ue(n,i,"Source"),ue(n,a,"Target"),be(n,e,{...r,source:i,target:a})}function Et(n,e,o){const t=pe(n,e),r={...t,...o,id:t.id};return o.source&&ue(n,r.source,"Source"),o.target&&ue(n,r.target,"Target"),be(n,e,r)}function kt(n,e,o,t){const r=pe(n,e),i=ye(r.payload,o,t);return be(n,e,{...r,payload:i})}function Ct(n,e,o,t){const r=pe(n,e);if(!r.labels)throw new te(`Edge "${e}" has no labels`);const i=r.labels.findIndex(c=>c.id===o);if(i===-1)throw new te(`Label "${o}" not found in edge "${e}"`);const a=[...r.labels];return a[i]={...a[i],...t,id:o},be(n,e,{...r,labels:a})}function xt(n,e,o){const t=ye(n.meta,e,o);return{...n,meta:t}}function Ge(n,e){const o=e?.maxHistorySize??100,t=s.ref(n),r=[],i=[],a=s.ref(!1),c=s.ref(!1);function l(){a.value=r.length>0,c.value=i.length>0}function m(E){const M=t.value;let N=M;for(const F of E.commands)N=Ie(N,F);if(!E.skipHistory){const F=e?.excludeCommandFromHistory,G=F?E.commands.filter(S=>!F(S)):E.commands;if(G.length>0){const S=G.length<E.commands.length?{...E,commands:G}:E;r.push({snapshot:M,envelope:S}),r.length>o&&r.shift(),i.length=0}}return t.value=N,l(),N}function f(){const E=r.pop();if(!E)return null;i.push({snapshot:t.value,envelope:E.envelope});const M=e?.preserveMetaOnUndoRedo?{...E.snapshot,meta:t.value.meta}:E.snapshot;return t.value=M,l(),M}function h(){const E=i.pop();if(!E)return null;r.push({snapshot:t.value,envelope:E.envelope});const M=e?.preserveMetaOnUndoRedo?{...E.snapshot,meta:t.value.meta}:E.snapshot;return t.value=M,l(),M}function u(){r.length=0,i.length=0,l()}function b(){return t.value}function D(E){t.value=E,u()}function L(E,M){const N={id:`update-${Date.now()}`,source:"system:update",label:M??"更新模型",timestamp:Date.now(),commands:[]};r.push({snapshot:t.value,envelope:N}),r.length>o&&r.shift(),i.length=0,t.value=E,l()}return{currentFlowModel:t,execute:m,undo:f,redo:h,canUndo:a,canRedo:c,get undoStack(){return r.map(E=>E.envelope)},get redoStack(){return i.map(E=>E.envelope)},clear:u,createSnapshot:b,replaceFlowModel:D,updateFlowModel:L}}function It(n){return n!==null&&typeof n=="object"&&n.rejected===!0}class St{plugins=[];editorContext=null;runtimeCtx=null;runtimeVersion=0;install(e,o){this.plugins=[...e].sort((t,r)=>(t.priority??100)-(r.priority??100)),this.editorContext=o;for(const t of this.plugins)t.install?.(o)}attachRuntime(e){const o=++this.runtimeVersion;this.runtimeCtx=e;const t=this.createSafeRuntimeContext(e,o);for(const r of this.plugins)r.attachRuntime?.(t)}detachRuntime(){for(const e of[...this.plugins].reverse())e.detachRuntime?.();this.runtimeCtx=null}createSafeRuntimeContext(e,o){const t=this,r=new Proxy(e.graph,{get(i,a,c){const l=Reflect.get(i,a,c);return a==="use"&&typeof l=="function"?function(...f){if(t.runtimeVersion===o)return l.apply(i,f)}:l}});return{...e,graph:r}}dispose(){for(const e of[...this.plugins].reverse())e.dispose?.();this.plugins=[],this.editorContext=null,this.runtimeCtx=null}transformCommand(e){if(!this.editorContext)return{envelope:e};let o=e;for(const t of this.plugins){if(!t.transformCommand)continue;const r=this.createPreview(o),i=t.transformCommand(o,r,this.editorContext);if(i===null)return{rejected:!0,error:{code:"plugin_rejected",reason:"",source:t.name}};if(It(i))return{rejected:!0,error:{code:i.code??"plugin_rejected",reason:i.reason,source:t.name}};o=i}return{envelope:o}}afterCommand(e,o,t){if(this.editorContext)for(const r of this.plugins)r.afterCommand?.(e,o,t,this.editorContext)}dispatchUiEvent(e){if(this.runtimeCtx)for(const o of this.plugins)o.onUiEvent?.(e,this.runtimeCtx)}dispatchSelectionChange(e){if(this.runtimeCtx)for(const o of this.plugins)o.onSelectionChange?.(e,this.runtimeCtx)}dispatchKeyboardShortcut(e){if(!this.runtimeCtx)return!1;for(const o of this.plugins)if(o.onKeyboardShortcut?.(e,this.runtimeCtx))return!0;return!1}collectContextMenuItems(e){if(!this.runtimeCtx)return[];const o=[];for(const t of this.plugins){const r=t.onBlankContextMenu?.(e,this.runtimeCtx);r&&o.push(...r)}return o}collectToolbarItems(){if(!this.editorContext)return[];const e=new Map;for(const o of this.plugins){const t=o.provideToolbarItems?.(this.editorContext);if(t)for(const r of t)e.set(r.id,r)}return[...e.values()].sort((o,t)=>(o.order??0)-(t.order??0))}collectNodeDecorations(e){if(!this.editorContext)return;let o;for(const t of this.plugins){const r=t.decorateNode?.(e,this.editorContext);r&&(o=o?{...o,...r}:r)}return o}collectEdgeDecorations(e){if(!this.editorContext)return;let o;for(const t of this.plugins){const r=t.decorateEdge?.(e,this.editorContext);r&&(o=o?{...o,...r}:r)}return o}collectExtendedApi(){if(!this.runtimeCtx)return{};const e={};for(const o of this.plugins){const t=o.extendApi?.(this.runtimeCtx.api,this.runtimeCtx);t&&Object.assign(e,t)}return e}createPreview(e){const o=this.editorContext;return{previewFlowModel(t){const r=t??e.commands;let i=o.flowModel.value;for(const a of r)i=Ie(i,a);return i}}}}let Nt=0;function W(){const n=Date.now().toString(36),e=Math.random().toString(36).substring(2,8);return`${n}-${e}-${++Nt}`}const Se=()=>W();function Mt(n){const{schema:e,plugins:o=[],historyOptions:t}=n,r=n.idGenerator??Se,i={version:"1.0",...n.initialFlowModel},a=Ge(i,t),c=s.ref(n.mode??"edit"),l=s.ref(!1),m=s.ref(null),f=s.ref([]),h={},u=new St;function b(M,N,F,G="user:toolbar"){const S={id:`history-${Date.now()}`,source:G,label:M,timestamp:Date.now(),commands:[]};u.afterCommand(S,N,F),f.value=u.collectToolbarItems(),n.onCommandResult?.({status:"applied",envelope:S,flowModel:F}),n.onFlowModelChange?.({flowModel:F,prevFlowModel:N,envelope:S,source:G})}const D={execute:a.execute,undo(){const M=a.currentFlowModel.value,N=a.undo();return N&&b("撤销",M,N),N},redo(){const M=a.currentFlowModel.value,N=a.redo();return N&&b("重做",M,N),N},get canUndo(){return a.canUndo},get canRedo(){return a.canRedo},get undoStack(){return a.undoStack},get redoStack(){return a.redoStack},clear:a.clear,createSnapshot:a.createSnapshot,replaceFlowModel(M){const N=a.currentFlowModel.value;a.replaceFlowModel(M),b("替换 FlowModel",N,M,"system:replace")},updateFlowModel(M,N){const F=a.currentFlowModel.value;a.updateFlowModel(M,N),b(N??"更新 FlowModel",F,M,"system:update")}},L={flowModel:s.computed(()=>a.currentFlowModel.value),history:D,schema:e,mode:c,idGenerator:r,executeCommand:E,replaceFlowModel(M){D.replaceFlowModel(M)},updateFlowModel(M,N){D.updateFlowModel(M,N)},setMode(M){c.value=M},selectionMode:l,setSelectionMode(M){l.value=M},api:m,toolbarItems:f,extendedApi:h,_pluginManager:u,_emitUiEvent:M=>{u.dispatchUiEvent(M)}};u.install(o,{flowModel:L.flowModel,history:D,schema:e,mode:c,idGenerator:r,executeCommand:E}),f.value=u.collectToolbarItems(),s.onScopeDispose(()=>{u.dispose()});function E(M){const N=u.transformCommand(M);if("rejected"in N){const S={status:"rejected",envelope:M,error:N.error};return n.onCommandResult?.(S),S}const F=N.envelope,G=a.currentFlowModel.value;try{const S=a.execute(F),U={status:"applied",envelope:F,flowModel:S};return u.afterCommand(F,G,S),f.value=u.collectToolbarItems(),n.onCommandResult?.(U),n.onFlowModelChange?.({flowModel:S,prevFlowModel:G,envelope:F,source:F.source}),U}catch(S){if(S instanceof te){const U={status:"invalid",envelope:F,error:{code:"constraint_violated",reason:S.message,source:"engine"}};return n.onCommandResult?.(U),U}throw S}}return L}const Dt=["top","right","bottom","left"];function Ue(){return Dt.map(n=>({id:n,group:n}))}function Ne(n,e){return e?.(n)??n.ports??Ue()}const xe=-1,At="flow-canvas-node-ring-target",De="flow-canvas-node-ring-target--decorated",Ae="flow-canvas-node-ring-target--pulse",_t="linear-gradient(135deg, #cadcfa 0%, #cee0ff 100%)";class Bt{graph;schema;shapeRegistry;resolveNodeDecoration;resolveEdgeDecoration;resolveCanvasContext;knownNodeIds=new Set;knownEdgeIds=new Set;syncing=!1;prevNodeDecorationClasses=new Map;prevNodeDecorationColors=new Set;prevEdgeDecorationClasses=new Map;prevEdgeDecorationColors=new Set;prevEdgeDecorationMarkerIds=new Set;highlightedNodeIds=new Set;highlightedEdgeIds=new Set;hoveredEdgeId=null;defaultHighlightedNodeIds=new Set;defaultHighlightedEdgeIds=new Set;prevEdgeStyleIds=new Set;nodeDefaultAttrs=new Map;edgeDefaultAttrs=new Map;lastModel=null;pendingDecorationRAFs=new Map;constructor(e,o,t,r,i,a){this.graph=e,this.schema=o,this.shapeRegistry=t,this.resolveNodeDecoration=r,this.resolveEdgeDecoration=i,this.resolveCanvasContext=a}syncFlowModel(e){if(!this.syncing){this.syncing=!0,this.lastModel=e;try{const o=this.resolveNodes(e),t=this.resolveEdges(e);this.syncNodes(o),this.syncEdges(t,e)}finally{this.syncing=!1}}}get isSyncing(){return this.syncing}saveNodeDefaultAttrs(e,o){const r=o.x6CellConfig?.attrs?.body;if(!r)return;const i={};let a=!1;r.stroke!==void 0&&(i.stroke=r.stroke,a=!0),r.strokeWidth!==void 0&&(i.strokeWidth=r.strokeWidth,a=!0),a&&this.nodeDefaultAttrs.set(e,i)}saveEdgeDefaultAttrs(e,o){const r=o?.x6EdgeConfig?.attrs?.line;if(!r)return;const i={};let a=!1;r.stroke!==void 0&&(i.stroke=r.stroke,a=!0),r.strokeWidth!==void 0&&(i.strokeWidth=r.strokeWidth,a=!0),r.strokeDasharray!==void 0&&(i.strokeDasharray=r.strokeDasharray,a=!0),a&&this.edgeDefaultAttrs.set(e,i)}restoreNodeAttr(e,o,t){const r=this.nodeDefaultAttrs.get(e.id)?.[t];if(r!==void 0)e.setAttrByPath(o,r);else{const i=t==="stroke"?"none":0;e.setAttrByPath(o,i)}}restoreEdgeAttr(e,o,t){const r=this.edgeDefaultAttrs.get(e.id)?.[t];r!==void 0?this.setEdgeAttrIfChanged(e,o,r):e.attr(o)!==void 0&&e.removeAttrByPath(o)}setEdgeAttrIfChanged(e,o,t){const r=e.attr(o),i=typeof r=="object"&&r!==null,a=typeof t=="object"&&t!==null;r!==t&&(i&&a&&JSON.stringify(r)===JSON.stringify(t)||e.setAttrByPath(o,t))}getNodeRingTarget(e){return e?e.querySelector(".flow-canvas-highlight-target")??e.querySelector(".flow-canvas-node-surface > :first-child"):null}syncEdgeMarker(e,o,t){const i=o?.x6EdgeConfig?.attrs?.line?.[t],a=`line/${t}`;e.removeAttrByPath(a),i!==void 0&&e.setAttrByPath(a,i)}getEdgeMarkerConfig(e,o){const r=e?.x6EdgeConfig?.attrs?.line?.[o];if(r)return typeof r=="string"?{name:r}:{...r}}applyEdgeMarkerDecoration(e,o,t,r){if(!r){this.prevEdgeDecorationMarkerIds.has(e.id)&&(this.syncEdgeMarker(e,o,t),this.prevEdgeDecorationMarkerIds.delete(e.id));return}const i=this.getEdgeMarkerConfig(o,t)??{name:"block",width:8,height:8};this.setEdgeAttrIfChanged(e,`line/${t}`,{...i,stroke:r,fill:r}),this.prevEdgeDecorationMarkerIds.add(e.id)}dispose(){for(const e of this.pendingDecorationRAFs.values())cancelAnimationFrame(e);this.pendingDecorationRAFs.clear(),this.knownNodeIds.clear(),this.knownEdgeIds.clear()}resolveNodes(e){const o=new Map;for(const[t,r]of Object.entries(e.nodes)){const i=this.schema.nodeTypes[r.type];if(!i)throw new He(`Unknown node type "${r.type}" for node "${t}". Registered types: [${Object.keys(this.schema.nodeTypes).join(", ")}]. Register the type in CanvasSchema.nodeTypes before using it in a FlowModel.`);const a=this.shapeRegistry.registerNodeType(r.type,i.component),c=i.getSize(r),l=Ne(r,i.getPorts);o.set(t,{model:r,definition:i,shapeName:a,size:c,ports:l})}return o}resolveEdges(e){const o=new Map;for(const[t,r]of Object.entries(e.edges)){const i=r.type??this.schema.defaultEdgeType??"default",a=this.schema.edgeTypes?.[i];o.set(t,{model:r,definition:a})}return o}syncNodes(e){const o=new Set(e.keys());for(const t of this.knownNodeIds)if(!o.has(t)){const r=this.graph.getCellById(t);r&&this.graph.removeCell(r),this.knownNodeIds.delete(t),this.defaultHighlightedNodeIds.delete(t),this.prevNodeDecorationClasses.delete(t),this.prevNodeDecorationColors.delete(t),this.nodeDefaultAttrs.delete(t);const i=this.pendingDecorationRAFs.get(t);i&&(cancelAnimationFrame(i),this.pendingDecorationRAFs.delete(t))}for(const[t,r]of e){const i=this.graph.getCellById(t);i?this.updateExistingNode(i,r):this.addNewNode(t,r)}}updateExistingNode(e,o){const{model:t,size:r,ports:i,definition:a}=o;if(e.getData()?.type!==t.type){this.graph.removeCell(e),this.addNewNode(e.id,o);return}const l=e.getPosition();(l.x!==t.position.x||l.y!==t.position.y)&&e.setPosition(t.position.x,t.position.y);const m=e.getSize();(m.width!==r.width||m.height!==r.height)&&e.setSize(r.width,r.height,{silent:!0}),this.syncNodePorts(e,i),e.setData({...t}),this.applyNodeBehavior(e,t,a),this.applyNodeHighlightAndDecoration(e,t)}syncNodePorts(e,o){const t=e.getPorts(),r=new Set(o.map(a=>a.id)),i=new Set(t.map(a=>a.id));for(const a of t)a.id&&!r.has(a.id)&&e.removePort(a.id);for(const a of o)i.has(a.id)||e.addPort({id:a.id,group:a.group,...a.x6PortConfig})}addNewNode(e,o){const{model:t,shapeName:r,size:i,ports:a,definition:c}=o,l={id:t.id,shape:r,x:t.position.x,y:t.position.y,width:i.width,height:i.height,data:{...t},ports:{groups:{top:{position:"top",attrs:{circle:{r:6,magnet:!0,fill:"#3a84ff",stroke:"#fff",strokeWidth:1,visibility:"hidden"}}},right:{position:"right",attrs:{circle:{r:6,magnet:!0,fill:"#3a84ff",stroke:"#fff",strokeWidth:1,visibility:"hidden"}}},bottom:{position:"bottom",attrs:{circle:{r:6,magnet:!0,fill:"#3a84ff",stroke:"#fff",strokeWidth:1,visibility:"hidden"}}},left:{position:"left",attrs:{circle:{r:6,magnet:!0,fill:"#3a84ff",stroke:"#fff",strokeWidth:1,visibility:"hidden"}}}},items:a.map(f=>({id:f.id,group:f.group,...f.x6PortConfig}))},...c.x6CellConfig};this.graph.addNode(l),this.knownNodeIds.add(e),this.saveNodeDefaultAttrs(e,c);const m=this.graph.getCellById(e);m&&(this.applyNodeBehavior(m,t,c),this.applyNodeHighlightAndDecoration(m,t),this.scheduleDecorationRetryIfNeeded(m))}scheduleDecorationRetryIfNeeded(e){const o=this.graph.findViewByCell(e)?.container;if(this.getNodeRingTarget(o))return;const t=e.id,r=this.pendingDecorationRAFs.get(t);r&&cancelAnimationFrame(r);const i=requestAnimationFrame(()=>{if(this.pendingDecorationRAFs.delete(t),!this.knownNodeIds.has(t))return;const a=this.lastModel?.nodes[t];if(!a)return;const c=this.graph.getCellById(t);c?.isNode()&&this.applyNodeHighlightAndDecoration(c,a)});this.pendingDecorationRAFs.set(t,i)}applyNodeBehavior(e,o,t){if(!t.getBehavior)return;const r=this.resolveCanvasContext?.();if(!r)return;const i=t.getBehavior(o,r);if(i.draggable!==void 0&&e.setProp("draggable",i.draggable,{silent:!0}),i.connectable!==void 0){const c=i.connectable?!0:i.targetable===!1?!1:"passive";for(const l of e.getPorts())e.setPortProp(l.id,"attrs/circle/magnet",c,{silent:!0})}if(i.showPorts!==void 0){const c=i.showPorts;for(const l of e.getPorts())e.setPortProp(l.id,"attrs/circle/visibility",c?"visible":"hidden",{silent:!0})}const a=e.getData()??{};i.deletable!==void 0&&a._deletable!==i.deletable&&e.setData({...a,_deletable:i.deletable},{silent:!0}),i.selectable!==void 0&&a._selectable!==i.selectable&&e.setData({...e.getData(),_selectable:i.selectable},{silent:!0})}syncEdges(e,o){const t=new Set(e.keys());for(const r of this.knownEdgeIds)if(!t.has(r)){const i=this.graph.getCellById(r);i&&this.graph.removeCell(i),this.knownEdgeIds.delete(r),this.defaultHighlightedEdgeIds.delete(r),this.prevEdgeDecorationClasses.delete(r),this.prevEdgeDecorationColors.delete(r),this.prevEdgeDecorationMarkerIds.delete(r),this.prevEdgeStyleIds.delete(r),this.edgeDefaultAttrs.delete(r)}for(const[r,i]of e){const a=this.graph.getCellById(r),{model:c,definition:l}=i;a?(this.updateExistingEdge(a,c,l,o),this.knownEdgeIds.has(r)||(this.knownEdgeIds.add(r),this.saveEdgeDefaultAttrs(r,l))):this.addNewEdge(r,c,l)}}updateExistingEdge(e,o,t,r){const i=e.getSource(),a=e.getTarget(),c=i.cell!==o.source.nodeId||i.port!==o.source.portId,l=a.cell!==o.target.nodeId||a.port!==o.target.portId;c&&e.setSource({cell:o.source.nodeId,port:o.source.portId}),l&&e.setTarget({cell:o.target.nodeId,port:o.target.portId});const f=(e.getData()?.type??void 0)!==(o.type??void 0);if(f){if(t?.router){const h=typeof t.router=="string"?{name:t.router}:t.router;e.setRouter(h)}if(t?.connector){const h=typeof t.connector=="string"?{name:t.connector}:t.connector;e.setConnector(h)}}(f||c||l)&&(this.syncEdgeMarker(e,t,"sourceMarker"),this.syncEdgeMarker(e,t,"targetMarker")),this.syncEdgeLabels(e,o),e.getZIndex()!==xe&&e.setZIndex(xe),e.setData({...o},{silent:!0}),this.applyEdgeStyleAndDecoration(e,o,t)}syncEdgeLabels(e,o){if(!o.labels?.length){e.getLabels().length>0&&e.setLabels([]);return}const t=o.labels.map(r=>({attrs:{label:{text:r.text??""}},position:r.position!=null?{distance:r.position}:void 0}));e.setLabels(t)}addNewEdge(e,o,t){const r={id:o.id,source:{cell:o.source.nodeId,port:o.source.portId},target:{cell:o.target.nodeId,port:o.target.portId},data:{...o},zIndex:xe};t?.router&&(r.router=typeof t.router=="string"?{name:t.router}:t.router),t?.connector&&(r.connector=typeof t.connector=="string"?{name:t.connector}:t.connector),t?.x6EdgeConfig&&Object.assign(r,t.x6EdgeConfig),o.labels?.length&&(r.labels=o.labels.map(a=>({attrs:{label:{text:a.text??""}},position:a.position!=null?{distance:a.position}:void 0}))),this.graph.addEdge(r),this.knownEdgeIds.add(e),this.saveEdgeDefaultAttrs(e,t);const i=this.graph.getCellById(e);i&&this.applyEdgeStyleAndDecoration(i,o,t)}refreshEdgeStyles(){if(this.lastModel)for(const[e,o]of Object.entries(this.lastModel.edges)){const t=this.graph.getCellById(e);if(!t?.isEdge())continue;const r=o.type??this.schema.defaultEdgeType??"default",i=this.schema.edgeTypes?.[r];this.applyEdgeStyleAndDecoration(t,o,i)}}refreshSingleEdgeStyle(e){if(!this.lastModel)return;const o=this.lastModel.edges[e];if(!o)return;const t=this.graph.getCellById(e);if(!t?.isEdge())return;const r=o.type??this.schema.defaultEdgeType??"default",i=this.schema.edgeTypes?.[r];this.applyEdgeStyleAndDecoration(t,o,i)}refreshNodeHighlights(){if(this.lastModel)for(const[e,o]of Object.entries(this.lastModel.nodes)){const t=this.graph.getCellById(e);t?.isNode()&&this.applyNodeHighlightAndDecoration(t,o)}}applyNodeHighlightAndDecoration(e,o){const t=this.highlightedNodeIds.has(e.id),r=this.resolveNodeDecoration?.(o),i=this.graph.findViewByCell(e)?.container,a=this.getNodeRingTarget(i),c=this.prevNodeDecorationClasses.get(e.id);c&&(i?.classList.remove(c),this.prevNodeDecorationClasses.delete(e.id)),r?.className&&(i?.classList.add(r.className),this.prevNodeDecorationClasses.set(e.id,r.className));const l=r?.borderColor,f=l??(t?"#3a84ff":void 0),h=this.prevNodeDecorationColors.has(e.id)||this.defaultHighlightedNodeIds.has(e.id);f?(e.setAttrByPath("body/stroke",f),e.setAttrByPath("body/strokeWidth",2)):h&&(this.restoreNodeAttr(e,"body/stroke","stroke"),this.restoreNodeAttr(e,"body/strokeWidth","strokeWidth")),a&&(a.classList.add(At),l?(a.classList.add(De),a.style.setProperty("--flow-canvas-node-decoration-ring-background",l),a.style.setProperty("--flow-canvas-node-decoration-ring-opacity","0.95")):(a.classList.remove(De),a.style.removeProperty("--flow-canvas-node-decoration-ring-background"),a.style.removeProperty("--flow-canvas-node-decoration-ring-opacity")),t?(a.classList.add(Ae),a.style.setProperty("--flow-canvas-node-pulse-ring-background",l??_t),a.style.setProperty("--flow-canvas-node-pulse-ring-opacity","0.95")):(a.classList.remove(Ae),a.style.removeProperty("--flow-canvas-node-pulse-ring-background"),a.style.removeProperty("--flow-canvas-node-pulse-ring-opacity"))),l?this.prevNodeDecorationColors.add(e.id):this.prevNodeDecorationColors.delete(e.id),t&&!l?this.defaultHighlightedNodeIds.add(e.id):this.defaultHighlightedNodeIds.delete(e.id)}getHoveredEdgeId(){return this.hoveredEdgeId}setHoveredEdge(e){this.hoveredEdgeId=e}setHighlightedNodes(e){this.highlightedNodeIds=new Set(e)}setHighlightedEdges(e){const o=this.highlightedEdgeIds;return this.highlightedEdgeIds=new Set(e),o}applyEdgeStyleAndDecoration(e,o,t){const r=this.highlightedEdgeIds.has(e.id),i=this.resolveEdgeDecoration?.(o),a=this.prevEdgeDecorationClasses.get(e.id);a&&(this.graph.findViewByCell(e)?.container?.classList.remove(a),this.prevEdgeDecorationClasses.delete(e.id)),i?.className&&(this.graph.findViewByCell(e)?.container?.classList.add(i.className),this.prevEdgeDecorationClasses.set(e.id,i.className));let c,l,m;if(t?.style){const L=this.graph.isSelected?.(e)??!1,E=this.hoveredEdgeId===e.id,M=t.style(o,{selected:L,highlighted:r,hovered:E});c=M.stroke,l=M.strokeWidth,m=M.strokeDasharray}const f=!t?.style&&r?"#3a84ff":void 0,h=i?.strokeColor,u=i?.targetMarkerColor,b=h??c??f,D=!!t?.style||this.prevEdgeDecorationColors.has(e.id)||this.defaultHighlightedEdgeIds.has(e.id)||this.prevEdgeStyleIds.has(e.id);b?this.setEdgeAttrIfChanged(e,"line/stroke",b):D&&this.restoreEdgeAttr(e,"line/stroke","stroke"),this.applyEdgeMarkerDecoration(e,t,"targetMarker",u),t?.style?(this.prevEdgeStyleIds.add(e.id),l?this.setEdgeAttrIfChanged(e,"line/strokeWidth",l):this.restoreEdgeAttr(e,"line/strokeWidth","strokeWidth"),m?this.setEdgeAttrIfChanged(e,"line/strokeDasharray",m):this.restoreEdgeAttr(e,"line/strokeDasharray","strokeDasharray")):this.prevEdgeStyleIds.has(e.id)&&(this.restoreEdgeAttr(e,"line/strokeWidth","strokeWidth"),this.restoreEdgeAttr(e,"line/strokeDasharray","strokeDasharray"),this.prevEdgeStyleIds.delete(e.id)),h?this.prevEdgeDecorationColors.add(e.id):this.prevEdgeDecorationColors.delete(e.id),f?this.defaultHighlightedEdgeIds.add(e.id):this.defaultHighlightedEdgeIds.delete(e.id)}}class Pt{instanceId=W();registeredShapes=new Map;wrappedComponents=new Map;getShapeName(e){let o=this.registeredShapes.get(e);return o||(o=`flow-node-${this.instanceId}-${e}`,this.registeredShapes.set(e,o)),o}registerNodeType(e,o){const t=this.getShapeName(e);let r=this.wrappedComponents.get(e);return r||(r=s.defineComponent({name:`FlowCanvasNodeShape${e.replace(/(^|[-_])(\w)/g,(i,a,c)=>c.toUpperCase())}`,setup(){return()=>s.h("div",{class:"flow-canvas-node-surface"},[s.h(o)])}}),this.wrappedComponents.set(e,r)),lt.register({shape:t,component:r,width:100,height:40}),t}dispose(){this.registeredShapes.clear(),this.wrappedComponents.clear()}}class Tt{graph;onUiEvent;onCommand;flowModelRef;idGenerator;disposers=[];constructor(e,o,t,r,i){this.graph=e,this.onUiEvent=o,this.onCommand=t,this.flowModelRef=r,this.idGenerator=i??Se,this.bindEvents()}dispose(){for(const e of this.disposers)e();this.disposers=[]}bindEvents(){this.on("node:click",({node:e})=>{this.onUiEvent({type:"node.click",nodeId:e.id})}),this.on("node:dblclick",({node:e})=>{this.onUiEvent({type:"node.dblclick",nodeId:e.id})}),this.on("node:contextmenu",({node:e,e:o})=>{this.onUiEvent({type:"node.contextmenu",nodeId:e.id,position:{x:o.clientX,y:o.clientY}})}),this.on("edge:click",({edge:e,e:o})=>{const r=o.target?.closest?.(".x6-edge-label");if(r){const a=e.getData?.()?.labels??[],c=r.parentElement?.querySelectorAll(".x6-edge-label"),l=c?Array.from(c).indexOf(r):0,m=a[Math.max(0,l)];this.onUiEvent({type:"edge.label.click",edgeId:e.id,labelId:m?.id??`label-${l}`});return}this.onUiEvent({type:"edge.click",edgeId:e.id})}),this.on("blank:click",({e})=>{const o=this.graph.clientToLocal(e.clientX,e.clientY);this.onUiEvent({type:"blank.click",position:{x:o.x,y:o.y}})}),this.on("blank:contextmenu",({e})=>{this.onUiEvent({type:"blank.contextmenu",position:{x:e.clientX,y:e.clientY}})}),this.on("node:moved",({node:e})=>{const o=e.getPosition();this.onCommand({id:W(),source:"user:drag",label:"移动节点",timestamp:Date.now(),commands:[{type:"node.move",nodeId:e.id,position:{x:o.x,y:o.y}}]})}),this.on("edge:connected",({edge:e,isNew:o})=>{const t=e.getSourceCell(),r=e.getTargetCell();if(!t||!r)return;const i=e.getSourcePortId(),a=e.getTargetPortId(),c=e.id in this.flowModelRef.value.edges;o&&!c?(this.graph.removeCell(e),this.onCommand({id:W(),source:"user:drag",label:"连线",timestamp:Date.now(),commands:[{type:"edge.add",edge:{id:this.idGenerator("edge"),source:{nodeId:t.id,portId:i??void 0},target:{nodeId:r.id,portId:a??void 0}}}]})):this.onCommand({id:W(),source:"user:drag",label:"重连",timestamp:Date.now(),commands:[{type:"edge.reconnect",edgeId:e.id,source:{nodeId:t.id,portId:i??void 0},target:{nodeId:r.id,portId:a??void 0}}]})}),this.on("edge:change:labels",({edge:e,current:o})=>{const r=e.getData?.()?.labels??[];if(!r.length||!o?.length)return;const i=[];for(let a=0;a<Math.min(r.length,o.length);a++){const c=o[a],l=r[a];if(!l?.id)continue;const m=typeof c.position=="object"?c.position?.distance:c.position;m!=null&&i.push({type:"edge.label.update",edgeId:e.id,labelId:l.id,patch:{position:m}})}i.length&&this.onCommand({id:W(),source:"user:drag",label:"拖动标签",timestamp:Date.now(),commands:i})})}on(e,o){this.graph.on(e,o),this.disposers.push(()=>this.graph.off(e,o))}}function Lt(n){function e(o){const t=n.getCellById(o);if(!t||!t.isNode())return null;const r=t,i=r.getPosition(),a=r.getSize(),c={x:i.x,y:i.y,width:a.width,height:a.height},l=n.localToGraph(c);return new DOMRect(l.x,l.y,l.width,l.height)}return{getNodeScreenRect:e}}const Rt=Object.freeze({top:24,right:8,bottom:8,left:8});function je(n){return{nodeIds:n.filter(e=>e.isNode()).map(e=>e.id),edgeIds:n.filter(e=>e.isEdge()).map(e=>e.id)}}function Ot(n,e=Rt){return new DOMRect(n.x-e.left,n.y-e.top,n.width+e.left+e.right,n.height+e.top+e.bottom)}function $t(n,e){const o=[...e.nodeIds.map(i=>n.getCellById(i)),...e.edgeIds.map(i=>n.getCellById(i))].filter(i=>!!i);if(o.length===0)return null;const t=n.getCellsBBox(o);if(!t)return null;const r=n.localToGraph(t);return Ot(r)}function We(n,e,o){const t=n.nodeIds.filter(a=>{const c=e.nodes[a];if(!c)return!1;const l=o(c);return l.deletable!==!1&&l.deleteDisabled!==!0}),r=new Set(t),i=n.edgeIds.filter(a=>{const c=e.edges[a];return c?!r.has(c.source.nodeId)&&!r.has(c.target.nodeId):!1});return{nodeIds:t,edgeIds:i}}function Ft(n){return[...n.edgeIds.map(e=>({type:"edge.remove",edgeId:e})),...n.nodeIds.map(e=>({type:"node.remove",nodeId:e}))]}const zt=100;function Vt({graph:n,overlayManager:e,executeCommand:o,schema:t,flowModel:r,getNodeBehavior:i,idGenerator:a,defaultInsertGap:c,getContextMenuItems:l,onHighlightChange:m,resolveNodeShape:f}){const h=a??Se;let u=[],b=[],D=null,L=!1,E=null;async function M(){if(L)return D;L=!0;try{const g=await import("@antv/x6-plugin-dnd"),w=g.Dnd??g.default;return w?(D=new w({target:n,scaled:!0,animation:!0,getDragNode:d=>d.clone(),getDropNode:d=>d.clone()}),D):null}catch{return console.warn("[flow-canvas] @antv/x6-plugin-dnd not available, add it to your dependencies"),null}}function N(){return new Promise(g=>{requestAnimationFrame(()=>requestAnimationFrame(()=>g()))})}const F=({node:g})=>{const w=g.getData?.();if(!w?._dndSessionId||w._dndSessionId!==E)return;E=null;const d=g.getPosition();n.removeNode(g.id);const{_dndSessionId:p,...v}=w,y=v.id||h("node");o({id:W(),source:"user:drag",label:"拖入节点",timestamp:Date.now(),commands:[{type:"node.add",node:{...v,id:y,position:{x:d.x,y:d.y}}}]})};n.on("node:added",F);function G(g){const w=t.nodeTypes[g.type];return Ne(g,w?.getPorts)}function S(g){return g??je(n.getSelectedCells?.()??[])}function U(g,w,d,p,v){switch(g){case"left":return{x:w.position.x-v-p.width,y:w.position.y+(d.height-p.height)/2};case"top":return{x:w.position.x+(d.width-p.width)/2,y:w.position.y-v-p.height};case"bottom":return{x:w.position.x+(d.width-p.width)/2,y:w.position.y+d.height+v};default:return{x:w.position.x+d.width+v,y:w.position.y+(d.height-p.height)/2}}}function T(g){switch(g){case"left":return"right";case"top":return"bottom";case"bottom":return"top";default:return"left"}}const O={zoomIn(){n.zoom(.1)},zoomOut(){n.zoom(-.1)},zoomTo(g){n.zoomTo(g)},zoomToFit(){n.zoomToFit({padding:40,maxScale:1.5})},getZoom(){return n.zoom()},centerContent(){n.centerContent()},scrollToOrigin(){n.translate(0,0)},scrollToNode(g){const w=n.getCellById(g);w&&n.centerCell(w)},getSelection(){return S()},getSelectionBounds(g){return $t(n,S(g))},selectNodes(g){const w=g.map(d=>n.getCellById(d)).filter(Boolean);n.select?.(w)},selectEdges(g){const w=g.map(d=>n.getCellById(d)).filter(Boolean);n.select?.(w)},clearSelection(){const g=n.getSelectedCells?.();g?.length&&n.unselect?.(g)},deleteSelection(g){const w=S(g?.selection),d=We(w,r.value,i??(()=>({}))),p=Ft(d);if(p.length===0)return null;const v=o({id:W(),source:g?.source??"user:toolbar",label:g?.label??"删除选中",timestamp:Date.now(),commands:p});return v.status==="applied"&&g?.clearSelectionAfterApply!==!1&&O.clearSelection(),v},registerDndSource(g,w){const d=async p=>{const v=await M();if(!v)return;const y=W();E=y;const k=w(),R=f?.(k.type),V=n.createNode({width:R?.width??154,height:R?.height??54,shape:R?.shapeName??"rect",data:{...k,_dndSessionId:y}});v.start(V,p)};return g.addEventListener("mousedown",d),()=>{g.removeEventListener("mousedown",d)}},startConnection(g,w){const d=n.getCellById(g);if(!d?.isNode())return;const p=d,v=n.findViewByCell(p);if(!v)return;const y=v.findPortElem(w,"circle")??v.findPortElem(w);if(!y)return;const R=(y.matches?.("[magnet]")?y:y.querySelector?.("[magnet]"))??y,V=R.getBoundingClientRect(),A=V.left+V.width/2,P=V.top+V.height/2,C=new MouseEvent("mousedown",{clientX:A,clientY:P,button:0,buttons:1,bubbles:!0,cancelable:!0});R.dispatchEvent(C)},async exportAsImage(g){const{domToBlob:w}=await import("modern-screenshot"),d=g?.padding??20,p=g?.backgroundColor??n.options.background?.color??"#ffffff",v=n.zoom(),y=n.translate(),k=n.getContentBBox(),R=k.width/v,V=k.height/v;if(R===0||V===0)return new Blob;const A=(k.x-y.tx)/v,P=(k.y-y.ty)/v,C=Math.ceil(R+d*2),B=Math.ceil(V+d*2),z=document.createElement("div");z.style.cssText="position:fixed;left:-99999px;top:0;pointer-events:none;";const q=n.container.cloneNode(!0);q.style.width=`${C}px`,q.style.height=`${B}px`,q.style.overflow="visible";const K=q.querySelector("svg");K&&(K.setAttribute("width",String(C)),K.setAttribute("height",String(B)),K.style.width=`${C}px`,K.style.height=`${B}px`),q.querySelector(".x6-graph-svg-viewport")?.setAttribute("transform",`matrix(1,0,0,1,${-A+d},${-P+d})`),z.appendChild(q),document.body.appendChild(z);try{return await N(),await w(q,{width:C,height:B,backgroundColor:p,scale:g?.scale??window.devicePixelRatio,filter:j=>{if(j instanceof Element){const X=j.getAttribute("class")??"";if(X.includes("x6-widget-selection")||X.includes("x6-widget-transform")||X.includes("x6-graph-grid")||X.includes("x6-graph-background"))return!1}return!0}})}catch(j){return console.warn("[flow-canvas] Export failed:",j),new Blob}finally{z.remove()}},highlightNodes(g){u=g,m?.(u,b)},highlightEdges(g){b=g,m?.(u,b)},clearHighlight(){u=[],b=[],m?.([],[])},overlay:e,getContextMenuItems(g){return l?.(g)??[]},insertNodeToRight(g,w,d){const p=r.value,v=p.nodes[g];if(!v)return{status:"invalid",envelope:{id:"",source:"user:toolbar",timestamp:Date.now(),commands:[]},error:{code:"constraint_violated",reason:`Source node "${g}" not found`,source:"api"}};const y=d?.gap??c??zt,k=d?.direction??"right",R=t.nodeTypes[v.type],V=t.nodeTypes[w.type],A=R?.getSize(v)??{width:154,height:54},P=V?.getSize({...w,position:{x:0,y:0}})??{width:154,height:54},C=U(k,v,A,P,y),B=w.id||h("node"),z={...w,id:B,position:C},q=[{type:"node.add",node:z}];if(d?.autoWireEdges){const ee=G(v),j=G(z),X=k,ce=T(k),ne=ee.find(x=>x.group===X),ae=j.find(x=>x.group===ce),Ee=j.find(x=>x.group===X),fe=ne?Object.values(p.edges).find(x=>x.source.nodeId===g&&x.source.portId===ne.id):Object.values(p.edges).find(x=>x.source.nodeId===g);if(fe){const x=fe.target,I=P.width+y,_=k==="right"?I:k==="left"?-I:0,H=k==="bottom"?I:k==="top"?-I:0,Y=new Set,oe=[x.nodeId];for(;oe.length>0;){const Z=oe.shift();if(Y.has(Z)||Z===g)continue;Y.add(Z);const de=p.nodes[Z];if(de){q.push({type:"node.move",nodeId:Z,position:{x:de.position.x+_,y:de.position.y+H}});for(const le of Object.values(p.edges))le.source.nodeId===Z&&!Y.has(le.target.nodeId)&&oe.push(le.target.nodeId)}}q.push({type:"edge.remove",edgeId:fe.id}),q.push({type:"edge.add",edge:{id:h("edge"),source:{nodeId:g,portId:ne?.id},target:{nodeId:B,portId:ae?.id}}}),q.push({type:"edge.add",edge:{id:h("edge"),source:{nodeId:B,portId:Ee?.id},target:x}})}else q.push({type:"edge.add",edge:{id:h("edge"),source:{nodeId:g,portId:ne?.id},target:{nodeId:B,portId:ae?.id}}})}const K={id:W(),source:d?.source??"user:toolbar",label:d?.label??"插入节点",timestamp:Date.now(),commands:q};return o(K)},onGraphEvent(g,w){return n.on(g,w),()=>n.off(g,w)},unsafeGetGraph(){return n}};return O}function qt(){const n=s.ref(null),e=s.ref(!1);let o=null,t=!1;function r(h){o&&(clearTimeout(o),o=null),n.value=h}function i(h=100){t||(o&&clearTimeout(o),o=setTimeout(()=>{n.value=null,o=null},h))}function a(){t=!0,o&&(clearTimeout(o),o=null)}function c(h=100){t=!1,i(h)}function l(){o&&(clearTimeout(o),o=null)}function m(){l(),t=!1,n.value=null}function f(){o&&clearTimeout(o)}return{hoveredNodeId:n,isDraggingNode:e,enter:r,leave:i,enterOverlay:a,leaveOverlay:c,cancelLeave:l,reset:m,cleanup:f}}const _e=10,he=12;function Be(n,e){const o=n.getTotalLength();if(o===0)return{...e,length:0,totalLength:0};let t=n.getPointAtLength(0),r=1/0;const i=50,a=o/i;let c=0;for(let h=0;h<=i;h++){const u=h*a,b=n.getPointAtLength(u),D=(b.x-e.x)**2+(b.y-e.y)**2;D<r&&(r=D,t=b,c=u)}const l=Math.max(0,c-a),m=Math.min(o,c+a),f=(m-l)/20;for(let h=l;h<=m;h+=f){const u=n.getPointAtLength(h),b=(u.x-e.x)**2+(u.y-e.y)**2;b<r&&(r=b,t=u,c=h)}return{x:t.x,y:t.y,length:c,totalLength:o}}function Pe(n,e){return n<_e||n>e-_e}function Te(n,e,o){const t=n.querySelectorAll(".x6-edge-label");for(const r of t){const i=r.getBoundingClientRect();if(e>=i.left-he&&e<=i.right+he&&o>=i.top-he&&o<=i.bottom+he)return!0}return!1}function Le(){const n="http://www.w3.org/2000/svg",e=document.createElementNS(n,"g");e.setAttribute("class","flow-canvas-edge-delete-tool"),e.style.cursor="pointer";const o=document.createElementNS(n,"rect");o.setAttribute("width","20"),o.setAttribute("height","20"),o.setAttribute("x","-10"),o.setAttribute("y","-10"),o.setAttribute("rx","4"),o.setAttribute("ry","4"),o.setAttribute("fill","#3a84ff"),e.appendChild(o);const t=document.createElementNS(n,"text");return t.setAttribute("font-family","flow-canvas"),t.setAttribute("font-size","16"),t.setAttribute("fill","#ffffff"),t.setAttribute("text-anchor","middle"),t.setAttribute("dominant-baseline","central"),t.textContent="",e.appendChild(t),e}function Ht(n){let e=null,o=null;function t(c,l){if(i(),o=c,l.target?.closest?.(".x6-edge-label"))return;const f=n.getCellById(c);if(!f?.isEdge())return;const h=n.findViewByCell(f);if(!h)return;const u=h.container.querySelector("path");if(!u)return;const b=n.clientToLocal(l.clientX,l.clientY),D=Be(u,b);if(Pe(D.length,D.totalLength)||Te(h.container,l.clientX,l.clientY))return;const L=Le();L.setAttribute("transform",`translate(${D.x}, ${D.y})`),h.container.appendChild(L),e=L}function r(c){if(!o)return;if(c.target?.closest?.(".x6-edge-label")){e&&e.setAttribute("display","none");return}const m=n.getCellById(o);if(!m?.isEdge())return;const f=n.findViewByCell(m);if(!f)return;const h=f.container.querySelector("path");if(!h)return;const u=n.clientToLocal(c.clientX,c.clientY),b=Be(h,u);if(Pe(b.length,b.totalLength)||Te(f.container,c.clientX,c.clientY))e&&e.setAttribute("display","none");else if(e)e.removeAttribute("display"),e.setAttribute("transform",`translate(${b.x}, ${b.y})`);else{const D=Le();D.setAttribute("transform",`translate(${b.x}, ${b.y})`),f.container.appendChild(D),e=D}}function i(){e&&(e.remove(),e=null),o=null}function a(c){c===o&&(e=null,o=null)}return{show:t,move:r,remove:i,handleEdgeRemoved:a}}function Gt(n){let e=null,o=0;function t(f){const h=f?"visible":"hidden";for(const u of n.getNodes())for(const b of u.getPorts())u.setPortProp(b.id,"attrs/circle/visibility",h)}function r(f){if(!e)for(const h of f.getPorts())f.setPortProp(h.id,"attrs/circle/visibility","visible")}function i(f){if(!e)for(const h of f.getPorts())f.setPortProp(h.id,"attrs/circle/visibility","hidden")}function a(f,h){if(!f.getTargetCell())if(e=f.id,h?.size)for(const u of n.getNodes()){const b=h.has(u.id)?"hidden":"visible";for(const D of u.getPorts())u.setPortProp(D.id,"attrs/circle/visibility",b)}else t(!0)}function c(){e=null,t(!1),o=Date.now()+300}function l(f){f===e&&(e=null,t(!1))}function m(){return!e&&Date.now()>=o}return{showNodePorts:r,hideNodePorts:i,handleEdgeAdded:a,handleEdgeConnected:c,handleEdgeRemoved:l,canShowEdgeTool:m}}function Re(n){return n==="top"||n==="right"||n==="bottom"||n==="left"}function Ut(n){const{editor:e,nodeHover:o,isSelectionModeActive:t,viewportVersion:r,getNodeBehavior:i,getInsertGap:a}=n,{isDraggingNode:c}=n,l=s.ref(null),m=s.ref(!1);let f=null,h=null,u=null;const b=s.computed(()=>({enabled:!0,portGroup:"right",...n.quickAddProp.value}));function D(){f&&(clearTimeout(f),f=null)}function L(){f&&clearTimeout(f),f=setTimeout(()=>{l.value=null,f=null},150)}function E(A){return m.value?!0:(D(),g(A)?(l.value=A,!0):(l.value=null,!1))}function M(){D(),o.enterOverlay()}function N(){L(),o.leaveOverlay()}function F(A){const P=e.schema.nodeTypes[A.type];return Ne(A,P?.getPorts)}function G(A,P){const C=b.value.getPort?.(A,P);if(!C)return null;const B=typeof C=="string"?C:C.id;return P.find(z=>z.id===B)??null}function S(A,P){const C=e.api.value?.overlay.getNodeScreenRect(A);if(!C)return null;switch(P){case"top":return{x:C.x+C.width/2,y:C.y};case"bottom":return{x:C.x+C.width/2,y:C.y+C.height};case"left":return{x:C.x,y:C.y+C.height/2};case"right":return{x:C.x+C.width,y:C.y+C.height/2};default:return null}}function U(A,P,C){if(!h)return S(A,C);const B=h.getCellById(A);if(B?.isNode()){const z=B,q=h.findViewByCell(z),K=q?.findPortElem(P,"circle")??q?.findPortElem(P);if(K){const ee=h.container.getBoundingClientRect(),j=K.getBoundingClientRect();return{x:j.left-ee.left+j.width/2,y:j.top-ee.top+j.height/2}}}return S(A,C)}function T(A){const P=F(A),C=G(A,P)??P.find(z=>z.group===b.value.portGroup)??null;if(!C)return null;const B=U(A.id,C.id,C.group);return B?{portId:C.id,portGroup:C.group,portPosition:B}:null}function O(A){const P=T(A),C=b.value.insertDirection;if(typeof C=="function"){const B=C(A,P?{id:P.portId,group:P.portGroup}:null);if(B)return B}else if(C)return C;return P&&Re(P.portGroup)?P.portGroup:Re(b.value.portGroup)?b.value.portGroup:"right"}function g(A){if(!b.value.enabled||e.mode.value!=="edit")return!1;const C=e.flowModel.value.nodes[A];return!C||i(C).quickAddEnabled===!1?!1:!!T(C)}const w=s.computed(()=>{if(r.value,!b.value.enabled)return null;const A=l.value;if(!A||c.value||!e.api.value||e.mode.value!=="edit"||t.value)return null;const C=e.flowModel.value.nodes[A];if(!C)return null;const B=i(C);if(B.quickAddEnabled===!1)return null;const z=T(C);return z?{node:C,...z,behavior:B}:null});function d(A){m.value=!0,w.value&&e._emitUiEvent({type:"node.quick-add",nodeId:A,position:w.value.portPosition})}function p(){m.value=!1}function v(A){const P=e.api.value;if(!P)return;const C=e.flowModel.value.nodes[A];if(!C)return;const B=T(C);B&&P.startConnection(A,B.portId)}function y(A,P){const C=e.api.value;if(!C)return;const B=P.id||e.idGenerator("node"),z={...P,id:B},q=e.flowModel.value.nodes[A];if(!q)return;C.insertNodeToRight(A,z,{autoWireEdges:!0,direction:O(q),gap:a(),source:"user:quick-add",label:"快捷插入节点"}).status==="applied"&&e._emitUiEvent({type:"node.action.quick-insert",sourceNodeId:A,newNodeId:B}),n.closePopover()}function k(A){if(!h)return;const P=h.getCellById(A);if(!P?.isNode())return;const C=P,B=e.flowModel.value.nodes[A];if(!B)return;const z=T(B);let q=!0;i(B).hidePortForQuickAdd===!1&&(q=!1);const ee=q&&!c.value&&!!z&&g(A);for(const j of C.getPorts()){const X=ee&&j.id===z?.portId?"hidden":"visible";C.setPortProp(j.id,"attrs/circle/visibility",X)}}function R(A,P){u?.(),h=A,u=s.watch([l,c],([C],[B])=>{if(B&&B!==C){const z=A.getCellById(B);z?.isNode()&&P(z)}C&&k(C)},{flush:"sync"})}s.watch(w,A=>{A||(m.value=!1)});function V(){f&&clearTimeout(f),u?.(),u=null,h=null}return{quickAddNodeId:l,quickAddPopoverOpen:m,mergedConfig:b,data:w,enter:E,leave:L,cancelLeave:D,handleOverlayEnter:M,handleOverlayLeave:N,handleOpen:d,handleClose:p,handleStartDrag:v,handleInsert:y,isActiveForNode:g,syncNodePorts:k,attachRuntime:R,cleanup:V}}const jt=15,Wt=10;function Xt(n){const{editor:e}=n;let o=null,t=null,r=null,i=null;const a=[];let c=null;const l=s.computed(()=>({enabled:!1,bufferMargin:jt,incomingPortGroup:"left",outgoingPortGroup:"right",...n.edgeDropProp.value}));function m(g){if(!o)return null;const w=o.getCellById(g);if(!w?.isEdge())return null;const d=o.findViewByCell(w)?.container;if(!d)return null;const p=d.querySelectorAll("path");for(const v of p)if(v.getAttribute("stroke")!=="transparent")return v;return null}function f(g){const w=m(g);w&&(w.style.stroke="#3a84ff",i=g)}function h(){if(!i)return;const g=m(i);g&&(g.style.stroke=""),i=null}function u(g,w,d){if(o){const p=o.getCellById(g);if(p?.isNode()){const v=p.getPorts().find(y=>y.group===d);if(v?.id)return v.id}}if(w.ports?.length){const p=w.ports.find(v=>v.group===d);if(p)return p.id}return d}function b(g){const w=g.getTotalLength();if(w===0)return[];const d=[];for(let v=0;v<=w;v+=Wt){const y=g.getPointAtLength(v);d.push({x:y.x,y:y.y})}const p=g.getPointAtLength(w);return d.push({x:p.x,y:p.y}),d}function D(g,w,d){if(!o)return null;const p=l.value,v=p.bufferMargin,y={x:g.x+v,y:g.y+v,width:Math.max(0,g.width-v*2),height:Math.max(0,g.height-v*2)};if(y.width<=0||y.height<=0)return null;const k=y.x+y.width,R=y.y+y.height;let V=null;const A=g.x+g.width/2,P=g.y+g.height/2;for(const C of o.getEdges()){const B=w.edges[C.id];if(!B||d&&(B.source.nodeId===d||B.target.nodeId===d)||p.isEdgeDropTarget&&!p.isEdgeDropTarget(B,w))continue;const z=o.findViewByCell(C);if(!z)continue;const q=z.findOne?.("path");if(!q||typeof q.getTotalLength!="function")continue;const K=b(q);if(!K.length)continue;let ee=!1,j=1/0;for(const X of K)if(X.x>=y.x&&X.x<=k&&X.y>=y.y&&X.y<=R){const ce=X.x-A,ne=X.y-P,ae=ce*ce+ne*ne;ae<j&&(j=ae),ee=!0}ee&&(!V||j<V.distSq)&&(V={edgeId:C.id,edge:B,distSq:j})}return V?{edgeId:V.edgeId,edge:V.edge}:null}function L(g,w){if(!l.value.enabled)return;const p=e.flowModel.value,v=D(g,p,w);v?t!==v.edgeId&&(h(),t=v.edgeId,f(v.edgeId)):t&&(h(),t=null)}let E=!0;function M({node:g}){if(t=null,!l.value.enabled)return;const w=e.flowModel.value,d=w.nodes[g.id];if(!d){E=!1;return}const p=l.value;E=!p.isNodeInsertable||p.isNodeInsertable(d,w)}function N({node:g}){!l.value.enabled||!E||r===null&&(r=requestAnimationFrame(()=>{if(r=null,!o)return;const w=g.getPosition(),d=g.getSize();L({x:w.x,y:w.y,width:d.width,height:d.height},g.id)}))}function F(){r!==null&&(cancelAnimationFrame(r),r=null),h(),E=!0}function G(){if(!o)return;let g=!1;c=()=>{if(!l.value.enabled)return;const w=document.querySelector(".x6-widget-dnd");if(!w){g&&(g=!1,h(),t=null);return}g=!0,r===null&&(r=requestAnimationFrame(()=>{if(r=null,!o)return;const d=w.getBoundingClientRect(),p=o.clientToLocal(d.left,d.top),v=o.clientToLocal(d.right,d.bottom),y={x:p.x,y:p.y,width:v.x-p.x,height:v.y-p.y};L(y)}))},document.addEventListener("mousemove",c),a.push(()=>{c&&(document.removeEventListener("mousemove",c),c=null)})}function S(){h(),t=null,r!==null&&(cancelAnimationFrame(r),r=null)}function U(g){if(!t||g.source!=="user:drag")return g;const w=t;t=null,h();const d=e.flowModel.value,p=d.edges[w];if(!p)return g;const v=g.commands.find(z=>z.type==="node.add"||z.type==="node.move");if(!v)return g;const y=v.type==="node.add"?v.node.id:v.nodeId,k=v.type==="node.add"?v.node:d.nodes[v.nodeId];if(!k)return g;const R=l.value;if(R.isNodeInsertable&&!R.isNodeInsertable(k,d))return g;const V=u(y,k,R.incomingPortGroup),A=u(y,k,R.outgoingPortGroup),P=e.idGenerator("edge"),C=e.idGenerator("edge"),B=[{type:"edge.remove",edgeId:w},{type:"edge.add",edge:{id:P,type:p.type,source:{nodeId:p.source.nodeId,portId:p.source.portId},target:{nodeId:y,portId:V}}},{type:"edge.add",edge:{id:C,type:p.type,source:{nodeId:y,portId:A},target:{nodeId:p.target.nodeId,portId:p.target.portId}}}];return{...g,source:"user:edge-drop",commands:[...g.commands,...B]}}function T(g){o=g;const w=(d,p)=>{g.on(d,p),a.push(()=>g.off(d,p))};w("node:move",M),w("node:change:position",N),w("node:moved",F),G()}function O(){S();for(const g of a)g();a.length=0,o=null,E=!0}return{attachRuntime:T,tryExpandForEdgeDrop:U,cleanup:O}}function Kt(n){function e(r){return{id:n.idGenerator("node"),type:r.type,label:r.label,ports:r.ports?JSON.parse(JSON.stringify(r.ports)):void 0,payload:r.payload?JSON.parse(JSON.stringify(r.payload)):void 0,extensions:r.extensions?JSON.parse(JSON.stringify(r.extensions)):void 0}}function o(r,i,a){const c=n.api.value;switch(r){case"delete":return n.executeCommand({id:W(),source:"user:toolbar",label:"删除节点",timestamp:Date.now(),commands:[{type:"node.remove",nodeId:i}]}),n._emitUiEvent({type:"node.action.delete",nodeId:i}),!0;case"copy":{if(!c)break;const l=n.flowModel.value.nodes[i];if(!l)break;const m=e(l),f=50;n.executeCommand({id:W(),source:"user:toolbar",label:"复制节点",timestamp:Date.now(),commands:[{type:"node.add",node:{...m,position:{x:l.position.x+f,y:l.position.y+f}}}]}),c.selectNodes([m.id]),n._emitUiEvent({type:"node.action.copy",sourceNodeId:i,newNodeId:m.id});break}case"copy-insert":{if(!c)break;const l=n.flowModel.value.nodes[i];if(!l)break;const m=e(l);c.insertNodeToRight(i,m,{autoWireEdges:!0,gap:a,label:"复制并插入节点"}),c.selectNodes([m.id]),n._emitUiEvent({type:"node.action.copy-insert",sourceNodeId:i,newNodeId:m.id});break}case"disconnect":{const l=n.flowModel.value,m=Object.entries(l.edges).filter(([,f])=>{const h=f;return h.source.nodeId===i||h.target.nodeId===i}).map(([f])=>f);if(m.length===0)break;n.executeCommand({id:W(),source:"user:toolbar",label:"断开连线",timestamp:Date.now(),commands:m.map(f=>({type:"edge.remove",edgeId:f}))}),n._emitUiEvent({type:"node.action.disconnect",nodeId:i,edgeIds:m});break}case"debug":{n._emitUiEvent({type:"node.action.debug",nodeId:i});break}}return!1}function t(r){n.api.value?.deleteSelection({selection:r,source:"user:toolbar",label:"批量删除选中"})}return{handleNodeAction:o,deleteSelection:t}}function Yt(){return{refX:0,children:[{tagName:"path",d:"M -16 -5 L -8 0 L -16 5 Z",transform:"rotate(0)"},{tagName:"circle",cx:0,cy:0,r:8,fill:"#3a84ff",stroke:"#3a84ff",transform:"rotate(0)"}]}}function Zt(n,e){const o=e.defaultEdgeType??"default",t=e.edgeTypes?.[o],r={zIndex:-1,attrs:{line:{stroke:"#abb5cc",strokeWidth:2,targetMarker:{name:"block",width:8,height:8}}}};t?.router&&(r.router=typeof t.router=="string"?{name:t.router}:t.router),t?.connector&&(r.connector=typeof t.connector=="string"?{name:t.connector}:t.connector),t?.x6EdgeConfig&&Object.assign(r,t.x6EdgeConfig);const i=r.attrs??{},a=i.line??{};return r.attrs={...i,line:{...a,targetMarker:Yt()}},n.createEdge(r)}const Qt=".x6-widget-selection",Jt=".x6-graph-svg";function eo(n){const e=n.querySelector(Qt),o=n.querySelector(Jt);return!e||!o||e.parentNode!==o.parentNode||!o.parentNode||o.previousSibling===e?!1:(o.parentNode.insertBefore(e,o),!0)}function to(n){const e=()=>eo(n);e();const o=new MutationObserver(()=>{e()});return o.observe(n,{childList:!0}),()=>o.disconnect()}function oo(n,e,o){const t=new Set(e),r=new Set(o),i=new Set([...t,...r]);for(const a of i){const c=n.getCellById(a);if(!c?.isNode())continue;const l=r.has(a),m=c.getData()??{};m._selected!==l&&c.setData({...m,_selected:l})}}const no={class:"flow-canvas-node-actions__bar"},ro=s.defineComponent({__name:"node-actions-toolbar",props:{node:{},position:{},config:{},behavior:{},actionsOffset:{}},emits:["action"],setup(n,{emit:e}){const o=n,t=s.computed(()=>{const h=o.actionsOffset?.x??0,u=o.actionsOffset?.y??0,b=h!==0||u!==0;return{left:`${o.position.x}px`,top:`${o.position.y}px`,transform:b?`translate(${h}px, ${u}px)`:"translateX(-100%)"}}),r=e,i=s.computed(()=>({debug:{visible:o.config.showDebug&&o.behavior.debuggable!==!1,disabled:o.behavior.debugDisabled===!0},delete:{visible:o.config.showDelete&&o.behavior.deletable!==!1,disabled:o.behavior.deleteDisabled===!0},copy:{visible:o.config.showCopy&&o.behavior.copyable!==!1,disabled:o.behavior.copyDisabled===!0},copyInsert:{visible:o.config.showCopyInsert&&o.behavior.copyable!==!1,disabled:o.behavior.copyInsertDisabled===!0},disconnect:{visible:o.config.showDisconnect&&o.behavior.disconnectable!==!1,disabled:o.behavior.disconnectDisabled===!0}})),a=s.computed(()=>i.value.copy.visible||i.value.copyInsert.visible||i.value.disconnect.visible),c=s.ref(!1);let l=null;function m(){l&&(clearTimeout(l),l=null),c.value=!0}function f(){l=setTimeout(()=>{c.value=!1,l=null},100)}return s.onBeforeUnmount(()=>{l&&clearTimeout(l)}),(h,u)=>(s.openBlock(),s.createElementBlock("div",{class:"flow-canvas-node-actions",style:s.normalizeStyle(t.value)},[s.createElementVNode("div",no,[i.value.debug.visible?(s.openBlock(),s.createElementBlock("i",{key:0,class:s.normalizeClass(["flow-canvas-icon canvas-debug flow-canvas-node-actions__icon",{"is-disabled":i.value.debug.disabled}]),onClick:u[0]||(u[0]=b=>!i.value.debug.disabled&&r("action","debug",n.node.id))},null,2)):s.createCommentVNode("",!0),i.value.delete.visible?(s.openBlock(),s.createElementBlock("i",{key:1,class:s.normalizeClass(["flow-canvas-icon canvas-shanchu flow-canvas-node-actions__icon",{"is-disabled":i.value.delete.disabled}]),onClick:u[1]||(u[1]=b=>!i.value.delete.disabled&&r("action","delete",n.node.id))},null,2)):s.createCommentVNode("",!0),a.value?(s.openBlock(),s.createElementBlock("div",{key:2,class:"flow-canvas-node-actions__more-wrapper",onMouseenter:m,onMouseleave:f},[...u[5]||(u[5]=[s.createElementVNode("i",{class:"flow-canvas-icon canvas-gengduo flow-canvas-node-actions__icon"},null,-1)])],32)):s.createCommentVNode("",!0)]),s.createVNode(s.Transition,{name:"flow-canvas-fade"},{default:s.withCtx(()=>[c.value&&a.value?(s.openBlock(),s.createElementBlock("div",{key:0,class:"flow-canvas-node-actions__dropdown",onMouseenter:m,onMouseleave:f},[i.value.copy.visible?(s.openBlock(),s.createElementBlock("div",{key:0,class:s.normalizeClass(["flow-canvas-node-actions__dropdown-item",{"is-disabled":i.value.copy.disabled}]),onClick:u[2]||(u[2]=b=>!i.value.copy.disabled&&r("action","copy",n.node.id))},[...u[6]||(u[6]=[s.createElementVNode("i",{class:"flow-canvas-icon canvas-copy-fuzhi-2"},null,-1),s.createElementVNode("span",null,"复制",-1)])],2)):s.createCommentVNode("",!0),i.value.copyInsert.visible?(s.openBlock(),s.createElementBlock("div",{key:1,class:s.normalizeClass(["flow-canvas-node-actions__dropdown-item",{"is-disabled":i.value.copyInsert.disabled}]),onClick:u[3]||(u[3]=b=>!i.value.copyInsert.disabled&&r("action","copy-insert",n.node.id))},[...u[7]||(u[7]=[s.createElementVNode("i",{class:"flow-canvas-icon canvas-fuzhibingcharu"},null,-1),s.createElementVNode("span",null,"复制并插入",-1)])],2)):s.createCommentVNode("",!0),i.value.disconnect.visible?(s.openBlock(),s.createElementBlock("div",{key:2,class:s.normalizeClass(["flow-canvas-node-actions__dropdown-item",{"is-disabled":i.value.disconnect.disabled}]),onClick:u[4]||(u[4]=b=>!i.value.disconnect.disabled&&r("action","disconnect",n.node.id))},[...u[8]||(u[8]=[s.createElementVNode("i",{class:"flow-canvas-icon canvas-unlock-jiebang"},null,-1),s.createElementVNode("span",null,"断开连线",-1)])],2)):s.createCommentVNode("",!0)],32)):s.createCommentVNode("",!0)]),_:1})],4))}}),se=(n,e)=>{const o=n.__vccOpts||n;for(const[t,r]of e)o[t]=r;return o},Xe=se(ro,[["__scopeId","data-v-3b39dab5"]]),so={key:0,class:"flow-canvas-quick-add__tooltip"},io=5,ao=s.defineComponent({__name:"node-quick-add-popover",props:{node:{},portPosition:{}},emits:["open","close","start-drag","mouseenter","mouseleave"],setup(n,{expose:e,emit:o}){const t=n,r=o,i=s.ref(),a=s.ref(),c=s.ref(!1),l=s.ref(!1);let m=null,f=!1,h=null;function u(T){T.preventDefault(),T.stopPropagation(),m={x:T.clientX,y:T.clientY},f=!1,document.addEventListener("mousemove",b),document.addEventListener("mouseup",D)}function b(T){if(!m)return;const O=T.clientX-m.x,g=T.clientY-m.y;Math.sqrt(O*O+g*g)>=io&&(f=!0,L(),r("start-drag",t.node.id))}function D(){L(),f||E(),m=null,f=!1}function L(){document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",D)}function E(){l.value?N():M()}function M(){l.value=!0,r("open",t.node.id),requestAnimationFrame(()=>{document.addEventListener("mousedown",F)})}function N(){l.value=!1,r("close"),document.removeEventListener("mousedown",F)}function F(T){const O=T.target;i.value?.contains(O)||a.value?.contains(O)||N()}function G(){l.value||r("mouseleave")}function S(){h&&(clearTimeout(h),h=null),r("mouseenter")}function U(){h=setTimeout(()=>{N(),r("mouseleave"),h=null},150)}return s.onBeforeUnmount(()=>{L(),h&&clearTimeout(h),document.removeEventListener("mousedown",F)}),e({closePopover:N}),(T,O)=>(s.openBlock(),s.createElementBlock("div",{class:"flow-canvas-quick-add",style:s.normalizeStyle({left:`${n.portPosition.x}px`,top:`${n.portPosition.y}px`}),onMouseenter:O[2]||(O[2]=g=>r("mouseenter")),onMouseleave:G,onClick:O[3]||(O[3]=s.withModifiers(()=>{},["stop"]))},[s.createElementVNode("div",{ref_key:"btnRef",ref:i,class:s.normalizeClass(["flow-canvas-quick-add__btn",{"is-hovered":c.value,"is-active":l.value}]),onMouseenter:O[0]||(O[0]=g=>c.value=!0),onMouseleave:O[1]||(O[1]=g=>c.value=!1),onMousedown:u},[...O[4]||(O[4]=[s.createElementVNode("i",{class:"flow-canvas-icon canvas-zoom-add"},null,-1)])],34),c.value&&!l.value?(s.openBlock(),s.createElementBlock("div",so,[...O[5]||(O[5]=[s.createElementVNode("div",null,[s.createElementVNode("b",null,"点击"),s.createTextVNode(" 添加节点")],-1),s.createElementVNode("div",null,[s.createElementVNode("b",null,"拖拽"),s.createTextVNode(" 连接节点")],-1)])])):s.createCommentVNode("",!0),s.createVNode(s.Transition,{name:"flow-canvas-fade"},{default:s.withCtx(()=>[l.value?(s.openBlock(),s.createElementBlock("div",{key:0,ref_key:"popoverRef",ref:a,class:"flow-canvas-quick-add__popover",onMouseenter:S,onMouseleave:U},[s.renderSlot(T.$slots,"default",{},()=>[O[6]||(O[6]=s.createElementVNode("div",{class:"flow-canvas-quick-add__default-content"},"节点快捷操作面板",-1))],!0)],544)):s.createCommentVNode("",!0)]),_:3})],36))}}),Ke=se(ao,[["__scopeId","data-v-336cc3b4"]]),lo={class:"flow-canvas-selection-actions__bar"},co=s.defineComponent({__name:"selection-actions-toolbar",props:{position:{},canDelete:{type:Boolean}},emits:["action"],setup(n,{emit:e}){const o=n,t=e,r=s.computed(()=>({left:`${o.position.x}px`,top:`${o.position.y}px`,transform:"translateX(-100%)"}));return(i,a)=>(s.openBlock(),s.createElementBlock("div",{class:"flow-canvas-selection-actions",style:s.normalizeStyle(r.value)},[s.createElementVNode("div",lo,[s.createElementVNode("i",{class:s.normalizeClass(["flow-canvas-icon canvas-shanchu flow-canvas-selection-actions__icon",{"is-disabled":!n.canDelete}]),onClick:a[0]||(a[0]=c=>n.canDelete&&t("action","delete"))},null,2)])],4))}}),uo=se(co,[["__scopeId","data-v-25eb8b79"]]),fo={class:"flow-canvas-runtime-core__overlay"},go=s.defineComponent({__name:"canvas-runtime-core",props:{editor:{},graphOptions:{},nodeActions:{},quickAdd:{},edgeDrop:{},getConnectionExcludedNodeIds:{type:Function},toolbarInclude:{}},emits:["ui-event"],setup(n,{expose:e,emit:o}){const t=n,r=o,i=s.ref(),a=s.ref();let c,l,m,f,h=null,u=null,b=null,D=null,L=null;const E=qt(),{hoveredNodeId:M,isDraggingNode:N}=E,F=E.enterOverlay,G=()=>E.leaveOverlay(),S=s.ref(0),U=s.ref({nodeIds:[],edgeIds:[]});function T(x){const I=t.editor.api.value;return I?t.editor.schema.nodeTypes[x.type]?.getBehavior?.(x,{api:I,flowModel:t.editor.flowModel.value,history:t.editor.history,mode:t.editor.mode.value})??{}:{}}const O=s.computed(()=>t.editor.mode.value==="edit"&&t.editor.selectionMode.value),g=s.computed(()=>({showDebug:!1,showDelete:!0,showCopy:!0,showCopyInsert:!0,showDisconnect:!0,insertGap:100,...t.nodeActions})),w=s.computed(()=>{if(S.value,!t.editor.api.value)return[];const x=t.editor.flowModel.value,I=t.editor.api.value.overlay,_=[];for(const[H,Y]of Object.entries(x.nodes)){const oe=t.editor._pluginManager.collectNodeDecorations(Y);if(!oe?.badge)continue;const Z=I.getNodeScreenRect(H);Z&&_.push({nodeId:H,x:Z.x+Z.width-4,y:Z.y-8,badge:oe.badge})}return _}),d=s.computed(()=>{S.value;const x=M.value;if(!x||N.value||!t.editor.api.value||t.editor.mode.value!=="edit"||O.value)return null;const _=t.editor.flowModel.value.nodes[x];if(!_)return null;const H=t.editor.api.value.overlay.getNodeScreenRect(x);if(!H)return null;const Y=T(_);return Y.showActions===!1?null:{node:_,position:{x:H.x+H.width,y:H.y+H.height+4},behavior:Y}}),p=s.computed(()=>{if(S.value,!t.editor.api.value||t.editor.mode.value!=="edit")return null;const x=U.value;if(x.nodeIds.length+x.edgeIds.length===0)return null;const I=t.editor.api.value.getSelectionBounds(x);if(!I)return null;const _=We(x,t.editor.flowModel.value,T);return{position:{x:I.x+I.width,y:I.y+I.height+4},canDelete:_.nodeIds.length>0||_.edgeIds.length>0}}),v=s.ref(),y=Ut({editor:t.editor,quickAddProp:s.computed(()=>t.quickAdd),isDraggingNode:N,nodeHover:E,isSelectionModeActive:O,viewportVersion:S,getNodeBehavior:T,getInsertGap:()=>g.value.insertGap,closePopover:()=>v.value?.closePopover()}),k=y.data,R=y.handleOpen,V=y.handleStartDrag;function A(){y.handleClose(),E.leaveOverlay(200),y.leave()}const P=y.handleOverlayEnter,C=y.handleOverlayLeave,B=y.handleInsert,z=Xt({editor:t.editor,edgeDropProp:s.computed(()=>t.edgeDrop)}),q=Kt(t.editor);function K(x,I){q.handleNodeAction(x,I,g.value.insertGap)&&(M.value=null)}function ee(x){x==="delete"&&q.deleteSelection(U.value)}function j(x){if(t.editor.mode.value!=="edit")return;if((x.metaKey||x.ctrlKey)&&(x.key==="z"||x.key==="Z")){if(x.shiftKey){if(!t.toolbarInclude?.includes("redo"))return;t.editor.history.redo()}else{if(!t.toolbarInclude?.includes("undo"))return;t.editor.history.undo()}x.preventDefault();return}t.editor._pluginManager.dispatchKeyboardShortcut(x)&&(x.preventDefault(),x.stopPropagation())}function X(x,I){const _=c,H=Y=>{const oe=_.isRubberbandEnabled?.()??!1;oe&&_.disableRubberband?.(),Y?c.enablePanning():c.disablePanning(),oe&&_.enableRubberband?.()};x&&I?(_.enableSelection?.(),E.reset(),y.quickAddNodeId.value=null,y.quickAddPopoverOpen.value=!1,h?.remove(),H(!1),_.enableRubberband?.()):(_.disableRubberband?.(),H(!0),_.disableSelection?.(),_.cleanSelection?.())}function ce(x){c.on("node:move",({node:I})=>{N.value=!0;const _=t.editor.flowModel.value.nodes[I.id];_&&T(_).bringToFrontOnDrag===!1||I.toFront?.()}),c.on("node:moved",()=>{N.value=!1}),c.on("node:mouseenter",({node:I})=>{if(O.value){M.value=null,y.quickAddNodeId.value=null,x.hideNodePorts(I);return}E.enter(I.id);const _=t.editor.flowModel.value.nodes[I.id];if(_&&T(_).showPorts===!1){y.mergedConfig.value.enabled&&y.enter(I.id);return}y.mergedConfig.value.enabled&&y.enter(I.id)||x.showNodePorts(I)}),c.on("node:mouseleave",({node:I})=>{if(O.value){x.hideNodePorts(I);return}const _=t.editor.flowModel.value.nodes[I.id];let H=100;_&&T(_).actionsOffset&&(H=300),E.leave(H),y.mergedConfig.value.enabled?y.quickAddNodeId.value===I.id&&!y.quickAddPopoverOpen.value?y.leave():y.quickAddNodeId.value!==I.id&&x.hideNodePorts(I):x.hideNodePorts(I)})}function ne(x){c.on("edge:added",({edge:I})=>{let _;if(t.getConnectionExcludedNodeIds&&!I.getTargetCell()){const H=I.getSourceCell();if(H){const Y=t.getConnectionExcludedNodeIds(H.id);_=Y instanceof Set?Y:new Set(Y)}}x.handleEdgeAdded(I,_)}),c.on("edge:connected",()=>{x.handleEdgeConnected()}),c.on("edge:removed",({edge:I})=>{x.handleEdgeRemoved(I.id),h.handleEdgeRemoved(I.id)}),c.on("edge:mouseenter",({edge:I,e:_})=>{const H=l.getHoveredEdgeId();l.setHoveredEdge(I.id),H&&H!==I.id&&l.refreshSingleEdgeStyle(H),l.refreshSingleEdgeStyle(I.id),t.editor.mode.value==="edit"&&!O.value&&x.canShowEdgeTool()&&h.show(I.id,_)}),c.on("edge:mouseleave",({edge:I})=>{l.setHoveredEdge(null),l.refreshSingleEdgeStyle(I.id),h.remove()}),c.on("edge:click",({edge:I,e:_})=>{_.target?.closest?.(".flow-canvas-edge-delete-tool")&&t.editor.mode.value==="edit"&&(h.remove(),t.editor.executeCommand({id:W(),source:"user:toolbar",label:"删除连线",timestamp:Date.now(),commands:[{type:"edge.remove",edgeId:I.id}]}))}),u=I=>h.move(I),c.container.addEventListener("mousemove",u)}function ae(){b=x=>{if(!M.value&&!y.quickAddNodeId.value)return;const I=x.target;if(I?.closest?.(".x6-node")||I?.closest?.(".flow-canvas-node-actions")||I?.closest?.(".flow-canvas-quick-add")){E.cancelLeave(),y.cancelLeave();return}E.leave(180),y.quickAddPopoverOpen.value||y.leave()},i.value?.addEventListener("mousemove",b),D=()=>{E.reset(),y.quickAddPopoverOpen.value||(y.quickAddNodeId.value=null)},i.value?.addEventListener("mouseleave",D),i.value?.addEventListener("keydown",j)}function Ee(){s.watch(()=>t.editor.flowModel.value,x=>l.syncFlowModel(x)),s.watch([()=>t.editor.mode.value,()=>t.editor.selectionMode.value],([x,I])=>{X(x==="edit",I)},{immediate:!0})}s.onMounted(()=>{if(!a.value)return;const x=new Set(["model","container"]),I={};if(t.graphOptions)for(const[$,Q]of Object.entries(t.graphOptions)){if(x.has($)){console.warn(`[flow-canvas] graphOptions.${$} is managed by the engine and will be ignored`);continue}I[$]=Q}c=new at.Graph({container:a.value,autoResize:!0,background:{color:"#edf2fc"},grid:{visible:!0,size:20,type:"dot",args:{color:"#C1CADB",thickness:2}},highlighting:{magnetAdsorbed:{name:"className",args:{className:"flow-canvas-magnet-adsorbed"}}},panning:{enabled:!0},mousewheel:{enabled:!0,modifiers:["ctrl","meta"]},interacting:{nodeMovable($){return $.cell.getProp("draggable")!==!1}},connecting:{allowBlank:!1,allowMulti:!0,allowLoop:!1,allowNode:!1,allowEdge:!1,highlight:!0,anchor:"center",connectionPoint:"anchor",snap:{radius:30},createEdge(){return Zt(this,t.editor.schema)}},...I}),m=new Pt,l=new Bt(c,t.editor.schema,m,$=>t.editor._pluginManager.collectNodeDecorations($),$=>t.editor._pluginManager.collectEdgeDecorations($),()=>t.editor.api.value?{api:t.editor.api.value,flowModel:t.editor.flowModel.value,history:t.editor.history,mode:t.editor.mode.value}:null);const _=Lt(c),H=Vt({graph:c,overlayManager:_,executeCommand:$=>t.editor.executeCommand(z.tryExpandForEdgeDrop($)),schema:t.editor.schema,flowModel:t.editor.flowModel,getNodeBehavior:T,idGenerator:t.editor.idGenerator,defaultInsertGap:t.nodeActions?.insertGap,getContextMenuItems:$=>t.editor._pluginManager.collectContextMenuItems($),onHighlightChange:($,Q)=>{l.setHighlightedNodes($);const re=l.setHighlightedEdges(Q);l.refreshNodeHighlights();const J=new Set(Q);for(const ie of re)J.has(ie)||l.refreshSingleEdgeStyle(ie);for(const ie of J)re.has(ie)||l.refreshSingleEdgeStyle(ie)},resolveNodeShape:$=>{const Q=t.editor.schema.nodeTypes[$];if(!Q)return null;const re=m.registerNodeType($,Q.component),J=Q.getSize({id:"",type:$,position:{x:0,y:0}});return{shapeName:re,width:J.width,height:J.height}}});t.editor.api.value=H;const Y={flowModel:t.editor.flowModel,history:t.editor.history,schema:t.editor.schema,mode:t.editor.mode,idGenerator:t.editor.idGenerator,executeCommand:t.editor.executeCommand,selectionMode:t.editor.selectionMode,api:H,overlay:_,graph:c};t.editor._pluginManager.attachRuntime(Y);const oe=t.editor._pluginManager.collectExtendedApi();Object.assign(t.editor.extendedApi,oe),t.editor._emitUiEvent=$=>{t.editor._pluginManager.dispatchUiEvent($),r("ui-event",$)},f=new Tt(c,$=>{($.type==="node.click"||$.type==="node.dblclick"||$.type==="node.contextmenu")&&E.enter($.nodeId),t.editor._emitUiEvent($)},$=>{if(l.isSyncing)return;const Q=z.tryExpandForEdgeDrop($);if(t.editor.executeCommand(Q).status!=="applied"){for(const J of Q.commands)if(J.type==="edge.add"){const ie=c.getCellById(J.edge.id);ie&&c.removeCell(ie)}}},t.editor.flowModel,t.editor.idGenerator),h=Ht(c);const Z=Gt(c);y.attachRuntime(c,$=>Z.hideNodePorts($)),z.attachRuntime(c),ce(Z),ne(Z),L=to(c.container);let de=new Set,le=new Set;c.on("selection:changed",()=>{const $=je(c.getSelectedCells?.()??[]),Q=new Set($.nodeIds);oo(c,de,Q),de=Q,U.value=$,t.editor._pluginManager.dispatchSelectionChange($),r("ui-event",{type:"selection.change",nodeIds:$.nodeIds,edgeIds:$.edgeIds}),l.refreshNodeHighlights();const re=new Set($.edgeIds);for(const J of le)re.has(J)||l.refreshSingleEdgeStyle(J);for(const J of re)le.has(J)||l.refreshSingleEdgeStyle(J);le=re});const ke=()=>{S.value++};c.on("translate",ke),c.on("scale",ke),c.on("resize",ke),ae(),l.syncFlowModel(t.editor.flowModel.value),Ee()});function fe(){E.reset(),y.quickAddNodeId.value=null,y.quickAddPopoverOpen.value=!1}return e({resetHoverState:fe}),s.onBeforeUnmount(()=>{E.cleanup(),y.cleanup(),z.cleanup(),h?.remove(),u&&c?.container?.removeEventListener("mousemove",u),b&&i.value?.removeEventListener("mousemove",b),D&&i.value?.removeEventListener("mouseleave",D),L?.(),i.value?.removeEventListener("keydown",j),t.editor._pluginManager.detachRuntime(),t.editor.api.value=null;for(const x of Object.keys(t.editor.extendedApi))delete t.editor.extendedApi[x];f?.dispose(),l?.dispose(),m?.dispose(),c?.dispose()}),(x,I)=>(s.openBlock(),s.createElementBlock("div",{ref_key:"rootRef",ref:i,class:s.normalizeClass(["flow-canvas-runtime-core",{"flow-canvas-runtime-core--selection-mode":O.value}]),tabindex:"0"},[s.createElementVNode("div",{ref_key:"containerRef",ref:a,class:"flow-canvas-runtime-core__graph"},null,512),s.createElementVNode("div",fo,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(w.value,_=>(s.openBlock(),s.createElementBlock("div",{key:`badge-${_.nodeId}`,class:"flow-canvas-runtime-core__badge",style:s.normalizeStyle({left:`${_.x}px`,top:`${_.y}px`,backgroundColor:_.badge.color})},s.toDisplayString(_.badge.text),5))),128)),s.unref(k)?(s.openBlock(),s.createBlock(Ke,{key:0,ref_key:"quickAddPopoverRef",ref:v,node:s.unref(k).node,"port-position":s.unref(k).portPosition,onOpen:s.unref(R),onClose:A,onStartDrag:s.unref(V),onMouseenter:s.unref(P),onMouseleave:s.unref(C)},{default:s.withCtx(()=>[s.renderSlot(x.$slots,"quick-add-panel",{node:s.unref(k).node,api:n.editor.api.value,insertNodeToRight:_=>s.unref(B)(s.unref(k).node.id,_),closePopover:()=>v.value?.closePopover()},void 0,!0)]),_:3},8,["node","port-position","onOpen","onStartDrag","onMouseenter","onMouseleave"])):s.createCommentVNode("",!0),d.value?(s.openBlock(),s.createBlock(Xe,{key:1,node:d.value.node,position:d.value.position,config:g.value,behavior:d.value.behavior,"actions-offset":d.value.behavior.actionsOffset,onAction:K,onMouseenter:s.unref(F),onMouseleave:G},null,8,["node","position","config","behavior","actions-offset","onMouseenter"])):s.createCommentVNode("",!0),p.value?(s.openBlock(),s.createBlock(uo,{key:2,position:p.value.position,"can-delete":p.value.canDelete,onAction:ee},null,8,["position","can-delete"])):s.createCommentVNode("",!0)])],2))}}),po=se(go,[["__scopeId","data-v-a9bbf5f1"]]),ho={class:"flow-canvas-node-palette"},vo=["data-node-type"],mo={class:"flow-canvas-node-palette__item-label"},yo=s.defineComponent({__name:"canvas-node-palette",props:{editor:{},items:{}},setup(n){const e=n,o=s.ref(),t=s.computed(()=>e.items?e.items:Object.keys(e.editor.schema.nodeTypes).map(r=>({type:r,label:r.charAt(0).toUpperCase()+r.slice(1)})));return s.watch([()=>e.editor.api.value,t,o],([r,i,a],c,l)=>{if(!r||!a)return;const m=[];for(const f of i){const h=a.querySelector(`[data-node-type="${f.type}"]`);if(!h)continue;const u=r.registerDndSource(h,()=>({id:W(),type:f.type,label:f.label,position:{x:0,y:0}}));m.push(u)}l(()=>{for(const f of m)f()})},{flush:"post"}),(r,i)=>(s.openBlock(),s.createElementBlock("div",ho,[s.createElementVNode("div",{ref_key:"listRef",ref:o,class:"flow-canvas-node-palette__list"},[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(t.value,a=>(s.openBlock(),s.createElementBlock("div",{key:a.type,class:"flow-canvas-node-palette__item","data-node-type":a.type},[a.icon?(s.openBlock(),s.createElementBlock("i",{key:0,class:s.normalizeClass([a.icon,"flow-canvas-node-palette__item-icon"])},null,2)):s.createCommentVNode("",!0),s.createElementVNode("span",mo,s.toDisplayString(a.label),1)],8,vo))),128))],512)]))}}),Ye=se(yo,[["__scopeId","data-v-300314b7"]]),wo={class:"flow-canvas-layout"},bo={class:"flow-canvas-layout__main"},Eo={class:"flow-canvas-layout__content"},ko={key:0,class:"flow-canvas-layout__footer"},Co=s.defineComponent({__name:"canvas-layout",props:{sidebarCollapsed:{type:Boolean,default:!1},sidebarWidth:{default:260},hideSidebar:{type:Boolean,default:!1},hideFooter:{type:Boolean,default:!1},editor:{default:void 0},paletteItems:{default:void 0}},emits:["update:sidebarCollapsed"],setup(n){return(e,o)=>(s.openBlock(),s.createElementBlock("div",wo,[!n.hideSidebar&&(e.$slots.sidebar||n.editor)?(s.openBlock(),s.createElementBlock("aside",{key:0,class:s.normalizeClass(["flow-canvas-layout__sidebar",{"is-collapsed":n.sidebarCollapsed}]),style:s.normalizeStyle({width:n.sidebarCollapsed?"0px":`${n.sidebarWidth}px`})},[s.renderSlot(e.$slots,"sidebar",{},()=>[n.editor?(s.openBlock(),s.createBlock(Ye,{key:0,editor:n.editor,items:n.paletteItems},null,8,["editor","items"])):s.createCommentVNode("",!0)],!0)],6)):s.createCommentVNode("",!0),s.createElementVNode("div",bo,[s.createElementVNode("div",Eo,[s.renderSlot(e.$slots,"default",{},void 0,!0)]),!n.hideFooter&&e.$slots.footer?(s.openBlock(),s.createElementBlock("div",ko,[s.renderSlot(e.$slots,"footer",{},void 0,!0)])):s.createCommentVNode("",!0)])]))}}),xo=se(Co,[["__scopeId","data-v-26f35b6b"]]),Oe=typeof navigator<"u"&&/Mac|iPod|iPhone|iPad/.test(navigator.platform??navigator.userAgent),Io=["undo","redo"];function Ze(n){const e=new Set(n?.include),o=new Set(Io.filter(l=>!e.has(l))),t=[{id:"undo",type:"undo",group:"history",icon:"flow-canvas-icon canvas-undo",description:"撤销",shortcut:Oe?["⌘","Z"]:["Ctrl","Z"],order:10},{id:"redo",type:"redo",group:"history",icon:"flow-canvas-icon canvas-redo",description:"重做",shortcut:Oe?["⇧","⌘","Z"]:["Ctrl","Shift","Z"],order:11}],r=[{id:"select",type:"select",group:"tools",icon:"flow-canvas-icon canvas-kuangxuan",description:"框选模式",order:20},{id:"auto-layout",type:"auto-layout",group:"tools",icon:"flow-canvas-icon canvas-beautify",description:"自动排版",order:21},{id:"export",type:"export",group:"tools",icon:"flow-canvas-icon canvas-xiazai",description:"下载",order:24}],i=[{id:"zoom-out",type:"zoom-out",group:"zoom",icon:"flow-canvas-icon canvas-zoom-minus",description:"缩小画布",order:30},{id:"zoom-display",type:"zoom-display",group:"zoom",order:31},{id:"zoom-in",type:"zoom-in",group:"zoom",icon:"flow-canvas-icon canvas-zoom-add",description:"放大画布",order:32}],a=[{id:"reset",type:"reset",group:"reset",icon:"flow-canvas-icon canvas-reset-1_1",description:"重置视图",order:40}];return[...[...t,...r].filter(l=>!o.has(l.type)),...i,...a]}const So={class:"flow-canvas-toolbar"},No={key:0,class:"flow-canvas-toolbar__separator"},Mo={class:"flow-canvas-toolbar__group"},Do={key:0,class:"flow-canvas-toolbar__zoom-display"},Ao=["data-toolbar-id","data-toolbar-type","disabled","onClick","onMouseenter"],_o=["textContent"],Bo={key:0,class:"flow-canvas-toolbar-tooltip__kbd"},Po=s.defineComponent({__name:"canvas-toolbar",props:{items:{},exclude:{},include:{},editor:{}},setup(n){const e=new Set(["undo","redo","select","auto-layout","search","minimap","export"]),o=new Set(["select","search","minimap"]);function t(d){return d.id.startsWith("plugin:")||d.type==="custom"}function r(d){return d!=="custom"&&o.has(d)}const i=n,a=s.computed(()=>{if(i.items)return i.items;const d=Ze({include:i.include}),p=i.editor.toolbarItems.value,v=new Set(i.exclude??[]),y=new Map;for(const k of d)y.set(k.id,k);for(const k of p){const R=y.get(k.id);R?y.set(k.id,{...R,...k,order:R.order,group:R.group}):t(k)&&y.set(k.id,k)}return[...y.values()].filter(k=>k.type==="custom"||!e.has(k.type)?!0:!v.has(k.type)).sort((k,R)=>(k.order??0)-(R.order??0))}),c=s.ref(1),l=s.ref(null),m=s.ref(null),f=s.ref(!1);let h=null;s.watch(()=>i.editor.api.value,d=>{h?.(),h=null,d&&(c.value=d.getZoom(),h=d.onGraphEvent("scale",()=>{c.value=d.getZoom()}))},{immediate:!0});const u=s.reactive({visible:!1,text:"",shortcut:[],x:0,y:0});function b(d,p){if(!p.description)return;const y=d.currentTarget.getBoundingClientRect();u.text=p.description,u.shortcut=p.shortcut??[],u.visible=!0,s.nextTick(()=>{const k=l.value?.offsetWidth??0,R=l.value?.offsetHeight??0;u.x=y.left+y.width/2-k/2,u.y=y.top-R-6})}function D(){u.visible=!1,l.value=null}s.onScopeDispose(()=>{h?.()});const L=s.computed(()=>`${Math.round(c.value*100)}%`),E=s.computed(()=>i.editor.api.value?{api:i.editor.api.value,flowModel:i.editor.flowModel.value,history:i.editor.history,mode:i.editor.mode.value}:null);function M(d){return d.visible===!1?!1:typeof d.visible=="function"?E.value?d.visible(E.value):!1:!0}function N(d){return typeof d.active=="function"?E.value?d.active(E.value):!1:d.active!==void 0?d.active:d.type==="select"?i.editor.selectionMode.value:!1}const F=s.computed(()=>{const d=g.value.filter(v=>r(v.type)&&N(v));if(d.length===0)return null;const p=m.value;return p&&d.some(v=>v.type===p)?p:d[0]?.type??null});function G(d){return r(d.type)?F.value===d.type:N(d)}function S(d){return!E.value||d.disabled===!0?!0:typeof d.disabled=="function"?d.disabled(E.value):d.type==="undo"?!i.editor.history.canUndo.value:d.type==="redo"?!i.editor.history.canRedo.value:d.type==="export"?f.value:!1}function U(d){if(!(!E.value||!r(d.type)||!N(d))){if(d.type==="select"){i.editor.setSelectionMode(!1);return}d.onClick?.(E.value)}}function T(d){if(r(d.type))for(const p of g.value)!r(p.type)||p.id===d.id||U(p)}function O(d){if(!E.value||S(d))return;if(r(d.type)&&(m.value=d.type,T(d)),d.onClick){d.onClick(E.value);return}const{api:p}=E.value;switch(d.type){case"undo":i.editor.history.undo();break;case"redo":i.editor.history.redo();break;case"zoom-in":p.zoomIn(),c.value=p.getZoom();break;case"zoom-out":p.zoomOut(),c.value=p.getZoom();break;case"fit":p.zoomToFit();break;case"reset":p.zoomTo(1),p.scrollToOrigin(),c.value=1;break;case"export":if(f.value)break;f.value=!0,p.exportAsImage().then(v=>{const y=URL.createObjectURL(v),k=document.createElement("a");k.href=y,k.download="canvas-export.png",k.click(),URL.revokeObjectURL(y)}).catch(v=>{console.warn("[flow-canvas] Export failed:",v)}).finally(()=>{f.value=!1});break;case"select":i.editor.setSelectionMode(!i.editor.selectionMode.value);break;case"auto-layout":i.editor._emitUiEvent({type:"toolbar.auto-layout"});break;case"search":case"minimap":console.warn(`[flow-canvas] "${d.type}" toolbar item has no built-in handler. Provide an onClick callback.`);break;default:d.type!=="custom"&&console.warn(`[flow-canvas] No default handler for toolbar type "${d.type}". Provide an onClick handler.`);break}}const g=s.computed(()=>a.value.filter(M)),w=s.computed(()=>{const d=new Map,p=[];for(const v of g.value){const y=v.group??"default";d.has(y)||(d.set(y,[]),p.push(y)),d.get(y).push(v)}return p.map(v=>({name:v,items:d.get(v)})).filter(v=>v.items.length>0)});return(d,p)=>(s.openBlock(),s.createElementBlock("div",So,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(w.value,(v,y)=>(s.openBlock(),s.createElementBlock(s.Fragment,{key:v.name},[y>0?(s.openBlock(),s.createElementBlock("div",No)):s.createCommentVNode("",!0),s.createElementVNode("div",Mo,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(v.items,k=>(s.openBlock(),s.createElementBlock(s.Fragment,{key:k.id},[k.type==="zoom-display"?(s.openBlock(),s.createElementBlock("span",Do,s.toDisplayString(L.value),1)):(s.openBlock(),s.createElementBlock("button",{key:1,type:"button",class:s.normalizeClass(["flow-canvas-toolbar__btn",{"is-disabled":S(k),"is-active":G(k),"is-exporting":k.type==="export"&&f.value}]),"data-toolbar-id":k.id,"data-toolbar-type":k.type,disabled:S(k),onClick:R=>O(k),onMouseenter:R=>b(R,k),onMouseleave:D},[k.component?(s.openBlock(),s.createBlock(s.resolveDynamicComponent(k.component),{key:0})):k.icon?(s.openBlock(),s.createElementBlock("i",{key:1,class:s.normalizeClass(k.icon)},null,2)):(s.openBlock(),s.createElementBlock("span",{key:2,class:"flow-canvas-toolbar__text",textContent:s.toDisplayString(k.text??k.description??k.id)},null,8,_o))],42,Ao))],64))),128))])],64))),128)),(s.openBlock(),s.createBlock(s.Teleport,{to:"body"},[u.visible?(s.openBlock(),s.createElementBlock("div",{key:0,ref_key:"tooltipRef",ref:l,class:"flow-canvas-toolbar-tooltip",style:s.normalizeStyle({left:`${u.x}px`,top:`${u.y}px`})},[s.createElementVNode("span",null,s.toDisplayString(u.text),1),u.shortcut.length?(s.openBlock(),s.createElementBlock("kbd",Bo,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(u.shortcut,(v,y)=>(s.openBlock(),s.createElementBlock("span",{key:y},s.toDisplayString(v),1))),128))])):s.createCommentVNode("",!0),p[0]||(p[0]=s.createElementVNode("div",{class:"flow-canvas-toolbar-tooltip__arrow"},null,-1))],4)):s.createCommentVNode("",!0)]))]))}}),To=se(Po,[["__scopeId","data-v-904248f4"]]),Lo={class:"flow-canvas-default-node__ep-label"},Ro={key:1,class:"flow-canvas-default-node__diamond flow-canvas-highlight-target"},Oo={key:2,class:"flow-canvas-default-node__task-label"},$o=s.defineComponent({__name:"default-node",setup(n){const o=s.inject("getNode")?.(),t=s.computed(()=>o?.getData?.()??null),r=s.computed(()=>t.value?.label||t.value?.type||""),i={start:"canvas-kaishi",end:"canvas-stop","parallel-gateway":"canvas-bingxingwangguan","branch-gateway":"canvas-fenzhiwangguan","converge-gateway":"canvas-huijuwangguan","conditional-parallel-gateway":"canvas-tiaojianbingxingwangguan"},a=new Set(["start","end"]),c=new Set(["parallel-gateway","branch-gateway","converge-gateway","conditional-parallel-gateway"]),l=s.computed(()=>{const f=t.value?.type??"";return a.has(f)?"endpoint":c.has(f)?"gateway":"task"}),m=s.computed(()=>i[t.value?.type??""]??"");return(f,h)=>(s.openBlock(),s.createElementBlock("div",{class:s.normalizeClass(["flow-canvas-default-node",[`is-${l.value}`,{"flow-canvas-highlight-target":l.value!=="gateway"}]])},[l.value==="endpoint"?(s.openBlock(),s.createElementBlock(s.Fragment,{key:0},[m.value?(s.openBlock(),s.createElementBlock("i",{key:0,class:s.normalizeClass([["flow-canvas-icon",m.value],"flow-canvas-default-node__ep-icon"])},null,2)):s.createCommentVNode("",!0),s.createElementVNode("span",Lo,s.toDisplayString(r.value),1)],64)):l.value==="gateway"?(s.openBlock(),s.createElementBlock("div",Ro,[m.value?(s.openBlock(),s.createElementBlock("i",{key:0,class:s.normalizeClass([["flow-canvas-icon",m.value],"flow-canvas-default-node__gw-icon"])},null,2)):s.createCommentVNode("",!0)])):(s.openBlock(),s.createElementBlock("span",Oo,s.toDisplayString(r.value),1))],2))}}),Qe=se($o,[["__scopeId","data-v-f0e24a9f"]]),Fo={start:{label:"开始",icon:"flow-canvas-icon canvas-kaishi",width:88,height:40},end:{label:"结束",icon:"flow-canvas-icon canvas-stop",width:88,height:40},empty:{label:"空节点",icon:"flow-canvas-icon canvas-jiedi",width:240,height:48},"parallel-gateway":{label:"并行网关",icon:"flow-canvas-icon canvas-bingxingwangguan",width:64,height:64},"branch-gateway":{label:"分支网关",icon:"flow-canvas-icon canvas-fenzhiwangguan",width:64,height:64},"converge-gateway":{label:"汇聚网关",icon:"flow-canvas-icon canvas-huijuwangguan",width:64,height:64},"conditional-parallel-gateway":{label:"条件并行网关",icon:"flow-canvas-icon canvas-tiaojianbingxingwangguan",width:64,height:64}},$e=(n,e)=>({stroke:e.hovered?"#3a84ff":"#abb5cc",strokeWidth:2});function Fe(){return{attrs:{line:{stroke:"#abb5cc",strokeWidth:2,targetMarker:{name:"block",width:8,height:8}}}}}function Je(){return{manhattan:{router:{name:"manhattan",args:{padding:10,maxDirectionChange:90}},connector:{name:"rounded",args:{radius:8}},style:$e,x6EdgeConfig:Fe()},bezier:{connector:{name:"smooth"},style:$e,x6EdgeConfig:Fe()}}}function zo(n){const e=n?.nodeTypes??Fo,o={},t=[];for(const[a,c]of Object.entries(e)){const l=c.width??150,m=c.height??50;o[a]={component:Qe,getSize:()=>({width:l,height:m}),getPorts:()=>Ue()},t.push({type:a,label:c.label??a,icon:c.icon})}const r={...Je(),...n?.edgeTypes},i=n?.defaultEdgeType??"manhattan";return{schema:{nodeTypes:o,defaultEdgeType:i,edgeTypes:r},paletteItems:t}}function Vo(n){return{name:"connection-validator",priority:10,transformCommand(e,o,t){const r=new Set;for(const i of e.commands)i.type==="edge.remove"&&r.add(i.edgeId);for(const i of e.commands){if(i.type!=="edge.add"&&i.type!=="edge.reconnect")continue;const a=t.flowModel.value,c=i.type==="edge.add"?i.edge.source.nodeId:i.source?.nodeId,l=i.type==="edge.add"?i.edge.target.nodeId:i.target?.nodeId;if(!c||!l)continue;const m=a.nodes[c],f=a.nodes[l];if(!m||!f)continue;const h=i.type==="edge.add"?i.edge.source.portId:i.source?.portId,u=i.type==="edge.add"?i.edge.target.portId:i.target?.portId,b=h?m.ports?.find(N=>N.id===h):void 0,D=u?f.ports?.find(N=>N.id===u):void 0,L=i.type==="edge.reconnect"?i.edgeId:void 0,E=Object.values(a.edges).filter(N=>N.id!==L&&!r.has(N.id)),M=n({flowModel:a,sourceNode:m,targetNode:f,sourcePort:b,targetPort:D,existingEdges:E});if(!M.valid)return{rejected:!0,reason:M.reason??"Connection validation failed",code:"validation_failed"}}return e}}}function qo(n){const{rubberband:e=!0,multiple:o=!0,movable:t=!0}=n??{};return{name:"selection",priority:90,attachRuntime(r){r.graph.use(new ct.Selection({enabled:!0,rubberband:e,multiple:o,movable:t,pointerEvents:"none",showNodeSelectionBox:!0,filter:i=>!(i.isNode()&&(i.getData?.()??{})._selectable===!1)}))}}}function Ho(n){const{tolerance:e=10,color:o="#3a84ff"}=n??{};let t=null;return{name:"snapline",priority:90,async attachRuntime(r){const{Snapline:i}=await import("@antv/x6-plugin-snapline");r.graph.use(new i({enabled:!0,tolerance:e,className:"flow-canvas-snapline"})),t=document.createElement("style"),t.textContent=`.flow-canvas-snapline line { stroke: ${o} !important; }`,document.head.appendChild(t)},detachRuntime(){t?.remove(),t=null}}}const Go={class:"flow-canvas-search-popover__input-box"},Uo=["value","placeholder"],jo={key:0,class:"flow-canvas-search-popover__no-result"},Wo={class:"flow-canvas-search-popover__counter"},Xo=["onMouseenter","onClick"],Ko={class:"flow-canvas-search-popover__item-label"},Yo=s.defineComponent({__name:"search-popover",props:{open:{type:Boolean},position:{},query:{},results:{},matchIndex:{default:-1},placeholder:{default:"搜索节点名称"},isAnchorTarget:{type:Function,default:void 0}},emits:["update:query","select","nextMatch","prevMatch","close"],setup(n,{emit:e}){const o=n,t=e,r=s.ref(null),i=s.ref(null),a=s.ref(-1);s.watch(()=>o.open,u=>{u&&(a.value=-1,s.nextTick(()=>{r.value?.focus(),r.value?.select()}))}),s.watch(()=>o.query,()=>{a.value=-1}),s.watch(()=>o.results.length,u=>{if(!u){a.value=-1;return}a.value>=u&&(a.value=-1)});function c(u){t("update:query",u.target.value)}function l(u){a.value=u}function m(){a.value=-1}function f(u){if(u.key==="Escape"){u.preventDefault(),t("close");return}if(u.key==="ArrowDown"){if(u.preventDefault(),!o.results.length)return;a.value=a.value<o.results.length-1?a.value+1:0;return}if(u.key==="ArrowUp"){if(u.preventDefault(),!o.results.length)return;a.value=a.value>0?a.value-1:o.results.length-1;return}if(u.key==="Enter"){if(u.preventDefault(),a.value>=0){const b=o.results[a.value];b&&t("select",b.id);return}u.shiftKey?t("prevMatch"):t("nextMatch")}}function h(u){if(!o.open)return;const b=u.target;b&&i.value?.contains(b)||o.isAnchorTarget?.(u.target)||t("close")}return s.onMounted(()=>{document.addEventListener("mousedown",h)}),s.onBeforeUnmount(()=>{document.removeEventListener("mousedown",h)}),(u,b)=>n.open?(s.openBlock(),s.createElementBlock("div",{key:0,ref_key:"panelRef",ref:i,class:"flow-canvas-search-popover",style:s.normalizeStyle({left:`${n.position.x}px`,top:`${n.position.y}px`,width:`${n.position.width}px`})},[s.createElementVNode("div",Go,[s.createElementVNode("input",{ref_key:"inputRef",ref:r,value:n.query,placeholder:n.placeholder,onInput:c,onKeydown:f},null,40,Uo),n.query?(s.openBlock(),s.createElementBlock(s.Fragment,{key:0},[n.results.length?(s.openBlock(),s.createElementBlock(s.Fragment,{key:1},[s.createElementVNode("button",{type:"button",class:"flow-canvas-search-popover__nav-btn","aria-label":"上一个",onClick:b[0]||(b[0]=D=>t("prevMatch"))},[...b[2]||(b[2]=[s.createElementVNode("svg",{viewBox:"0 0 16 16",width:"12",height:"12"},[s.createElementVNode("path",{d:"M10.3 12.3 6 8l4.3-4.3",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),s.createElementVNode("span",Wo,s.toDisplayString(n.matchIndex>=0?n.matchIndex+1:0)+" / "+s.toDisplayString(n.results.length),1),s.createElementVNode("button",{type:"button",class:"flow-canvas-search-popover__nav-btn","aria-label":"下一个",onClick:b[1]||(b[1]=D=>t("nextMatch"))},[...b[3]||(b[3]=[s.createElementVNode("svg",{viewBox:"0 0 16 16",width:"12",height:"12"},[s.createElementVNode("path",{d:"M5.7 3.7 10 8l-4.3 4.3",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])])],64)):(s.openBlock(),s.createElementBlock("span",jo,"无结果"))],64)):s.createCommentVNode("",!0),b[4]||(b[4]=s.createElementVNode("i",{class:"flow-canvas-icon canvas-search flow-canvas-search-popover__search-icon"},null,-1))]),n.query&&n.results.length?(s.openBlock(),s.createElementBlock("div",{key:0,class:"flow-canvas-search-popover__list-box",onMouseleave:m},[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(n.results,(D,L)=>(s.openBlock(),s.createElementBlock("button",{key:D.id,type:"button",class:s.normalizeClass(["flow-canvas-search-popover__item",{"is-active":L===a.value,"is-matched":L===n.matchIndex}]),onMouseenter:E=>l(L),onClick:E=>t("select",D.id)},[s.createElementVNode("span",Ko,s.toDisplayString(D.label),1)],42,Xo))),128))],32)):s.createCommentVNode("",!0)],4)):s.createCommentVNode("",!0)}}),Zo=se(Yo,[["__scopeId","data-v-aca2b1c1"]]),ze=282,Qo=4,Jo=300,ve="flow-canvas-node-ring-target--search-match",me="flow-canvas-node-ring-target--search-current",en="flow-canvas-node-ring-target";function tn(n){return n!==null}function on(n){const e=new Set;return n.map(o=>o?.trim()).filter(o=>!!o).filter(o=>{const t=o.toLowerCase();return e.has(t)?!1:(e.add(t),!0)})}function nn(n,e){const o=Math.max(8,window.innerWidth-e-8);return Math.min(Math.max(8,n),o)}function rn(n,e){const o=e?.getNodeMeta?.(n);if(o===null)return null;const t=o?.label?.trim()||n.label?.trim()||n.id,r=o?.subtitle?.trim()||void 0,i=on(o?.keywords??[n.label,r]);return i.length?{id:n.id,label:t,subtitle:r,keywords:i}:null}function sn(n){let e=null,o=null,t=null,r=null,i=null,a=null;const c=s.ref(!1),l=s.ref(""),m=s.ref({x:0,y:0,width:ze}),f=s.ref(-1),h=s.computed(()=>e?Object.values(e.flowModel.value.nodes).map(p=>rn(p,n)).filter(tn):[]),u=s.computed(()=>{const p=l.value.trim().toLowerCase(),v=Math.max(1,n?.maxResults??Jo);return p?h.value.filter(y=>y.keywords.some(k=>k.toLowerCase().includes(p))).slice(0,v):h.value.slice(0,v)});function b(){return t?.querySelector('.flow-canvas-toolbar__btn[data-toolbar-type="search"]')}function D(){return b()?.closest(".flow-canvas-toolbar")}function L(){const p=D(),v=t?.getBoundingClientRect(),y=p?.getBoundingClientRect()??v;if(!y)return;const k=Math.max(ze,Math.round(y.width));m.value={x:nn(y.left,k),y:y.bottom+Qo,width:k}}function E(p){if(!o)return null;const v=o.graph.getCellById(p);if(!v?.isNode())return null;const y=o.graph.findViewByCell(v)?.container;return y?y.querySelector(".flow-canvas-highlight-target")??y.querySelector(".flow-canvas-node-surface > :first-child"):null}function M(){if(!o)return;const p=o.graph.getNodes();for(const v of p){const y=E(v.id);y&&y.classList.remove(ve,me)}}function N(){if(!o)return;const p=l.value.trim().toLowerCase();if(!c.value||!p){M();return}const v=new Set(u.value.map(R=>R.id)),y=f.value>=0?u.value[f.value]?.id:null,k=o.graph.getNodes();for(const R of k){const V=E(R.id);V&&(V.classList.add(en),R.id===y?(V.classList.remove(ve),V.classList.add(me)):v.has(R.id)?(V.classList.remove(me),V.classList.add(ve)):V.classList.remove(ve,me))}}function F(p){if(!o)return;const v=u.value.findIndex(y=>y.id===p);v>=0&&(f.value=v),o.api.scrollToNode(p),N()}function G(){const p=u.value;if(p.length===0)return;const v=f.value<p.length-1?f.value+1:0;f.value=v,F(p[v].id)}function S(){const p=u.value;if(p.length===0)return;const v=f.value>0?f.value-1:p.length-1;f.value=v,F(p[v].id)}function U(){o&&(c.value=!0,L(),requestAnimationFrame(()=>L()))}function T(){c.value=!1,l.value="",f.value=-1,M()}function O(){if(c.value){T();return}U()}function g(p){const v=b();return!!(v&&p instanceof Node&&v.contains(p))}function w(){c.value&&L()}const d=s.defineComponent({name:"FlowCanvasSearchHost",setup(){return()=>s.h(Zo,{open:c.value,position:m.value,query:l.value,results:u.value,matchIndex:f.value,placeholder:n?.placeholder??"搜索节点名称",isAnchorTarget:g,"onUpdate:query":p=>{l.value=p,f.value=-1},onSelect:F,onNextMatch:G,onPrevMatch:S,onClose:T})}});return{name:"search",priority:90,install(p){e=p},attachRuntime(p){o=p,t=p.graph.container.closest(".flow-canvas-layout__content")??p.graph.container.parentElement,r=document.createElement("div"),r.className="flow-canvas-search-host",document.body.append(r),i=s.createApp(d),i.mount(r),a=s.watch(()=>[l.value,u.value.length],()=>{f.value=-1,N()}),window.addEventListener("resize",w),window.addEventListener("scroll",w,!0)},detachRuntime(){T(),a?.(),a=null,window.removeEventListener("resize",w),window.removeEventListener("scroll",w,!0),i?.unmount(),i=null,r?.remove(),r=null,t=null,o=null},dispose(){T(),a?.(),a=null,e=null},provideToolbarItems(){return[{id:"plugin:search",type:"search",icon:"flow-canvas-icon canvas-search",description:"搜索",group:"tools",order:22,active:()=>c.value,onClick:O}]}}}const Ve=52,qe=16,et=4,an=40;function ln(n){const{mountRect:e,toolbarRect:o,fallbackLeft:t,fallbackTop:r,fallbackWidth:i,height:a}=n,c=n.offset??et;return!o||o.width<=0?{left:t,top:r,width:i,height:a}:{left:Math.round(o.left-e.left),top:Math.round(o.bottom-e.top+c),width:Math.round(o.width),height:a}}function cn(n){const e=document.createElement("div");e.className="flow-canvas-minimap",n.floating!==!1&&e.classList.add("flow-canvas-minimap--floating");const o=document.createElement("div");o.className="flow-canvas-minimap__host",e.append(o),Object.assign(e.style,{width:`${n.width}px`,height:`${n.height}px`}),n.floating!==!1&&Object.assign(e.style,{top:`${Ve}px`,left:`${qe}px`});let t=null,r=n.defaultOpen??!1,i=null,a=null,c=null,l=null,m={width:n.width,height:n.height};function f(S,U){if(!t)return;const T=t;T.options.width=S,T.options.height=U,T.updatePaper(n.sourceGraph.container.clientWidth,n.sourceGraph.container.clientHeight)}function h(){if(n.floating===!1)return;const S=ln({mountRect:n.mountTarget.getBoundingClientRect(),toolbarRect:n.getToolbarElement?.()?.getBoundingClientRect()??null,fallbackLeft:qe,fallbackTop:Ve,fallbackWidth:n.width,height:n.height,offset:n.panelOffset??et});m={width:S.width,height:S.height},Object.assign(e.style,{left:`${S.left}px`,top:`${S.top}px`,width:`${S.width}px`,height:`${S.height}px`}),f(S.width,S.height)}function u(){if(n.floating===!1||typeof ResizeObserver>"u")return;const S=n.getToolbarElement?.()??null;a||(a=new ResizeObserver(()=>{r&&(u(),h())})),l!==S&&(a.disconnect(),a.observe(n.mountTarget),S&&a.observe(S),l=S)}function b(){n.floating!==!1&&(h(),u(),c||(c=()=>{r&&(u(),h())},window.addEventListener("resize",c)))}function D(){c&&(window.removeEventListener("resize",c),c=null),a?.disconnect(),a=null,l=null}function L(){!n.onClickOutside||i||(i=S=>{const U=S.target;U&&e.contains(U)||S.target?.closest('[data-toolbar-type="minimap"]')||S.target?.closest(".flow-canvas-layout__content")||n.onClickOutside()},document.addEventListener("mousedown",i))}function E(){i&&(document.removeEventListener("mousedown",i),i=null)}function M(){t||(t=new dt.MiniMap({container:o,width:m.width,height:m.height,padding:n.contentPadding??an,scalable:!1}),n.sourceGraph.use(t))}function N(S){r=S,e.style.display=r?"":"none",r?(b(),M(),L(),requestAnimationFrame(()=>{r&&(u(),h())})):(E(),D())}function F(){N(r),n.mountTarget.appendChild(e)}function G(){E(),D(),t?.dispose(),t=null,e.remove()}return F(),{element:e,isOpen:()=>r,setOpen:N,toggle(){const S=!r;return N(S),S},destroy:G}}function dn(n){let e=null,o=null;const t=s.ref(!1);function r(){return o?.querySelector('.flow-canvas-toolbar__btn[data-toolbar-type="minimap"]')}function i(){return r()?.closest(".flow-canvas-toolbar")}function a(l){e?.setOpen(l),t.value=l}function c(){e&&(t.value=e.toggle())}return{name:"minimap",priority:90,attachRuntime(l){const m=l,f=n?.width??334,h=n?.height??180;o=m.graph.container.closest(".flow-canvas-layout__content")??m.graph.container.parentElement;const u=n?.container??o;u&&(e=cn({sourceGraph:l.graph,mountTarget:u,width:f,height:h,floating:!n?.container,defaultOpen:!1,getToolbarElement:n?.container?void 0:i,onClickOutside:()=>a(!1)}),a(!1))},detachRuntime(){e?.destroy(),e=null,o=null,t.value=!1},provideToolbarItems(){return[{id:"plugin:minimap",type:"minimap",icon:"flow-canvas-icon canvas-map",description:"小地图",group:"tools",order:23,active:()=>t.value,onClick:c}]}}}function un(){let n=null,e=0;return{name:"clipboard",priority:90,onKeyboardShortcut(o,t){const r=o.metaKey||o.ctrlKey;if(r&&o.key==="c"){const i=t.graph.getSelectedCells?.()??[];if(!i.length)return!1;const a=t.flowModel.value,c=new Set(i.filter(f=>f.isNode()).map(f=>f.id)),l=[...c].map(f=>a.nodes[f]).filter(Boolean);if(!l.length)return!1;const m=Object.values(a.edges).filter(f=>c.has(f.source.nodeId)&&c.has(f.target.nodeId));return n={nodes:l,edges:m},e=0,!0}if(r&&o.key==="v"){if(!n?.nodes.length)return!1;e++;const i=e*30,a=new Map,c=[];for(const l of n.nodes){const m=`${l.id}_cp${W().slice(0,6)}`;a.set(l.id,m),c.push({type:"node.add",node:{...l,id:m,position:{x:l.position.x+i,y:l.position.y+i},payload:l.payload?{...l.payload}:{},extensions:l.extensions?{...l.extensions}:void 0}})}for(const l of n.edges){const m=a.get(l.source.nodeId),f=a.get(l.target.nodeId);!m||!f||c.push({type:"edge.add",edge:{...l,id:`${l.id}_cp${W().slice(0,6)}`,source:{...l.source,nodeId:m},target:{...l.target,nodeId:f},labels:l.labels?.map(h=>({...h,id:`${h.id}_cp${W().slice(0,6)}`})),payload:l.payload?{...l.payload}:{}}})}return c.length&&t.executeCommand({id:W(),source:"user:keyboard",label:"粘贴",timestamp:Date.now(),commands:c}),!0}return!1}}}exports.CanvasConstraintError=te;exports.CanvasLayout=xo;exports.CanvasNodePalette=Ye;exports.CanvasRuntime=po;exports.CanvasSchemaError=He;exports.CanvasToolbar=To;exports.DefaultNode=Qe;exports.NodeActionsToolbar=Xe;exports.NodeQuickAddPopover=Ke;exports.applyCanvasCommand=Ie;exports.clipboardPlugin=un;exports.connectionValidatorPlugin=Vo;exports.createBuiltinEdgeTypes=Je;exports.createCanvasHistory=Ge;exports.createDefaultSchema=zo;exports.createDefaultToolbarItems=Ze;exports.createEmptyFlowModel=ut;exports.generateId=W;exports.minimapPlugin=dn;exports.searchPlugin=sn;exports.selectionPlugin=qo;exports.snaplinePlugin=Ho;exports.useCanvasEditor=Mt;
package/dist/index.d.ts CHANGED
@@ -224,6 +224,8 @@ interface CanvasHistory {
224
224
  clear(): void;
225
225
  createSnapshot(): FlowModel;
226
226
  replaceFlowModel(model: FlowModel): void;
227
+ /** 更新 FlowModel,同时保留历史栈(当前状态入 undo 栈)。 */
228
+ updateFlowModel(model: FlowModel, label?: string): void;
227
229
  }
228
230
  interface CanvasHistoryOptions {
229
231
  maxHistorySize?: number;
@@ -267,9 +269,20 @@ interface NodeDecoration {
267
269
  };
268
270
  borderColor?: string;
269
271
  }
272
+ interface EdgeGradientStop {
273
+ offset: number;
274
+ color: string;
275
+ opacity?: number;
276
+ }
277
+ interface EdgeStrokeGradient {
278
+ type: 'linearGradient';
279
+ stops: EdgeGradientStop[];
280
+ attrs?: Record<string, unknown>;
281
+ }
270
282
  interface EdgeDecoration {
271
283
  className?: string;
272
- strokeColor?: string;
284
+ strokeColor?: string | EdgeStrokeGradient;
285
+ targetMarkerColor?: string;
273
286
  }
274
287
  interface ContextMenuItem {
275
288
  id: string;
@@ -628,6 +641,8 @@ interface CanvasEditorContext {
628
641
  idGenerator: IdGenerator;
629
642
  executeCommand(envelope: CommandEnvelope): CommandExecutionResult;
630
643
  replaceFlowModel(model: FlowModel): void;
644
+ /** 更新 FlowModel,同时保留历史栈(当前状态入 undo 栈),支持撤销。 */
645
+ updateFlowModel(model: FlowModel, label?: string): void;
631
646
  setMode(mode: CanvasMode): void;
632
647
  /** 框选模式:开启后左键拖拽画布空白区域为框选,关闭时为画布平移 */
633
648
  selectionMode: Ref<boolean>;
@@ -679,7 +694,10 @@ type __VLS_Slots$2 = {
679
694
  closePopover: () => void;
680
695
  }) => unknown;
681
696
  };
682
- declare const __VLS_base$2: vue.DefineComponent<__VLS_Props$5, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
697
+ declare function resetHoverState(): void;
698
+ declare const __VLS_base$2: vue.DefineComponent<__VLS_Props$5, {
699
+ resetHoverState: typeof resetHoverState;
700
+ }, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
683
701
  "ui-event": (event: CanvasUiEvent) => any;
684
702
  }, string, vue.PublicProps, Readonly<__VLS_Props$5> & Readonly<{
685
703
  "onUi-event"?: ((event: CanvasUiEvent) => any) | undefined;
@@ -874,7 +892,6 @@ interface SearchNodeMeta {
874
892
  }
875
893
  interface SearchPluginOptions {
876
894
  placeholder?: string;
877
- emptyText?: string;
878
895
  maxResults?: number;
879
896
  getNodeMeta?: (node: FlowNodeModel) => SearchNodeMeta | null | undefined;
880
897
  }