@ptahjs/dnd 0.1.1 → 0.1.3

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,45 +1,6 @@
1
- //#region src/core/EventDispatcher.js
2
- var e = class {
3
- #e = /* @__PURE__ */ new Map();
4
- emit(e, t) {
5
- let n = this.#e.get(e);
6
- if (!n || n.length === 0) return t;
7
- let r = n.slice();
8
- for (let n of r) try {
9
- n(t);
10
- } catch (t) {
11
- console.error(`[EventDispatcher] handler error for "${e}":`, t);
12
- }
13
- return t;
14
- }
15
- pipe(e, t) {
16
- let n = this.#e.get(e);
17
- if (!n || n.length === 0) return t;
18
- let r = t;
19
- for (let t of n.slice()) try {
20
- let e = t(r);
21
- e !== void 0 && (r = e);
22
- } catch (t) {
23
- console.error(`[EventDispatcher] pipe handler error for "${e}":`, t);
24
- }
25
- return r;
26
- }
27
- on(e, t) {
28
- let n = this.#e.get(e);
29
- return n ? n.includes(t) || n.push(t) : this.#e.set(e, [t]), this;
30
- }
31
- off(e, t) {
32
- let n = this.#e.get(e);
33
- if (n) if (t) {
34
- let e = n.indexOf(t);
35
- e !== -1 && n.splice(e, 1);
36
- } else this.#e.delete(e);
37
- return this;
38
- }
39
- offAll() {
40
- this.#e.clear();
41
- }
42
- }, t = {
1
+ (function(){try{const elementStyle=document.createElement('style');elementStyle.appendChild(document.createTextNode(".draggable-dot-wrap{pointer-events:none;z-index:1;box-sizing:border-box;position:absolute;inset:0}.draggable-dot{z-index:2;pointer-events:auto;background:#3a7afe;border-radius:50%;width:10px;height:10px;display:block;position:absolute;transform:translate(-50%,-50%)}.draggable-dot[data-pos=tl]{cursor:nw-resize;top:0%;left:0%}.draggable-dot[data-pos=tm]{cursor:n-resize;border-radius:8px;width:16px;height:8px;top:0%;left:50%}.draggable-dot[data-pos=tr]{cursor:ne-resize;top:0%;right:0%;transform:translate(50%,-50%)}.draggable-dot[data-pos=rm]{cursor:e-resize;border-radius:8px;width:8px;height:16px;top:50%;right:0%;transform:translate(50%,-50%)}.draggable-dot[data-pos=br]{cursor:se-resize;bottom:0%;right:0%;transform:translate(50%,50%)}.draggable-dot[data-pos=bm]{cursor:s-resize;border-radius:8px;width:16px;height:8px;bottom:0%;left:50%;transform:translate(-50%,50%)}.draggable-dot[data-pos=bl]{cursor:sw-resize;bottom:0%;left:0%;transform:translate(-50%,50%)}.draggable-dot[data-pos=lm]{cursor:w-resize;border-radius:8px;width:8px;height:16px;top:50%;left:0%}.draggable-rotate{z-index:2;cursor:grab;pointer-events:auto;position:absolute;top:0;left:50%;transform:translate(-50%,-200%)}.draggable-rotate:after{content:\"\";background:url(data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20viewBox%3D%220%200%201024%201024%22%3E%3Cpath%20fill%3D%22%233a7afe%22%20d%3D%22M784.512%20230.272v-50.56a32%2032%200%201%201%2064%200v149.056a32%2032%200%200%201-32%2032H667.52a32%2032%200%201%201%200-64h92.992A320%20320%200%201%200%20524.8%20833.152a320%20320%200%200%200%20320-320h64a384%20384%200%200%201-384%20384%20384%20384%200%200%201-384-384%20384%20384%200%200%201%20643.712-282.88z%22/%3E%3C/svg%3E) 50%/contain no-repeat;width:16px;height:16px;display:block}.draggable-markline-x,.draggable-markline-y{z-index:9999;background-color:#3a7afe;display:none;position:absolute;top:0;left:0}.draggable-markline-x{width:1px;height:100%}.draggable-markline-y{width:100%;height:1px}.dnd-mirror{pointer-events:none;z-index:999999;will-change:transform;opacity:.5;background:#fff;margin:0;position:fixed;top:0;left:0;transform:translate(0,0)}.dnd-indicator{--dnd-color:#3a7afe;--dnd-dot:6px;--dnd-line:2px;pointer-events:none;background:var(--dnd-color);display:none;position:absolute}.dnd-indicator.dnd-indicator-active{display:block}.dnd-indicator:before,.dnd-indicator:after{content:\"\";background:var(--dnd-color);width:var(--dnd-dot);height:var(--dnd-dot);opacity:0;border-radius:50%;transition:opacity .15s;position:absolute}.dnd-indicator-active:before,.dnd-indicator-active:after{opacity:1}.dnd-indicator--top,.dnd-indicator--bottom{height:var(--dnd-line);width:100%;left:0}.dnd-indicator--top{top:0}.dnd-indicator--bottom{bottom:0}.dnd-indicator--top:before,.dnd-indicator--bottom:before{left:-2px}.dnd-indicator--top:after,.dnd-indicator--bottom:after{right:-2px}.dnd-indicator--top:before,.dnd-indicator--top:after{top:-2px}.dnd-indicator--bottom:before,.dnd-indicator--bottom:after{bottom:-2px}.dnd-indicator--left,.dnd-indicator--right{width:var(--dnd-line);height:100%;top:0}.dnd-indicator--left{left:0}.dnd-indicator--right{right:0}.dnd-indicator--left:before,.dnd-indicator--left:after{left:-2px}.dnd-indicator--right:before,.dnd-indicator--right:after{right:-2px}.dnd-indicator--left:before,.dnd-indicator--right:before{top:-2px}.dnd-indicator--left:after,.dnd-indicator--right:after{bottom:-2px}.dnd-marquee{pointer-events:none;z-index:9999;background:#4096ff1a;border:1px solid #4096ff99;position:absolute}\n/*$vite$:1*/"));document.head.appendChild(elementStyle)}catch(e){console.error('PtahJs Style Inject:',e)}})();import { EventDispatcher as e } from "@ptahjs/shared";
2
+ //#region src/constant.js
3
+ var t = {
43
4
  dataAttr: "data",
44
5
  copyAttr: "copy",
45
6
  dragAttr: "drag",
@@ -75,38 +36,43 @@ var e = class {
75
36
  }, o = {
76
37
  EDGE: 48,
77
38
  MIN_SPEED: 180,
78
- MAX_SPEED: 600
79
- };
39
+ MAX_SPEED: 600,
40
+ MIN_DT: 8,
41
+ MAX_DT: 64,
42
+ DEFAULT_DT: 16.67
43
+ }, s = .5, c = .5;
80
44
  //#endregion
81
45
  //#region src/utils/computeDropRegion.js
82
- function s(e, t) {
83
- let n = `dropRegionFns_${(t instanceof Set ? Array.from(t).sort().join(",") : t) || "all"}`;
84
- if (e?.cache?.[n]) return e.cache[n];
85
- let a = () => {
46
+ function l(e, t) {
47
+ let n;
48
+ n = t instanceof Set ? t.__regionKey ??= Array.from(t).sort().join(",") : t;
49
+ let a = `dropRegionFns_${n || "all"}`;
50
+ if (e?.cache?.[a]) return e.cache[a];
51
+ let o = () => {
86
52
  if (e.currentDrop) return e.currentDropRect || void 0;
87
- }, o = !t || t === "all" || t instanceof Set && (t.has("top") || t.has("bottom")), s = !t || t === "all" || t instanceof Set && (t.has("left") || t.has("right")), c = {
88
- isOverTop: o ? () => {
89
- let t = a();
53
+ }, s = !t || t === "all" || t instanceof Set && (t.has("top") || t.has("bottom")), c = !t || t === "all" || t instanceof Set && (t.has("left") || t.has("right")), l = {
54
+ isOverTop: s ? () => {
55
+ let t = o();
90
56
  return t ? e.y < t.y + t.height * r : !1;
91
57
  } : () => !1,
92
- isOverBottom: o ? () => {
93
- let t = a();
58
+ isOverBottom: s ? () => {
59
+ let t = o();
94
60
  return t ? e.y > t.y + t.height * (1 - r) : !1;
95
61
  } : () => !1,
96
- isOverLeft: s ? () => {
97
- let t = a();
62
+ isOverLeft: c ? () => {
63
+ let t = o();
98
64
  return t ? e.x < t.x + t.width * i : !1;
99
65
  } : () => !1,
100
- isOverRight: s ? () => {
101
- let t = a();
66
+ isOverRight: c ? () => {
67
+ let t = o();
102
68
  return t ? e.x > t.x + t.width * (1 - i) : !1;
103
69
  } : () => !1
104
70
  };
105
- return e?.cache && (e.cache[n] = c), c;
71
+ return e?.cache && (e.cache[a] = l), l;
106
72
  }
107
73
  //#endregion
108
74
  //#region src/utils/parseData.js
109
- function c(e) {
75
+ function u(e) {
110
76
  if (e === void 0) return;
111
77
  let t = String(e).trim();
112
78
  if (!t) return "";
@@ -118,7 +84,7 @@ function c(e) {
118
84
  }
119
85
  //#endregion
120
86
  //#region src/utils/createPayload.js
121
- function l(e, n) {
87
+ function d(e, n) {
122
88
  let r = () => {
123
89
  let e = n.currentDrop;
124
90
  if (!e) return;
@@ -137,7 +103,7 @@ function l(e, n) {
137
103
  return;
138
104
  }
139
105
  let i = n.adapter.getAttr(e, t.dataAttr);
140
- return r.dropDataEl === e && i === r.dropDataRaw ? r.dropDataParsed : (r.dropDataEl = e, r.dropDataRaw = i, r.dropDataParsed = c(i), r.dropDataParsed);
106
+ return r.dropDataEl === e && i === r.dropDataRaw ? r.dropDataParsed : (r.dropDataEl = e, r.dropDataRaw = i, r.dropDataParsed = u(i), r.dropDataParsed);
141
107
  };
142
108
  if (!n.cache.hitDropFn) {
143
109
  let e = -1, t = 0, r = 0, i, a;
@@ -154,8 +120,12 @@ function l(e, n) {
154
120
  type: e,
155
121
  namespace: n.namespace,
156
122
  data: n.data,
157
- dropData: i(),
158
- dropPoint: r(),
123
+ get dropData() {
124
+ return i();
125
+ },
126
+ get dropPoint() {
127
+ return r();
128
+ },
159
129
  indicatorRegion: n.lastIndicatorRegion,
160
130
  isDragScope: n.isDragScope,
161
131
  isCopy: n.isCopy,
@@ -169,12 +139,12 @@ function l(e, n) {
169
139
  dy: n.dy,
170
140
  started: n.started,
171
141
  hitDrop: n.cache.hitDropFn,
172
- ...s(n)
142
+ ...l(n)
173
143
  };
174
144
  }
175
145
  //#endregion
176
146
  //#region src/utils/createSession.js
177
- function u(e) {
147
+ function f(e) {
178
148
  return {
179
149
  adapter: void 0,
180
150
  currentDropRect: void 0,
@@ -227,7 +197,7 @@ function u(e) {
227
197
  }
228
198
  //#endregion
229
199
  //#region src/utils/createContext.js
230
- function d({ dnd: e, session: t, store: n, frame: r, adapter: i }) {
200
+ function p({ dnd: e, session: t, store: n, frame: r, adapter: i }) {
231
201
  let a = /* @__PURE__ */ new Map();
232
202
  return {
233
203
  dnd: e,
@@ -237,24 +207,27 @@ function d({ dnd: e, session: t, store: n, frame: r, adapter: i }) {
237
207
  adapter: i,
238
208
  payload: (e = "drag") => {
239
209
  if (a.has(e)) return a.get(e);
240
- let n = l(e, t);
210
+ let n = d(e, t);
241
211
  return a.set(e, n), n;
212
+ },
213
+ resetPayloadCache() {
214
+ a.clear();
242
215
  }
243
216
  };
244
217
  }
245
218
  //#endregion
246
219
  //#region src/utils/isToggleEnabled.js
247
- function f(e, t, n = !0) {
220
+ function m(e, t, n = !0) {
248
221
  if (!e?.getAttribute) return n;
249
222
  let r = `data-${t}`, i = e.getAttribute(t) ?? e.getAttribute(r);
250
223
  return i === null ? n : String(i).toLowerCase() !== "false";
251
224
  }
252
225
  //#endregion
253
226
  //#region src/utils/matchHandle.js
254
- function p(e, n) {
227
+ function h(e, n) {
255
228
  let r = n?.closestDraggable?.(e) || e?.closest?.(`[${t.dragAttr}], [${t.dragdropAttr}]`);
256
229
  if (!r) return;
257
- let i = f(r, t.rotatableAttr, !0), a = f(r, t.resizableAttr, !0);
230
+ let i = m(r, t.rotatableAttr, !0), a = m(r, t.resizableAttr, !0);
258
231
  if (i && (r.hasAttribute(t.handleRotateAttr) || r.querySelector?.(`[${t.handleRotateAttr}]`)) || a && (r.hasAttribute(t.handleResizeAttr) || r.querySelector?.(`[${t.handleResizeAttr}]`))) {
259
232
  let n = (i ? e.closest?.(`[${t.handleRotateAttr}]`) : null) || (a ? e.closest?.(`[${t.handleResizeAttr}]`) : null);
260
233
  return n && r.contains(n) ? n : r;
@@ -267,19 +240,19 @@ function p(e, n) {
267
240
  }
268
241
  //#endregion
269
242
  //#region src/utils/isHTMLElement.js
270
- function m(e) {
243
+ function g(e) {
271
244
  return e && typeof e == "object" && e.nodeType === 1;
272
245
  }
273
246
  //#endregion
274
247
  //#region src/utils/isIgnoreClick.js
275
- function h(e) {
276
- if (!m(e)) return !1;
248
+ function _(e) {
249
+ if (!g(e)) return !1;
277
250
  let n = t.ignoreClickAttr, r = `data-${n}`;
278
251
  return !!(e.closest?.(`[${n}], [${r}]`) || e.hasAttribute?.(n) || e.hasAttribute?.(r));
279
252
  }
280
253
  //#endregion
281
254
  //#region src/utils/scopeHelpers.js
282
- var g = t.dragScopeAttr, _ = `[${g}], [data-${g}]`, v = class {
255
+ var v = t.dragScopeAttr, y = `[${v}], [data-${v}]`, b = class {
283
256
  #e = 0;
284
257
  #t = /* @__PURE__ */ new WeakMap();
285
258
  #n = /* @__PURE__ */ new WeakMap();
@@ -348,7 +321,15 @@ var g = t.dragScopeAttr, _ = `[${g}], [data-${g}]`, v = class {
348
321
  o = o.parentElement;
349
322
  }
350
323
  }
351
- }, y = class {
324
+ hitDropForSource(e, t, n, r) {
325
+ let i = this.hitDrop(e, t, n, r);
326
+ if (i && r && this.isDrop(r)) {
327
+ let n = this.measureRect(r);
328
+ if (n && e >= n.left && e <= n.right && t >= n.top && t <= n.bottom) return;
329
+ }
330
+ return i;
331
+ }
332
+ }, x = class {
352
333
  #e = !1;
353
334
  #t = !1;
354
335
  #n = 0;
@@ -379,7 +360,7 @@ var g = t.dragScopeAttr, _ = `[${g}], [data-${g}]`, v = class {
379
360
  this.#e = !1, this.#n = 0;
380
361
  }
381
362
  };
382
- }, b = class {
363
+ }, S = class {
383
364
  #e;
384
365
  #t = new AbortController();
385
366
  #n = !1;
@@ -448,7 +429,7 @@ var g = t.dragScopeAttr, _ = `[${g}], [data-${g}]`, v = class {
448
429
  reason: n
449
430
  }), e.preventDefault?.();
450
431
  };
451
- }, ee = class {
432
+ }, C = class {
452
433
  scrolled = !1;
453
434
  now = 0;
454
435
  classOps = /* @__PURE__ */ new Map();
@@ -486,7 +467,7 @@ var g = t.dragScopeAttr, _ = `[${g}], [data-${g}]`, v = class {
486
467
  for (let [t, n] of this.styleOps) if (!e || !this.removeOps.has(t)) for (let [e, r] of n) r == null ? e.includes("-") ? t?.style?.removeProperty?.(e) : t?.style && (t.style[e] = "") : e.includes("-") ? t?.style?.setProperty?.(e, String(r)) : t?.style && (t.style[e] = r);
487
468
  for (let e of this.fnOps) e?.();
488
469
  }
489
- }, te = class {
470
+ }, ee = class {
490
471
  #e = [];
491
472
  use(e, t) {
492
473
  e && (this.#e.push(e), this.#e.sort((e, t) => (e.order ?? 0) - (t.order ?? 0)), e.onAttach?.(t));
@@ -526,7 +507,7 @@ var g = t.dragScopeAttr, _ = `[${g}], [data-${g}]`, v = class {
526
507
  dispose() {
527
508
  this.#e.length = 0;
528
509
  }
529
- }, ne = class {
510
+ }, te = class {
530
511
  #e;
531
512
  #t;
532
513
  constructor({ store: e, session: t } = {}) {
@@ -570,7 +551,7 @@ var g = t.dragScopeAttr, _ = `[${g}], [data-${g}]`, v = class {
570
551
  lastMoveTs: 0
571
552
  }), this.#t.dragAbort = new AbortController();
572
553
  let { cache: t } = this.#t;
573
- return t && (t.dropDataEl = void 0, t.dropDataRaw = void 0, t.dropDataParsed = void 0, t.dropRegionFns = void 0, t.hitDropFn = void 0, t.dropRectDirty = !0), {
554
+ return t && (t.dropDataEl = void 0, t.dropDataRaw = void 0, t.dropDataParsed = void 0, t.hitDropFn = void 0, t.dropRectDirty = !0), {
574
555
  handled: !0,
575
556
  accepted: !0,
576
557
  dragAbort: this.#t.dragAbort
@@ -605,21 +586,22 @@ var g = t.dragScopeAttr, _ = `[${g}], [data-${g}]`, v = class {
605
586
  }
606
587
  }
607
588
  resetSession({ ended: e } = { ended: !1 }) {
608
- let t = this.#e, n = this.#t, r = u(t);
589
+ let t = this.#e, n = this.#t, r = f(t);
609
590
  return r.adapter = n?.adapter, e && (r.suppressNextClick = !0, r.lastDragTs = performance.now()), this.#t = r, r;
610
591
  }
611
- }, re = class extends e {
592
+ }, w = class extends e {
612
593
  #e = new AbortController();
613
594
  #t;
614
595
  #n;
615
- #r = new v();
616
- #i = new ee();
596
+ #r = new b();
597
+ #i = new C();
617
598
  #a = { selectedByNs: /* @__PURE__ */ new Map() };
618
599
  #o;
619
- #s = new te();
600
+ #s = new ee();
620
601
  #c;
621
602
  #l;
622
603
  #u = !1;
604
+ #d;
623
605
  canDrop = () => !0;
624
606
  renderMirror = void 0;
625
607
  get root() {
@@ -633,14 +615,14 @@ var g = t.dragScopeAttr, _ = `[${g}], [data-${g}]`, v = class {
633
615
  }
634
616
  constructor(e = {}) {
635
617
  super(), this.#n = { threshold: e.threshold ?? a.DRAG_START };
636
- let t = u(this.#a);
637
- t.threshold = this.#n.threshold, t.adapter = this.#r, this.#o = new ne({
618
+ let t = f(this.#a);
619
+ t.threshold = this.#n.threshold, t.adapter = this.#r, this.#o = new te({
638
620
  store: this.#a,
639
621
  session: t
640
- }), this.#c = new y(this.#h), this.#l = new b({
641
- onDown: this.#f,
642
- onMove: this.#p,
643
- onUp: this.#m
622
+ }), this.#c = new x(this.#g), this.#l = new S({
623
+ onDown: this.#p,
624
+ onMove: this.#m,
625
+ onUp: this.#h
644
626
  }), this.setRoot(e.root);
645
627
  }
646
628
  use(e) {
@@ -650,7 +632,7 @@ var g = t.dragScopeAttr, _ = `[${g}], [data-${g}]`, v = class {
650
632
  let t = this.#r.resolveRoot(e);
651
633
  if (t === this.#t) return;
652
634
  let n = this.#t;
653
- this.#e.abort(), this.#e = new AbortController(), this.#t = t, this.#l.setRoot(this.#t), this.#t && (this.#s.onRootChange(this.#t, n, this.#e.signal), this.#t.addEventListener("click", this.#d, {
635
+ this.#e.abort(), this.#e = new AbortController(), this.#t = t, this.#l.setRoot(this.#t), this.#t && (this.#s.onRootChange(this.#t, n, this.#e.signal), this.#t.addEventListener("click", this.#f, {
654
636
  capture: !0,
655
637
  passive: !1,
656
638
  signal: this.#e.signal
@@ -660,7 +642,7 @@ var g = t.dragScopeAttr, _ = `[${g}], [data-${g}]`, v = class {
660
642
  if (this.#u) return;
661
643
  this.#e.abort(), this.#l.destroy(), this.#c.cancel();
662
644
  let e = this.#o.session;
663
- e?.active && (this.#s.onEnd(d({
645
+ e?.active && (this.#s.onEnd(p({
664
646
  dnd: this,
665
647
  session: e,
666
648
  store: this.#a,
@@ -669,22 +651,22 @@ var g = t.dragScopeAttr, _ = `[${g}], [data-${g}]`, v = class {
669
651
  }), {
670
652
  ended: !1,
671
653
  reason: "destroy"
672
- }), e.dragAbort?.abort()), this.#s.onDestroy(this, e), this.#s.dispose?.(), this.offAll(), this.#u = !0;
654
+ }), e.dragAbort?.abort()), this.#s.onDestroy(this, e), this.#s.dispose?.(), this.#d = void 0, this.offAll(), this.#u = !0;
673
655
  }
674
- #d = (e) => {
656
+ #f = (e) => {
675
657
  let t = this.#o?.session;
676
658
  if (!t?.suppressNextClick) return;
677
659
  let n = performance.now(), r = !t.lastDragTs || n - t.lastDragTs < 800;
678
660
  t.suppressNextClick = !1, r && (e.preventDefault?.(), e.stopPropagation?.(), e.stopImmediatePropagation?.());
679
661
  };
680
- #f = (e) => {
662
+ #p = (e) => {
681
663
  if (!this.#t || e.button !== 0) return { accepted: !1 };
682
- let n = p(e.target, this.#r);
664
+ let n = h(e.target, this.#r);
683
665
  if (!n) return { accepted: !1 };
684
666
  let r = this.#r.closestDraggable(n);
685
667
  if (!r || e.target?.closest?.("input, textarea, select, button, a[href], [contenteditable]")) return { accepted: !1 };
686
668
  e.preventDefault(), e.target?.setPointerCapture?.(e.pointerId);
687
- let i = this.#r.getNamespace(r), a = this.#r.closestDrop(r), o = r.getBoundingClientRect(), s = c(this.#r.getAttr(r, t.dataAttr));
669
+ let i = this.#r.getNamespace(r), a = this.#r.closestDrop(r), o = r.getBoundingClientRect(), s = u(this.#r.getAttr(r, t.dataAttr));
688
670
  if (!this.#o.dispatch({
689
671
  type: "DOWN",
690
672
  pointerId: e.pointerId,
@@ -700,22 +682,22 @@ var g = t.dragScopeAttr, _ = `[${g}], [data-${g}]`, v = class {
700
682
  mirrorOffsetX: e.clientX - o.left,
701
683
  mirrorOffsetY: e.clientY - o.top
702
684
  })?.accepted) return { accepted: !1 };
703
- let l = this.#o.session;
704
- l.threshold = this.#n.threshold, l.adapter = this.#r, this.#i.reset(performance.now()), this.#r.beginFrame(), l.cache.frameId = this.#r.frameId;
705
- let u = d({
685
+ let c = this.#o.session;
686
+ c.threshold = this.#n.threshold, c.adapter = this.#r, this.#i.reset(performance.now()), this.#r.beginFrame(), c.cache.frameId = this.#r.frameId;
687
+ let l = p({
706
688
  dnd: this,
707
- session: l,
689
+ session: c,
708
690
  store: this.#a,
709
691
  frame: this.#i,
710
692
  adapter: this.#r
711
693
  });
712
- return this.#s.onDown(u, e), this.#i.commit(), this.#r.endFrame(), {
694
+ return this.#s.onDown(l, e), this.#i.commit(), this.#r.endFrame(), {
713
695
  accepted: !0,
714
696
  pointerId: e.pointerId,
715
- signal: l.dragAbort.signal
697
+ signal: c.dragAbort.signal
716
698
  };
717
699
  };
718
- #p = ({ pointerId: e, x: t, y: n }) => {
700
+ #m = ({ pointerId: e, x: t, y: n }) => {
719
701
  let r = this.#o.dispatch({
720
702
  type: "MOVE",
721
703
  pointerId: e,
@@ -725,18 +707,18 @@ var g = t.dragScopeAttr, _ = `[${g}], [data-${g}]`, v = class {
725
707
  if (!r?.handled) return;
726
708
  let i = this.#o.session;
727
709
  if (r.startedNow) {
728
- let e = d({
710
+ let e = p({
729
711
  dnd: this,
730
712
  session: i,
731
713
  store: this.#a,
732
714
  frame: this.#i,
733
715
  adapter: this.#r
734
716
  });
735
- this.#s.onStart(e), this.emit("dragstart", l("dragstart", i));
717
+ this.#s.onStart(e), this.emit("dragstart", d("dragstart", i));
736
718
  }
737
719
  r.started && this.#c.request();
738
720
  };
739
- #m = ({ event: e, pointerId: t, reason: n }) => {
721
+ #h = ({ event: e, pointerId: t, reason: n }) => {
740
722
  let r = this.#o.dispatch({
741
723
  type: "END",
742
724
  pointerId: t,
@@ -746,8 +728,8 @@ var g = t.dragScopeAttr, _ = `[${g}], [data-${g}]`, v = class {
746
728
  let i = this.#o.session;
747
729
  "pointerId" in e && e.target?.releasePointerCapture?.(e.pointerId);
748
730
  let a = !!r.ended;
749
- this.#r.beginFrame(), i.cache.frameId = this.#r.frameId, i.currentDrop = this.#r.hitDrop(i.x, i.y, i.namespace, i.sourceEl), i.currentDropRect = i.currentDrop ? this.#r.measureRect(i.currentDrop) : void 0, this.#r.endFrame();
750
- let o = d({
731
+ this.#r.beginFrame(), i.cache.frameId = this.#r.frameId, i.currentDrop = this.#r.hitDropForSource(i.x, i.y, i.namespace, i.sourceEl), i.currentDropRect = i.currentDrop ? this.#r.measureRect(i.currentDrop) : void 0, this.#r.endFrame();
732
+ let o = p({
751
733
  dnd: this,
752
734
  session: i,
753
735
  store: this.#a,
@@ -758,34 +740,32 @@ var g = t.dragScopeAttr, _ = `[${g}], [data-${g}]`, v = class {
758
740
  ended: a,
759
741
  reason: n || "pointerup"
760
742
  });
761
- let s = l(a ? "drop" : "cancel", i);
762
- i.dragAbort?.abort(), i.dragAbort = void 0, this.#c.cancel();
743
+ let s = d(a ? "drop" : "cancel", i);
744
+ i.dragAbort?.abort(), i.dragAbort = void 0, this.#c.cancel(), this.#d = void 0;
763
745
  let c = this.#o.resetSession({ ended: a });
764
746
  c.adapter = this.#r, a ? this.emit("drop", s) : this.emit("cancel", s), e.preventDefault?.();
765
747
  };
766
- #h = (e) => {
748
+ #g = (e) => {
767
749
  let t = this.#o.session;
768
750
  if (!t.active || !t.started) return !1;
769
751
  this.#i.reset(e), this.#r.beginFrame(), t.cache.frameId = this.#r.frameId;
770
- let n = d({
752
+ let n = this.#d;
753
+ !n || n.session !== t ? n = this.#d = p({
771
754
  dnd: this,
772
755
  session: t,
773
756
  store: this.#a,
774
757
  frame: this.#i,
775
758
  adapter: this.#r
776
- }), r = !1;
759
+ }) : n.resetPayloadCache();
760
+ let r = !1;
777
761
  return t.dirty &&= (this.#s.onMeasure(n), this.#s.onCompute(n), this.emit("drag", n.payload("drag")), this.#s.onCommit(n), this.#i.commit(), this.#i.scrolled && (r = !0), !1), this.#s.onAfterDrag(n) && (r = !0), r && (t.dirty = !0), this.#r.endFrame(), t.dirty || r;
778
762
  };
779
- }, x = class {
763
+ }, T = class {
780
764
  order = 10;
781
765
  onMeasure(e) {
782
766
  let t = e.session;
783
767
  if (!t.active || !t.started) return;
784
- let n = e.adapter.hitDrop(t.x, t.y, t.namespace, t.sourceEl);
785
- if (n && t.sourceEl && e.adapter.isDrop(t.sourceEl)) {
786
- let r = e.adapter.measureRect(t.sourceEl);
787
- r && t.x >= r.left && t.x <= r.right && t.y >= r.top && t.y <= r.bottom && (n = void 0);
788
- }
768
+ let n = e.adapter.hitDropForSource(t.x, t.y, t.namespace, t.sourceEl);
789
769
  if (n !== t.currentDrop && (t.currentDrop = n, t.cache && (t.cache.dropRectDirty = !0)), !n) {
790
770
  t.currentDropRect = void 0, t.cache && (t.cache.dropRectDirty = !1);
791
771
  return;
@@ -814,18 +794,18 @@ var g = t.dragScopeAttr, _ = `[${g}], [data-${g}]`, v = class {
814
794
  let t = e.session;
815
795
  if (!t?.active || !t?.started) return;
816
796
  let r = t.cache ||= {}, i = r._dropClassEl, a = t.currentDrop;
817
- m(i) && i !== a && (e.frame.toggleClass(i, n.canDrop, !1), e.frame.toggleClass(i, n.noDrop, !1)), m(a) && (e.frame.toggleClass(a, n.canDrop, !!t.currentAllowed), e.frame.toggleClass(a, n.noDrop, !t.currentAllowed)), r._dropClassEl = a;
797
+ g(i) && i !== a && (e.frame.toggleClass(i, n.canDrop, !1), e.frame.toggleClass(i, n.noDrop, !1)), g(a) && (e.frame.toggleClass(a, n.canDrop, !!t.currentAllowed), e.frame.toggleClass(a, n.noDrop, !t.currentAllowed)), r._dropClassEl = a;
818
798
  }
819
799
  onEnd(e) {
820
800
  let t = e?.session;
821
801
  if (!t) return;
822
802
  let r = t.cache?._dropClassEl;
823
- m(r) && r.classList.remove(n.canDrop, n.noDrop), t.cache && (t.cache._dropClassEl = void 0);
803
+ g(r) && r.classList.remove(n.canDrop, n.noDrop), t.cache && (t.cache._dropClassEl = void 0);
824
804
  }
825
805
  onDestroy(e, t) {
826
806
  this.onEnd({ session: t });
827
807
  }
828
- }, S = class {
808
+ }, E = class {
829
809
  order = 0;
830
810
  onStart = (e) => {
831
811
  let r = e?.session;
@@ -851,20 +831,20 @@ var g = t.dragScopeAttr, _ = `[${g}], [data-${g}]`, v = class {
851
831
  onDestroy = (e, t) => {
852
832
  this.onEnd({ session: t });
853
833
  };
854
- }, C = /(auto|scroll|overlay)/i;
855
- function w(e) {
834
+ }, D = /(auto|scroll|overlay)/i;
835
+ function ne(e) {
856
836
  if (!(e instanceof HTMLElement)) return !1;
857
- let t = getComputedStyle(e), n = C.test(t.overflowY) && e.scrollHeight > e.clientHeight + 1;
858
- return C.test(t.overflowX) && e.scrollWidth > e.clientWidth + 1 || n;
837
+ let t = getComputedStyle(e), n = D.test(t.overflowY) && e.scrollHeight > e.clientHeight + 1;
838
+ return D.test(t.overflowX) && e.scrollWidth > e.clientWidth + 1 || n;
859
839
  }
860
- function T(e) {
840
+ function re(e) {
861
841
  let t = e;
862
842
  for (; t;) {
863
- if (w(t)) return t;
843
+ if (ne(t)) return t;
864
844
  t = t.parentElement;
865
845
  }
866
846
  }
867
- function E(e, t, n, r) {
847
+ function O(e, t, n, r) {
868
848
  return e < t + r ? {
869
849
  dir: -1,
870
850
  k: (t + r - e) / r
@@ -876,7 +856,7 @@ function E(e, t, n, r) {
876
856
  k: 0
877
857
  };
878
858
  }
879
- var D = class {
859
+ var ie = class {
880
860
  order = 1e4;
881
861
  constructor(e = {}) {
882
862
  this.edge = e.edge ?? o.EDGE, this.minSpeed = e.minSpeed ?? o.MIN_SPEED, this.maxSpeed = e.maxSpeed ?? o.MAX_SPEED, this.allowWindowScroll = e.allowWindowScroll ?? !0;
@@ -884,69 +864,75 @@ var D = class {
884
864
  onAfterDrag = (e) => {
885
865
  let t = e.session;
886
866
  if (!t.active || !t.started) return !1;
887
- let n = t.currentDrop ? T(t.currentDrop) : void 0, r = !1;
888
- if (!n && this.allowWindowScroll && (n = document.scrollingElement || document.documentElement, r = !!n), !n) return !1;
889
- let i = e.frame.now, a = t.cache.autoScrollLastTs || 0, o = a ? Math.max(8, Math.min(64, i - a)) : 16.67;
890
- t.cache && (t.cache.autoScrollLastTs = i);
891
- let s = r ? {
867
+ let n = t.cache, r, i;
868
+ if (n && n.autoScrollTargetDrop === t.currentDrop ? (r = n.autoScrollTarget, i = n.autoScrollUseWindow) : (r = t.currentDrop ? re(t.currentDrop) : void 0, i = !1, !r && this.allowWindowScroll && (r = document.scrollingElement || document.documentElement, i = !!r), n && (n.autoScrollTargetDrop = t.currentDrop, n.autoScrollTarget = r, n.autoScrollUseWindow = i)), !r) return !1;
869
+ let a = e.frame.now, s = t.cache.autoScrollLastTs || 0, c = s ? Math.max(o.MIN_DT, Math.min(o.MAX_DT, a - s)) : o.DEFAULT_DT;
870
+ t.cache && (t.cache.autoScrollLastTs = a);
871
+ let l = i ? {
892
872
  left: 0,
893
873
  top: 0,
894
874
  right: innerWidth,
895
875
  bottom: innerHeight
896
- } : e.adapter.measureRect(n), c = t.x, l = t.y, u = E(c, s.left, s.right, this.edge), d = E(l, s.top, s.bottom, this.edge), f = (e) => this.minSpeed + (this.maxSpeed - this.minSpeed) * e, p = u.dir ? u.dir * f(u.k) * o / 1e3 : 0, m = d.dir ? d.dir * f(d.k) * o / 1e3 : 0;
897
- if (!p && !m) return !1;
898
- let h = n.scrollTop, g = n.scrollLeft;
899
- r ? window.scrollBy(p, m) : n.scrollBy({
900
- left: p,
901
- top: m,
876
+ } : e.adapter.measureRect(r), u = t.x, d = t.y, f = O(u, l.left, l.right, this.edge), p = O(d, l.top, l.bottom, this.edge), m = (e) => this.minSpeed + (this.maxSpeed - this.minSpeed) * e, h = f.dir ? f.dir * m(f.k) * c / 1e3 : 0, g = p.dir ? p.dir * m(p.k) * c / 1e3 : 0;
877
+ if (!h && !g) return !1;
878
+ let _ = r.scrollTop, v = r.scrollLeft;
879
+ i ? window.scrollBy(h, g) : r.scrollBy({
880
+ left: h,
881
+ top: g,
902
882
  behavior: "auto"
903
883
  });
904
- let _ = h !== n.scrollTop || g !== n.scrollLeft;
905
- return _ && e.frame && (e.frame.scrolled = !0), _;
884
+ let y = _ !== r.scrollTop || v !== r.scrollLeft;
885
+ return y && e.frame && (e.frame.scrolled = !0), y;
906
886
  };
907
887
  onEnd = (e) => {
908
888
  let t = e?.session;
909
- t?.cache && (t.cache.autoScrollLastTs = 0);
889
+ t?.cache && (t.cache.autoScrollLastTs = 0, t.cache.autoScrollTargetDrop = void 0, t.cache.autoScrollTarget = void 0, t.cache.autoScrollUseWindow = !1);
910
890
  };
911
- }, O = {
891
+ }, k = {
912
892
  top: n.indicatorTop,
913
893
  right: n.indicatorRight,
914
894
  bottom: n.indicatorBottom,
915
895
  left: n.indicatorLeft
916
- }, k = Object.values(O), ie = new Set([
896
+ }, A = Object.values(k), j = /* @__PURE__ */ new Set([
917
897
  "top",
918
898
  "right",
919
899
  "bottom",
920
900
  "left"
921
901
  ]);
922
- function A(e, t, n, r) {
923
- m(t) && (e.frame.toggleClass ? e.frame.toggleClass(t, n, !!r) : t.classList.toggle(n, !!r));
902
+ function M(e, t, n, r) {
903
+ g(t) && e.frame.toggleClass(t, n, !!r);
924
904
  }
925
- function ae(e) {
926
- if (!m(e)) return;
905
+ function N(e) {
906
+ if (!g(e)) return;
927
907
  let n = t.dropIndicatorAttr || "drop-indicator", r = `data-${n}`, i;
928
908
  if (e.hasAttribute?.(n)) i = e.getAttribute?.(n);
929
909
  else if (e.hasAttribute?.(r)) i = e.getAttribute?.(r);
930
910
  else return;
931
911
  let a = (i ?? "").trim();
932
912
  if (!a) return "all";
933
- console.log("raw", i);
934
913
  let o = /* @__PURE__ */ new Set();
935
914
  for (let e of a.split(/[,\s]+/)) {
936
915
  let t = (e || "").trim().toLowerCase();
937
- ie.has(t) && o.add(t);
916
+ j.has(t) && o.add(t);
938
917
  }
939
918
  return o.size ? o : void 0;
940
919
  }
920
+ function ae(e, t) {
921
+ let n = e.session?.cache;
922
+ if (!n) return N(t);
923
+ if (n.indicatorSupportEl === t) return n.indicatorSupport;
924
+ let r = N(t);
925
+ return n.indicatorSupportEl = t, n.indicatorSupport = r, r;
926
+ }
941
927
  function oe(e) {
942
928
  let t = e.session, r = e.dnd?.root?.ownerDocument || document, i = t.indicatorEl;
943
- m(i) || (i = r.createElement("div"), i.classList.add(n.dropIndicator), t.indicatorEl = i);
929
+ g(i) || (i = r.createElement("div"), i.classList.add(n.dropIndicator), t.indicatorEl = i);
944
930
  let a = t.currentDrop || e.dnd?.root || r.body;
945
- return m(a) && i.parentNode !== a && a.appendChild(i), i;
931
+ return g(a) && i.parentNode !== a && a.appendChild(i), i;
946
932
  }
947
933
  function se(e, t) {
948
934
  if (!e.currentDrop || !e.currentDropRect) return;
949
- let n = s(e, t);
935
+ let n = l(e, t);
950
936
  if (n.isOverLeft()) return "left";
951
937
  if (n.isOverRight()) return "right";
952
938
  if (n.isOverTop()) return "top";
@@ -961,31 +947,31 @@ var le = class {
961
947
  onCommit(e) {
962
948
  let t = e.session;
963
949
  if (!t?.active || !t?.started) return;
964
- let r = t.currentDrop, i = ae(r);
950
+ let r = t.currentDrop, i = ae(e, r);
965
951
  if (!i) {
966
952
  let r = t.indicatorEl;
967
- if (m(r)) {
968
- A(e, r, n.dropIndicatorActive, !1);
969
- for (let t of k) A(e, r, t, !1);
953
+ if (g(r)) {
954
+ M(e, r, n.dropIndicatorActive, !1);
955
+ for (let t of A) M(e, r, t, !1);
970
956
  }
971
957
  t.indicatorRegion = void 0;
972
958
  return;
973
959
  }
974
960
  let a = oe(e), o = ce(e), s = se(t, i), c = i === "all" || s && i.has(s) ? s : void 0, l = !!(r && t.currentDropRect && o && c);
975
- if (A(e, a, n.dropIndicatorActive, l), t.indicatorRegion = l ? c : void 0, l) for (let [t, n] of Object.entries(O)) A(e, a, n, t === c);
976
- else for (let t of k) A(e, a, t, !1);
961
+ if (M(e, a, n.dropIndicatorActive, l), t.indicatorRegion = l ? c : void 0, l) for (let [t, n] of Object.entries(k)) M(e, a, n, t === c);
962
+ else for (let t of A) M(e, a, t, !1);
977
963
  }
978
964
  onEnd(e) {
979
965
  let t = e.session;
980
- t && (t.lastIndicatorRegion = t.indicatorRegion ?? "inside", m(t.indicatorEl) && t.indicatorEl.remove(), t.indicatorEl = void 0, t.indicatorRegion = void 0);
966
+ t && (t.lastIndicatorRegion = t.indicatorRegion ?? "inside", g(t.indicatorEl) && t.indicatorEl.remove(), t.indicatorEl = void 0, t.indicatorRegion = void 0);
981
967
  }
982
968
  onDestroy(e, t) {
983
969
  this.onEnd({ session: t });
984
970
  }
985
- }, j = "draggable-dot-wrap", M = "draggable-dot", N = "draggable-rotate";
986
- function P(e, n = {}) {
971
+ }, P = "draggable-dot-wrap", F = "draggable-dot", I = "draggable-rotate";
972
+ function ue(e, n = {}) {
987
973
  let { resizable: r = !0, rotatable: i = !0 } = n, a = e.createElement("div");
988
- if (a.classList.add(j), a.dataset.resizable = String(r), a.dataset.rotatable = String(i), r) for (let [n, r] of [
974
+ if (a.classList.add(P), a.dataset.resizable = String(r), a.dataset.rotatable = String(i), r) for (let [n, r] of [
989
975
  ["nw", "tl"],
990
976
  ["n", "tm"],
991
977
  ["ne", "tr"],
@@ -996,83 +982,79 @@ function P(e, n = {}) {
996
982
  ["w", "lm"]
997
983
  ]) {
998
984
  let i = e.createElement("div");
999
- i.classList.add(M), i.setAttribute(t.handleResizeAttr, ""), i.dataset.dir = n, i.dataset.pos = r, a.appendChild(i);
985
+ i.classList.add(F), i.setAttribute(t.handleResizeAttr, ""), i.dataset.dir = n, i.dataset.pos = r, a.appendChild(i);
1000
986
  }
1001
987
  if (i) {
1002
988
  let n = e.createElement("div");
1003
- n.classList.add(N), n.setAttribute(t.handleRotateAttr, ""), n.dataset.dir = "rotate", a.appendChild(n);
989
+ n.classList.add(I), n.setAttribute(t.handleRotateAttr, ""), n.dataset.dir = "rotate", a.appendChild(n);
1004
990
  }
1005
991
  return a;
1006
992
  }
1007
- function F(e) {
1008
- m(e) && e.querySelector?.(`.${j}`)?.remove();
993
+ function L(e) {
994
+ g(e) && e.querySelector?.(`.${P}`)?.remove();
1009
995
  }
1010
- function I(e) {
1011
- if (!m(e)) return;
1012
- let n = !!e.closest?.(_), r = e.querySelector?.(".draggable-dot-wrap") || null, i = !!r, a = f(e, t.resizableAttr, !0), o = f(e, t.rotatableAttr, !0), s = a || o;
996
+ function R(e) {
997
+ if (!g(e)) return;
998
+ let n = !!e.closest?.(y), r = e.querySelector?.(".draggable-dot-wrap") || null, i = !!r, a = m(e, t.resizableAttr, !0), o = m(e, t.rotatableAttr, !0), s = a || o;
1013
999
  if (!n) {
1014
- i && F(e);
1000
+ i && L(e);
1015
1001
  return;
1016
1002
  }
1017
1003
  if (!s) {
1018
- i && F(e);
1004
+ i && L(e);
1019
1005
  return;
1020
1006
  }
1021
1007
  if (r && (String(r.dataset?.resizable) !== String(a) || String(r.dataset?.rotatable) !== String(o)) && (r.remove(), r = null, i = !1), !i) {
1022
1008
  let t = getComputedStyle(e).position;
1023
- (t === "static" || !t) && (e.style.position = "relative"), e.appendChild(P(e.ownerDocument || document, {
1009
+ (t === "static" || !t) && (e.style.position = "relative"), e.appendChild(ue(e.ownerDocument || document, {
1024
1010
  resizable: a,
1025
1011
  rotatable: o
1026
1012
  }));
1027
1013
  }
1028
1014
  }
1029
- function L(e, t, r, i) {
1015
+ function z(e, t) {
1016
+ if (!e) return;
1017
+ let r = Array.isArray(e) ? e : [e];
1018
+ for (let e of r) t ? t(e, n.active, !1) : e?.classList?.remove?.(n.active), L(e);
1019
+ }
1020
+ function B(e, t, r, i) {
1030
1021
  let a = t.get(i);
1031
- if (a && a !== r) if (Array.isArray(a)) for (let e of a) e?.classList?.remove?.(n.active), F(e);
1032
- else a.classList.remove(n.active), F(a);
1033
- r.classList.add(n.active), I(r), t.set(i, r);
1022
+ a && a !== r && z(a), r.classList.add(n.active), R(r), t.set(i, r);
1034
1023
  }
1035
- function R(e, t, r) {
1036
- let i = e.get(r);
1037
- if (i) if (Array.isArray(i)) for (let e of i) e?.classList?.remove?.(n.active), F(e);
1038
- else i.classList.remove(n.active), F(i);
1039
- for (let e of t) e.classList.add(n.active), I(e);
1024
+ function V(e, t, r) {
1025
+ z(e.get(r));
1026
+ for (let e of t) e.classList.add(n.active), R(e);
1040
1027
  e.set(r, t);
1041
1028
  }
1042
- function z(e, t) {
1029
+ function H(e, t) {
1043
1030
  if (t !== void 0) {
1044
- let r = e.get(t);
1045
- if (r) {
1046
- if (Array.isArray(r)) for (let e of r) e?.classList?.remove?.(n.active), F(e);
1047
- else r?.classList?.remove?.(n.active), F(r);
1048
- e.delete(t);
1049
- }
1031
+ let n = e.get(t);
1032
+ n && (z(n), e.delete(t));
1050
1033
  return;
1051
1034
  }
1052
- for (let t of e.values()) if (Array.isArray(t)) for (let e of t) e?.classList?.remove?.(n.active), F(e);
1053
- else t?.classList?.remove?.(n.active), F(t);
1035
+ for (let t of e.values()) z(t);
1054
1036
  e.clear();
1055
1037
  }
1056
- var B = class {
1038
+ var U = class {
1057
1039
  order = -50;
1058
1040
  #e;
1059
1041
  onAttach(e) {
1060
1042
  this.#e = e;
1061
1043
  }
1062
1044
  onRootChange(e, t, n) {
1063
- if (!m(e)) return;
1045
+ if (!g(e)) return;
1064
1046
  let r = this.#e.monitor;
1065
1047
  e.addEventListener("pointerdown", (e) => {
1066
- if (e.button !== 0 || h(e.target)) return;
1048
+ if (e.button !== 0 || _(e.target)) return;
1067
1049
  let t = r.selectedByNs;
1068
1050
  if (!t) return;
1069
1051
  let n = r.adapter.closestDraggable(e.target);
1070
1052
  if (!n) {
1071
- z(t);
1053
+ H(t);
1072
1054
  return;
1073
1055
  }
1074
1056
  let i = r.adapter.getNamespace(n), a = t.get(i);
1075
- Array.isArray(a) && a.length > 1 && a.includes(n) || L(null, t, n, i);
1057
+ Array.isArray(a) && a.length > 1 && a.includes(n) || B(null, t, n, i);
1076
1058
  }, {
1077
1059
  capture: !0,
1078
1060
  signal: n
@@ -1080,22 +1062,20 @@ var B = class {
1080
1062
  }
1081
1063
  onDown(e, t) {
1082
1064
  let r = e?.session;
1083
- if (!r?.sourceEl || t?.button !== 0 || h(t.target)) return;
1065
+ if (!r?.sourceEl || t?.button !== 0 || _(t.target)) return;
1084
1066
  let i = e.store?.selectedByNs || r.selectedByNs;
1085
1067
  if (!i) return;
1086
1068
  let a = r.namespace || e.adapter.getNamespace(r.sourceEl), o = i.get(a);
1087
- Array.isArray(o) && o.length > 1 && o.includes(r.sourceEl) || (o && o !== r.sourceEl && (Array.isArray(o) ? o.forEach((t) => {
1088
- e.frame.toggleClass(t, n.active, !1), F(t);
1089
- }) : (e.frame.toggleClass(o, n.active, !1), F(o))), e.frame.toggleClass(r.sourceEl, n.active, !0), I(r.sourceEl), i.set(a, r.sourceEl));
1069
+ Array.isArray(o) && o.length > 1 && o.includes(r.sourceEl) || (o && o !== r.sourceEl && z(o, (t, n, r) => e.frame.toggleClass(t, n, r)), e.frame.toggleClass(r.sourceEl, n.active, !0), R(r.sourceEl), i.set(a, r.sourceEl));
1090
1070
  }
1091
1071
  onDestroy(e, t) {
1092
1072
  let n = t?.selectedByNs;
1093
- n && z(n);
1073
+ n && H(n);
1094
1074
  }
1095
1075
  };
1096
1076
  //#endregion
1097
1077
  //#region src/services/MarqueeSelectionService.js
1098
- function V(e, t, n, r) {
1078
+ function de(e, t, n, r) {
1099
1079
  return {
1100
1080
  left: Math.min(e, n),
1101
1081
  right: Math.max(e, n),
@@ -1105,11 +1085,11 @@ function V(e, t, n, r) {
1105
1085
  height: Math.abs(r - t)
1106
1086
  };
1107
1087
  }
1108
- function H(e, t) {
1109
- let n = Math.max(e.left, t.left), r = Math.min(e.right, t.right), i = Math.max(e.top, t.top), a = Math.min(e.bottom, t.bottom), o = r - n, s = a - i;
1110
- return o <= 0 || s <= 0 ? !1 : o * s > (t.right - t.left) * (t.bottom - t.top) * .5;
1088
+ function fe(e, t) {
1089
+ let n = Math.max(e.left, t.left), r = Math.min(e.right, t.right), i = Math.max(e.top, t.top), a = Math.min(e.bottom, t.bottom), o = r - n, c = a - i;
1090
+ return o <= 0 || c <= 0 ? !1 : o * c > (t.right - t.left) * (t.bottom - t.top) * s;
1111
1091
  }
1112
- var U = class {
1092
+ var pe = class {
1113
1093
  order = -40;
1114
1094
  #e;
1115
1095
  #t;
@@ -1117,9 +1097,9 @@ var U = class {
1117
1097
  this.#e = e;
1118
1098
  }
1119
1099
  onRootChange(e, t, n) {
1120
- this.#t = n, m(e) && e.addEventListener("pointerdown", (e) => {
1121
- if (e.button !== 0 || h(e.target)) return;
1122
- let t = e.target.closest(_);
1100
+ this.#t = n, g(e) && e.addEventListener("pointerdown", (e) => {
1101
+ if (e.button !== 0 || _(e.target)) return;
1102
+ let t = e.target.closest(y);
1123
1103
  t && (this.#e.monitor.adapter.closestDraggable(e.target) || this.#n(t, e));
1124
1104
  }, {
1125
1105
  capture: !0,
@@ -1127,63 +1107,67 @@ var U = class {
1127
1107
  });
1128
1108
  }
1129
1109
  #n(e, r) {
1130
- let i = r.clientX, o = r.clientY, s = this.#e.monitor.adapter.getNamespace(e), c = parseFloat(e.getAttribute(t.scaleRatioAttr) || "1"), l = document.createElement("div");
1131
- l.classList.add(n.marquee), e.appendChild(l);
1132
- let u = !1, d = (t) => {
1133
- let n = t.clientX - i, r = t.clientY - o;
1134
- if (!u && Math.abs(n) < a.MARQUEE_MOVE && Math.abs(r) < a.MARQUEE_MOVE) return;
1135
- u = !0;
1136
- let d = V(i, o, t.clientX, t.clientY);
1137
- this.#r(l, d, e, c);
1138
- let f = this.#i(e, s, d), p = this.#e.monitor.selectedByNs;
1139
- p && (z(p, s), f.length > 0 && R(p, f, s));
1140
- }, f = new AbortController(), p = [f.signal, this.#t].filter(Boolean), m = () => {
1141
- if (!f.signal.aborted) {
1110
+ let i = r.clientX, o = r.clientY, s = this.#e.monitor.adapter, c = s.getNamespace(e), l = parseFloat(e.getAttribute(t.scaleRatioAttr) || "1"), u = document.createElement("div");
1111
+ u.classList.add(n.marquee), e.appendChild(u);
1112
+ let d = e.getBoundingClientRect(), f = [];
1113
+ for (let n of e.querySelectorAll(`[${t.dragAttr}], [${t.dragdropAttr}]`)) s.getNamespace(n) === c && f.push(n);
1114
+ let p = !1, m = 0, h = null, g = this.#t, _ = new AbortController(), v = () => y(), y = () => {
1115
+ if (!_.signal.aborted) {
1116
+ m &&= (cancelAnimationFrame(m), 0), g?.removeEventListener?.("abort", v);
1142
1117
  try {
1143
- l.remove();
1118
+ u.remove();
1144
1119
  } catch {}
1145
- f.abort();
1120
+ _.abort();
1146
1121
  }
1147
- }, h = () => {
1148
- if (!u) {
1122
+ }, b = () => {
1123
+ m = 0;
1124
+ let e = h;
1125
+ if (!e) return;
1126
+ let t = de(i, o, e.clientX, e.clientY);
1127
+ this.#r(u, t, d, l);
1128
+ let n = this.#i(f, s, t), r = this.#e.monitor.selectedByNs;
1129
+ r && (H(r, c), n.length > 0 && V(r, n, c));
1130
+ }, x = (e) => {
1131
+ let t = e.clientX - i, n = e.clientY - o;
1132
+ !p && Math.abs(t) < a.MARQUEE_MOVE && Math.abs(n) < a.MARQUEE_MOVE || (p = !0, h = e, m ||= requestAnimationFrame(b));
1133
+ }, S = () => {
1134
+ if (!p) {
1149
1135
  let e = this.#e.monitor?.selectedByNs;
1150
- e && z(e, s);
1136
+ e && H(e, c);
1151
1137
  }
1152
- m();
1138
+ y();
1153
1139
  };
1154
- for (let e of p) {
1155
- if (e.aborted) {
1156
- m();
1157
- return;
1158
- }
1159
- e.addEventListener("abort", m, { once: !0 });
1140
+ if (g?.aborted) {
1141
+ y();
1142
+ return;
1160
1143
  }
1161
- let g = { signal: f.signal };
1162
- document.addEventListener("pointermove", d, g), document.addEventListener("pointerup", h, g), document.addEventListener("pointercancel", m, g), window.addEventListener("blur", m, g);
1144
+ g?.addEventListener?.("abort", v, { once: !0 });
1145
+ let C = { signal: _.signal };
1146
+ document.addEventListener("pointermove", x, C), document.addEventListener("pointerup", S, C), document.addEventListener("pointercancel", y, C), window.addEventListener("blur", y, C);
1163
1147
  }
1164
1148
  #r(e, t, n, r) {
1165
- let i = n.getBoundingClientRect(), a = (t.left - i.left) / r, o = (t.top - i.top) / r, s = t.width / r, c = t.height / r;
1166
- e.style.left = `${a}px`, e.style.top = `${o}px`, e.style.width = `${s}px`, e.style.height = `${c}px`;
1167
- }
1168
- #i(e, n, r) {
1169
- let i = this.#e.monitor.adapter, a = e.querySelectorAll(`[${t.dragAttr}], [${t.dragdropAttr}]`), o = [];
1170
- for (let e of a) {
1171
- if (i.getNamespace(e) !== n) continue;
1172
- let t = i.measureRect(e);
1173
- t && H(r, t) && o.push(e);
1149
+ let i = (t.left - n.left) / r, a = (t.top - n.top) / r, o = t.width / r, s = t.height / r;
1150
+ e.style.left = `${i}px`, e.style.top = `${a}px`, e.style.width = `${o}px`, e.style.height = `${s}px`;
1151
+ }
1152
+ #i(e, t, n) {
1153
+ let r = [];
1154
+ for (let i of e) {
1155
+ let e = t.measureRect(i);
1156
+ e && fe(n, e) && r.push(i);
1174
1157
  }
1175
- return o;
1158
+ return r;
1176
1159
  }
1177
1160
  };
1178
1161
  //#endregion
1179
1162
  //#region src/services/transform/utils/geometry.js
1180
1163
  function W(e = 0) {
1181
- return `${Number.parseInt(String(e), 10) || 0}px`;
1164
+ let t = Number(e);
1165
+ return Number.isFinite(t) ? `${Math.round(t * 100) / 100}px` : "0px";
1182
1166
  }
1183
1167
  function G(e) {
1184
1168
  return e * Math.PI / 180;
1185
1169
  }
1186
- function ue(e, t) {
1170
+ function me(e, t) {
1187
1171
  return Math.sqrt(e * e + t * t);
1188
1172
  }
1189
1173
  function K(e, t) {
@@ -1205,7 +1189,7 @@ function J(e, t, n, r) {
1205
1189
  let i = n - e, a = r - t, o = Math.atan2(a, i) * 180 / Math.PI + 90;
1206
1190
  return o = (o % 360 + 360) % 360, o;
1207
1191
  }
1208
- function de(e, t, n) {
1192
+ function he(e, t, n) {
1209
1193
  let { width: r, height: i } = e;
1210
1194
  return {
1211
1195
  height: Math.abs(i),
@@ -1214,7 +1198,7 @@ function de(e, t, n) {
1214
1198
  y: n - Math.abs(i) / 2
1215
1199
  };
1216
1200
  }
1217
- function fe({ centerX: e, centerY: t, width: n, height: r, angle: i }) {
1201
+ function ge({ centerX: e, centerY: t, width: n, height: r, angle: i }) {
1218
1202
  return {
1219
1203
  angle: i,
1220
1204
  height: r,
@@ -1245,7 +1229,7 @@ function Y(e) {
1245
1229
  }
1246
1230
  //#endregion
1247
1231
  //#region src/services/transform/utils/cursor.js
1248
- var pe = {
1232
+ var _e = {
1249
1233
  e: "right",
1250
1234
  n: "top",
1251
1235
  ne: "top-right",
@@ -1254,7 +1238,7 @@ var pe = {
1254
1238
  se: "bottom-right",
1255
1239
  sw: "bottom-left",
1256
1240
  w: "left"
1257
- }, me = [
1241
+ }, ve = [
1258
1242
  "n",
1259
1243
  "ne",
1260
1244
  "e",
@@ -1263,7 +1247,7 @@ var pe = {
1263
1247
  "sw",
1264
1248
  "w",
1265
1249
  "nw"
1266
- ], he = {
1250
+ ], ye = {
1267
1251
  0: 0,
1268
1252
  1: 1,
1269
1253
  2: 1,
@@ -1276,7 +1260,7 @@ var pe = {
1276
1260
  9: 6,
1277
1261
  10: 7,
1278
1262
  11: 7
1279
- }, ge = {
1263
+ }, be = {
1280
1264
  e: 2,
1281
1265
  n: 0,
1282
1266
  ne: 1,
@@ -1286,13 +1270,13 @@ var pe = {
1286
1270
  sw: 5,
1287
1271
  w: 6
1288
1272
  };
1289
- function _e(e, t) {
1290
- let n = he[Math.floor((e % 360 + 360) % 360 / 30)];
1291
- return me[(ge[t] + n) % 8];
1273
+ function xe(e, t) {
1274
+ let n = ye[Math.floor((e % 360 + 360) % 360 / 30)];
1275
+ return ve[(be[t] + n) % 8];
1292
1276
  }
1293
1277
  //#endregion
1294
1278
  //#region src/services/transform/utils/markline.js
1295
- function ve(e, t) {
1279
+ function Se(e, t) {
1296
1280
  let n = {
1297
1281
  x: [],
1298
1282
  y: []
@@ -1332,63 +1316,112 @@ function ve(e, t) {
1332
1316
  });
1333
1317
  }), n;
1334
1318
  }
1335
- function ye(e) {
1319
+ function Ce({ side: e = "", source: t, targetRects: n = [], threshold: r = 10 }) {
1320
+ let i = {
1321
+ diffX: 0,
1322
+ diffY: 0,
1323
+ guideLeft: void 0,
1324
+ guideTop: void 0
1325
+ };
1326
+ if (!t) return i;
1327
+ let a = e.includes("left"), o = e.includes("right"), s = e.includes("top"), c = e.includes("bottom");
1328
+ if (a || o) {
1329
+ let e = a ? t.left : t.right;
1330
+ for (let t of n) {
1331
+ let n = [
1332
+ t.left,
1333
+ t.left + t.width / 2,
1334
+ t.left + t.width
1335
+ ], a;
1336
+ for (let t of n) if (Math.abs(t - e) < r) {
1337
+ a = t;
1338
+ break;
1339
+ }
1340
+ if (a !== void 0) {
1341
+ i.diffX = a - e, i.guideLeft = a;
1342
+ break;
1343
+ }
1344
+ }
1345
+ }
1346
+ if (s || c) {
1347
+ let e = s ? t.top : t.bottom;
1348
+ for (let t of n) {
1349
+ let n = [
1350
+ t.top,
1351
+ t.top + t.height / 2,
1352
+ t.top + t.height
1353
+ ], a;
1354
+ for (let t of n) if (Math.abs(t - e) < r) {
1355
+ a = t;
1356
+ break;
1357
+ }
1358
+ if (a !== void 0) {
1359
+ i.diffY = a - e, i.guideTop = a;
1360
+ break;
1361
+ }
1362
+ }
1363
+ }
1364
+ return i;
1365
+ }
1366
+ function X(e) {
1336
1367
  let t = e.querySelector(".draggable-markline-x"), n = e.querySelector(".draggable-markline-y");
1337
1368
  return t || (t = document.createElement("div"), t.className = "draggable-markline-x", e.appendChild(t)), n || (n = document.createElement("div"), n.className = "draggable-markline-y", e.appendChild(n)), {
1338
1369
  x: t,
1339
1370
  y: n
1340
1371
  };
1341
1372
  }
1342
- function X(e) {
1373
+ function Z(e) {
1343
1374
  e && (e.style.display = "none");
1344
1375
  }
1345
1376
  //#endregion
1346
1377
  //#region src/services/transform/utils/resize.js
1347
- function Z(e, t, n) {
1378
+ function Q(e, t, n) {
1348
1379
  let r = e + t;
1349
1380
  return r > n ? e = r : (t = n - e, e = n), {
1350
1381
  deltaW: t,
1351
1382
  width: e
1352
1383
  };
1353
1384
  }
1354
- function Q(e, t, n) {
1385
+ function $(e, t, n) {
1355
1386
  let r = e + t;
1356
1387
  return r > n ? e = r : (t = n - e, e = n), {
1357
1388
  deltaH: t,
1358
1389
  height: e
1359
1390
  };
1360
1391
  }
1361
- function be(e, t, n, r, i, a, o) {
1392
+ function we(e, t, n, r, i, a, o) {
1362
1393
  let { width: s, height: c, centerX: l, centerY: u, rotateAngle: d } = t, f = s < 0 ? -1 : 1, p = c < 0 ? -1 : 1;
1363
- switch (s = Math.abs(s), c = Math.abs(c), [
1394
+ s = Math.abs(s), c = Math.abs(c);
1395
+ let m = G(d), h = Math.cos(m), g = Math.sin(m);
1396
+ switch ([
1364
1397
  "top-left",
1365
1398
  "top-right",
1366
1399
  "bottom-left",
1367
1400
  "bottom-right"
1368
- ].includes(e) && (e === "top-right" ? r = -r : e === "bottom-left" ? n = -n : e === "top-left" && (n = -n, r = -r), {width: s, deltaW: n} = Z(s, n, a), {height: c, deltaH: r} = Q(c, r, o), i && (r = n / i, c = s / i)), e) {
1401
+ ].includes(e) && (e === "top-right" ? r = -r : e === "bottom-left" ? n = -n : e === "top-left" && (n = -n, r = -r), {width: s, deltaW: n} = Q(s, n, a), {height: c, deltaH: r} = $(c, r, o), i && (r = n / i, c = s / i)), e) {
1369
1402
  case "right":
1370
- ({width: s, deltaW: n} = Z(s, n, a)), i ? (r = n / i, c = s / i, l += n / 2 * Math.cos(G(d)) - r / 2 * Math.sin(G(d)), u += n / 2 * Math.sin(G(d)) + r / 2 * Math.cos(G(d))) : (l += n / 2 * Math.cos(G(d)), u += n / 2 * Math.sin(G(d)));
1403
+ ({width: s, deltaW: n} = Q(s, n, a)), i ? (r = n / i, c = s / i, l += n / 2 * h - r / 2 * g, u += n / 2 * g + r / 2 * h) : (l += n / 2 * h, u += n / 2 * g);
1371
1404
  break;
1372
1405
  case "top-right":
1373
- l += n / 2 * Math.cos(G(d)) + r / 2 * Math.sin(G(d)), u += n / 2 * Math.sin(G(d)) - r / 2 * Math.cos(G(d));
1406
+ l += n / 2 * h + r / 2 * g, u += n / 2 * g - r / 2 * h;
1374
1407
  break;
1375
1408
  case "bottom-right":
1376
- l += n / 2 * Math.cos(G(d)) - r / 2 * Math.sin(G(d)), u += n / 2 * Math.sin(G(d)) + r / 2 * Math.cos(G(d));
1409
+ l += n / 2 * h - r / 2 * g, u += n / 2 * g + r / 2 * h;
1377
1410
  break;
1378
1411
  case "bottom":
1379
- ({height: c, deltaH: r} = Q(c, r, o)), i ? (n = r * i, s = c * i, l += n / 2 * Math.cos(G(d)) - r / 2 * Math.sin(G(d)), u += n / 2 * Math.sin(G(d)) + r / 2 * Math.cos(G(d))) : (l -= r / 2 * Math.sin(G(d)), u += r / 2 * Math.cos(G(d)));
1412
+ ({height: c, deltaH: r} = $(c, r, o)), i ? (n = r * i, s = c * i, l += n / 2 * h - r / 2 * g, u += n / 2 * g + r / 2 * h) : (l -= r / 2 * g, u += r / 2 * h);
1380
1413
  break;
1381
1414
  case "bottom-left":
1382
- l -= n / 2 * Math.cos(G(d)) + r / 2 * Math.sin(G(d)), u -= n / 2 * Math.sin(G(d)) - r / 2 * Math.cos(G(d));
1415
+ l -= n / 2 * h + r / 2 * g, u -= n / 2 * g - r / 2 * h;
1383
1416
  break;
1384
1417
  case "left":
1385
- n = -n, {width: s, deltaW: n} = Z(s, n, a), i ? (c = s / i, r = n / i, l -= n / 2 * Math.cos(G(d)) + r / 2 * Math.sin(G(d)), u -= n / 2 * Math.sin(G(d)) - r / 2 * Math.cos(G(d))) : (l -= n / 2 * Math.cos(G(d)), u -= n / 2 * Math.sin(G(d)));
1418
+ n = -n, {width: s, deltaW: n} = Q(s, n, a), i ? (c = s / i, r = n / i, l -= n / 2 * h + r / 2 * g, u -= n / 2 * g - r / 2 * h) : (l -= n / 2 * h, u -= n / 2 * g);
1386
1419
  break;
1387
1420
  case "top-left":
1388
- l -= n / 2 * Math.cos(G(d)) - r / 2 * Math.sin(G(d)), u -= n / 2 * Math.sin(G(d)) + r / 2 * Math.cos(G(d));
1421
+ l -= n / 2 * h - r / 2 * g, u -= n / 2 * g + r / 2 * h;
1389
1422
  break;
1390
1423
  case "top":
1391
- r = -r, {height: c, deltaH: r} = Q(c, r, o), i ? (s = c * i, n = r * i, l += n / 2 * Math.cos(G(d)) + r / 2 * Math.sin(G(d)), u += n / 2 * Math.sin(G(d)) - r / 2 * Math.cos(G(d))) : (l += r / 2 * Math.sin(G(d)), u -= r / 2 * Math.cos(G(d)));
1424
+ r = -r, {height: c, deltaH: r} = $(c, r, o), i ? (s = c * i, n = r * i, l += n / 2 * h + r / 2 * g, u += n / 2 * g - r / 2 * h) : (l += r / 2 * g, u -= r / 2 * h);
1392
1425
  break;
1393
1426
  default: break;
1394
1427
  }
@@ -1405,23 +1438,23 @@ function be(e, t, n, r, i, a, o) {
1405
1438
  }
1406
1439
  //#endregion
1407
1440
  //#region src/services/transform/utils/handles.js
1408
- function xe(e) {
1441
+ function Te(e) {
1409
1442
  let t = e?.querySelector?.(":scope > .draggable-dot-wrap");
1410
1443
  return t ? [...t.querySelectorAll?.(".draggable-dot") || []] : [];
1411
1444
  }
1412
- function Se(e) {
1445
+ function Ee(e) {
1413
1446
  let t = e?.dataset?.dir;
1414
- return t && pe[t] || "right";
1447
+ return t && _e[t] || "right";
1415
1448
  }
1416
- function Ce(e) {
1449
+ function De(e) {
1417
1450
  return !!e?.hasAttribute?.(t.handleRotateAttr);
1418
1451
  }
1419
- function $(e) {
1452
+ function Oe(e) {
1420
1453
  return !!e?.hasAttribute?.(t.handleResizeAttr);
1421
1454
  }
1422
1455
  //#endregion
1423
1456
  //#region src/services/TransformControllerService.js
1424
- var we = class {
1457
+ var ke = class {
1425
1458
  order = 25;
1426
1459
  #e;
1427
1460
  constructor(e = {}) {
@@ -1463,22 +1496,22 @@ var we = class {
1463
1496
  }
1464
1497
  onDown(e) {
1465
1498
  let t = e?.session;
1466
- if (!t?.isDragScope || !m(t.sourceEl) || !this.#e.resizable) return;
1499
+ if (!t?.isDragScope || !g(t.sourceEl) || !this.#e.resizable) return;
1467
1500
  let { angle: n } = Y(t.sourceEl);
1468
- n && this.#l(t.sourceEl, n);
1501
+ n && this.#u(t.sourceEl, n);
1469
1502
  }
1470
1503
  onStart(e) {
1471
1504
  let n = e.session;
1472
- if (!n?.active || !n?.started || !n.isDragScope || !m(n.sourceEl) || typeof this.#e.canTransform == "function" && !this.#e.canTransform(n.sourceEl)) return;
1473
- let r = n.selectedByNs?.get(n.namespace), i = Array.isArray(r) && r.length > 1, a = "move", o = "", s = this.#e.rotatable && f(n.sourceEl, t.rotatableAttr, !0), c = this.#e.resizable && f(n.sourceEl, t.resizableAttr, !0);
1474
- if (Ce(n.handleEl) && s) {
1505
+ if (!n?.active || !n?.started || !n.isDragScope || !g(n.sourceEl) || typeof this.#e.canTransform == "function" && !this.#e.canTransform(n.sourceEl)) return;
1506
+ let r = n.selectedByNs?.get(n.namespace), i = Array.isArray(r) && r.length > 1, a = "move", o = "", s = this.#e.rotatable && m(n.sourceEl, t.rotatableAttr, !0), c = this.#e.resizable && m(n.sourceEl, t.resizableAttr, !0);
1507
+ if (De(n.handleEl) && s) {
1475
1508
  if (i) return;
1476
1509
  a = "rotate";
1477
- } else if ($(n.handleEl) && c) {
1510
+ } else if (Oe(n.handleEl) && c) {
1478
1511
  if (i) return;
1479
- a = "resize", o = Se(n.handleEl);
1512
+ a = "resize", o = Ee(n.handleEl);
1480
1513
  }
1481
- this.#e.disableMirrorInScope && this.#m(n), this.#e.disableDropIndicatorInScope && this.#h(n), n.cache.__transform = {
1514
+ this.#e.disableMirrorInScope && this.#h(n), this.#e.disableDropIndicatorInScope && this.#g(n), n.cache.__transform = {
1482
1515
  phase: 0,
1483
1516
  type: a,
1484
1517
  side: o,
@@ -1519,12 +1552,12 @@ var we = class {
1519
1552
  onMeasure(e) {
1520
1553
  let n = e.session, r = n?.cache?.__transform;
1521
1554
  if (!n?.active || !n?.started || !n.isDragScope || !r || r.phase !== 0) return;
1522
- if (!m(n.sourceEl)) {
1555
+ if (!g(n.sourceEl)) {
1523
1556
  n.cache.__transform = void 0;
1524
1557
  return;
1525
1558
  }
1526
1559
  let i = e.adapter.closestDragScope(n.sourceEl);
1527
- if (!m(i)) {
1560
+ if (!g(i)) {
1528
1561
  n.cache.__transform = void 0;
1529
1562
  return;
1530
1563
  }
@@ -1551,26 +1584,26 @@ var we = class {
1551
1584
  y: o.top + o.height / 2 - r.center.y
1552
1585
  };
1553
1586
  let s = [...i.querySelectorAll?.(`[${t.dragAttr}]`) || []], c = [];
1554
- for (let t of s) t !== n.sourceEl && m(t) && c.push(q(t, a, e.adapter));
1555
- if (r.lines = ve(c, o), this.#e.markline) {
1556
- let e = ye(i);
1587
+ for (let t of s) t !== n.sourceEl && g(t) && c.push(q(t, a, e.adapter));
1588
+ if (r.lines = Se(c, o), r.targetRects = c, this.#e.markline) {
1589
+ let e = X(i);
1557
1590
  r.guideX = e.x, r.guideY = e.y;
1558
1591
  }
1559
1592
  }
1560
1593
  if (r.multiSelection.enabled) {
1561
1594
  let e = n.selectedByNs?.get(n.namespace);
1562
- if (Array.isArray(e)) for (let t of e) t !== n.sourceEl && m(t) && (r.multiSelection.elements.push(t), r.multiSelection.initialTransforms.push(Y(t)));
1595
+ if (Array.isArray(e)) for (let t of e) t !== n.sourceEl && g(t) && (r.multiSelection.elements.push(t), r.multiSelection.initialTransforms.push(Y(t)));
1563
1596
  }
1564
1597
  r.phase = 1;
1565
1598
  }
1566
1599
  onCompute(e) {
1567
1600
  let t = e.session, n = t?.cache?.__transform;
1568
- !t?.active || !t?.started || !t.isDragScope || !n || n.phase !== 1 || m(t.sourceEl) && (n.didCompute = !0, n.type === "move" ? this.#r(t, n) : n.type === "rotate" ? this.#i(t, n) : n.type === "resize" && this.#a(t, n));
1601
+ !t?.active || !t?.started || !t.isDragScope || !n || n.phase !== 1 || g(t.sourceEl) && (n.didCompute = !0, n.type === "move" ? this.#r(t, n) : n.type === "rotate" ? this.#i(t, n) : n.type === "resize" && this.#a(t, n));
1569
1602
  }
1570
1603
  onCommit(e) {
1571
1604
  let t = e.session, n = t?.cache?.__transform;
1572
- if (!t?.active || !t?.started || !t.isDragScope || !n || n.phase !== 1 || !n.didCompute || !m(t.sourceEl)) return;
1573
- if (this.#d(e, t.sourceEl, n), n.multiSelection.enabled && n.type === "move") {
1605
+ if (!t?.active || !t?.started || !t.isDragScope || !n || n.phase !== 1 || !n.didCompute || !g(t.sourceEl)) return;
1606
+ if (this.#f(e, t.sourceEl, n), n.multiSelection.enabled && n.type === "move") {
1574
1607
  let t = n.data.x - n.start.x, r = n.data.y - n.start.y;
1575
1608
  for (let i = 0; i < n.multiSelection.elements.length; i++) {
1576
1609
  let a = n.multiSelection.elements[i], o = n.multiSelection.initialTransforms[i], s = {
@@ -1580,37 +1613,59 @@ var we = class {
1580
1613
  height: o.height,
1581
1614
  angle: o.angle
1582
1615
  };
1583
- this.#u(e, a, s);
1616
+ this.#d(e, a, s);
1584
1617
  }
1585
1618
  }
1586
1619
  n.type === "rotate" && this.#e.resizable && n.lastCursorAngle !== n.data?.angle && (n.lastCursorAngle = n.data?.angle, e.frame?.run?.(() => {
1587
- this.#l(t.sourceEl, n.lastCursorAngle || 0);
1588
- })), this.#e.markline && this.#c(e, n);
1620
+ this.#u(t.sourceEl, n.lastCursorAngle || 0);
1621
+ })), this.#e.markline && this.#l(e, n);
1589
1622
  let r = e.dnd;
1590
1623
  if (r?.emit && n?.data) {
1591
- let i = {
1624
+ let i = n.__emitPayload;
1625
+ i || (i = n.__emitPayload = {
1592
1626
  type: n.type,
1593
- el: t.sourceEl,
1594
- ...n.data
1595
- }, a = n.type === "move" ? "draggable:drag" : n.type === "rotate" ? "draggable:rotate" : "draggable:resize";
1596
- e.frame?.run?.(() => {
1597
- r.emit(a, i);
1598
- });
1627
+ el: t.sourceEl
1628
+ }, n.__emitEvt = n.type === "move" ? "draggable:drag" : n.type === "rotate" ? "draggable:rotate" : "draggable:resize", n.__emitRun = () => r.emit(n.__emitEvt, n.__emitPayload)), i.el = t.sourceEl, i.x = n.data.x, i.y = n.data.y, i.width = n.data.width, i.height = n.data.height, i.angle = n.data.angle, e.frame?.run?.(n.__emitRun);
1599
1629
  }
1600
1630
  n.didCompute = !1;
1601
1631
  }
1602
- onEnd(e, t) {
1603
- let n = e.session, r = n?.cache?.__transform;
1604
- r && (X(r.guideX), X(r.guideY), t?.ended && m(n?.sourceEl) && r?.data && e.dnd?.emit?.("draggable:drop", {
1605
- type: r.type,
1606
- el: n.sourceEl,
1607
- data: n.data,
1608
- ...r.data
1609
- }), t?.ended && r.type === "rotate" && this.#e.resizable && m(n?.sourceEl) && this.#l(n.sourceEl, r.data?.angle || 0), n.cache.__transform = void 0);
1632
+ onEnd(e, n) {
1633
+ let r = e.session, i = r?.cache?.__transform;
1634
+ if (i) {
1635
+ if (Z(i.guideX), Z(i.guideY), n?.ended && g(r?.sourceEl) && i?.data && (e.dnd?.emit?.("draggable:drop", {
1636
+ type: i.type,
1637
+ el: r.sourceEl,
1638
+ data: r.data,
1639
+ ...i.data
1640
+ }), i.multiSelection?.enabled && i.type === "move")) {
1641
+ let n = i.data.x - i.start.x, a = i.data.y - i.start.y, o = [{
1642
+ el: r.sourceEl,
1643
+ x: i.data.x,
1644
+ y: i.data.y,
1645
+ width: i.data.width,
1646
+ height: i.data.height,
1647
+ angle: i.data.angle,
1648
+ data: r.data
1649
+ }, ...i.multiSelection.elements.map((r, o) => {
1650
+ let s = i.multiSelection.initialTransforms[o];
1651
+ return {
1652
+ el: r,
1653
+ x: s.x + n,
1654
+ y: s.y + a,
1655
+ width: s.width,
1656
+ height: s.height,
1657
+ angle: s.angle,
1658
+ data: u(e.adapter?.getAttr?.(r, t.dataAttr))
1659
+ };
1660
+ })];
1661
+ e.dnd?.emit?.("draggable:multi-drop", o);
1662
+ }
1663
+ n?.ended && i.type === "rotate" && this.#e.resizable && g(r?.sourceEl) && this.#u(r.sourceEl, i.data?.angle || 0), r.cache.__transform = void 0;
1664
+ }
1610
1665
  }
1611
1666
  onDestroy(e, t) {
1612
1667
  let n = t?.cache?.__transform;
1613
- n && (X(n.guideX), X(n.guideY), t.cache.__transform = void 0);
1668
+ n && (Z(n.guideX), Z(n.guideY), t.cache.__transform = void 0);
1614
1669
  }
1615
1670
  #r(e, t) {
1616
1671
  let n = this.#n(t), r = t.start.x + e.dx / n, i = t.start.y + e.dy / n;
@@ -1618,7 +1673,7 @@ var we = class {
1618
1673
  ...t.data,
1619
1674
  x: r,
1620
1675
  y: i
1621
- }, this.#s(t), this.#f(t.data, t.boundary);
1676
+ }, this.#s(t), this.#p(t.data, t.boundary);
1622
1677
  }
1623
1678
  #i(e, t) {
1624
1679
  let n = this.#n(t), r = t.containerRect;
@@ -1634,13 +1689,13 @@ var we = class {
1634
1689
  };
1635
1690
  }
1636
1691
  #a(e, t) {
1637
- let n = this.#n(t), r = this.#e.aspectRatio, i = e.dx / n, a = e.dy / n, o = Math.atan2(a, i), s = ue(i, a), c = o - G(t.start.angle), l = s * Math.cos(c), u = s * Math.sin(c), d = {
1692
+ let n = this.#n(t), r = this.#e.aspectRatio, i = e.dx / n, a = e.dy / n, o = Math.atan2(a, i), s = me(i, a), c = o - G(t.start.angle), l = s * Math.cos(c), u = s * Math.sin(c), d = {
1638
1693
  centerX: t.start.x + t.start.width / 2,
1639
1694
  centerY: t.start.y + t.start.height / 2,
1640
1695
  height: t.start.height,
1641
1696
  rotateAngle: t.start.angle,
1642
1697
  width: t.start.width
1643
- }, { position: { centerX: f, centerY: p }, size: { width: m, height: h } } = be(t.side, d, l, u, r, this.#e.minWidth, this.#e.minHeight), g = fe({
1698
+ }, { position: { centerX: f, centerY: p }, size: { width: m, height: h } } = we(t.side, d, l, u, r, this.#e.minWidth, this.#e.minHeight), g = ge({
1644
1699
  angle: t.data.angle,
1645
1700
  centerX: f,
1646
1701
  centerY: p,
@@ -1648,14 +1703,14 @@ var we = class {
1648
1703
  width: m
1649
1704
  }), _ = {
1650
1705
  ...t.data,
1651
- ...de(g, f, p)
1706
+ ...he(g, f, p)
1652
1707
  };
1653
1708
  if (this.#e.maxWidth > 0 && (_.width = Math.min(_.width, this.#e.maxWidth)), this.#e.maxHeight > 0 && (_.height = Math.min(_.height, this.#e.maxHeight)), this.#e.snapToGrid) {
1654
1709
  let e = _.x + _.width / 2, n = _.y + _.height / 2, i = this.#e.gridX, a = this.#e.gridY, o = t.start.width + K(_.width - t.start.width, i), s;
1655
1710
  s = r ? o / r : t.start.height + K(_.height - t.start.height, a), _.width = Math.abs(o), _.height = Math.abs(s), _.x = e - _.width / 2, _.y = n - _.height / 2;
1656
1711
  }
1657
1712
  let v = _;
1658
- this.#p(v, t.boundary) ? (t.data = v, t.lastValidData = { ...v }) : t.data = t.lastValidData ? { ...t.lastValidData } : { ...t.start }, this.#s(t);
1713
+ this.#m(v, t.boundary) ? (t.data = v, t.lastValidData = { ...v }) : t.data = t.lastValidData ? { ...t.lastValidData } : { ...t.start }, this.#c(t);
1659
1714
  }
1660
1715
  #o(e) {
1661
1716
  let t = e?.data, n = e?.viewportCenterOffset;
@@ -1697,46 +1752,79 @@ var we = class {
1697
1752
  }
1698
1753
  this.#e.snap && (r.diffX && (e.data.x += r.diffX), r.diffY && (e.data.y += r.diffY)), e.mark = r;
1699
1754
  }
1700
- #c(e, t) {
1755
+ #c(e) {
1756
+ if (!this.#e.snap && !this.#e.markline || !e?.targetRects || !e.containerRectScaled) return;
1757
+ let t = {
1758
+ diffX: 0,
1759
+ diffY: 0,
1760
+ left: void 0,
1761
+ top: void 0
1762
+ };
1763
+ if ((e.data.angle || 0) !== 0 || this.#e.aspectRatio) {
1764
+ e.mark = t;
1765
+ return;
1766
+ }
1767
+ let n = this.#o(e), { diffX: r, diffY: i, guideLeft: a, guideTop: o } = Ce({
1768
+ side: e.side,
1769
+ source: n,
1770
+ targetRects: e.targetRects,
1771
+ threshold: this.#e.snapThreshold
1772
+ });
1773
+ if (t.diffX = r, t.diffY = i, t.left = a === void 0 ? void 0 : a - e.containerRectScaled.left, t.top = o === void 0 ? void 0 : o - e.containerRectScaled.top, this.#e.snap && (r || i)) {
1774
+ let n = this.#n(e), a = { ...e.data }, o = { ...e.data }, s = e.side || "";
1775
+ if (r) {
1776
+ let e = r / n;
1777
+ s.includes("left") ? (o.x += e, o.width -= e) : s.includes("right") && (o.width += e);
1778
+ }
1779
+ if (i) {
1780
+ let e = i / n;
1781
+ s.includes("top") ? (o.y += e, o.height -= e) : s.includes("bottom") && (o.height += e);
1782
+ }
1783
+ let c = o.width >= this.#e.minWidth && o.height >= this.#e.minHeight;
1784
+ c && this.#e.maxWidth > 0 && o.width > this.#e.maxWidth && (c = !1), c && this.#e.maxHeight > 0 && o.height > this.#e.maxHeight && (c = !1), c && !this.#m(o, e.boundary) && (c = !1), c ? (e.data = o, e.lastValidData = { ...o }) : (e.data = a, t.left = void 0, t.top = void 0);
1785
+ }
1786
+ e.mark = t;
1787
+ }
1788
+ #l(e, t) {
1701
1789
  let { guideX: n, guideY: r } = t, i = t.mark || {};
1702
1790
  n && (i.left === void 0 ? e.frame?.setStyle?.(n, "display", "none") : (e.frame?.setStyle?.(n, "display", "block"), e.frame?.setStyle?.(n, "transform", `translate(${W(i.left)}, 0)`))), r && (i.top === void 0 ? e.frame?.setStyle?.(r, "display", "none") : (e.frame?.setStyle?.(r, "display", "block"), e.frame?.setStyle?.(r, "transform", `translate(0, ${W(i.top)})`)));
1703
1791
  }
1704
- #l(e, t) {
1705
- let n = xe(e);
1792
+ #u(e, t) {
1793
+ let n = Te(e);
1706
1794
  for (let e of n) {
1707
1795
  let n = e?.dataset?.dir;
1708
- n && (e.style.cursor = `${_e(t, n)}-resize`);
1796
+ n && (e.style.cursor = `${xe(t, n)}-resize`);
1709
1797
  }
1710
1798
  }
1711
- #u(e, t, n) {
1799
+ #d(e, t, n) {
1712
1800
  e.frame?.setStyle?.(t, "transform", `translate(${W(n.x)}, ${W(n.y)}) rotate(${n.angle}deg)`);
1713
1801
  }
1714
- #d(e, t, n) {
1802
+ #f(e, t, n) {
1715
1803
  let r = n.data;
1716
- n.lastAppliedW !== r.width && (e.frame?.setStyle?.(t, "width", W(r.width)), n.lastAppliedW = r.width), n.lastAppliedH !== r.height && (e.frame?.setStyle?.(t, "height", W(r.height)), n.lastAppliedH = r.height), (n.lastAppliedX !== r.x || n.lastAppliedY !== r.y || n.lastAppliedAngle !== r.angle) && (this.#u(e, t, r), n.lastAppliedX = r.x, n.lastAppliedY = r.y, n.lastAppliedAngle = r.angle);
1804
+ n.lastAppliedW !== r.width && (e.frame?.setStyle?.(t, "width", W(r.width)), n.lastAppliedW = r.width), n.lastAppliedH !== r.height && (e.frame?.setStyle?.(t, "height", W(r.height)), n.lastAppliedH = r.height), (n.lastAppliedX !== r.x || n.lastAppliedY !== r.y || n.lastAppliedAngle !== r.angle) && (this.#d(e, t, r), n.lastAppliedX = r.x, n.lastAppliedY = r.y, n.lastAppliedAngle = r.angle);
1717
1805
  }
1718
- #f(e, t) {
1806
+ #p(e, t) {
1719
1807
  if (!t) return;
1720
1808
  let n = G(e.angle || 0), r = Math.abs(Math.cos(n)), i = Math.abs(Math.sin(n)), a = e.width * r + e.height * i, o = e.width * i + e.height * r, s = (a - e.width) / 2, c = t.w - a / 2 - e.width / 2, l = (o - e.height) / 2, u = t.h - o / 2 - e.height / 2;
1721
1809
  e.x = Math.max(Math.min(s, c), Math.min(e.x, Math.max(s, c))), e.y = Math.max(Math.min(l, u), Math.min(e.y, Math.max(l, u)));
1722
1810
  }
1723
- #p(e, t) {
1811
+ #m(e, t) {
1724
1812
  if (!t) return !0;
1725
- let n = G(e.angle || 0), r = Math.abs(Math.cos(n)), i = Math.abs(Math.sin(n)), a = e.width * r + e.height * i, o = e.width * i + e.height * r, s = e.x + e.width / 2, c = e.y + e.height / 2, l = s - a / 2, u = s + a / 2, d = c - o / 2, f = c + o / 2;
1726
- return !(l < -.5 || d < -.5 || u > t.w + .5 || f > t.h + .5);
1813
+ let n = G(e.angle || 0), r = Math.abs(Math.cos(n)), i = Math.abs(Math.sin(n)), a = e.width * r + e.height * i, o = e.width * i + e.height * r, s = e.x + e.width / 2, l = e.y + e.height / 2, u = s - a / 2, d = s + a / 2, f = l - o / 2, p = l + o / 2, m = c;
1814
+ return !(u < -m || f < -m || d > t.w + m || p > t.h + m);
1727
1815
  }
1728
- #m(e) {
1816
+ #h(e) {
1729
1817
  if (e?.mirrorEl) {
1730
1818
  try {
1731
1819
  e.mirrorEl.parentNode?.removeChild?.(e.mirrorEl);
1732
1820
  } catch {}
1733
1821
  e.mirrorEl = void 0;
1734
1822
  }
1735
- if (m(e?.sourceEl)) try {
1823
+ if (g(e?.sourceEl)) try {
1736
1824
  e.sourceEl.style.visibility = "";
1737
1825
  } catch {}
1738
1826
  }
1739
- #h(e) {
1827
+ #g(e) {
1740
1828
  if (e?.indicatorEl) {
1741
1829
  try {
1742
1830
  e.indicatorEl.parentNode?.removeChild?.(e.indicatorEl);
@@ -1745,9 +1833,9 @@ var we = class {
1745
1833
  }
1746
1834
  e.currentDrop = void 0, e.currentDropRect = void 0, e.currentAllowed = !1;
1747
1835
  }
1748
- }, Te = {
1836
+ }, Ae = {
1749
1837
  name: "@ptahjs/dnd",
1750
- version: "0.1.1"
1838
+ version: "0.1.3"
1751
1839
  };
1752
1840
  //#endregion
1753
- export { j as ACTIVE_WRAP_CLASS, B as ActiveSelectionService, D as AutoScrollService, M as DOT_CLASS, re as Dnd, Te as DndVersion, le as DropIndicatorService, x as DropService, U as MarqueeSelectionService, S as MirrorService, N as ROTATE_CLASS, we as TransformControllerService, z as clearAll, R as setMultipleActive };
1841
+ export { P as ACTIVE_WRAP_CLASS, U as ActiveSelectionService, ie as AutoScrollService, F as DOT_CLASS, w as Dnd, Ae as DndVersion, le as DropIndicatorService, T as DropService, pe as MarqueeSelectionService, E as MirrorService, I as ROTATE_CLASS, ke as TransformControllerService, H as clearAll, V as setMultipleActive };