marquee-selection 0.0.13 → 0.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,34 +1,34 @@
1
- function pe(Wt) {
1
+ function ye(Jt) {
2
2
  const {
3
3
  container: B,
4
- selectable: pt = "img",
5
- exclude: et,
6
- selectionMode: ht = "intersects",
7
- minOverlapRatio: Kt = 0,
8
- overlapMetric: _t = "element",
9
- selectedClass: nt = "selected",
10
- onChange: dt,
11
- preventAncestorSelection: Jt = !0,
12
- conflictStrategy: Qt,
4
+ selectable: dt = "img",
5
+ exclude: ot,
6
+ selectionMode: yt = "intersects",
7
+ minOverlapRatio: Qt = 0,
8
+ overlapMetric: Zt = "element",
9
+ selectedClass: st = "selected",
10
+ onChange: gt,
11
+ preventAncestorSelection: te = !0,
12
+ conflictStrategy: ee,
13
13
  groupMode: q = !1,
14
- groupOverlayClass: Rt,
15
- groupColor: yt,
16
- groupRandomColor: Zt = !1,
17
- groupColorPalette: ot,
18
- multi: At = !1,
19
- combineMode: gt,
20
- hoverHighlight: st = !1,
21
- hoverClass: It = "hovered",
22
- onSelectionEnd: Lt,
23
- quickGroupOnDblClick: mt = !1,
24
- quickGroupSelector: Nt,
25
- allowIntersectionSelection: H = !0,
26
- allowUnionSelection: U = !0,
27
- allowContainmentSelection: j = !0,
28
- toolbarButtons: R
29
- } = Wt, Ot = Array.isArray(et) ? et.filter(Boolean) : et ? [et] : [], bt = (t) => {
30
- if (!t || !Ot.length) return !1;
31
- for (const e of Ot)
14
+ groupOverlayClass: It,
15
+ groupColor: mt,
16
+ groupRandomColor: ne = !1,
17
+ groupColorPalette: lt,
18
+ multi: Nt = !1,
19
+ combineMode: bt,
20
+ hoverHighlight: rt = !1,
21
+ hoverClass: Ot = "hovered",
22
+ onSelectionEnd: Gt,
23
+ quickGroupOnDblClick: vt = !1,
24
+ quickGroupSelector: Ft,
25
+ allowIntersectionSelection: V = !0,
26
+ allowUnionSelection: W = !0,
27
+ allowContainmentSelection: K = !0,
28
+ toolbarButtons: M
29
+ } = Jt, Pt = Array.isArray(ot) ? ot.filter(Boolean) : ot ? [ot] : [], xt = (t) => {
30
+ if (!t || !Pt.length) return !1;
31
+ for (const e of Pt)
32
32
  try {
33
33
  if (t instanceof Element && t.matches(e)) return !0;
34
34
  } catch {
@@ -36,206 +36,206 @@ function pe(Wt) {
36
36
  return !1;
37
37
  };
38
38
  if (!B) throw new Error("container is required");
39
- let vt = 0, wt = 0, W = !1, $ = null, xt = !1, Y = /* @__PURE__ */ new Set(), V = null, Et = "replace", a = [], lt = [], N = [], D = [], T = [];
40
- const te = () => (R ?? []).map((t) => ({
39
+ let wt = 0, Et = 0, J = !1, $ = null, St = !1, D = /* @__PURE__ */ new Set(), _ = null, Ct = "replace", a = [], it = [], I = [], H = [], U = [];
40
+ const oe = () => (M ?? []).map((t) => ({
41
41
  label: (t == null ? void 0 : t.label) ?? "",
42
42
  title: (t == null ? void 0 : t.title) ?? ""
43
- })), K = (t) => !R || R.length === 0 ? null : (T[t] || (T[t] = te()), T[t]), ee = () => `hsl(${Math.floor(Math.random() * 360)}, 70%, 55%)`, St = () => {
44
- if (yt && typeof yt == "string")
45
- return yt;
46
- if (Zt) {
47
- if (Array.isArray(ot) && ot.length > 0) {
48
- const t = Math.floor(Math.random() * ot.length);
49
- return ot[t];
43
+ })), Q = (t) => !M || M.length === 0 ? null : (U[t] || (U[t] = oe()), U[t]), se = () => `hsl(${Math.floor(Math.random() * 360)}, 70%, 55%)`, zt = () => {
44
+ if (mt && typeof mt == "string")
45
+ return mt;
46
+ if (ne) {
47
+ if (Array.isArray(lt) && lt.length > 0) {
48
+ const t = Math.floor(Math.random() * lt.length);
49
+ return lt[t];
50
50
  }
51
- return ee();
51
+ return se();
52
52
  }
53
53
  return "rgba(255, 165, 0, 0.9)";
54
54
  };
55
- let A = null;
56
- const _ = [], Ct = [];
57
- let X = null;
58
- const zt = (t) => {
55
+ let k = null;
56
+ const Z = [], $t = [];
57
+ let j = null;
58
+ const Mt = (t) => {
59
59
  if (!t.length) return null;
60
60
  const e = new Set(t);
61
- for (let s = 0; s < a.length; s++) {
62
- const i = a[s] || [];
61
+ for (let r = 0; r < a.length; r++) {
62
+ const i = a[r] || [];
63
63
  if (i.length !== e.size) continue;
64
64
  let c = !0;
65
- const o = new Set(i);
66
- if (o.size !== e.size && (c = !1), c) {
65
+ const s = new Set(i);
66
+ if (s.size !== e.size && (c = !1), c) {
67
67
  for (const n of e)
68
- if (!o.has(n)) {
68
+ if (!s.has(n)) {
69
69
  c = !1;
70
70
  break;
71
71
  }
72
72
  }
73
- if (c) return s;
73
+ if (c) return r;
74
74
  }
75
75
  return null;
76
76
  };
77
- let Gt = null;
78
- const Ft = (t) => {
79
- const e = !!N[t], s = a[t] || [];
80
- for (const i of s)
77
+ let Tt = null;
78
+ const Bt = (t) => {
79
+ const e = !!I[t], r = a[t] || [];
80
+ for (const i of r)
81
81
  i.style.visibility = e ? "hidden" : "";
82
- }, rt = (t, e) => t < 0 || t >= a.length ? !1 : (N[t] = e, Ft(t), !0);
83
- let J = null;
84
- const it = (t) => {
85
- st && (J && J !== t && J.classList.remove(It), t && J !== t && t.classList.add(It), J = t);
86
- }, ne = () => {
82
+ }, ct = (t, e) => t < 0 || t >= a.length ? !1 : (I[t] = e, Bt(t), !0);
83
+ let tt = null;
84
+ const at = (t) => {
85
+ rt && (tt && tt !== t && tt.classList.remove(Ot), t && tt !== t && t.classList.add(Ot), tt = t);
86
+ }, le = () => {
87
87
  const t = document.createElement("div");
88
88
  return t.style.position = "fixed", t.style.left = "0px", t.style.top = "0px", t.style.width = "0px", t.style.height = "0px", t.style.outline = "1px dashed #268aff", t.style.background = "rgba(38,138,255,0.12)", t.style.pointerEvents = "none", t.style.zIndex = "2147483647", t.style.boxSizing = "border-box", document.body.appendChild(t), t;
89
- }, ct = (t, e) => t.left < e.right && t.right > e.left && t.top < e.bottom && t.bottom > e.top, oe = (t, e) => t.left <= e.left && t.right >= e.right && t.top <= e.top && t.bottom >= e.bottom, se = (t, e) => {
90
- const s = Math.max(t.left, e.left), i = Math.min(t.right, e.right), c = Math.max(t.top, e.top), o = Math.min(t.bottom, e.bottom), n = Math.max(0, i - s), l = Math.max(0, o - c), y = n * l, p = Math.max(1, e.width * e.height);
91
- return y / p;
92
- }, le = (t, e) => {
93
- const s = Math.max(t.left, e.left), i = Math.min(t.right, e.right), c = Math.max(t.top, e.top), o = Math.min(t.bottom, e.bottom), n = Math.max(0, i - s), l = Math.max(0, o - c), y = n * l, p = Math.max(1, t.width * t.height), f = Math.max(1, e.width * e.height), h = p + f - y;
94
- return y / h;
95
- }, Pt = (t, e) => _t === "iou" ? le(t, e) : se(t, e), Bt = (t, e, s, i) => {
96
- const c = Math.min(t, s), o = Math.min(e, i), n = Math.abs(s - t), l = Math.abs(i - e);
97
- return { left: c, top: o, width: n, height: l };
98
- }, $t = (t) => {
89
+ }, ft = (t, e) => t.left < e.right && t.right > e.left && t.top < e.bottom && t.bottom > e.top, re = (t, e) => t.left <= e.left && t.right >= e.right && t.top <= e.top && t.bottom >= e.bottom, ie = (t, e) => {
90
+ const r = Math.max(t.left, e.left), i = Math.min(t.right, e.right), c = Math.max(t.top, e.top), s = Math.min(t.bottom, e.bottom), n = Math.max(0, i - r), l = Math.max(0, s - c), f = n * l, u = Math.max(1, e.width * e.height);
91
+ return f / u;
92
+ }, ce = (t, e) => {
93
+ const r = Math.max(t.left, e.left), i = Math.min(t.right, e.right), c = Math.max(t.top, e.top), s = Math.min(t.bottom, e.bottom), n = Math.max(0, i - r), l = Math.max(0, s - c), f = n * l, u = Math.max(1, t.width * t.height), p = Math.max(1, e.width * e.height), d = u + p - f;
94
+ return f / d;
95
+ }, qt = (t, e) => Zt === "iou" ? ce(t, e) : ie(t, e), Yt = (t, e, r, i) => {
96
+ const c = Math.min(t, r), s = Math.min(e, i), n = Math.abs(r - t), l = Math.abs(i - e);
97
+ return { left: c, top: s, width: n, height: l };
98
+ }, kt = (t) => {
99
99
  const e = t.map((n) => n.getBoundingClientRect()).filter((n) => n.width > 0 && n.height > 0);
100
100
  if (!e.length) return null;
101
- const s = Math.min(...e.map((n) => n.left)), i = Math.min(...e.map((n) => n.top)), c = Math.max(...e.map((n) => n.right)), o = Math.max(...e.map((n) => n.bottom));
102
- return { left: s, top: i, width: c - s, height: o - i };
103
- }, Q = () => {
104
- lt.forEach((t) => t.remove()), lt = [];
105
- }, O = () => {
106
- if (Q(), !q) return;
107
- const t = [], e = (s, i) => s.left < i.right && s.right > i.left && s.top < i.bottom && s.bottom > i.top;
108
- a.forEach((s, i) => {
109
- const c = $t(s);
101
+ const r = Math.min(...e.map((n) => n.left)), i = Math.min(...e.map((n) => n.top)), c = Math.max(...e.map((n) => n.right)), s = Math.max(...e.map((n) => n.bottom));
102
+ return { left: r, top: i, width: c - r, height: s - i };
103
+ }, et = () => {
104
+ it.forEach((t) => t.remove()), it = [];
105
+ }, N = () => {
106
+ if (et(), !q) return;
107
+ const t = [], e = (r, i) => r.left < i.right && r.right > i.left && r.top < i.bottom && r.bottom > i.top;
108
+ a.forEach((r, i) => {
109
+ const c = kt(r);
110
110
  if (!c) return;
111
- const o = D[i] || "rgba(255, 165, 0, 0.9)", n = document.createElement("div");
112
- n.style.position = "fixed", n.style.pointerEvents = "none", n.style.zIndex = "2147483646", n.style.left = `${c.left}px`, n.style.top = `${c.top}px`, n.style.width = `${c.width}px`, n.style.height = `${c.height}px`, n.style.boxSizing = "border-box", n.style.outline = `1px solid ${o}`, n.style.background = "transparent", document.body.appendChild(n);
111
+ const s = H[i] || "rgba(255, 165, 0, 0.9)", n = document.createElement("div");
112
+ n.style.position = "fixed", n.style.pointerEvents = "none", n.style.zIndex = "2147483646", n.style.left = `${c.left}px`, n.style.top = `${c.top}px`, n.style.width = `${c.width}px`, n.style.height = `${c.height}px`, n.style.boxSizing = "border-box", n.style.outline = `1px solid ${s}`, n.style.background = "transparent", document.body.appendChild(n);
113
113
  const l = document.createElement("div");
114
- l.style.position = "absolute", l.style.display = "inline-flex", l.style.alignItems = "center", l.style.gap = "6px", l.style.minWidth = "max-content", l.style.padding = "2px 6px", l.style.fontSize = "12px", l.style.lineHeight = "16px", l.style.color = "#fff", l.style.background = o, l.style.borderRadius = "4px", l.style.pointerEvents = "auto";
115
- const y = document.createElement("span");
116
- y.textContent = `组 ${i + 1}`;
117
- const p = document.createElement("button");
118
- p.textContent = N[i] ? "显示" : "隐藏", p.style.background = "rgba(0,0,0,0.15)", p.style.border = "none", p.style.color = "#fff", p.style.padding = "2px 6px", p.style.borderRadius = "3px", p.style.cursor = "pointer", p.onclick = (v) => {
119
- v.stopPropagation(), rt(i, !N[i]), O(), F();
114
+ l.style.position = "absolute", l.style.display = "inline-grid", l.style.gridTemplateColumns = "1fr 1fr 1fr", l.style.gap = "2px", l.style.minWidth = "max-content", l.style.padding = "3px 4px", l.style.fontSize = "11px", l.style.lineHeight = "14px", l.style.color = "#fff", l.style.background = s, l.style.borderRadius = "4px", l.style.pointerEvents = "auto", l.style.opacity = "0.35", l.style.transition = "opacity 0.15s ease";
115
+ const f = document.createElement("span");
116
+ f.textContent = `${i + 1}`, f.style.position = "absolute", f.style.left = "0", f.style.top = "0", f.style.fontSize = "9px", f.style.lineHeight = "14px", f.style.minWidth = "14px", f.style.textAlign = "center", f.style.padding = "0 3px", f.style.background = s, f.style.color = "#fff", f.style.borderRadius = "0 0 4px 0", f.style.fontWeight = "bold", f.style.pointerEvents = "none", n.appendChild(f);
117
+ const u = document.createElement("button");
118
+ u.textContent = I[i] ? "显示" : "隐藏", u.style.background = "rgba(0,0,0,0.15)", u.style.border = "none", u.style.color = "#fff", u.style.padding = "2px 4px", u.style.borderRadius = "3px", u.style.cursor = "pointer", u.style.fontSize = "10px", u.style.textAlign = "center", u.onclick = (v) => {
119
+ v.stopPropagation(), ct(i, !I[i]), N(), F();
120
120
  };
121
- const f = document.createElement("button");
122
- f.textContent = "取消组", f.style.background = "rgba(0,0,0,0.15)", f.style.border = "none", f.style.color = "#fff", f.style.padding = "2px 6px", f.style.borderRadius = "3px", f.style.cursor = "pointer", f.onclick = (v) => {
123
- v.stopPropagation(), rt(i, !1), qt(i);
124
- }, l.appendChild(y), l.appendChild(p), l.appendChild(f);
125
- const h = (v) => {
126
- const r = c ? new DOMRect(c.left, c.top, c.width, c.height) : null;
127
- if (!r) return [];
128
- const d = [];
129
- return a.forEach((w, u) => {
130
- if (u === v) return;
131
- const b = $t(w);
132
- if (!b) return;
133
- const S = new DOMRect(b.left, b.top, b.width, b.height);
134
- ct(r, S) && d.push(u);
135
- }), d;
121
+ const p = document.createElement("button");
122
+ p.textContent = "取消组", p.style.background = "rgba(0,0,0,0.15)", p.style.border = "none", p.style.color = "#fff", p.style.padding = "2px 4px", p.style.borderRadius = "3px", p.style.cursor = "pointer", p.style.fontSize = "10px", p.style.textAlign = "center", p.onclick = (v) => {
123
+ v.stopPropagation(), ct(i, !1), Dt(i);
124
+ }, l.appendChild(u), l.appendChild(p);
125
+ const d = (v) => {
126
+ const o = c ? new DOMRect(c.left, c.top, c.width, c.height) : null;
127
+ if (!o) return [];
128
+ const h = [];
129
+ return a.forEach((y, b) => {
130
+ if (b === v) return;
131
+ const w = kt(y);
132
+ if (!w) return;
133
+ const E = new DOMRect(w.left, w.top, w.width, w.height);
134
+ ft(o, E) && h.push(b);
135
+ }), h;
136
136
  };
137
137
  if ((() => {
138
- if (A !== i) return;
139
- const v = h(i);
138
+ if (k !== i) return;
139
+ const v = d(i);
140
140
  if (v.length === 0) return;
141
- const r = document.createElement("button");
142
- r.textContent = "合并", r.style.background = "rgba(0,0,0,0.15)", r.style.border = "none", r.style.color = "#fff", r.style.padding = "2px 6px", r.style.borderRadius = "3px", r.style.cursor = "pointer";
143
- const d = () => {
144
- const w = l.querySelector(".merge-panel");
145
- w && w.remove();
146
- const u = document.createElement("div");
147
- u.className = "merge-panel", u.style.position = "absolute", u.style.left = "0", u.style.top = "22px", u.style.minWidth = "160px", u.style.padding = "8px", u.style.background = "#fff", u.style.color = "#333", u.style.border = "1px solid rgba(0,0,0,0.15)", u.style.borderRadius = "6px", u.style.boxShadow = "0 4px 12px rgba(0,0,0,0.15)", u.style.pointerEvents = "auto", u.style.zIndex = "2147483647";
141
+ const o = document.createElement("button");
142
+ o.textContent = "合并", o.style.background = "rgba(0,0,0,0.15)", o.style.border = "none", o.style.color = "#fff", o.style.padding = "2px 4px", o.style.borderRadius = "3px", o.style.cursor = "pointer", o.style.fontSize = "10px", o.style.textAlign = "center";
143
+ const h = () => {
144
+ const y = l.querySelector(".merge-panel");
145
+ y && y.remove();
148
146
  const b = document.createElement("div");
149
- b.textContent = "选择要合并的组", b.style.fontSize = "12px", b.style.marginBottom = "6px", u.appendChild(b);
150
- const S = document.createElement("div");
151
- S.style.maxHeight = "200px", S.style.overflow = "auto";
152
- const I = [];
153
- v.forEach((z) => {
154
- const k = document.createElement("label");
155
- k.style.display = "flex", k.style.alignItems = "center", k.style.gap = "6px", k.style.fontSize = "12px", k.style.margin = "4px 0";
156
- const L = document.createElement("input");
157
- L.type = "checkbox", L.checked = !0, L.value = String(z);
158
- const tt = document.createElement("span");
159
- tt.textContent = `组 ${z + 1}`, k.appendChild(L), k.appendChild(tt), S.appendChild(k), I.push(L);
160
- }), u.appendChild(S);
161
- const P = document.createElement("div");
162
- P.style.display = "flex", P.style.gap = "8px", P.style.marginTop = "8px";
163
- const C = document.createElement("button");
164
- C.textContent = "确认", C.style.padding = "2px 8px", C.style.cursor = "pointer";
165
- const M = document.createElement("button");
166
- M.textContent = "取消", M.style.padding = "2px 8px", M.style.cursor = "pointer", P.appendChild(C), P.appendChild(M), u.appendChild(P), M.onclick = (z) => {
167
- z.stopPropagation(), u.remove();
168
- }, C.onclick = (z) => {
169
- z.stopPropagation();
170
- const k = I.filter((E) => E.checked).map((E) => parseInt(E.value, 10)).filter((E) => !Number.isNaN(E));
171
- if (k.length === 0) {
172
- u.remove();
147
+ b.className = "merge-panel", b.style.position = "absolute", b.style.left = "0", b.style.top = "22px", b.style.minWidth = "160px", b.style.padding = "8px", b.style.background = "#fff", b.style.color = "#333", b.style.border = "1px solid rgba(0,0,0,0.15)", b.style.borderRadius = "6px", b.style.boxShadow = "0 4px 12px rgba(0,0,0,0.15)", b.style.pointerEvents = "auto", b.style.zIndex = "2147483647";
148
+ const w = document.createElement("div");
149
+ w.textContent = "选择要合并的组", w.style.fontSize = "12px", w.style.marginBottom = "6px", b.appendChild(w);
150
+ const E = document.createElement("div");
151
+ E.style.maxHeight = "200px", E.style.overflow = "auto";
152
+ const z = [];
153
+ v.forEach((T) => {
154
+ const G = document.createElement("label");
155
+ G.style.display = "flex", G.style.alignItems = "center", G.style.gap = "6px", G.style.fontSize = "12px", G.style.margin = "4px 0";
156
+ const Y = document.createElement("input");
157
+ Y.type = "checkbox", Y.checked = !0, Y.value = String(T);
158
+ const At = document.createElement("span");
159
+ At.textContent = `组 ${T + 1}`, G.appendChild(Y), G.appendChild(At), E.appendChild(G), z.push(Y);
160
+ }), b.appendChild(E);
161
+ const C = document.createElement("div");
162
+ C.style.display = "flex", C.style.gap = "8px", C.style.marginTop = "8px";
163
+ const R = document.createElement("button");
164
+ R.textContent = "确认", R.style.padding = "2px 8px", R.style.cursor = "pointer";
165
+ const P = document.createElement("button");
166
+ P.textContent = "取消", P.style.padding = "2px 8px", P.style.cursor = "pointer", C.appendChild(R), C.appendChild(P), b.appendChild(C), P.onclick = (T) => {
167
+ T.stopPropagation(), b.remove();
168
+ }, R.onclick = (T) => {
169
+ T.stopPropagation();
170
+ const G = z.filter((S) => S.checked).map((S) => parseInt(S.value, 10)).filter((S) => !Number.isNaN(S));
171
+ if (G.length === 0) {
172
+ b.remove();
173
173
  return;
174
174
  }
175
- const L = /* @__PURE__ */ new Set();
176
- (a[i] || []).forEach((E) => L.add(E)), k.forEach((E) => {
177
- (a[E] || []).forEach((ue) => L.add(ue));
178
- }), a[i] = Array.from(L);
179
- const fe = [...k].sort((E, ut) => ut - E);
180
- let kt = i;
181
- fe.forEach((E) => {
182
- E < 0 || E >= a.length || E === i || (rt(E, !1), a.splice(E, 1), N.splice(E, 1), D.splice(E, 1), T.length > E && T.splice(E, 1), A !== null && (A === E ? A = null : A > E && A--), E < kt && kt--);
183
- }), A = kt;
184
- const Vt = /* @__PURE__ */ new Set();
185
- a.forEach((E) => E.forEach((ut) => Vt.add(ut))), G(Vt), O(), u.remove(), F();
186
- }, l.appendChild(u);
175
+ const Y = /* @__PURE__ */ new Set();
176
+ (a[i] || []).forEach((S) => Y.add(S)), G.forEach((S) => {
177
+ (a[S] || []).forEach((de) => Y.add(de));
178
+ }), a[i] = Array.from(Y);
179
+ const he = [...G].sort((S, ht) => ht - S);
180
+ let Lt = i;
181
+ he.forEach((S) => {
182
+ S < 0 || S >= a.length || S === i || (ct(S, !1), a.splice(S, 1), I.splice(S, 1), H.splice(S, 1), U.length > S && U.splice(S, 1), k !== null && (k === S ? k = null : k > S && k--), S < Lt && Lt--);
183
+ }), k = Lt;
184
+ const _t = /* @__PURE__ */ new Set();
185
+ a.forEach((S) => S.forEach((ht) => _t.add(ht))), O(_t), N(), b.remove(), F();
186
+ }, l.appendChild(b);
187
187
  };
188
- r.onclick = (w) => {
189
- w.stopPropagation(), d();
190
- }, l.appendChild(r);
191
- })(), n.appendChild(l), R && R.length) {
192
- const v = (r, d) => {
193
- const w = document.createElement("button"), u = K(i);
194
- if (!u) return;
195
- const b = u[d] ?? (u[d] = {
196
- label: r.label || "按钮",
197
- title: r.title || ""
198
- }), S = () => {
199
- w.textContent = b.label || "", w.title = b.title || "";
188
+ o.onclick = (y) => {
189
+ y.stopPropagation(), h();
190
+ }, l.appendChild(o);
191
+ })(), n.appendChild(l), M && M.length) {
192
+ const v = (o, h) => {
193
+ const y = document.createElement("button"), b = Q(i);
194
+ if (!b) return;
195
+ const w = b[h] ?? (b[h] = {
196
+ label: o.label || "按钮",
197
+ title: o.title || ""
198
+ }), E = () => {
199
+ y.textContent = w.label || "", y.title = w.title || "";
200
200
  };
201
- S(), w.style.background = "rgba(0,0,0,0.15)", w.style.border = "none", w.style.color = "#fff", w.style.padding = "2px 6px", w.style.borderRadius = "3px", w.style.cursor = "pointer", r.className && (w.className += (w.className ? " " : "") + r.className), w.onclick = (I) => {
202
- var M;
203
- I.stopPropagation();
204
- const P = {
201
+ E(), y.style.background = "rgba(0,0,0,0.15)", y.style.border = "none", y.style.color = "#fff", y.style.padding = "2px 4px", y.style.borderRadius = "3px", y.style.cursor = "pointer", y.style.fontSize = "10px", y.style.textAlign = "center", o.className && (y.className += (y.className ? " " : "") + o.className), y.onclick = (z) => {
202
+ var P;
203
+ z.stopPropagation();
204
+ const C = {
205
205
  index: i,
206
206
  group: a[i] || [],
207
- controller: Gt,
208
- getSnapshot: () => ft(),
207
+ controller: Tt,
208
+ getSnapshot: () => ut(),
209
209
  refresh: () => {
210
- O(), F();
210
+ N(), F();
211
211
  },
212
- mouseX: I.clientX,
213
- mouseY: I.clientY,
212
+ mouseX: z.clientX,
213
+ mouseY: z.clientY,
214
214
  anchorRect: l.getBoundingClientRect(),
215
215
  anchorEl: l,
216
216
  overlayEl: n,
217
- label: b.label,
218
- title: b.title,
219
- buttonEl: w
220
- }, C = (z) => {
221
- Object.defineProperty(P, z, {
217
+ label: w.label,
218
+ title: w.title,
219
+ buttonEl: y
220
+ }, R = (T) => {
221
+ Object.defineProperty(C, T, {
222
222
  configurable: !0,
223
- get: () => b[z],
224
- set: (k) => {
225
- const L = k ?? "";
226
- b[z] !== L && (b[z] = L, S());
223
+ get: () => w[T],
224
+ set: (G) => {
225
+ const Y = G ?? "";
226
+ w[T] !== Y && (w[T] = Y, E());
227
227
  }
228
228
  });
229
229
  };
230
- C("label"), C("title");
230
+ R("label"), R("title");
231
231
  try {
232
- (M = r.onClick) == null || M.call(r, P);
232
+ (P = o.onClick) == null || P.call(o, C);
233
233
  } catch {
234
234
  }
235
- }, l.appendChild(w);
235
+ }, l.appendChild(y);
236
236
  };
237
- R.forEach(
238
- (r, d) => v(r, d)
237
+ M.forEach(
238
+ (o, h) => v(o, h)
239
239
  );
240
240
  }
241
241
  (() => {
@@ -244,474 +244,489 @@ function pe(Wt) {
244
244
  "tr",
245
245
  "bl",
246
246
  "br"
247
- ], r = l.style.visibility;
247
+ ], o = l.style.visibility;
248
248
  l.style.visibility = "hidden";
249
- const d = 28, w = 6;
250
- t: for (let u = 0; u < v.length; u++)
251
- for (let b = 0; b < 6; b++) {
249
+ const h = 28, y = 6;
250
+ t: for (let b = 0; b < v.length; b++)
251
+ for (let w = 0; w < 6; w++) {
252
252
  l.style.left = "", l.style.right = "", l.style.top = "", l.style.bottom = "";
253
- const S = l.offsetHeight || 22;
254
- v[u] === "tl" ? (l.style.left = "0", l.style.top = `${-S - w + b * d}px`) : v[u] === "tr" ? (l.style.right = "0", l.style.top = `${-S - w + b * d}px`) : v[u] === "bl" ? (l.style.left = "0", l.style.top = `${c.height + w + b * d}px`) : (l.style.right = "0", l.style.top = `${c.height + w + b * d}px`);
255
- const I = l.getBoundingClientRect(), P = {
256
- left: I.left,
257
- top: I.top,
258
- right: I.right,
259
- bottom: I.bottom
253
+ const E = l.offsetHeight || 22;
254
+ v[b] === "tl" ? (l.style.left = "0", l.style.top = `${-E - y + w * h}px`) : v[b] === "tr" ? (l.style.right = "0", l.style.top = `${-E - y + w * h}px`) : v[b] === "bl" ? (l.style.left = "0", l.style.top = `${c.height + y + w * h}px`) : (l.style.right = "0", l.style.top = `${c.height + y + w * h}px`);
255
+ const z = l.getBoundingClientRect(), C = {
256
+ left: z.left,
257
+ top: z.top,
258
+ right: z.right,
259
+ bottom: z.bottom
260
260
  };
261
- let C = !1;
262
- for (const M of t)
263
- if (e(P, M)) {
264
- C = !0;
261
+ let R = !1;
262
+ for (const P of t)
263
+ if (e(C, P)) {
264
+ R = !0;
265
265
  break;
266
266
  }
267
- if (!C) {
268
- t.push(P);
267
+ if (!R) {
268
+ t.push(C);
269
269
  break t;
270
270
  }
271
271
  }
272
- l.style.visibility = r;
273
- })(), l.addEventListener("mouseenter", () => {
272
+ l.style.visibility = o;
273
+ })();
274
+ const x = () => {
275
+ l.style.opacity = "1";
276
+ }, X = () => {
277
+ l.style.opacity = "0.35";
278
+ };
279
+ l.addEventListener("mouseenter", () => {
280
+ x();
274
281
  try {
275
- lt.forEach((v) => v.style.zIndex = "2147483646"), n.style.zIndex = "2147483647";
282
+ it.forEach((v) => v.style.zIndex = "2147483646"), n.style.zIndex = "2147483647";
276
283
  } catch {
277
284
  }
285
+ }), l.addEventListener("mouseleave", X);
286
+ const A = document.createElement("div");
287
+ A.style.position = "absolute", A.style.inset = "0", A.style.pointerEvents = "auto", A.style.background = "transparent", A.style.zIndex = "0", n.appendChild(A), A.addEventListener("mouseenter", x), A.addEventListener("mouseleave", () => {
288
+ setTimeout(() => {
289
+ !l.matches(":hover") && !A.matches(":hover") && X();
290
+ }, 100);
278
291
  });
279
- const x = (v) => {
280
- const r = document.createElement("div");
281
- r.style.position = "absolute", r.style.pointerEvents = "auto", r.style.background = "transparent", r.style.zIndex = "2147483647";
282
- const d = 8;
283
- v === "top" ? (r.style.cursor = "ns-resize", r.style.left = "-4px", r.style.right = "-4px", r.style.top = `-${d / 2 | 0}px`, r.style.height = `${d}px`) : v === "bottom" ? (r.style.cursor = "ns-resize", r.style.left = "-4px", r.style.right = "-4px", r.style.bottom = `-${d / 2 | 0}px`, r.style.height = `${d}px`) : v === "left" ? (r.style.cursor = "ew-resize", r.style.top = "-4px", r.style.bottom = "-4px", r.style.left = `-${d / 2 | 0}px`, r.style.width = `${d}px`) : v === "right" ? (r.style.cursor = "ew-resize", r.style.top = "-4px", r.style.bottom = "-4px", r.style.right = `-${d / 2 | 0}px`, r.style.width = `${d}px`) : v === "nw" ? (r.style.cursor = "nwse-resize", r.style.left = `-${d / 2 | 0}px`, r.style.top = `-${d / 2 | 0}px`, r.style.width = `${d}px`, r.style.height = `${d}px`) : v === "ne" ? (r.style.cursor = "nesw-resize", r.style.right = `-${d / 2 | 0}px`, r.style.top = `-${d / 2 | 0}px`, r.style.width = `${d}px`, r.style.height = `${d}px`) : v === "sw" ? (r.style.cursor = "nesw-resize", r.style.left = `-${d / 2 | 0}px`, r.style.bottom = `-${d / 2 | 0}px`, r.style.width = `${d}px`, r.style.height = `${d}px`) : v === "se" && (r.style.cursor = "nwse-resize", r.style.right = `-${d / 2 | 0}px`, r.style.bottom = `-${d / 2 | 0}px`, r.style.width = `${d}px`, r.style.height = `${d}px`), r.onmousedown = (w) => {
284
- w.preventDefault(), w.stopPropagation();
285
- const u = {
292
+ const L = (v) => {
293
+ const o = document.createElement("div");
294
+ o.style.position = "absolute", o.style.pointerEvents = "auto", o.style.background = "transparent", o.style.zIndex = "2147483647";
295
+ const h = 8;
296
+ v === "top" ? (o.style.cursor = "ns-resize", o.style.left = "-4px", o.style.right = "-4px", o.style.top = `-${h / 2 | 0}px`, o.style.height = `${h}px`) : v === "bottom" ? (o.style.cursor = "ns-resize", o.style.left = "-4px", o.style.right = "-4px", o.style.bottom = `-${h / 2 | 0}px`, o.style.height = `${h}px`) : v === "left" ? (o.style.cursor = "ew-resize", o.style.top = "-4px", o.style.bottom = "-4px", o.style.left = `-${h / 2 | 0}px`, o.style.width = `${h}px`) : v === "right" ? (o.style.cursor = "ew-resize", o.style.top = "-4px", o.style.bottom = "-4px", o.style.right = `-${h / 2 | 0}px`, o.style.width = `${h}px`) : v === "nw" ? (o.style.cursor = "nwse-resize", o.style.left = `-${h / 2 | 0}px`, o.style.top = `-${h / 2 | 0}px`, o.style.width = `${h}px`, o.style.height = `${h}px`) : v === "ne" ? (o.style.cursor = "nesw-resize", o.style.right = `-${h / 2 | 0}px`, o.style.top = `-${h / 2 | 0}px`, o.style.width = `${h}px`, o.style.height = `${h}px`) : v === "sw" ? (o.style.cursor = "nesw-resize", o.style.left = `-${h / 2 | 0}px`, o.style.bottom = `-${h / 2 | 0}px`, o.style.width = `${h}px`, o.style.height = `${h}px`) : v === "se" && (o.style.cursor = "nwse-resize", o.style.right = `-${h / 2 | 0}px`, o.style.bottom = `-${h / 2 | 0}px`, o.style.width = `${h}px`, o.style.height = `${h}px`), o.onmousedown = (y) => {
297
+ y.preventDefault(), y.stopPropagation();
298
+ const b = {
286
299
  left: parseFloat(n.style.left || "0"),
287
300
  top: parseFloat(n.style.top || "0"),
288
301
  width: parseFloat(n.style.width || "0"),
289
302
  height: parseFloat(n.style.height || "0")
290
303
  };
291
- X = {
304
+ j = {
292
305
  idx: i,
293
306
  side: v,
294
- startX: w.clientX,
295
- startY: w.clientY,
296
- startRect: u,
307
+ startX: y.clientX,
308
+ startY: y.clientY,
309
+ startRect: b,
297
310
  overlay: n
298
- }, document.addEventListener("mousemove", Mt), document.addEventListener("mouseup", re, { once: !0 });
299
- }, n.appendChild(r);
311
+ }, document.addEventListener("mousemove", Rt), document.addEventListener("mouseup", ae, { once: !0 });
312
+ }, n.appendChild(o);
300
313
  };
301
- x("top"), x("right"), x("bottom"), x("left"), x("nw"), x("ne"), x("sw"), x("se"), Rt && n.classList.add(Rt), lt.push(n);
314
+ L("top"), L("right"), L("bottom"), L("left"), L("nw"), L("ne"), L("sw"), L("se"), It && n.classList.add(It), it.push(n);
302
315
  });
303
- }, Mt = (t) => {
304
- if (!X) return;
305
- const { idx: e, side: s, startX: i, startY: c, startRect: o, overlay: n } = X, l = t.clientX - i, y = t.clientY - c;
306
- let p = o.left, f = o.top, h = o.width, g = o.height;
316
+ }, Rt = (t) => {
317
+ if (!j) return;
318
+ const { idx: e, side: r, startX: i, startY: c, startRect: s, overlay: n } = j, l = t.clientX - i, f = t.clientY - c;
319
+ let u = s.left, p = s.top, d = s.width, g = s.height;
307
320
  const m = 4;
308
- s === "left" || s === "nw" || s === "sw" ? (p = o.left + l, h = o.width - l, h < m && (p = o.left + (o.width - m), h = m)) : (s === "right" || s === "ne" || s === "se") && (h = o.width + l, h < m && (h = m)), s === "top" || s === "nw" || s === "ne" ? (f = o.top + y, g = o.height - y, g < m && (f = o.top + (o.height - m), g = m)) : (s === "bottom" || s === "sw" || s === "se") && (g = o.height + y, g < m && (g = m)), n.style.left = `${p}px`, n.style.top = `${f}px`, n.style.width = `${h}px`, n.style.height = `${g}px`;
309
- const x = Z(p, f, h, g), v = new Set(a[e] || []), r = /* @__PURE__ */ new Set();
310
- a.forEach((C, M) => {
311
- M !== e && C.forEach((z) => r.add(z));
321
+ r === "left" || r === "nw" || r === "sw" ? (u = s.left + l, d = s.width - l, d < m && (u = s.left + (s.width - m), d = m)) : (r === "right" || r === "ne" || r === "se") && (d = s.width + l, d < m && (d = m)), r === "top" || r === "nw" || r === "ne" ? (p = s.top + f, g = s.height - f, g < m && (p = s.top + (s.height - m), g = m)) : (r === "bottom" || r === "sw" || r === "se") && (g = s.height + f, g < m && (g = m)), n.style.left = `${u}px`, n.style.top = `${p}px`, n.style.width = `${d}px`, n.style.height = `${g}px`;
322
+ const x = nt(u, p, d, g), X = new Set(a[e] || []), A = /* @__PURE__ */ new Set();
323
+ a.forEach((E, z) => {
324
+ z !== e && E.forEach((C) => A.add(C));
312
325
  });
313
- const d = new Set(x);
314
- let w = !1, u = !1;
315
- for (let C = 0; C < a.length; C++) {
316
- if (C === e) continue;
317
- const M = new Set(a[C] || []);
318
- let z = 0;
319
- for (const k of d) M.has(k) && z++;
320
- if (z !== 0 && !(z === M.size && z === d.size))
321
- if (z === M.size)
322
- u = !0;
323
- else if (z === d.size)
324
- u = !0;
326
+ const L = new Set(x);
327
+ let v = !1, o = !1;
328
+ for (let E = 0; E < a.length; E++) {
329
+ if (E === e) continue;
330
+ const z = new Set(a[E] || []);
331
+ let C = 0;
332
+ for (const R of L) z.has(R) && C++;
333
+ if (C !== 0 && !(C === z.size && C === L.size))
334
+ if (C === z.size)
335
+ o = !0;
336
+ else if (C === L.size)
337
+ o = !0;
325
338
  else {
326
- w = !0;
339
+ v = !0;
327
340
  break;
328
341
  }
329
342
  }
330
- const b = x.filter((C) => !v.has(C)).length, S = !H && (w || !j && u), I = !U && b > 0;
331
- if (S || I) {
343
+ const h = x.filter((E) => !X.has(E)).length, y = !V && (v || !K && o), b = !W && h > 0;
344
+ if (y || b) {
332
345
  n.style.outline = "1px dashed #ff4d4f", n.style.background = "rgba(255,77,79,0.06)";
333
- const C = /* @__PURE__ */ new Set();
334
- a.forEach((M, z) => {
335
- (z === e ? a[e] || [] : M).forEach((L) => C.add(L));
336
- }), G(C);
346
+ const E = /* @__PURE__ */ new Set();
347
+ a.forEach((z, C) => {
348
+ (C === e ? a[e] || [] : z).forEach((P) => E.add(P));
349
+ }), O(E);
337
350
  } else {
338
- const C = D[e] || "rgba(255, 165, 0, 0.9)";
339
- n.style.outline = `1px solid ${C}`, n.style.background = "transparent";
340
- const M = /* @__PURE__ */ new Set();
341
- a.forEach((z, k) => {
342
- (k === e ? x : z).forEach((tt) => M.add(tt));
343
- }), G(M);
351
+ const E = H[e] || "rgba(255, 165, 0, 0.9)";
352
+ n.style.outline = `1px solid ${E}`, n.style.background = "transparent";
353
+ const z = /* @__PURE__ */ new Set();
354
+ a.forEach((C, R) => {
355
+ (R === e ? x : C).forEach((T) => z.add(T));
356
+ }), O(z);
344
357
  }
345
- }, re = (t) => {
346
- if (!X) return;
347
- const { idx: e, overlay: s, startRect: i } = X, c = parseFloat(s.style.left || "0"), o = parseFloat(s.style.top || "0"), n = parseFloat(s.style.width || "0"), l = parseFloat(s.style.height || "0"), y = Z(c, o, n, l), p = new Set(a[e] || []), f = /* @__PURE__ */ new Set();
348
- a.forEach((u, b) => {
349
- b !== e && u.forEach((S) => f.add(S));
358
+ }, ae = (t) => {
359
+ if (!j) return;
360
+ const { idx: e, overlay: r, startRect: i } = j, c = parseFloat(r.style.left || "0"), s = parseFloat(r.style.top || "0"), n = parseFloat(r.style.width || "0"), l = parseFloat(r.style.height || "0"), f = nt(c, s, n, l), u = new Set(a[e] || []), p = /* @__PURE__ */ new Set();
361
+ a.forEach((o, h) => {
362
+ h !== e && o.forEach((y) => p.add(y));
350
363
  });
351
- const h = new Set(y);
364
+ const d = new Set(f);
352
365
  let g = !1, m = !1;
353
- for (let u = 0; u < a.length; u++) {
354
- if (u === e) continue;
355
- const b = new Set(a[u] || []);
356
- let S = 0;
357
- for (const I of h) b.has(I) && S++;
358
- if (S !== 0 && !(S === b.size && S === h.size))
359
- if (S === b.size || S === h.size)
366
+ for (let o = 0; o < a.length; o++) {
367
+ if (o === e) continue;
368
+ const h = new Set(a[o] || []);
369
+ let y = 0;
370
+ for (const b of d) h.has(b) && y++;
371
+ if (y !== 0 && !(y === h.size && y === d.size))
372
+ if (y === h.size || y === d.size)
360
373
  m = !0;
361
374
  else {
362
375
  g = !0;
363
376
  break;
364
377
  }
365
378
  }
366
- const x = y.filter((u) => !p.has(u)).length, v = !H && (g || !j && m), r = !U && x > 0;
367
- if (v || r) {
368
- const u = /* @__PURE__ */ new Set();
369
- a.forEach((b) => b.forEach((S) => u.add(S))), G(u), O(), X = null, document.removeEventListener("mousemove", Mt), F();
379
+ const x = f.filter((o) => !u.has(o)).length, X = !V && (g || !K && m), A = !W && x > 0;
380
+ if (X || A) {
381
+ const o = /* @__PURE__ */ new Set();
382
+ a.forEach((h) => h.forEach((y) => o.add(y))), O(o), N(), j = null, document.removeEventListener("mousemove", Rt), F();
370
383
  return;
371
384
  }
372
- a[e] = y;
373
- const w = /* @__PURE__ */ new Set();
374
- a.forEach((u) => u.forEach((b) => w.add(b))), G(w), O(), X = null, document.removeEventListener("mousemove", Mt), F();
375
- }, qt = (t) => {
385
+ a[e] = f;
386
+ const v = /* @__PURE__ */ new Set();
387
+ a.forEach((o) => o.forEach((h) => v.add(h))), O(v), N(), j = null, document.removeEventListener("mousemove", Rt), F();
388
+ }, Dt = (t) => {
376
389
  if (t < 0 || t >= a.length) return !1;
377
390
  const e = a[t];
378
- e && e.forEach((i) => i.style.visibility = ""), a.splice(t, 1), N.splice(t, 1), D.splice(t, 1), T.length > t && T.splice(t, 1), A !== null && (A === t ? A = null : A > t && A--), Q(), O();
379
- const s = /* @__PURE__ */ new Set();
380
- return a.forEach((i) => i.forEach((c) => s.add(c))), G(s), F(), !0;
381
- }, ie = (t, e, s) => {
382
- if (!q || !R || R.length === 0 || t < 0 || t >= a.length || e < 0 || e >= R.length) return !1;
383
- const i = K(t);
391
+ e && e.forEach((i) => i.style.visibility = ""), a.splice(t, 1), I.splice(t, 1), H.splice(t, 1), U.length > t && U.splice(t, 1), k !== null && (k === t ? k = null : k > t && k--), et(), N();
392
+ const r = /* @__PURE__ */ new Set();
393
+ return a.forEach((i) => i.forEach((c) => r.add(c))), O(r), F(), !0;
394
+ }, fe = (t, e, r) => {
395
+ if (!q || !M || M.length === 0 || t < 0 || t >= a.length || e < 0 || e >= M.length) return !1;
396
+ const i = Q(t);
384
397
  if (!i) return !1;
385
398
  const c = i[e];
386
399
  if (!c) return !1;
387
- let o = !1;
388
- if (s.label !== void 0) {
389
- const n = s.label ?? "";
390
- c.label !== n && (c.label = n, o = !0);
400
+ let s = !1;
401
+ if (r.label !== void 0) {
402
+ const n = r.label ?? "";
403
+ c.label !== n && (c.label = n, s = !0);
391
404
  }
392
- if (s.title !== void 0) {
393
- const n = s.title ?? "";
394
- c.title !== n && (c.title = n, o = !0);
405
+ if (r.title !== void 0) {
406
+ const n = r.title ?? "";
407
+ c.title !== n && (c.title = n, s = !0);
395
408
  }
396
- return o && O(), o;
397
- }, ce = (t) => {
409
+ return s && N(), s;
410
+ }, pe = (t) => {
398
411
  if (!q || !Array.isArray(t) || t.length === 0) return !1;
399
- const e = Array.from(new Set(t)).filter((f) => {
400
- var h;
412
+ const e = Array.from(new Set(t)).filter((p) => {
413
+ var d;
401
414
  try {
402
- return !!f && B.contains(f) && !bt(f) && ((h = f.matches) == null ? void 0 : h.call(f, pt));
415
+ return !!p && B.contains(p) && !xt(p) && ((d = p.matches) == null ? void 0 : d.call(p, dt));
403
416
  } catch {
404
417
  return !1;
405
418
  }
406
419
  });
407
- if (e.length === 0 || zt(e) !== null) return !1;
420
+ if (e.length === 0 || Mt(e) !== null) return !1;
408
421
  const i = new Set(e);
409
- let c = !1, o = !1;
410
- for (const f of a) {
411
- const h = new Set(f);
422
+ let c = !1, s = !1;
423
+ for (const p of a) {
424
+ const d = new Set(p);
412
425
  let g = 0;
413
- for (const m of i) h.has(m) && g++;
414
- if (g !== 0 && !(g === h.size && g === i.size))
415
- if (g === h.size || g === i.size)
416
- o = !0;
426
+ for (const m of i) d.has(m) && g++;
427
+ if (g !== 0 && !(g === d.size && g === i.size))
428
+ if (g === d.size || g === i.size)
429
+ s = !0;
417
430
  else {
418
431
  c = !0;
419
432
  break;
420
433
  }
421
434
  }
422
- const n = new Set(Y), l = !H && (c || !j && o), y = !U && n.size > 0 && e.length > 0;
423
- if (l || y) return !1;
424
- a.push(e), N.push(!1), D.push(St()), R != null && R.length && K(a.length - 1), A = a.length - 1;
425
- const p = /* @__PURE__ */ new Set();
426
- return a.forEach((f) => f.forEach((h) => p.add(h))), G(p), O(), F(), !0;
427
- }, ae = (t) => {
435
+ const n = new Set(D), l = !V && (c || !K && s), f = !W && n.size > 0 && e.length > 0;
436
+ if (l || f) return !1;
437
+ a.push(e), I.push(!1), H.push(zt()), M != null && M.length && Q(a.length - 1), k = a.length - 1;
438
+ const u = /* @__PURE__ */ new Set();
439
+ return a.forEach((p) => p.forEach((d) => u.add(d))), O(u), N(), F(), !0;
440
+ }, ue = (t) => {
428
441
  if (q) return "add";
429
- const e = At ? gt ?? "add" : "replace";
430
- return At ? gt === "auto" ? t.shiftKey ? "add" : t.altKey ? "subtract" : t.metaKey || t.ctrlKey ? "toggle" : "add" : gt ?? e : "replace";
431
- }, G = (t) => {
432
- for (const e of Array.from(Y))
433
- t.has(e) || e.classList.remove(nt);
442
+ const e = Nt ? bt ?? "add" : "replace";
443
+ return Nt ? bt === "auto" ? t.shiftKey ? "add" : t.altKey ? "subtract" : t.metaKey || t.ctrlKey ? "toggle" : "add" : bt ?? e : "replace";
444
+ }, O = (t) => {
445
+ for (const e of Array.from(D))
446
+ t.has(e) || e.classList.remove(st);
434
447
  for (const e of Array.from(t))
435
- Y.has(e) || e.classList.add(nt);
436
- Y = t, dt && dt(q ? {
448
+ D.has(e) || e.classList.add(st);
449
+ D = t, gt && gt(q ? {
437
450
  type: "groups",
438
451
  groups: a.slice(),
439
- flat: Array.from(Y)
440
- } : { type: "single", selected: Array.from(Y) });
441
- }, Yt = (t, e, s) => {
442
- if (s === "replace") return new Set(e);
452
+ flat: Array.from(D)
453
+ } : { type: "single", selected: Array.from(D) });
454
+ }, Xt = (t, e, r) => {
455
+ if (r === "replace") return new Set(e);
443
456
  const i = new Set(t);
444
- if (s === "add")
457
+ if (r === "add")
445
458
  for (const c of e) i.add(c);
446
- else if (s === "subtract")
459
+ else if (r === "subtract")
447
460
  for (const c of e) i.delete(c);
448
- else if (s === "toggle")
461
+ else if (r === "toggle")
449
462
  for (const c of e)
450
463
  i.has(c) ? i.delete(c) : i.add(c);
451
464
  return i;
452
- }, Dt = (t) => {
465
+ }, Ht = (t) => {
453
466
  if (t.button !== 0) return;
454
467
  const e = t.target;
455
- !B.contains(e) && e !== document.body || (vt = t.clientX, wt = t.clientY, W = !0, $ = ne(), Et = ae(t), V = new Set(Y), t.preventDefault());
456
- }, Tt = (t) => {
468
+ !B.contains(e) && e !== document.body || (wt = t.clientX, Et = t.clientY, J = !0, $ = le(), Ct = ue(t), _ = new Set(D), t.preventDefault());
469
+ }, Ut = (t) => {
457
470
  var g;
458
- if (!W && st) {
459
- const m = t.target, x = (g = m == null ? void 0 : m.closest) == null ? void 0 : g.call(m, pt);
460
- x && B.contains(x) && !bt(x) ? it(x) : it(null);
471
+ if (!J && rt) {
472
+ const m = t.target, x = (g = m == null ? void 0 : m.closest) == null ? void 0 : g.call(m, dt);
473
+ x && B.contains(x) && !xt(x) ? at(x) : at(null);
461
474
  }
462
- if (!W || !$) return;
463
- const { left: e, top: s, width: i, height: c } = Bt(
464
- vt,
475
+ if (!J || !$) return;
476
+ const { left: e, top: r, width: i, height: c } = Yt(
465
477
  wt,
478
+ Et,
466
479
  t.clientX,
467
480
  t.clientY
468
481
  );
469
- $.style.left = `${e}px`, $.style.top = `${s}px`, $.style.width = `${i}px`, $.style.height = `${c}px`;
470
- const o = Z(e, s, i, c), n = V ?? /* @__PURE__ */ new Set(), l = new Set(o);
471
- let y = 0;
472
- for (const m of l) n.has(m) && y++;
473
- let p = "disjoint";
474
- y === 0 ? p = "disjoint" : y === l.size && y === n.size ? p = "equal" : y === l.size || y === n.size ? p = "containment" : p = "partial";
475
- const f = !H && (p === "partial" || !j && p === "containment"), h = !U && n.size > 0 && o.length > 0;
476
- if (xt = f || h, $ && (xt ? ($.style.outline = "1px dashed #ff4d4f", $.style.background = "rgba(255,77,79,0.12)") : ($.style.outline = "1px dashed #268aff", $.style.background = "rgba(38,138,255,0.12)")), xt)
477
- G(n);
482
+ $.style.left = `${e}px`, $.style.top = `${r}px`, $.style.width = `${i}px`, $.style.height = `${c}px`;
483
+ const s = nt(e, r, i, c), n = _ ?? /* @__PURE__ */ new Set(), l = new Set(s);
484
+ let f = 0;
485
+ for (const m of l) n.has(m) && f++;
486
+ let u = "disjoint";
487
+ f === 0 ? u = "disjoint" : f === l.size && f === n.size ? u = "equal" : f === l.size || f === n.size ? u = "containment" : u = "partial";
488
+ const p = !V && (u === "partial" || !K && u === "containment"), d = !W && n.size > 0 && s.length > 0;
489
+ if (St = p || d, $ && (St ? ($.style.outline = "1px dashed #ff4d4f", $.style.background = "rgba(255,77,79,0.12)") : ($.style.outline = "1px dashed #268aff", $.style.background = "rgba(38,138,255,0.12)")), St)
490
+ O(n);
478
491
  else {
479
- const m = Yt(n, o, Et);
480
- G(m);
492
+ const m = Xt(n, s, Ct);
493
+ O(m);
481
494
  }
482
- }, Xt = (t) => {
483
- if (!W) return;
484
- W = !1, $ && $.parentNode && $.parentNode.removeChild($), $ = null;
485
- const { left: e, top: s, width: i, height: c } = Bt(
486
- vt,
495
+ }, jt = (t) => {
496
+ if (!J) return;
497
+ J = !1, $ && $.parentNode && $.parentNode.removeChild($), $ = null;
498
+ const { left: e, top: r, width: i, height: c } = Yt(
487
499
  wt,
500
+ Et,
488
501
  t.clientX,
489
502
  t.clientY
490
- ), o = Z(e, s, i, c), n = V ?? /* @__PURE__ */ new Set(), l = new Set(o);
491
- let y = 0;
492
- for (const x of l) n.has(x) && y++;
493
- let p = "disjoint";
494
- y === 0 ? p = "disjoint" : y === l.size && y === n.size ? p = "equal" : y === l.size || y === n.size ? p = "containment" : p = "partial";
495
- const f = !H && (p === "partial" || !j && p === "containment"), h = !U && n.size > 0 && o.length > 0;
496
- if (f || h) {
497
- G(n), V = null, F();
503
+ ), s = nt(e, r, i, c), n = _ ?? /* @__PURE__ */ new Set(), l = new Set(s);
504
+ let f = 0;
505
+ for (const x of l) n.has(x) && f++;
506
+ let u = "disjoint";
507
+ f === 0 ? u = "disjoint" : f === l.size && f === n.size ? u = "equal" : f === l.size || f === n.size ? u = "containment" : u = "partial";
508
+ const p = !V && (u === "partial" || !K && u === "containment"), d = !W && n.size > 0 && s.length > 0;
509
+ if (p || d) {
510
+ O(n), _ = null, F();
498
511
  return;
499
512
  }
500
- const m = Yt(n, o, Et);
501
- if (G(m), q && o.length > 0) {
502
- const x = zt(o);
513
+ const m = Xt(n, s, Ct);
514
+ if (O(m), q && s.length > 0) {
515
+ const x = Mt(s);
503
516
  if (x !== null) {
504
517
  try {
505
518
  console.warn(`重复编组被阻止:与已存在的第${x + 1}组元素完全一致`);
506
519
  } catch {
507
520
  }
508
- V = null, F();
521
+ _ = null, F();
509
522
  return;
510
523
  }
511
- a.push(o), A = a.length - 1, N.push(!1), D.push(St()), R != null && R.length && K(a.length - 1);
512
- const v = /* @__PURE__ */ new Set();
513
- a.forEach((r) => r.forEach((d) => v.add(d))), G(v), O();
524
+ a.push(s), k = a.length - 1, I.push(!1), H.push(zt()), M != null && M.length && Q(a.length - 1);
525
+ const X = /* @__PURE__ */ new Set();
526
+ a.forEach((A) => A.forEach((L) => X.add(L))), O(X), N();
514
527
  }
515
- V = null, F();
516
- }, Ht = (t) => {
528
+ _ = null, F();
529
+ }, Vt = (t) => {
517
530
  var m;
518
- if (!mt || !q) return;
531
+ if (!vt || !q) return;
519
532
  const e = t.target;
520
533
  if (!e) return;
521
- let s = e;
522
- if (Nt && (s = ((m = e.closest) == null ? void 0 : m.call(e, Nt)) || null), !s || !B.contains(s)) return;
523
- const i = s.getBoundingClientRect(), c = Z(i.left, i.top, i.width, i.height), o = new Set(Y), n = new Set(c);
534
+ let r = e;
535
+ if (Ft && (r = ((m = e.closest) == null ? void 0 : m.call(e, Ft)) || null), !r || !B.contains(r)) return;
536
+ const i = r.getBoundingClientRect(), c = nt(i.left, i.top, i.width, i.height), s = new Set(D), n = new Set(c);
524
537
  let l = 0;
525
- for (const x of n) o.has(x) && l++;
526
- let y = "disjoint";
527
- l === 0 ? y = "disjoint" : l === n.size && l === o.size ? y = "equal" : l === n.size || l === o.size ? y = "containment" : y = "partial";
528
- const p = !H && (y === "partial" || !j && y === "containment"), f = !U && o.size > 0 && c.length > 0;
529
- if (c.length === 0 || p || f) {
538
+ for (const x of n) s.has(x) && l++;
539
+ let f = "disjoint";
540
+ l === 0 ? f = "disjoint" : l === n.size && l === s.size ? f = "equal" : l === n.size || l === s.size ? f = "containment" : f = "partial";
541
+ const u = !V && (f === "partial" || !K && f === "containment"), p = !W && s.size > 0 && c.length > 0;
542
+ if (c.length === 0 || u || p) {
530
543
  F();
531
544
  return;
532
545
  }
533
- const h = zt(c);
534
- if (h !== null) {
546
+ const d = Mt(c);
547
+ if (d !== null) {
535
548
  try {
536
- console.warn(`重复编组被阻止:与已存在的第${h + 1}组元素完全一致`);
549
+ console.warn(`重复编组被阻止:与已存在的第${d + 1}组元素完全一致`);
537
550
  } catch {
538
551
  }
539
552
  F();
540
553
  return;
541
554
  }
542
- a.push(c), A = a.length - 1, N.push(!1), D.push(St()), R != null && R.length && K(a.length - 1);
555
+ a.push(c), k = a.length - 1, I.push(!1), H.push(zt()), M != null && M.length && Q(a.length - 1);
543
556
  const g = /* @__PURE__ */ new Set();
544
- a.forEach((x) => x.forEach((v) => g.add(v))), G(g), O(), F();
545
- }, Ut = () => it(null);
546
- function Z(t, e, s, i) {
547
- if (s === 0 || i === 0) return [];
548
- const c = B.getBoundingClientRect(), o = new DOMRect(t, e, s, i);
549
- if (!ct(o, c)) return [];
550
- const n = Array.from(B.querySelectorAll(pt));
557
+ a.forEach((x) => x.forEach((X) => g.add(X))), O(g), N(), F();
558
+ }, Wt = () => at(null);
559
+ function nt(t, e, r, i) {
560
+ if (r === 0 || i === 0) return [];
561
+ const c = B.getBoundingClientRect(), s = new DOMRect(t, e, r, i);
562
+ if (!ft(s, c)) return [];
563
+ const n = Array.from(B.querySelectorAll(dt));
551
564
  let l = [];
552
- const y = /* @__PURE__ */ new Map();
553
- for (const f of n) {
554
- if (bt(f)) continue;
555
- const h = f.getBoundingClientRect();
556
- if (!ct(h, c)) continue;
565
+ const f = /* @__PURE__ */ new Map();
566
+ for (const p of n) {
567
+ if (xt(p)) continue;
568
+ const d = p.getBoundingClientRect();
569
+ if (!ft(d, c)) continue;
557
570
  let g = !1;
558
- if (ht === "contains")
559
- g = oe(o, h);
560
- else if (ht === "center") {
561
- const m = h.left + h.width / 2, x = h.top + h.height / 2;
562
- g = m >= o.left && m <= o.right && x >= o.top && x <= o.bottom;
571
+ if (yt === "contains")
572
+ g = re(s, d);
573
+ else if (yt === "center") {
574
+ const m = d.left + d.width / 2, x = d.top + d.height / 2;
575
+ g = m >= s.left && m <= s.right && x >= s.top && x <= s.bottom;
563
576
  } else
564
- ct(o, h) && (g = Pt(o, h) >= Math.max(0, Math.min(1, Kt)));
577
+ ft(s, d) && (g = qt(s, d) >= Math.max(0, Math.min(1, Qt)));
565
578
  if (g) {
566
- const m = ht === "contains" ? 1 : Pt(o, h);
567
- y.set(f, m), l.push(f);
579
+ const m = yt === "contains" ? 1 : qt(s, d);
580
+ f.set(p, m), l.push(p);
568
581
  }
569
582
  }
570
- const p = Qt ?? (Jt ? "leaf" : "none");
571
- if (p !== "none" && l.length > 1) {
572
- if (p === "leaf")
583
+ const u = ee ?? (te ? "leaf" : "none");
584
+ if (u !== "none" && l.length > 1) {
585
+ if (u === "leaf")
573
586
  l = l.filter(
574
- (f) => !l.some(
575
- (h) => h !== f && f.contains(h)
587
+ (p) => !l.some(
588
+ (d) => d !== p && p.contains(d)
576
589
  )
577
590
  );
578
- else if (p === "best") {
579
- const f = [...l].sort(
580
- (g, m) => (y.get(m) || 0) - (y.get(g) || 0)
581
- ), h = [];
582
- for (const g of f)
583
- h.find(
591
+ else if (u === "best") {
592
+ const p = [...l].sort(
593
+ (g, m) => (f.get(m) || 0) - (f.get(g) || 0)
594
+ ), d = [];
595
+ for (const g of p)
596
+ d.find(
584
597
  (x) => x.contains(g) || g.contains(x)
585
- ) || h.push(g);
586
- l = h;
598
+ ) || d.push(g);
599
+ l = d;
587
600
  }
588
601
  }
589
602
  return l;
590
603
  }
591
- document.addEventListener("mousedown", Dt, !0), document.addEventListener("mousemove", Tt), document.addEventListener("mouseup", Xt), st && B.addEventListener("mouseleave", Ut), q && mt && B.addEventListener("dblclick", Ht);
592
- const at = () => O();
593
- q && (window.addEventListener("scroll", at, !0), window.addEventListener("resize", at));
594
- const ft = () => {
604
+ document.addEventListener("mousedown", Ht, !0), document.addEventListener("mousemove", Ut), document.addEventListener("mouseup", jt), rt && B.addEventListener("mouseleave", Wt), q && vt && B.addEventListener("dblclick", Vt);
605
+ const pt = () => N();
606
+ q && (window.addEventListener("scroll", pt, !0), window.addEventListener("resize", pt));
607
+ const ut = () => {
595
608
  if (q) {
596
- const t = a.map((o) => $t(o)), e = Array(a.length).fill(null), s = t.map(
597
- (o) => o ? Math.max(0, o.width * o.height) : Number.POSITIVE_INFINITY
609
+ const t = a.map((s) => kt(s)), e = Array(a.length).fill(null), r = t.map(
610
+ (s) => s ? Math.max(0, s.width * s.height) : Number.POSITIVE_INFINITY
598
611
  );
599
- for (let o = 0; o < a.length; o++) {
600
- const n = t[o];
612
+ for (let s = 0; s < a.length; s++) {
613
+ const n = t[s];
601
614
  if (!n) continue;
602
- let l = null, y = Number.POSITIVE_INFINITY;
603
- for (let p = 0; p < a.length; p++) {
604
- if (o === p) continue;
605
- const f = t[p];
606
- if (!f) continue;
607
- if (f.left <= n.left && f.top <= n.top && f.left + f.width >= n.left + n.width && f.top + f.height >= n.top + n.height) {
608
- const g = Number(s[p]);
609
- g < y && (y = g, l = p);
615
+ let l = null, f = Number.POSITIVE_INFINITY;
616
+ for (let u = 0; u < a.length; u++) {
617
+ if (s === u) continue;
618
+ const p = t[u];
619
+ if (!p) continue;
620
+ if (p.left <= n.left && p.top <= n.top && p.left + p.width >= n.left + n.width && p.top + p.height >= n.top + n.height) {
621
+ const g = Number(r[u]);
622
+ g < f && (f = g, l = u);
610
623
  }
611
624
  }
612
- e[o] = l;
625
+ e[s] = l;
613
626
  }
614
627
  const i = Array.from(
615
628
  { length: a.length },
616
629
  () => []
617
630
  );
618
- for (let o = 0; o < a.length; o++) {
619
- const n = e[o];
620
- n != null && i[n] && i[n].push(o);
631
+ for (let s = 0; s < a.length; s++) {
632
+ const n = e[s];
633
+ n != null && i[n] && i[n].push(s);
621
634
  }
622
635
  const c = [];
623
- for (let o = 0; o < a.length; o++)
624
- (e[o] === null || e[o] === void 0) && c.push(o);
636
+ for (let s = 0; s < a.length; s++)
637
+ (e[s] === null || e[s] === void 0) && c.push(s);
625
638
  return {
626
639
  type: "groups",
627
- groups: a.map((o) => o.slice()),
628
- flat: Array.from(Y),
629
- hidden: N.slice(),
640
+ groups: a.map((s) => s.slice()),
641
+ flat: Array.from(D),
642
+ hidden: I.slice(),
630
643
  groupRects: t,
631
644
  groupNesting: { parents: e, children: i, roots: c }
632
645
  };
633
646
  }
634
- return { type: "single", selected: Array.from(Y) };
647
+ return { type: "single", selected: Array.from(D) };
635
648
  }, F = () => {
636
- const t = ft();
637
- if (Lt)
649
+ const t = ut();
650
+ if (Gt)
638
651
  try {
639
- Lt(t);
652
+ Gt(t);
640
653
  } catch {
641
654
  }
642
- for (const s of _)
655
+ for (const r of Z)
643
656
  try {
644
- s(t);
657
+ r(t);
645
658
  } catch {
646
659
  }
647
- const e = Ct.splice(0);
648
- for (const s of e)
660
+ const e = $t.splice(0);
661
+ for (const r of e)
649
662
  try {
650
- s(t);
663
+ r(t);
651
664
  } catch {
652
665
  }
653
- }, jt = {
666
+ }, Kt = {
654
667
  destroy() {
655
- document.removeEventListener("mousedown", Dt), document.removeEventListener("mousemove", Tt), document.removeEventListener("mouseup", Xt), $ && $.parentNode && $.parentNode.removeChild($), $ = null, B.querySelectorAll(`.${nt}`).forEach((e) => e.classList.remove(nt)), st && (B.removeEventListener("mouseleave", Ut), it(null)), q && (window.removeEventListener("scroll", at, !0), window.removeEventListener("resize", at)), q && mt && B.removeEventListener("dblclick", Ht), Q(), a.forEach(
656
- (e) => e.forEach((s) => s.style.visibility = "")
657
- ), a = [], N = [], D = [], T = [], A = null, Y.clear(), _.splice(0), Ct.splice(0);
668
+ document.removeEventListener("mousedown", Ht), document.removeEventListener("mousemove", Ut), document.removeEventListener("mouseup", jt), $ && $.parentNode && $.parentNode.removeChild($), $ = null, B.querySelectorAll(`.${st}`).forEach((e) => e.classList.remove(st)), rt && (B.removeEventListener("mouseleave", Wt), at(null)), q && (window.removeEventListener("scroll", pt, !0), window.removeEventListener("resize", pt)), q && vt && B.removeEventListener("dblclick", Vt), et(), a.forEach(
669
+ (e) => e.forEach((r) => r.style.visibility = "")
670
+ ), a = [], I = [], H = [], U = [], k = null, D.clear(), Z.splice(0), $t.splice(0);
658
671
  },
659
672
  getGroups() {
660
673
  return a.slice();
661
674
  },
662
675
  clearGroups() {
663
676
  a.forEach(
664
- (e) => e.forEach((s) => s.style.visibility = "")
665
- ), a = [], N = [], D = [], T = [], A = null, Q(), G(/* @__PURE__ */ new Set());
677
+ (e) => e.forEach((r) => r.style.visibility = "")
678
+ ), a = [], I = [], H = [], U = [], k = null, et(), O(/* @__PURE__ */ new Set());
666
679
  },
667
680
  removeGroup(t) {
668
- return qt(t);
681
+ return Dt(t);
669
682
  },
670
683
  addGroup(t) {
671
- return ce(t);
684
+ return pe(t);
672
685
  },
673
686
  setGroupVisibility(t, e) {
674
- return rt(t, e);
687
+ return ct(t, e);
675
688
  },
676
689
  toggleGroupVisibility(t) {
677
- return t < 0 || t >= a.length ? !1 : (N[t] = !N[t], Ft(t), O(), !0);
690
+ return t < 0 || t >= a.length ? !1 : (I[t] = !I[t], Bt(t), N(), !0);
678
691
  },
679
692
  getSelectionResult() {
680
- return ft();
693
+ return ut();
681
694
  },
682
695
  refresh() {
683
- O();
696
+ N();
684
697
  },
685
698
  hideOverlays() {
686
- Q();
699
+ et();
687
700
  },
688
701
  showAndRefreshOverlays() {
689
- O();
702
+ N();
690
703
  },
691
704
  // 获取当前组级嵌套信息
692
705
  getGroupNesting() {
693
- const t = ft();
706
+ const t = ut();
694
707
  return t.type === "groups" ? t.groupNesting : null;
695
708
  },
696
- setToolbarButtonProps(t, e, s) {
697
- return ie(t, e, s);
709
+ setToolbarButtonProps(t, e, r) {
710
+ return fe(t, e, r);
711
+ },
712
+ setViewScale(t) {
698
713
  },
699
714
  onSelectionEnd(t) {
700
- return _.push(t), () => {
701
- const e = _.indexOf(t);
702
- e >= 0 && _.splice(e, 1);
715
+ return Z.push(t), () => {
716
+ const e = Z.indexOf(t);
717
+ e >= 0 && Z.splice(e, 1);
703
718
  };
704
719
  },
705
720
  waitForSelectionEnd() {
706
721
  return new Promise((t) => {
707
- Ct.push(t);
722
+ $t.push(t);
708
723
  });
709
724
  }
710
725
  };
711
- return Gt = jt, jt;
726
+ return Tt = Kt, Kt;
712
727
  }
713
728
  export {
714
- pe as default,
715
- pe as marqueeSelection
729
+ ye as default,
730
+ ye as marqueeSelection
716
731
  };
717
732
  //# sourceMappingURL=marquee-selection.es.js.map