jbxl-workflow
Version:
流程图
1,258 lines • 1.15 MB
JavaScript
var lm = Object.defineProperty;
var od = (e) => {
throw TypeError(e);
};
var im = (e, t, n) => t in e ? lm(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
var Mr = (e, t, n) => im(e, typeof t != "symbol" ? t + "" : t, n), rd = (e, t, n) => t.has(e) || od("Cannot " + n);
var sd = (e, t, n) => (rd(e, t, "read from private field"), n ? n.call(e) : t.get(e)), ld = (e, t, n) => t.has(e) ? od("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), id = (e, t, n, a) => (rd(e, t, "write to private field"), a ? a.call(e, n) : t.set(e, n), n);
import { Graph as $e, Basecoat as co, ObjectExt as Xa, FunctionExt as Wn, Model as um, View as ei, Dom as xe, Collection as cm, Rectangle as Za, Cell as dm, CssLoader as Ml, ModifierKey as iu, Disposable as ti, Node as tc, Markup as fm, NodeView as zp, GraphView as pm, Platform as zs, NumberExt as Rr, Point as Go, Util as ud, BackgroundManager as hm, Config as vm } from "@antv/x6";
import { ref as A, defineComponent as ie, computed as D, createElementBlock as V, openBlock as N, mergeProps as Kt, unref as u, renderSlot as fe, useAttrs as da, useSlots as Kn, shallowRef as _n, watch as me, nextTick as Ve, onMounted as dt, toRef as _t, normalizeStyle as Ge, normalizeClass as z, createCommentVNode as se, Fragment as Ae, createElementVNode as M, createBlock as le, withCtx as Z, resolveDynamicComponent as Rt, withModifiers as Ue, createVNode as Q, toDisplayString as pe, provide as Nt, reactive as an, onActivated as gm, onUpdated as bs, inject as Oe, onBeforeUnmount as vn, withDirectives as lt, cloneVNode as mm, Text as Up, Comment as Hp, Transition as za, vShow as Ft, readonly as nc, onDeactivated as bm, isRef as Gt, vModelCheckbox as Rl, createTextVNode as ot, toRefs as fo, toHandlers as ym, renderList as et, h as He, createSlots as Ua, withKeys as ln, getCurrentInstance as ct, watchEffect as La, onUnmounted as wo, onBeforeMount as ac, toRaw as uu, warn as wm, getCurrentScope as Cm, onScopeDispose as Kp, resolveComponent as Et, resolveDirective as oc, Teleport as Sm, toHandlerKey as km, vModelText as xm, isVNode as cu, render as Il, normalizeProps as Tm, guardReactiveProps as Em, createApp as Pm } from "vue";
import { ElTooltip as pn, ElPopover as os, ElMessage as Bt, ElForm as ur, ElFormItem as tn, ElTreeSelect as Nm, ElCheckbox as cr, ElUpload as Dm, ElIcon as Am, ElImage as jp, ElImageViewer as _m, ElLoading as Wp, ElRadioGroup as Om, ElRadio as Mm, ElRow as Rm, ElCol as cd, ElSwitch as Im, ClickOutside as Lm, ElSlider as dd, ElCheckboxGroup as Fm, ElMessageBox as Bm } from "element-plus";
import Me from "dayjs";
$e.prototype.isHistoryEnabled = function() {
const e = this.getPlugin("history");
return e ? e.isEnabled() : !1;
};
$e.prototype.enableHistory = function() {
const e = this.getPlugin("history");
return e && e.enable(), this;
};
$e.prototype.disableHistory = function() {
const e = this.getPlugin("history");
return e && e.disable(), this;
};
$e.prototype.toggleHistory = function(e) {
const t = this.getPlugin("history");
return t && t.toggleEnabled(e), this;
};
$e.prototype.undo = function(e) {
const t = this.getPlugin("history");
return t && t.undo(e), this;
};
$e.prototype.redo = function(e) {
const t = this.getPlugin("history");
return t && t.redo(e), this;
};
$e.prototype.undoAndCancel = function(e) {
const t = this.getPlugin("history");
return t && t.cancel(e), this;
};
$e.prototype.canUndo = function() {
const e = this.getPlugin("history");
return e ? e.canUndo() : !1;
};
$e.prototype.canRedo = function() {
const e = this.getPlugin("history");
return e ? e.canRedo() : !1;
};
$e.prototype.cleanHistory = function(e) {
const t = this.getPlugin("history");
return t && t.clean(e), this;
};
$e.prototype.getHistoryStackSize = function() {
return this.getPlugin("history").getSize();
};
$e.prototype.getUndoStackSize = function() {
return this.getPlugin("history").getUndoSize();
};
$e.prototype.getRedoStackSize = function() {
return this.getPlugin("history").getRedoSize();
};
$e.prototype.getUndoRemainSize = function() {
return this.getPlugin("history").getUndoRemainSize();
};
var Yp = function(e, t, n, a) {
var o = arguments.length, r = o < 3 ? t : a === null ? a = Object.getOwnPropertyDescriptor(t, n) : a, s;
if (typeof Reflect == "object" && typeof Reflect.decorate == "function") r = Reflect.decorate(e, t, n, a);
else for (var l = e.length - 1; l >= 0; l--) (s = e[l]) && (r = (o < 3 ? s(r) : o > 3 ? s(t, n, r) : s(t, n)) || r);
return o > 3 && r && Object.defineProperty(t, n, r), r;
};
class dr extends co {
constructor(t = {}) {
super(), this.name = "history", this.batchCommands = null, this.batchLevel = 0, this.lastBatchIndex = -1, this.freezed = !1, this.stackSize = 0, this.handlers = [];
const { stackSize: n = 0 } = t;
this.stackSize = n, this.options = Vt.getOptions(t), this.validator = new dr.Validator({
history: this,
cancelInvalid: this.options.cancelInvalid
});
}
init(t) {
this.graph = t, this.model = this.graph.model, this.clean(), this.startListening();
}
// #region api
isEnabled() {
return !this.disabled;
}
enable() {
this.disabled && (this.options.enabled = !0);
}
disable() {
this.disabled || (this.options.enabled = !1);
}
toggleEnabled(t) {
return t != null ? t !== this.isEnabled() && (t ? this.enable() : this.disable()) : this.isEnabled() ? this.disable() : this.enable(), this;
}
undo(t = {}) {
if (!this.disabled) {
const n = this.undoStack.pop();
n && (this.revertCommand(n, t), this.redoStack.push(n), this.notify("undo", n, t));
}
return this;
}
redo(t = {}) {
if (!this.disabled) {
const n = this.redoStack.pop();
n && (this.applyCommand(n, t), this.undoStackPush(n), this.notify("redo", n, t));
}
return this;
}
/**
* Same as `undo()` but does not store the undo-ed command to the
* `redoStack`. Canceled command therefore cannot be redo-ed.
*/
cancel(t = {}) {
if (!this.disabled) {
const n = this.undoStack.pop();
n && (this.revertCommand(n, t), this.redoStack = [], this.notify("cancel", n, t));
}
return this;
}
getSize() {
return this.stackSize;
}
getUndoRemainSize() {
const t = this.undoStack.length;
return this.stackSize - t;
}
getUndoSize() {
return this.undoStack.length;
}
getRedoSize() {
return this.redoStack.length;
}
canUndo() {
return !this.disabled && this.undoStack.length > 0;
}
canRedo() {
return !this.disabled && this.redoStack.length > 0;
}
clean(t = {}) {
return this.undoStack = [], this.redoStack = [], this.notify("clean", null, t), this;
}
// #endregion
get disabled() {
return this.options.enabled !== !0;
}
validate(t, ...n) {
return this.validator.validate(t, ...n), this;
}
startListening() {
this.model.on("batch:start", this.initBatchCommand, this), this.model.on("batch:stop", this.storeBatchCommand, this), this.options.eventNames && this.options.eventNames.forEach((t, n) => {
this.handlers[n] = this.addCommand.bind(this, t), this.model.on(t, this.handlers[n]);
}), this.validator.on("invalid", (t) => this.trigger("invalid", t));
}
stopListening() {
this.model.off("batch:start", this.initBatchCommand, this), this.model.off("batch:stop", this.storeBatchCommand, this), this.options.eventNames && (this.options.eventNames.forEach((t, n) => {
this.model.off(t, this.handlers[n]);
}), this.handlers.length = 0), this.validator.off("invalid");
}
createCommand(t) {
return {
batch: t ? t.batch : !1,
data: {}
};
}
revertCommand(t, n) {
this.freezed = !0;
const a = Array.isArray(t) ? Vt.sortBatchCommands(t) : [t];
for (let o = a.length - 1; o >= 0; o -= 1) {
const r = a[o], s = Object.assign(Object.assign({}, n), Xa.pick(r.options, this.options.revertOptionsList || []));
this.executeCommand(r, !0, s);
}
this.freezed = !1;
}
applyCommand(t, n) {
this.freezed = !0;
const a = Array.isArray(t) ? Vt.sortBatchCommands(t) : [t];
for (let o = 0; o < a.length; o += 1) {
const r = a[o], s = Object.assign(Object.assign({}, n), Xa.pick(r.options, this.options.applyOptionsList || []));
this.executeCommand(r, !1, s);
}
this.freezed = !1;
}
executeCommand(t, n, a) {
const o = this.model, r = o.getCell(t.data.id), s = t.event;
if (Vt.isAddEvent(s) && n || Vt.isRemoveEvent(s) && !n)
r && r.remove(a);
else if (Vt.isAddEvent(s) && !n || Vt.isRemoveEvent(s) && n) {
const l = t.data;
l.node ? o.addNode(l.props, a) : l.edge && o.addEdge(l.props, a);
} else if (Vt.isChangeEvent(s)) {
const l = t.data, i = l.key;
if (i && r) {
const c = n ? l.prev[i] : l.next[i];
l.key === "attrs" && this.ensureUndefinedAttrs(c, n ? l.next[i] : l.prev[i]) && (a.dirty = !0), r.prop(i, c, a);
}
} else {
const l = this.options.executeCommand;
l && Wn.call(l, this, t, n, a);
}
}
addCommand(t, n) {
if (this.freezed || this.disabled)
return;
const a = n, o = a.options || {};
if (o.dryrun || Vt.isAddEvent(t) && this.options.ignoreAdd || Vt.isRemoveEvent(t) && this.options.ignoreRemove || Vt.isChangeEvent(t) && this.options.ignoreChange)
return;
const r = this.options.beforeAddCommand;
if (r != null && Wn.call(r, this, t, n) === !1)
return;
t === "cell:change:*" && (t = `cell:change:${a.key}`);
const s = a.cell, l = um.isModel(s);
let i;
if (this.batchCommands) {
i = this.batchCommands[Math.max(this.lastBatchIndex, 0)];
const d = l && !i.modelChange || i.data.id !== s.id, f = i.event !== t;
if (this.lastBatchIndex >= 0 && (d || f)) {
const p = this.batchCommands.findIndex((v) => (l && v.modelChange || v.data.id === s.id) && v.event === t);
p < 0 || Vt.isAddEvent(t) || Vt.isRemoveEvent(t) ? i = this.createCommand({ batch: !0 }) : (i = this.batchCommands[p], this.batchCommands.splice(p, 1)), this.batchCommands.push(i), this.lastBatchIndex = this.batchCommands.length - 1;
}
} else
i = this.createCommand({ batch: !1 });
if (Vt.isAddEvent(t) || Vt.isRemoveEvent(t)) {
const d = i.data;
return i.event = t, i.options = o, d.id = s.id, d.props = Xa.cloneDeep(s.toJSON()), s.isEdge() ? d.edge = !0 : s.isNode() && (d.node = !0), this.push(i, o);
}
if (Vt.isChangeEvent(t)) {
const d = n.key, f = i.data;
return (!i.batch || !i.event) && (i.event = t, i.options = o, f.key = d, f.prev == null && (f.prev = {}), f.prev[d] = Xa.cloneDeep(s.previous(d)), l ? i.modelChange = !0 : f.id = s.id), f.next == null && (f.next = {}), f.next[d] = Xa.cloneDeep(s.prop(d)), this.push(i, o);
}
const c = this.options.afterAddCommand;
c && Wn.call(c, this, t, n, i), this.push(i, o);
}
/**
* Gather multiple changes into a single command. These commands could
* be reverted with single `undo()` call. From the moment the function
* is called every change made on model is not stored into the undoStack.
* Changes are temporarily kept until `storeBatchCommand()` is called.
*/
// eslint-disable-next-line
initBatchCommand(t) {
this.freezed || (this.batchCommands ? this.batchLevel += 1 : (this.batchCommands = [this.createCommand({ batch: !0 })], this.batchLevel = 0, this.lastBatchIndex = -1));
}
/**
* Store changes temporarily kept in the undoStack. You have to call this
* function as many times as `initBatchCommand()` been called.
*/
storeBatchCommand(t) {
if (!this.freezed)
if (this.batchCommands && this.batchLevel <= 0) {
const n = this.filterBatchCommand(this.batchCommands);
n.length > 0 && (this.redoStack = [], this.undoStackPush(n), this.consolidateCommands(), this.notify("add", n, t)), this.batchCommands = null, this.lastBatchIndex = -1, this.batchLevel = 0;
} else this.batchCommands && this.batchLevel > 0 && (this.batchLevel -= 1);
}
filterBatchCommand(t) {
let n = t.slice();
const a = [];
for (; n.length > 0; ) {
const o = n.shift(), r = o.event, s = o.data.id;
if (r != null && (s != null || o.modelChange)) {
if (Vt.isAddEvent(r)) {
const l = n.findIndex((i) => Vt.isRemoveEvent(i.event) && i.data.id === s);
if (l >= 0) {
n = n.filter((i, c) => l < c || i.data.id !== s);
continue;
}
} else if (Vt.isRemoveEvent(r)) {
const l = n.findIndex((i) => Vt.isAddEvent(i.event) && i.data.id === s);
if (l >= 0) {
n.splice(l, 1);
continue;
}
} else if (Vt.isChangeEvent(r)) {
const l = o.data;
if (Xa.isEqual(l.prev, l.next))
continue;
}
a.push(o);
}
}
return a;
}
notify(t, n, a) {
const o = n == null ? null : Array.isArray(n) ? n : [n];
this.emit(t, { cmds: o, options: a }), this.graph.trigger(`history:${t}`, { cmds: o, options: a }), this.emit("change", { cmds: o, options: a }), this.graph.trigger("history:change", { cmds: o, options: a });
}
push(t, n) {
this.redoStack = [], t.batch ? (this.lastBatchIndex = Math.max(this.lastBatchIndex, 0), this.emit("batch", { cmd: t, options: n })) : (this.undoStackPush(t), this.consolidateCommands(), this.notify("add", t, n));
}
/**
* Conditionally combine multiple undo items into one.
*
* Currently this is only used combine a `cell:changed:position` event
* followed by multiple `cell:change:parent` and `cell:change:children`
* events, such that a "move + embed" action can be undone in one step.
*
* See https://github.com/antvis/X6/issues/2421
*
* This is an ugly WORKAROUND. It does not solve deficiencies in the batch
* system itself.
*/
consolidateCommands() {
var t;
const n = this.undoStack[this.undoStack.length - 1], a = this.undoStack[this.undoStack.length - 2];
if (!Array.isArray(n))
return;
const o = new Set(n.map((s) => s.event));
if (o.size !== 2 || !o.has("cell:change:parent") || !o.has("cell:change:children") || !n.every((s) => {
var l;
return s.batch && ((l = s.options) === null || l === void 0 ? void 0 : l.ui);
}) || !Array.isArray(a) || a.length !== 1)
return;
const r = a[0];
r.event !== "cell:change:position" || !(!((t = r.options) === null || t === void 0) && t.ui) || (a.push(...n), this.undoStack.pop());
}
undoStackPush(t) {
if (this.stackSize === 0) {
this.undoStack.push(t);
return;
}
this.undoStack.length >= this.stackSize && this.undoStack.shift(), this.undoStack.push(t);
}
ensureUndefinedAttrs(t, n) {
let a = !1;
return t !== null && n !== null && typeof t == "object" && typeof n == "object" && Object.keys(n).forEach((o) => {
t[o] === void 0 && n[o] !== void 0 ? (t[o] = void 0, a = !0) : typeof t[o] == "object" && typeof n[o] == "object" && (a = this.ensureUndefinedAttrs(t[o], n[o]));
}), a;
}
dispose() {
this.validator.dispose(), this.clean(), this.stopListening(), this.off();
}
}
Yp([
co.dispose()
], dr.prototype, "dispose", null);
(function(e) {
class t extends co {
constructor(a) {
super(), this.map = {}, this.command = a.history, this.cancelInvalid = a.cancelInvalid !== !1, this.command.on("add", this.onCommandAdded, this);
}
onCommandAdded({ cmds: a }) {
return Array.isArray(a) ? a.every((o) => this.isValidCommand(o)) : this.isValidCommand(a);
}
isValidCommand(a) {
if (a.options && a.options.validation === !1)
return !0;
const o = a.event && this.map[a.event] || [];
let r = null;
return o.forEach((s) => {
let l = 0;
const i = (c) => {
const d = s[l];
l += 1;
try {
if (d)
d(c, a, i);
else {
r = c;
return;
}
} catch (f) {
i(f);
}
};
i(r);
}), r ? (this.cancelInvalid && this.command.cancel(), this.emit("invalid", { err: r }), !1) : !0;
}
validate(a, ...o) {
const r = Array.isArray(a) ? a : a.split(/\s+/);
return o.forEach((s) => {
if (typeof s != "function")
throw new Error(`${r.join(" ")} requires callback functions.`);
}), r.forEach((s) => {
this.map[s] == null && (this.map[s] = []), this.map[s].push(o);
}), this;
}
dispose() {
this.command.off("add", this.onCommandAdded, this);
}
}
Yp([
co.dispose()
], t.prototype, "dispose", null), e.Validator = t;
})(dr || (dr = {}));
var Vt;
(function(e) {
function t(s) {
return s === "cell:added";
}
e.isAddEvent = t;
function n(s) {
return s === "cell:removed";
}
e.isRemoveEvent = n;
function a(s) {
return s != null && s.startsWith("cell:change:");
}
e.isChangeEvent = a;
function o(s) {
const l = [
"cell:added",
"cell:removed",
"cell:change:*"
], i = ["batch:start", "batch:stop"], c = s.eventNames ? s.eventNames.filter((d) => !(e.isChangeEvent(d) || l.includes(d) || i.includes(d))) : l;
return Object.assign(Object.assign({ enabled: !0 }, s), { eventNames: c, applyOptionsList: s.applyOptionsList || ["propertyPath"], revertOptionsList: s.revertOptionsList || ["propertyPath"] });
}
e.getOptions = o;
function r(s) {
const l = [];
for (let i = 0, c = s.length; i < c; i += 1) {
const d = s[i];
let f = null;
if (e.isAddEvent(d.event)) {
const p = d.data.id;
for (let v = 0; v < i; v += 1)
if (s[v].data.id === p) {
f = v;
break;
}
}
f !== null ? l.splice(f, 0, d) : l.push(d);
}
return l;
}
e.sortBatchCommands = r;
})(Vt || (Vt = {}));
var Vm = function(e, t, n, a) {
var o = arguments.length, r = o < 3 ? t : a === null ? a = Object.getOwnPropertyDescriptor(t, n) : a, s;
if (typeof Reflect == "object" && typeof Reflect.decorate == "function") r = Reflect.decorate(e, t, n, a);
else for (var l = e.length - 1; l >= 0; l--) (s = e[l]) && (r = (o < 3 ? s(r) : o > 3 ? s(t, n, r) : s(t, n)) || r);
return o > 3 && r && Object.defineProperty(t, n, r), r;
};
class Gp extends ei {
get graph() {
return this.options.graph;
}
get boxClassName() {
return this.prefixClassName(Pn.classNames.box);
}
get $boxes() {
return xe.children(this.container, this.boxClassName);
}
get handleOptions() {
return this.options;
}
constructor(t) {
super(), this.options = t, this.options.model && (this.options.collection = this.options.model.collection), this.options.collection ? this.collection = this.options.collection : (this.collection = new cm([], {
comparator: Pn.depthComparator
}), this.options.collection = this.collection), this.boxCount = 0, this.createContainer(), this.startListening();
}
startListening() {
const t = this.graph, n = this.collection;
this.delegateEvents({
[`mousedown .${this.boxClassName}`]: "onSelectionBoxMouseDown",
[`touchstart .${this.boxClassName}`]: "onSelectionBoxMouseDown"
}, !0), t.on("scale", this.onGraphTransformed, this), t.on("translate", this.onGraphTransformed, this), t.model.on("updated", this.onModelUpdated, this), n.on("added", this.onCellAdded, this), n.on("removed", this.onCellRemoved, this), n.on("reseted", this.onReseted, this), n.on("updated", this.onCollectionUpdated, this), n.on("node:change:position", this.onNodePositionChanged, this), n.on("cell:changed", this.onCellChanged, this);
}
stopListening() {
const t = this.graph, n = this.collection;
this.undelegateEvents(), t.off("scale", this.onGraphTransformed, this), t.off("translate", this.onGraphTransformed, this), t.model.off("updated", this.onModelUpdated, this), n.off("added", this.onCellAdded, this), n.off("removed", this.onCellRemoved, this), n.off("reseted", this.onReseted, this), n.off("updated", this.onCollectionUpdated, this), n.off("node:change:position", this.onNodePositionChanged, this), n.off("cell:changed", this.onCellChanged, this);
}
onRemove() {
this.stopListening();
}
onGraphTransformed() {
this.updateSelectionBoxes();
}
onCellChanged() {
this.updateSelectionBoxes();
}
onNodePositionChanged({ node: t, options: n }) {
const { showNodeSelectionBox: a, pointerEvents: o } = this.options, { ui: r, selection: s, translateBy: l, snapped: i } = n, c = (a !== !0 || o && this.getPointerEventsValue(o) === "none") && !this.translating && !s, d = r && l && t.id === l;
if (c && (d || i)) {
this.translating = !0;
const f = t.position(), p = t.previous("position"), v = f.x - p.x, h = f.y - p.y;
(v !== 0 || h !== 0) && this.translateSelectedNodes(v, h, t, n), this.translating = !1;
}
}
onModelUpdated({ removed: t }) {
t && t.length && this.unselect(t);
}
isEmpty() {
return this.length <= 0;
}
isSelected(t) {
return this.collection.has(t);
}
get length() {
return this.collection.length;
}
get cells() {
return this.collection.toArray();
}
select(t, n = {}) {
n.dryrun = !0;
const a = this.filter(Array.isArray(t) ? t : [t]);
return this.collection.add(a, n), this;
}
unselect(t, n = {}) {
return n.dryrun = !0, this.collection.remove(Array.isArray(t) ? t : [t], n), this;
}
reset(t, n = {}) {
if (t) {
if (n.batch) {
const c = this.filter(Array.isArray(t) ? t : [t]);
return this.collection.reset(c, Object.assign(Object.assign({}, n), { ui: !0 })), this;
}
const a = this.cells, o = this.filter(Array.isArray(t) ? t : [t]), r = {}, s = {};
a.forEach((c) => r[c.id] = c), o.forEach((c) => s[c.id] = c);
const l = [], i = [];
return o.forEach((c) => {
r[c.id] || l.push(c);
}), a.forEach((c) => {
s[c.id] || i.push(c);
}), i.length && this.unselect(i, Object.assign(Object.assign({}, n), { ui: !0 })), l.length && this.select(l, Object.assign(Object.assign({}, n), { ui: !0 })), i.length === 0 && l.length === 0 && this.updateContainer(), this;
}
return this.clean(n);
}
clean(t = {}) {
return this.length && (t.batch === !1 ? this.unselect(this.cells, t) : this.collection.reset([], Object.assign(Object.assign({}, t), { ui: !0 }))), this;
}
setFilter(t) {
this.options.filter = t;
}
setContent(t) {
this.options.content = t;
}
startSelecting(t) {
t = this.normalizeEvent(t), this.clean();
let n, a;
const o = this.graph.container;
if (t.offsetX != null && t.offsetY != null && o.contains(t.target))
n = t.offsetX, a = t.offsetY;
else {
const r = xe.offset(o), s = o.scrollLeft, l = o.scrollTop;
n = t.clientX - r.left + window.pageXOffset + s, a = t.clientY - r.top + window.pageYOffset + l;
}
xe.css(this.container, {
top: a,
left: n,
width: 1,
height: 1
}), this.setEventData(t, {
action: "selecting",
clientX: t.clientX,
clientY: t.clientY,
offsetX: n,
offsetY: a,
scrollerX: 0,
scrollerY: 0,
moving: !1
}), this.delegateDocumentEvents(Pn.documentEvents, t.data);
}
filter(t) {
const n = this.options.filter;
return t.filter((a) => Array.isArray(n) ? n.some((o) => typeof o == "string" ? a.shape === o : a.id === o.id) : typeof n == "function" ? Wn.call(n, this.graph, a) : !0);
}
stopSelecting(t) {
const n = this.graph, a = this.getEventData(t);
switch (a.action) {
case "selecting": {
let r = xe.width(this.container), s = xe.height(this.container);
const l = xe.offset(this.container), i = n.pageToLocal(l.left, l.top), c = n.transform.getScale();
r /= c.sx, s /= c.sy;
const d = new Za(i.x, i.y, r, s), f = this.getCellViewsInArea(d).map((p) => p.cell);
this.reset(f, { batch: !0 }), this.hideRubberband();
break;
}
case "translating": {
const r = n.snapToGrid(t.clientX, t.clientY);
if (!this.options.following) {
const s = a;
this.updateSelectedNodesPosition({
dx: s.clientX - s.originX,
dy: s.clientY - s.originY
});
}
this.graph.model.stopBatch("move-selection"), this.notifyBoxEvent("box:mouseup", t, r.x, r.y);
break;
}
default: {
this.clean();
break;
}
}
}
onMouseUp(t) {
this.getEventData(t).action && (this.stopSelecting(t), this.undelegateDocumentEvents());
}
onSelectionBoxMouseDown(t) {
this.options.following || t.stopPropagation();
const n = this.normalizeEvent(t);
this.options.movable && this.startTranslating(n);
const a = this.getCellViewFromElem(n.target);
this.setEventData(n, { activeView: a });
const o = this.graph.snapToGrid(n.clientX, n.clientY);
this.notifyBoxEvent("box:mousedown", n, o.x, o.y), this.delegateDocumentEvents(Pn.documentEvents, n.data);
}
startTranslating(t) {
this.graph.model.startBatch("move-selection");
const n = this.graph.snapToGrid(t.clientX, t.clientY);
this.setEventData(t, {
action: "translating",
clientX: n.x,
clientY: n.y,
originX: n.x,
originY: n.y
});
}
getRestrictArea() {
const t = this.graph.options.translating.restrict, n = typeof t == "function" ? Wn.call(t, this.graph, null) : t;
return typeof n == "number" ? this.graph.transform.getGraphArea().inflate(n) : n === !0 ? this.graph.transform.getGraphArea() : n || null;
}
getSelectionOffset(t, n) {
let a = t.x - n.clientX, o = t.y - n.clientY;
const r = this.getRestrictArea();
if (r) {
const s = this.collection.toArray(), l = dm.getCellsBBox(s, { deep: !0 }) || Za.create(), i = r.x - l.x, c = r.y - l.y, d = r.x + r.width - (l.x + l.width), f = r.y + r.height - (l.y + l.height);
if (a < i && (a = i), o < c && (o = c), d < a && (a = d), f < o && (o = f), !this.options.following) {
const p = t.x - n.originX, v = t.y - n.originY;
a = p <= i || p >= d ? 0 : a, o = v <= c || v >= f ? 0 : o;
}
}
return {
dx: a,
dy: o
};
}
updateElementPosition(t, n, a) {
const o = xe.css(t, "left"), r = xe.css(t, "top"), s = o ? parseFloat(o) : 0, l = r ? parseFloat(r) : 0;
xe.css(t, "left", s + n), xe.css(t, "top", l + a);
}
updateSelectedNodesPosition(t) {
const { dx: n, dy: a } = t;
if (n || a)
if (this.translateSelectedNodes(n, a), this.boxesUpdated)
this.collection.length > 1 && this.updateSelectionBoxes();
else {
const o = this.graph.transform.getScale();
for (let r = 0, s = this.$boxes, l = s.length; r < l; r += 1)
this.updateElementPosition(s[r], n * o.sx, a * o.sy);
this.updateElementPosition(this.selectionContainer, n * o.sx, a * o.sy);
}
}
autoScrollGraph(t, n) {
const a = this.graph.getPlugin("scroller");
return a ? a.autoScroll(t, n) : { scrollerX: 0, scrollerY: 0 };
}
adjustSelection(t) {
const n = this.normalizeEvent(t), a = this.getEventData(n);
switch (a.action) {
case "selecting": {
const r = a;
r.moving !== !0 && (xe.appendTo(this.container, this.graph.container), this.showRubberband(), r.moving = !0);
const { scrollerX: s, scrollerY: l } = this.autoScrollGraph(n.clientX, n.clientY);
r.scrollerX += s, r.scrollerY += l;
const i = n.clientX - r.clientX + r.scrollerX, c = n.clientY - r.clientY + r.scrollerY, d = parseInt(xe.css(this.container, "left") || "0", 10), f = parseInt(xe.css(this.container, "top") || "0", 10);
xe.css(this.container, {
left: i < 0 ? r.offsetX + i : d,
top: c < 0 ? r.offsetY + c : f,
width: Math.abs(i),
height: Math.abs(c)
});
break;
}
case "translating": {
const r = this.graph.snapToGrid(n.clientX, n.clientY), s = a, l = this.getSelectionOffset(r, s);
this.options.following ? this.updateSelectedNodesPosition(l) : this.updateContainerPosition(l), l.dx && (s.clientX = r.x), l.dy && (s.clientY = r.y), this.notifyBoxEvent("box:mousemove", t, r.x, r.y);
break;
}
}
this.boxesUpdated = !1;
}
translateSelectedNodes(t, n, a, o) {
const r = {}, s = [];
if (a && (r[a.id] = !0), this.collection.toArray().forEach((l) => {
l.getDescendants({ deep: !0 }).forEach((i) => {
r[i.id] = !0;
});
}), o && o.translateBy) {
const l = this.graph.getCellById(o.translateBy);
l && (r[l.id] = !0, l.getDescendants({ deep: !0 }).forEach((i) => {
r[i.id] = !0;
}), s.push(l));
}
this.collection.toArray().forEach((l) => {
if (!r[l.id]) {
const i = Object.assign(Object.assign({}, o), { selection: this.cid, exclude: s });
l.translate(t, n, i), this.graph.model.getConnectedEdges(l).forEach((c) => {
r[c.id] || (c.translate(t, n, i), r[c.id] = !0);
});
}
});
}
getCellViewsInArea(t) {
const n = this.graph, a = {
strict: this.options.strict
};
let o = [];
return this.options.rubberNode && (o = o.concat(n.model.getNodesInArea(t, a).map((r) => n.renderer.findViewByCell(r)).filter((r) => r != null))), this.options.rubberEdge && (o = o.concat(n.model.getEdgesInArea(t, a).map((r) => n.renderer.findViewByCell(r)).filter((r) => r != null))), o;
}
notifyBoxEvent(t, n, a, o) {
const s = this.getEventData(n).activeView;
this.trigger(t, { e: n, view: s, x: a, y: o, cell: s.cell });
}
getSelectedClassName(t) {
return this.prefixClassName(`${t.isNode() ? "node" : "edge"}-selected`);
}
addCellSelectedClassName(t) {
const n = this.graph.renderer.findViewByCell(t);
n && n.addClass(this.getSelectedClassName(t));
}
removeCellUnSelectedClassName(t) {
const n = this.graph.renderer.findViewByCell(t);
n && n.removeClass(this.getSelectedClassName(t));
}
destroySelectionBox(t) {
this.removeCellUnSelectedClassName(t), this.canShowSelectionBox(t) && (xe.remove(this.container.querySelector(`[data-cell-id="${t.id}"]`)), this.$boxes.length === 0 && this.hide(), this.boxCount = Math.max(0, this.boxCount - 1));
}
destroyAllSelectionBoxes(t) {
t.forEach((n) => this.removeCellUnSelectedClassName(n)), this.hide(), xe.remove(this.$boxes), this.boxCount = 0;
}
hide() {
xe.removeClass(this.container, this.prefixClassName(Pn.classNames.rubberband)), xe.removeClass(this.container, this.prefixClassName(Pn.classNames.selected));
}
showRubberband() {
xe.addClass(this.container, this.prefixClassName(Pn.classNames.rubberband));
}
hideRubberband() {
xe.removeClass(this.container, this.prefixClassName(Pn.classNames.rubberband));
}
showSelected() {
xe.removeAttribute(this.container, "style"), xe.addClass(this.container, this.prefixClassName(Pn.classNames.selected));
}
createContainer() {
this.container = document.createElement("div"), xe.addClass(this.container, this.prefixClassName(Pn.classNames.root)), this.options.className && xe.addClass(this.container, this.options.className), this.selectionContainer = document.createElement("div"), xe.addClass(this.selectionContainer, this.prefixClassName(Pn.classNames.inner)), this.selectionContent = document.createElement("div"), xe.addClass(this.selectionContent, this.prefixClassName(Pn.classNames.content)), xe.append(this.selectionContainer, this.selectionContent), xe.attr(this.selectionContainer, "data-selection-length", this.collection.length), xe.prepend(this.container, this.selectionContainer);
}
updateContainerPosition(t) {
(t.dx || t.dy) && this.updateElementPosition(this.selectionContainer, t.dx, t.dy);
}
updateContainer() {
const t = { x: 1 / 0, y: 1 / 0 }, n = { x: 0, y: 0 };
this.collection.toArray().filter((r) => this.canShowSelectionBox(r)).forEach((r) => {
const s = this.graph.renderer.findViewByCell(r);
if (s) {
const l = s.getBBox({
useCellGeometry: !0
});
t.x = Math.min(t.x, l.x), t.y = Math.min(t.y, l.y), n.x = Math.max(n.x, l.x + l.width), n.y = Math.max(n.y, l.y + l.height);
}
}), xe.css(this.selectionContainer, {
position: "absolute",
pointerEvents: "none",
left: t.x,
top: t.y,
width: n.x - t.x,
height: n.y - t.y
}), xe.attr(this.selectionContainer, "data-selection-length", this.collection.length);
const o = this.options.content;
if (o)
if (typeof o == "function") {
const r = Wn.call(o, this.graph, this, this.selectionContent);
r && (this.selectionContent.innerHTML = r);
} else
this.selectionContent.innerHTML = o;
this.collection.length > 0 && !this.container.parentNode ? xe.appendTo(this.container, this.graph.container) : this.collection.length <= 0 && this.container.parentNode && this.container.parentNode.removeChild(this.container);
}
canShowSelectionBox(t) {
return t.isNode() && this.options.showNodeSelectionBox === !0 || t.isEdge() && this.options.showEdgeSelectionBox === !0;
}
getPointerEventsValue(t) {
return typeof t == "string" ? t : t(this.cells);
}
createSelectionBox(t) {
if (this.addCellSelectedClassName(t), this.canShowSelectionBox(t)) {
const n = this.graph.renderer.findViewByCell(t);
if (n) {
const a = n.getBBox({
useCellGeometry: !0
}), o = this.boxClassName, r = document.createElement("div"), s = this.options.pointerEvents;
xe.addClass(r, o), xe.addClass(r, `${o}-${t.isNode() ? "node" : "edge"}`), xe.attr(r, "data-cell-id", t.id), xe.css(r, {
position: "absolute",
left: a.x,
top: a.y,
width: a.width,
height: a.height,
pointerEvents: s ? this.getPointerEventsValue(s) : "auto"
}), xe.appendTo(r, this.container), this.showSelected(), this.boxCount += 1;
}
}
}
updateSelectionBoxes() {
this.collection.length > 0 && (this.boxesUpdated = !0, this.confirmUpdate());
}
confirmUpdate() {
if (this.boxCount) {
this.hide();
for (let t = 0, n = this.$boxes, a = n.length; t < a; t += 1) {
const o = n[t], r = xe.attr(o, "data-cell-id");
xe.remove(o), this.boxCount -= 1;
const s = this.collection.get(r);
s && this.createSelectionBox(s);
}
this.updateContainer();
}
return 0;
}
getCellViewFromElem(t) {
const n = t.getAttribute("data-cell-id");
if (n) {
const a = this.collection.get(n);
if (a)
return this.graph.renderer.findViewByCell(a);
}
return null;
}
onCellRemoved({ cell: t }) {
this.destroySelectionBox(t), this.updateContainer();
}
onReseted({ previous: t, current: n }) {
this.destroyAllSelectionBoxes(t), n.forEach((a) => {
this.listenCellRemoveEvent(a), this.createSelectionBox(a);
}), this.updateContainer();
}
onCellAdded({ cell: t }) {
this.listenCellRemoveEvent(t), this.createSelectionBox(t), this.updateContainer();
}
listenCellRemoveEvent(t) {
t.off("removed", this.onCellRemoved, this), t.on("removed", this.onCellRemoved, this);
}
onCollectionUpdated({ added: t, removed: n, options: a }) {
t.forEach((r) => {
this.trigger("cell:selected", { cell: r, options: a }), r.isNode() ? this.trigger("node:selected", { cell: r, options: a, node: r }) : r.isEdge() && this.trigger("edge:selected", { cell: r, options: a, edge: r });
}), n.forEach((r) => {
this.trigger("cell:unselected", { cell: r, options: a }), r.isNode() ? this.trigger("node:unselected", { cell: r, options: a, node: r }) : r.isEdge() && this.trigger("edge:unselected", { cell: r, options: a, edge: r });
});
const o = {
added: t,
removed: n,
options: a,
selected: this.cells.filter((r) => !!this.graph.getCellById(r.id))
};
this.trigger("selection:changed", o);
}
// #endregion
dispose() {
this.clean(), this.remove(), this.off();
}
}
Vm([
ei.dispose()
], Gp.prototype, "dispose", null);
var Pn;
(function(e) {
const t = "widget-selection";
e.classNames = {
root: t,
inner: `${t}-inner`,
box: `${t}-box`,
content: `${t}-content`,
rubberband: `${t}-rubberband`,
selected: `${t}-selected`
}, e.documentEvents = {
mousemove: "adjustSelection",
touchmove: "adjustSelection",
mouseup: "onMouseUp",
touchend: "onMouseUp",
touchcancel: "onMouseUp"
};
function n(a) {
return a.getAncestors().length;
}
e.depthComparator = n;
})(Pn || (Pn = {}));
const $m = `.x6-widget-selection {
position: absolute;
top: 0;
left: 0;
display: none;
width: 0;
height: 0;
touch-action: none;
}
.x6-widget-selection-rubberband {
display: block;
overflow: visible;
opacity: 0.3;
}
.x6-widget-selection-selected {
display: block;
}
.x6-widget-selection-box {
cursor: move;
}
.x6-widget-selection-inner[data-selection-length='0'],
.x6-widget-selection-inner[data-selection-length='1'] {
display: none;
}
.x6-widget-selection-content {
position: absolute;
top: 100%;
right: -20px;
left: -20px;
margin-top: 30px;
padding: 6px;
line-height: 14px;
text-align: center;
border-radius: 6px;
}
.x6-widget-selection-content:empty {
display: none;
}
.x6-widget-selection-rubberband {
background-color: #3498db;
border: 2px solid #2980b9;
}
.x6-widget-selection-box {
box-sizing: content-box !important;
margin-top: -4px;
margin-left: -4px;
padding-right: 4px;
padding-bottom: 4px;
border: 2px dashed #feb663;
box-shadow: 2px 2px 5px #d3d3d3;
}
.x6-widget-selection-inner {
box-sizing: content-box !important;
margin-top: -8px;
margin-left: -8px;
padding-right: 12px;
padding-bottom: 12px;
border: 2px solid #feb663;
box-shadow: 2px 2px 5px #d3d3d3;
}
.x6-widget-selection-content {
color: #fff;
font-size: 10px;
background-color: #6a6b8a;
}
`;
$e.prototype.isSelectionEnabled = function() {
const e = this.getPlugin("selection");
return e ? e.isEnabled() : !1;
};
$e.prototype.enableSelection = function() {
const e = this.getPlugin("selection");
return e && e.enable(), this;
};
$e.prototype.disableSelection = function() {
const e = this.getPlugin("selection");
return e && e.disable(), this;
};
$e.prototype.toggleSelection = function(e) {
const t = this.getPlugin("selection");
return t && t.toggleEnabled(e), this;
};
$e.prototype.isMultipleSelection = function() {
const e = this.getPlugin("selection");
return e ? e.isMultipleSelection() : !1;
};
$e.prototype.enableMultipleSelection = function() {
const e = this.getPlugin("selection");
return e && e.enableMultipleSelection(), this;
};
$e.prototype.disableMultipleSelection = function() {
const e = this.getPlugin("selection");
return e && e.disableMultipleSelection(), this;
};
$e.prototype.toggleMultipleSelection = function(e) {
const t = this.getPlugin("selection");
return t && t.toggleMultipleSelection(e), this;
};
$e.prototype.isSelectionMovable = function() {
const e = this.getPlugin("selection");
return e ? e.isSelectionMovable() : !1;
};
$e.prototype.enableSelectionMovable = function() {
const e = this.getPlugin("selection");
return e && e.enableSelectionMovable(), this;
};
$e.prototype.disableSelectionMovable = function() {
const e = this.getPlugin("selection");
return e && e.disableSelectionMovable(), this;
};
$e.prototype.toggleSelectionMovable = function(e) {
const t = this.getPlugin("selection");
return t && t.toggleSelectionMovable(e), this;
};
$e.prototype.isRubberbandEnabled = function() {
const e = this.getPlugin("selection");
return e ? e.isRubberbandEnabled() : !1;
};
$e.prototype.enableRubberband = function() {
const e = this.getPlugin("selection");
return e && e.enableRubberband(), this;
};
$e.prototype.disableRubberband = function() {
const e = this.getPlugin("selection");
return e && e.disableRubberband(), this;
};
$e.prototype.toggleRubberband = function(e) {
const t = this.getPlugin("selection");
return t && t.toggleRubberband(e), this;
};
$e.prototype.isStrictRubberband = function() {
const e = this.getPlugin("selection");
return e ? e.isStrictRubberband() : !1;
};
$e.prototype.enableStrictRubberband = function() {
const e = this.getPlugin("selection");
return e && e.enableStrictRubberband(), this;
};
$e.prototype.disableStrictRubberband = function() {
const e = this.getPlugin("selection");
return e && e.disableStrictRubberband(), this;
};
$e.prototype.toggleStrictRubberband = function(e) {
const t = this.getPlugin("selection");
return t && t.toggleStrictRubberband(e), this;
};
$e.prototype.setRubberbandModifiers = function(e) {
const t = this.getPlugin("selection");
return t && t.setRubberbandModifiers(e), this;
};
$e.prototype.setSelectionFilter = function(e) {
const t = this.getPlugin("selection");
return t && t.setSelectionFilter(e), this;
};
$e.prototype.setSelectionDisplayContent = function(e) {
const t = this.getPlugin("selection");
return t && t.setSelectionDisplayContent(e), this;
};
$e.prototype.isSelectionEmpty = function() {
const e = this.getPlugin("selection");
return e ? e.isEmpty() : !0;
};
$e.prototype.cleanSelection = function(e) {
const t = this.getPlugin("selection");
return t && t.clean(e), this;
};
$e.prototype.resetSelection = function(e, t) {
const n = this.getPlugin("selection");
return n && n.reset(e, t), this;
};
$e.prototype.getSelectedCells = function() {
const e = this.getPlugin("selection");
return e ? e.getSelectedCells() : [];
};
$e.prototype.getSelectedCellCount = function() {
const e = this.getPlugin("selection");
return e ? e.getSelectedCellCount() : 0;
};
$e.prototype.isSelected = function(e) {
const t = this.getPlugin("selection");
return t ? t.isSelected(e) : !1;
};
$e.prototype.select = function(e, t) {
const n = this.getPlugin("selection");
return n && n.select(e, t), this;
};
$e.prototype.unselect = function(e, t) {
const n = this.getPlugin("selection");
return n && n.unselect(e, t), this;
};
var zm = function(e, t, n, a) {
var o = arguments.length, r = o < 3 ? t : a === null ? a = Object.getOwnPropertyDescriptor(t, n) : a, s;
if (typeof Reflect == "object" && typeof Reflect.decorate == "function") r = Reflect.decorate(e, t, n, a);
else for (var l = e.length - 1; l >= 0; l--) (s = e[l]) && (r = (o < 3 ? s(r) : o > 3 ? s(t, n, r) : s(t, n)) || r);
return o > 3 && r && Object.defineProperty(t, n, r), r;
};
class fr extends co {
get rubberbandDisabled() {
return this.options.enabled !== !0 || this.options.rubberband !== !0;
}
get disabled() {
return this.options.enabled !== !0;
}
get length() {
return this.selectionImpl.length;
}
get cells() {
return this.selectionImpl.cells;
}
constructor(t = {}) {
super(), this.name = "selection", this.movedMap = /* @__PURE__ */ new WeakMap(), this.unselectMap = /* @__PURE__ */ new WeakMap(), this.options = Object.assign(Object.assign({ enabled: !0 }, fr.defaultOptions), t), Ml.ensure(this.name, $m);
}
init(t) {
this.graph = t, this.selectionImpl = new Gp(Object.assign(Object.assign({}, this.options), { graph: t })), this.setup(), this.startListening();
}
// #region api
isEnabled() {
return !this.disabled;
}
enable() {
this.disabled && (this.options.enabled = !0);
}
disable() {
this.disabled || (this.options.enabled = !1);
}
toggleEnabled(t) {
return t != null ? t !== this.isEnabled() && (t ? this.enable() : this.disable()) : this.isEnabled() ? this.disable() : this.enable(), this;
}
isMultipleSelection() {
return this.isMultiple();
}
enableMultipleSelection() {
return this.enableMultiple(), this;
}
disableMultipleSelection() {
return this.disableMultiple(), this;
}
toggleMultipleSelection(t) {
return t != null ? t !== this.isMultipleSelection() && (t ? this.enableMultipleSelection() : this.disableMultipleSelection()) : this.isMultipleSelection() ? this.disableMultipleSelection() : this.enableMultipleSelection(), this;
}
isSelectionMovable() {
return this.options.movable !== !1;
}
enableSelectionMovable() {
return this.selectionImpl.options.movable = !0, this;
}
disableSelectionMovable() {
return this.selectionImpl.options.movable = !1, this;
}
toggleSelectionMovable(t) {
return t != null ? t !== this.isSelectionMovable() && (t ? this.enableSelectionMovable() : this.disableSelectionMovable()) : this.isSelectionMovable() ? this.disableSelectionMovable() : this.enableSelectionMovable(), this;
}
isRubberbandEnabled() {
return !this.rubberbandDisabled;
}
enableRubberband() {
return this.rubberbandDisabled && (this.options.rubberband = !0), this;
}
disableRubberband() {
return this.rubberbandDisabled || (this.options.rubberband = !1), this;
}
toggleRubberband(t) {
return t != null ? t !== this.isRubberbandEnabled() && (t ? this.enableRubberband() : this.disableRubberband()) : this.isRubberbandEnabled() ? this.disableRubberband() : this.enableRubberband(), this;
}
isStrictRubberband() {
return this.selectionImpl.options.strict === !0;
}
enableStrictRubberband() {
return this.selectionImpl.options.strict = !0, this;
}
disableStrictRubberband() {
return this.selectionImpl.options.strict = !1, this;
}
toggleStrictRubberband(t) {
return t != null ? t !== this.isStrictRubberband() && (t ? this.enableStrictRubberband() : this.disableStrictRubberband()) : this.isStrictRubberband() ? this.disableStrictRubberband() : this.enableStrictRubberband(), this;
}
setRubberbandModifiers(t) {
this.setModifiers(t);
}
setSelectionFilter(t) {
return this.setFilter(t), this;
}
setSelectionDisplayContent(t) {
return this.setContent(t), this;
}
isEmpty() {
return this.length <= 0;
}
clean(t = {}) {
return this.selectionImpl.clean(t), this;
}
reset(t, n = {}) {
return this.selectionImpl.reset(t ? this.getCells(t) : [], n), this;
}
getSelectedCells() {
return this.cells;
}
getSelectedCellCount() {
return this.length;
}
isSelected(t) {
return this.selectionImpl.isSelected(t);
}
select(t, n = {}) {
const a = this.getCells(t);
return a.length && (this.isMultiple() ? this.selectionImpl.select(a, n) : this.reset(a.slice(0, 1), n)), this;
}
unselect(t, n = {}) {
return this.selectionImpl.unselect(this.getCells(t), n), this;
}
// #endregion
setup() {
this.selectionImpl.on("*", (t, n) => {
this.trigger(t, n), this.graph.trigger(t, n);
});
}
startListening() {
this.graph.on("blank:mousedown", this.onBlankMouseDown, this), this.graph.on("blank:click", this.onBlankClick, this), this.graph.on("cell:mousemove", this.onCellMouseMove, this), this.graph.on("cell:mouseup", this.onCellMouseUp, this), this.selectionImpl.on("box:mousedown", this.onBoxMouseDown, this);
}
stopListening() {
this.graph.off("blank:mousedown", this.onBlankMouseDown, this), this.graph.off("blank:click", this.onBlankClick, this), this.graph.off("cell:mousemove", this.onCellMouseMove, this), this.graph.off("cell:mouseup", this.onCellMouseUp, this), this.selectionImpl.off("box:mousedown", this.onBoxMouseDown, this);
}
onBlankMouseDown({ e: t }) {
if (!this.allowBlankMouseDown(t))
return;
const n = this.graph.panning.allowPanning(t, !0), a = this.graph.getPlugin("scroller"), o = a && a.allowPanning(t, !0);
(this.allowRubberband(t, !0) || this.allowRubberband(t) && !o && !n) && this.startRubberband(t);
}
allowBlankMouseDown(t) {
const n = this.options.eventTypes;
return (n == null ? void 0 : n.includes("leftMouseDown")) && t.button === 0 || (n == null ? void 0 : n.includes("mouseWheelDown")) && t.button === 1;
}
onBlankClick() {
this.clean();
}
allowRubberband(t, n) {
return !this.rubberbandDisabled && iu.isMatch(t, this.options.modifiers, n);
}
allowMultipleSelection(t) {
return this.isMultiple() && iu.isMatch(t, this.options.multipleSelectionModifiers);
}
onCellMouseMove({ cell: t }) {
this.movedMap.set(t, !0);
}
onCellMouseUp({ e: t, cell: n }) {
const a = this.options;
let o = this.disabled;
!o && this.movedMap.has(n) && (o = a.selectCellOnMoved === !1, o || (o = a.selectNodeOnMoved === !1 && n.isNode()), o || (o = a.selectEdgeOnMoved === !1 && n.isEdge())), o || (this.allowMultipleSelection(t) ? this.unselectMap.has(n) ? this.unselectMap.delete(n) : this.isSelected(n) ? this.unselect(n) : this.select(n) : this.reset(n)), this.movedMap.delete(n);
}
onBoxMouseDown({ e: t, cell: n }) {
this.disabled || this.allowMultipleSelection(t) && (this.unselect(n), this.unselectMap.set(n, !0));
}
getCells(t) {
return (Array.isArray(t) ? t : [t]).map((n) => typeof n == "string" ? this.graph.getCellById(n) : n).filter((n) => n != null);
}
startRubberband(t) {
return this.rubberbandDisabled || this.selectionImpl.startSelecting(t), this;
}
isMultiple() {
return this.options.multiple !== !1;
}
enableMultiple() {
return this.options.multiple = !0, this;
}
disableMultiple() {
return this.options.multiple = !1, this;
}
setModifiers(t) {
return this.options.modifiers = t, this;
}
setContent(t) {
return this.selectionImpl.setContent(t), this;
}
setFilter(t) {
return this.selectionImpl.setFilter(t), this;
}
dispose() {
this.stopListening(), this.off(), this.selectionImpl.dispose(), Ml.clean(this.name);
}
}
zm([
co.dispose()
], fr.prototype, "dispose", null);
(function(e) {
e.defaultOptions = {