@ptahjs/dnd 0.0.3 → 0.1.1

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.
Files changed (3) hide show
  1. package/dist/dnd.css +1 -1
  2. package/dist/dnd.js +483 -303
  3. package/package.json +7 -3
package/dist/dnd.js CHANGED
@@ -2,18 +2,31 @@
2
2
  var e = class {
3
3
  #e = /* @__PURE__ */ new Map();
4
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) {
5
16
  let n = this.#e.get(e);
6
17
  if (!n || n.length === 0) return t;
7
18
  let r = t;
8
- for (let e of n) {
9
- let t = e(r);
10
- t !== void 0 && (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);
11
24
  }
12
25
  return r;
13
26
  }
14
27
  on(e, t) {
15
28
  let n = this.#e.get(e);
16
- return n ? n.push(t) : this.#e.set(e, [t]), this;
29
+ return n ? n.includes(t) || n.push(t) : this.#e.set(e, [t]), this;
17
30
  }
18
31
  off(e, t) {
19
32
  let n = this.#e.get(e);
@@ -54,37 +67,46 @@ var e = class {
54
67
  indicatorTop: "dnd-indicator--top",
55
68
  indicatorRight: "dnd-indicator--right",
56
69
  indicatorBottom: "dnd-indicator--bottom",
57
- indicatorLeft: "dnd-indicator--left"
58
- }, r = .5, i = 1 / 3;
70
+ indicatorLeft: "dnd-indicator--left",
71
+ marquee: "dnd-marquee"
72
+ }, r = .5, i = 1 / 3, a = {
73
+ MARQUEE_MOVE: 5,
74
+ DRAG_START: 3
75
+ }, o = {
76
+ EDGE: 48,
77
+ MIN_SPEED: 180,
78
+ MAX_SPEED: 600
79
+ };
59
80
  //#endregion
60
81
  //#region src/utils/computeDropRegion.js
61
- function a(e) {
62
- if (e?.cache?.dropRegionFns) return e.cache.dropRegionFns;
63
- let t = () => {
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 = () => {
64
86
  if (e.currentDrop) return e.currentDropRect || void 0;
65
- }, n = {
66
- isOverBottom: () => {
67
- let n = t();
68
- return n ? e.y > n.y + n.height * (1 - r) : !1;
69
- },
70
- isOverLeft: () => {
71
- let n = t();
72
- return n ? e.x < n.x + n.width * i : !1;
73
- },
74
- isOverRight: () => {
75
- let n = t();
76
- return n ? e.x > n.x + n.width * (1 - i) : !1;
77
- },
78
- isOverTop: () => {
79
- let n = t();
80
- return n ? e.y < n.y + n.height * r : !1;
81
- }
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();
90
+ return t ? e.y < t.y + t.height * r : !1;
91
+ } : () => !1,
92
+ isOverBottom: o ? () => {
93
+ let t = a();
94
+ return t ? e.y > t.y + t.height * (1 - r) : !1;
95
+ } : () => !1,
96
+ isOverLeft: s ? () => {
97
+ let t = a();
98
+ return t ? e.x < t.x + t.width * i : !1;
99
+ } : () => !1,
100
+ isOverRight: s ? () => {
101
+ let t = a();
102
+ return t ? e.x > t.x + t.width * (1 - i) : !1;
103
+ } : () => !1
82
104
  };
83
- return e?.cache && (e.cache.dropRegionFns = n), n;
105
+ return e?.cache && (e.cache[n] = c), c;
84
106
  }
85
107
  //#endregion
86
108
  //#region src/utils/parseData.js
87
- function o(e) {
109
+ function c(e) {
88
110
  if (e === void 0) return;
89
111
  let t = String(e).trim();
90
112
  if (!t) return "";
@@ -96,7 +118,7 @@ function o(e) {
96
118
  }
97
119
  //#endregion
98
120
  //#region src/utils/createPayload.js
99
- function s(e, n) {
121
+ function l(e, n) {
100
122
  let r = () => {
101
123
  let e = n.currentDrop;
102
124
  if (!e) return;
@@ -115,7 +137,7 @@ function s(e, n) {
115
137
  return;
116
138
  }
117
139
  let i = n.adapter.getAttr(e, t.dataAttr);
118
- return r.dropDataEl === e && i === r.dropDataRaw ? r.dropDataParsed : (r.dropDataEl = e, r.dropDataRaw = i, r.dropDataParsed = o(i), r.dropDataParsed);
140
+ return r.dropDataEl === e && i === r.dropDataRaw ? r.dropDataParsed : (r.dropDataEl = e, r.dropDataRaw = i, r.dropDataParsed = c(i), r.dropDataParsed);
119
141
  };
120
142
  if (!n.cache.hitDropFn) {
121
143
  let e = -1, t = 0, r = 0, i, a;
@@ -147,12 +169,12 @@ function s(e, n) {
147
169
  dy: n.dy,
148
170
  started: n.started,
149
171
  hitDrop: n.cache.hitDropFn,
150
- ...a(n)
172
+ ...s(n)
151
173
  };
152
174
  }
153
175
  //#endregion
154
176
  //#region src/utils/createSession.js
155
- function c(e) {
177
+ function u(e) {
156
178
  return {
157
179
  adapter: void 0,
158
180
  currentDropRect: void 0,
@@ -168,7 +190,7 @@ function c(e) {
168
190
  dx: 0,
169
191
  dy: 0,
170
192
  started: !1,
171
- threshold: 3,
193
+ threshold: a.DRAG_START,
172
194
  lastMoveTs: 0,
173
195
  sourceEl: void 0,
174
196
  handleEl: void 0,
@@ -205,7 +227,7 @@ function c(e) {
205
227
  }
206
228
  //#endregion
207
229
  //#region src/utils/createContext.js
208
- function l({ dnd: e, session: t, store: n, frame: r, adapter: i }) {
230
+ function d({ dnd: e, session: t, store: n, frame: r, adapter: i }) {
209
231
  let a = /* @__PURE__ */ new Map();
210
232
  return {
211
233
  dnd: e,
@@ -215,24 +237,24 @@ function l({ dnd: e, session: t, store: n, frame: r, adapter: i }) {
215
237
  adapter: i,
216
238
  payload: (e = "drag") => {
217
239
  if (a.has(e)) return a.get(e);
218
- let n = s(e, t);
240
+ let n = l(e, t);
219
241
  return a.set(e, n), n;
220
242
  }
221
243
  };
222
244
  }
223
245
  //#endregion
224
246
  //#region src/utils/isToggleEnabled.js
225
- function u(e, t, n = !0) {
247
+ function f(e, t, n = !0) {
226
248
  if (!e?.getAttribute) return n;
227
249
  let r = `data-${t}`, i = e.getAttribute(t) ?? e.getAttribute(r);
228
250
  return i === null ? n : String(i).toLowerCase() !== "false";
229
251
  }
230
252
  //#endregion
231
253
  //#region src/utils/matchHandle.js
232
- function d(e, n) {
254
+ function p(e, n) {
233
255
  let r = n?.closestDraggable?.(e) || e?.closest?.(`[${t.dragAttr}], [${t.dragdropAttr}]`);
234
256
  if (!r) return;
235
- let i = u(r, t.rotatableAttr, !0), a = u(r, t.resizableAttr, !0);
257
+ let i = f(r, t.rotatableAttr, !0), a = f(r, t.resizableAttr, !0);
236
258
  if (i && (r.hasAttribute(t.handleRotateAttr) || r.querySelector?.(`[${t.handleRotateAttr}]`)) || a && (r.hasAttribute(t.handleResizeAttr) || r.querySelector?.(`[${t.handleResizeAttr}]`))) {
237
259
  let n = (i ? e.closest?.(`[${t.handleRotateAttr}]`) : null) || (a ? e.closest?.(`[${t.handleResizeAttr}]`) : null);
238
260
  return n && r.contains(n) ? n : r;
@@ -245,12 +267,19 @@ function d(e, n) {
245
267
  }
246
268
  //#endregion
247
269
  //#region src/utils/isHTMLElement.js
248
- function f(e) {
270
+ function m(e) {
249
271
  return e && typeof e == "object" && e.nodeType === 1;
250
272
  }
251
273
  //#endregion
252
- //#region src/core/DomAdapter.js
253
- var p = class {
274
+ //#region src/utils/isIgnoreClick.js
275
+ function h(e) {
276
+ if (!m(e)) return !1;
277
+ let n = t.ignoreClickAttr, r = `data-${n}`;
278
+ return !!(e.closest?.(`[${n}], [${r}]`) || e.hasAttribute?.(n) || e.hasAttribute?.(r));
279
+ }
280
+ //#endregion
281
+ //#region src/utils/scopeHelpers.js
282
+ var g = t.dragScopeAttr, _ = `[${g}], [data-${g}]`, v = class {
254
283
  #e = 0;
255
284
  #t = /* @__PURE__ */ new WeakMap();
256
285
  #n = /* @__PURE__ */ new WeakMap();
@@ -319,7 +348,7 @@ var p = class {
319
348
  o = o.parentElement;
320
349
  }
321
350
  }
322
- }, m = class {
351
+ }, y = class {
323
352
  #e = !1;
324
353
  #t = !1;
325
354
  #n = 0;
@@ -339,8 +368,8 @@ var p = class {
339
368
  let e = !1;
340
369
  try {
341
370
  e = !!this.#r(performance.now());
342
- } catch {
343
- e = !1;
371
+ } catch (t) {
372
+ e = !1, console.error("[RafScheduler] frame callback error:", t);
344
373
  }
345
374
  if (this.#e) {
346
375
  if (e || this.#t) {
@@ -350,7 +379,7 @@ var p = class {
350
379
  this.#e = !1, this.#n = 0;
351
380
  }
352
381
  };
353
- }, h = class {
382
+ }, b = class {
354
383
  #e;
355
384
  #t = new AbortController();
356
385
  #n = !1;
@@ -411,13 +440,15 @@ var p = class {
411
440
  }), e.preventDefault();
412
441
  };
413
442
  #p = (e) => {
414
- !this.#n || !this.#c || "pointerId" in e && e.pointerId !== this.#r || (this.#c({
443
+ if (!this.#n || !this.#c || "pointerId" in e && e.pointerId !== this.#r) return;
444
+ let t = this.#r, n = e.type;
445
+ this.#d(), this.#c({
415
446
  event: e,
416
- pointerId: this.#r,
417
- reason: e.type
418
- }), this.#d(), e.preventDefault?.());
447
+ pointerId: t,
448
+ reason: n
449
+ }), e.preventDefault?.();
419
450
  };
420
- }, g = class {
451
+ }, ee = class {
421
452
  scrolled = !1;
422
453
  now = 0;
423
454
  classOps = /* @__PURE__ */ new Map();
@@ -455,7 +486,7 @@ var p = class {
455
486
  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);
456
487
  for (let e of this.fnOps) e?.();
457
488
  }
458
- }, _ = class {
489
+ }, te = class {
459
490
  #e = [];
460
491
  use(e, t) {
461
492
  e && (this.#e.push(e), this.#e.sort((e, t) => (e.order ?? 0) - (t.order ?? 0)), e.onAttach?.(t));
@@ -492,7 +523,10 @@ var p = class {
492
523
  onDestroy(e, t) {
493
524
  for (let n of this.#e) n.onDestroy?.(e, t);
494
525
  }
495
- }, v = class {
526
+ dispose() {
527
+ this.#e.length = 0;
528
+ }
529
+ }, ne = class {
496
530
  #e;
497
531
  #t;
498
532
  constructor({ store: e, session: t } = {}) {
@@ -558,47 +592,55 @@ var p = class {
558
592
  started: this.#t.started
559
593
  };
560
594
  }
561
- case "END": return !this.#t.active || e.pointerId !== void 0 && e.pointerId !== this.#t.pointerId ? { handled: !1 } : {
562
- handled: !0,
563
- ended: !!this.#t.started,
564
- reason: e.reason
565
- };
595
+ case "END": {
596
+ if (!this.#t.active || e.pointerId !== void 0 && e.pointerId !== this.#t.pointerId) return { handled: !1 };
597
+ let t = !!this.#t.started;
598
+ return this.#t.active = !1, {
599
+ handled: !0,
600
+ ended: t,
601
+ reason: e.reason
602
+ };
603
+ }
566
604
  default: return { handled: !1 };
567
605
  }
568
606
  }
569
607
  resetSession({ ended: e } = { ended: !1 }) {
570
- let t = this.#e, n = this.#t, r = c(t);
608
+ let t = this.#e, n = this.#t, r = u(t);
571
609
  return r.adapter = n?.adapter, e && (r.suppressNextClick = !0, r.lastDragTs = performance.now()), this.#t = r, r;
572
610
  }
573
- }, y = class extends e {
611
+ }, re = class extends e {
574
612
  #e = new AbortController();
575
613
  #t;
576
614
  #n;
577
- #r = new p();
578
- #i = new g();
615
+ #r = new v();
616
+ #i = new ee();
579
617
  #a = { selectedByNs: /* @__PURE__ */ new Map() };
580
618
  #o;
581
- #s = new _();
619
+ #s = new te();
582
620
  #c;
583
621
  #l;
622
+ #u = !1;
584
623
  canDrop = () => !0;
585
624
  renderMirror = void 0;
586
625
  get root() {
587
626
  return this.#t;
588
627
  }
589
628
  get monitor() {
590
- return this.#o?.session;
629
+ if (!this.#u) return this.#o?.session;
630
+ }
631
+ get destroyed() {
632
+ return this.#u;
591
633
  }
592
634
  constructor(e = {}) {
593
- super(), this.#n = { threshold: e.threshold ?? 3 };
594
- let t = c(this.#a);
595
- t.threshold = this.#n.threshold, t.adapter = this.#r, this.#o = new v({
635
+ 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({
596
638
  store: this.#a,
597
639
  session: t
598
- }), this.#c = new m(this.#m), this.#l = new h({
599
- onDown: this.#d,
600
- onMove: this.#f,
601
- onUp: this.#p
640
+ }), this.#c = new y(this.#h), this.#l = new b({
641
+ onDown: this.#f,
642
+ onMove: this.#p,
643
+ onUp: this.#m
602
644
  }), this.setRoot(e.root);
603
645
  }
604
646
  use(e) {
@@ -608,16 +650,17 @@ var p = class {
608
650
  let t = this.#r.resolveRoot(e);
609
651
  if (t === this.#t) return;
610
652
  let n = this.#t;
611
- 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.#u, {
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, {
612
654
  capture: !0,
613
655
  passive: !1,
614
656
  signal: this.#e.signal
615
657
  }));
616
658
  }
617
659
  destroy() {
660
+ if (this.#u) return;
618
661
  this.#e.abort(), this.#l.destroy(), this.#c.cancel();
619
662
  let e = this.#o.session;
620
- e?.active && (this.#s.onEnd(l({
663
+ e?.active && (this.#s.onEnd(d({
621
664
  dnd: this,
622
665
  session: e,
623
666
  store: this.#a,
@@ -626,55 +669,53 @@ var p = class {
626
669
  }), {
627
670
  ended: !1,
628
671
  reason: "destroy"
629
- }), e.dragAbort?.abort()), this.offAll(), this.#s.onDestroy(this, e);
630
- let t = this.#o.resetSession({ ended: !1 });
631
- t.adapter = this.#r;
672
+ }), e.dragAbort?.abort()), this.#s.onDestroy(this, e), this.#s.dispose?.(), this.offAll(), this.#u = !0;
632
673
  }
633
- #u = (e) => {
674
+ #d = (e) => {
634
675
  let t = this.#o?.session;
635
676
  if (!t?.suppressNextClick) return;
636
677
  let n = performance.now(), r = !t.lastDragTs || n - t.lastDragTs < 800;
637
678
  t.suppressNextClick = !1, r && (e.preventDefault?.(), e.stopPropagation?.(), e.stopImmediatePropagation?.());
638
679
  };
639
- #d = (e) => {
680
+ #f = (e) => {
640
681
  if (!this.#t || e.button !== 0) return { accepted: !1 };
641
- let n = d(e.target, this.#r);
682
+ let n = p(e.target, this.#r);
642
683
  if (!n) return { accepted: !1 };
643
684
  let r = this.#r.closestDraggable(n);
644
- if (!r) return { accepted: !1 };
685
+ if (!r || e.target?.closest?.("input, textarea, select, button, a[href], [contenteditable]")) return { accepted: !1 };
645
686
  e.preventDefault(), e.target?.setPointerCapture?.(e.pointerId);
646
- let i = this.#r.getNamespace(r), a = this.#r.closestDrop(r), s = r.getBoundingClientRect(), c = o(this.#r.getAttr(r, t.dataAttr));
687
+ let i = this.#r.getNamespace(r), a = this.#r.closestDrop(r), o = r.getBoundingClientRect(), s = c(this.#r.getAttr(r, t.dataAttr));
647
688
  if (!this.#o.dispatch({
648
689
  type: "DOWN",
649
690
  pointerId: e.pointerId,
650
691
  x: e.clientX,
651
692
  y: e.clientY,
652
693
  namespace: i,
653
- data: c,
694
+ data: s,
654
695
  sourceEl: r,
655
696
  handleEl: n,
656
697
  originDrop: a,
657
698
  isDragScope: !!this.#r.closestDragScope(r),
658
699
  isCopy: !!this.#r.getAttr(r, t.copyAttr),
659
- mirrorOffsetX: e.clientX - s.left,
660
- mirrorOffsetY: e.clientY - s.top
700
+ mirrorOffsetX: e.clientX - o.left,
701
+ mirrorOffsetY: e.clientY - o.top
661
702
  })?.accepted) return { accepted: !1 };
662
- let u = this.#o.session;
663
- u.threshold = this.#n.threshold, u.adapter = this.#r, this.#i.reset(performance.now()), this.#r.beginFrame(), u.cache.frameId = this.#r.frameId;
664
- let f = l({
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({
665
706
  dnd: this,
666
- session: u,
707
+ session: l,
667
708
  store: this.#a,
668
709
  frame: this.#i,
669
710
  adapter: this.#r
670
711
  });
671
- return this.#s.onDown(f, e), this.#i.commit(), this.#r.endFrame(), {
712
+ return this.#s.onDown(u, e), this.#i.commit(), this.#r.endFrame(), {
672
713
  accepted: !0,
673
714
  pointerId: e.pointerId,
674
- signal: u.dragAbort.signal
715
+ signal: l.dragAbort.signal
675
716
  };
676
717
  };
677
- #f = ({ pointerId: e, x: t, y: n }) => {
718
+ #p = ({ pointerId: e, x: t, y: n }) => {
678
719
  let r = this.#o.dispatch({
679
720
  type: "MOVE",
680
721
  pointerId: e,
@@ -684,18 +725,18 @@ var p = class {
684
725
  if (!r?.handled) return;
685
726
  let i = this.#o.session;
686
727
  if (r.startedNow) {
687
- let e = l({
728
+ let e = d({
688
729
  dnd: this,
689
730
  session: i,
690
731
  store: this.#a,
691
732
  frame: this.#i,
692
733
  adapter: this.#r
693
734
  });
694
- this.#s.onStart(e), this.emit("dragstart", s("dragstart", i));
735
+ this.#s.onStart(e), this.emit("dragstart", l("dragstart", i));
695
736
  }
696
737
  r.started && this.#c.request();
697
738
  };
698
- #p = ({ event: e, pointerId: t, reason: n }) => {
739
+ #m = ({ event: e, pointerId: t, reason: n }) => {
699
740
  let r = this.#o.dispatch({
700
741
  type: "END",
701
742
  pointerId: t,
@@ -706,7 +747,7 @@ var p = class {
706
747
  "pointerId" in e && e.target?.releasePointerCapture?.(e.pointerId);
707
748
  let a = !!r.ended;
708
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();
709
- let o = l({
750
+ let o = d({
710
751
  dnd: this,
711
752
  session: i,
712
753
  store: this.#a,
@@ -717,16 +758,16 @@ var p = class {
717
758
  ended: a,
718
759
  reason: n || "pointerup"
719
760
  });
720
- let c = s(a ? "drop" : "cancel", i);
761
+ let s = l(a ? "drop" : "cancel", i);
721
762
  i.dragAbort?.abort(), i.dragAbort = void 0, this.#c.cancel();
722
- let u = this.#o.resetSession({ ended: a });
723
- u.adapter = this.#r, a ? this.emit("drop", c) : this.emit("cancel", c), e.preventDefault?.();
763
+ let c = this.#o.resetSession({ ended: a });
764
+ c.adapter = this.#r, a ? this.emit("drop", s) : this.emit("cancel", s), e.preventDefault?.();
724
765
  };
725
- #m = (e) => {
766
+ #h = (e) => {
726
767
  let t = this.#o.session;
727
768
  if (!t.active || !t.started) return !1;
728
769
  this.#i.reset(e), this.#r.beginFrame(), t.cache.frameId = this.#r.frameId;
729
- let n = l({
770
+ let n = d({
730
771
  dnd: this,
731
772
  session: t,
732
773
  store: this.#a,
@@ -735,12 +776,16 @@ var p = class {
735
776
  }), r = !1;
736
777
  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;
737
778
  };
738
- }, b = class {
779
+ }, x = class {
739
780
  order = 10;
740
781
  onMeasure(e) {
741
782
  let t = e.session;
742
783
  if (!t.active || !t.started) return;
743
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
+ }
744
789
  if (n !== t.currentDrop && (t.currentDrop = n, t.cache && (t.cache.dropRectDirty = !0)), !n) {
745
790
  t.currentDropRect = void 0, t.cache && (t.cache.dropRectDirty = !1);
746
791
  return;
@@ -769,18 +814,18 @@ var p = class {
769
814
  let t = e.session;
770
815
  if (!t?.active || !t?.started) return;
771
816
  let r = t.cache ||= {}, i = r._dropClassEl, a = t.currentDrop;
772
- f(i) && i !== a && (e.frame.toggleClass(i, n.canDrop, !1), e.frame.toggleClass(i, n.noDrop, !1)), f(a) && (e.frame.toggleClass(a, n.canDrop, !!t.currentAllowed), e.frame.toggleClass(a, n.noDrop, !t.currentAllowed)), r._dropClassEl = a;
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;
773
818
  }
774
819
  onEnd(e) {
775
820
  let t = e?.session;
776
821
  if (!t) return;
777
822
  let r = t.cache?._dropClassEl;
778
- f(r) && r.classList.remove(n.canDrop, n.noDrop), t.cache && (t.cache._dropClassEl = void 0);
823
+ m(r) && r.classList.remove(n.canDrop, n.noDrop), t.cache && (t.cache._dropClassEl = void 0);
779
824
  }
780
825
  onDestroy(e, t) {
781
826
  this.onEnd({ session: t });
782
827
  }
783
- }, x = class {
828
+ }, S = class {
784
829
  order = 0;
785
830
  onStart = (e) => {
786
831
  let r = e?.session;
@@ -790,7 +835,7 @@ var p = class {
790
835
  width: `${i.width}px`,
791
836
  height: `${i.height}px`,
792
837
  position: "fixed"
793
- }), document.body.appendChild(a), r.mirrorEl = a);
838
+ }), (e.dnd?.root || document.body).appendChild(a), r.mirrorEl = a);
794
839
  };
795
840
  onCommit = (e) => {
796
841
  let t = e?.session;
@@ -806,20 +851,20 @@ var p = class {
806
851
  onDestroy = (e, t) => {
807
852
  this.onEnd({ session: t });
808
853
  };
809
- }, S = /(auto|scroll|overlay)/i;
810
- function C(e) {
854
+ }, C = /(auto|scroll|overlay)/i;
855
+ function w(e) {
811
856
  if (!(e instanceof HTMLElement)) return !1;
812
- let t = getComputedStyle(e), n = S.test(t.overflowY) && e.scrollHeight > e.clientHeight + 1;
813
- return S.test(t.overflowX) && e.scrollWidth > e.clientWidth + 1 || n;
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;
814
859
  }
815
- function w(e) {
860
+ function T(e) {
816
861
  let t = e;
817
862
  for (; t;) {
818
- if (C(t)) return t;
863
+ if (w(t)) return t;
819
864
  t = t.parentElement;
820
865
  }
821
866
  }
822
- function T(e, t, n, r) {
867
+ function E(e, t, n, r) {
823
868
  return e < t + r ? {
824
869
  dir: -1,
825
870
  k: (t + r - e) / r
@@ -831,15 +876,15 @@ function T(e, t, n, r) {
831
876
  k: 0
832
877
  };
833
878
  }
834
- var ee = class {
879
+ var D = class {
835
880
  order = 1e4;
836
881
  constructor(e = {}) {
837
- this.edge = e.edge ?? 48, this.minSpeed = e.minSpeed ?? 180, this.maxSpeed = e.maxSpeed ?? 600, this.allowWindowScroll = e.allowWindowScroll ?? !0;
882
+ 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;
838
883
  }
839
884
  onAfterDrag = (e) => {
840
885
  let t = e.session;
841
886
  if (!t.active || !t.started) return !1;
842
- let n = t.currentDrop ? w(t.currentDrop) : void 0, r = !1;
887
+ let n = t.currentDrop ? T(t.currentDrop) : void 0, r = !1;
843
888
  if (!n && this.allowWindowScroll && (n = document.scrollingElement || document.documentElement, r = !!n), !n) return !1;
844
889
  let i = e.frame.now, a = t.cache.autoScrollLastTs || 0, o = a ? Math.max(8, Math.min(64, i - a)) : 16.67;
845
890
  t.cache && (t.cache.autoScrollLastTs = i);
@@ -848,7 +893,7 @@ var ee = class {
848
893
  top: 0,
849
894
  right: innerWidth,
850
895
  bottom: innerHeight
851
- } : e.adapter.measureRect(n), c = t.x, l = t.y, u = T(c, s.left, s.right, this.edge), d = T(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;
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;
852
897
  if (!p && !m) return !1;
853
898
  let h = n.scrollTop, g = n.scrollLeft;
854
899
  r ? window.scrollBy(p, m) : n.scrollBy({
@@ -863,95 +908,84 @@ var ee = class {
863
908
  let t = e?.session;
864
909
  t?.cache && (t.cache.autoScrollLastTs = 0);
865
910
  };
866
- }, E = {
911
+ }, O = {
867
912
  top: n.indicatorTop,
868
913
  right: n.indicatorRight,
869
914
  bottom: n.indicatorBottom,
870
915
  left: n.indicatorLeft
871
- }, D = Object.values(E), O = new Set([
916
+ }, k = Object.values(O), ie = new Set([
872
917
  "top",
873
918
  "right",
874
919
  "bottom",
875
920
  "left"
876
921
  ]);
877
- function k(e, t, n, r) {
878
- f(t) && (e.frame.toggleClass ? e.frame.toggleClass(t, n, !!r) : t.classList.toggle(n, !!r));
922
+ function A(e, t, n, r) {
923
+ m(t) && (e.frame.toggleClass ? e.frame.toggleClass(t, n, !!r) : t.classList.toggle(n, !!r));
879
924
  }
880
- function A(e) {
881
- if (!f(e)) return;
882
- let n = t?.dropIndicatorAttr || "drop-indicator", r = `data-${n}`, i;
925
+ function ae(e) {
926
+ if (!m(e)) return;
927
+ let n = t.dropIndicatorAttr || "drop-indicator", r = `data-${n}`, i;
883
928
  if (e.hasAttribute?.(n)) i = e.getAttribute?.(n);
884
929
  else if (e.hasAttribute?.(r)) i = e.getAttribute?.(r);
885
930
  else return;
886
931
  let a = (i ?? "").trim();
887
932
  if (!a) return "all";
933
+ console.log("raw", i);
888
934
  let o = /* @__PURE__ */ new Set();
889
935
  for (let e of a.split(/[,\s]+/)) {
890
936
  let t = (e || "").trim().toLowerCase();
891
- O.has(t) && o.add(t);
937
+ ie.has(t) && o.add(t);
892
938
  }
893
939
  return o.size ? o : void 0;
894
940
  }
895
- function j(e) {
941
+ function oe(e) {
896
942
  let t = e.session, r = e.dnd?.root?.ownerDocument || document, i = t.indicatorEl;
897
- f(i) || (i = r.createElement("div"), i.classList.add(n.dropIndicator), t.indicatorEl = i);
943
+ m(i) || (i = r.createElement("div"), i.classList.add(n.dropIndicator), t.indicatorEl = i);
898
944
  let a = t.currentDrop || e.dnd?.root || r.body;
899
- return f(a) && i.parentNode !== a && a.appendChild(i), i;
945
+ return m(a) && i.parentNode !== a && a.appendChild(i), i;
900
946
  }
901
- function te(e) {
947
+ function se(e, t) {
902
948
  if (!e.currentDrop || !e.currentDropRect) return;
903
- let t = a(e);
904
- if (t.isOverLeft()) return "left";
905
- if (t.isOverRight()) return "right";
906
- if (t.isOverTop()) return "top";
907
- if (t.isOverBottom()) return "bottom";
949
+ let n = s(e, t);
950
+ if (n.isOverLeft()) return "left";
951
+ if (n.isOverRight()) return "right";
952
+ if (n.isOverTop()) return "top";
953
+ if (n.isOverBottom()) return "bottom";
908
954
  }
909
- function ne(e) {
955
+ function ce(e) {
910
956
  let t = e.session;
911
- if (!t.currentDrop) return !1;
912
- if (typeof t.currentAllowed == "boolean") return t.currentAllowed;
913
- let n = e.dnd?.canDrop;
914
- if (typeof n != "function") return !0;
915
- try {
916
- return !!n(e.payload("drag"));
917
- } catch {
918
- return !1;
919
- }
957
+ return t.currentDrop ? typeof t.currentAllowed == "boolean" ? t.currentAllowed : !0 : !1;
920
958
  }
921
- var M = class {
959
+ var le = class {
922
960
  order = 40;
923
961
  onCommit(e) {
924
962
  let t = e.session;
925
963
  if (!t?.active || !t?.started) return;
926
- let r = t.currentDrop, i = A(r);
964
+ let r = t.currentDrop, i = ae(r);
927
965
  if (!i) {
928
966
  let r = t.indicatorEl;
929
- if (f(r)) {
930
- k(e, r, n.dropIndicatorActive, !1);
931
- for (let t of D) k(e, r, t, !1);
967
+ if (m(r)) {
968
+ A(e, r, n.dropIndicatorActive, !1);
969
+ for (let t of k) A(e, r, t, !1);
932
970
  }
933
971
  t.indicatorRegion = void 0;
934
972
  return;
935
973
  }
936
- let a = j(e), o = ne(e), s = te(t), c = i === "all" || s && i.has(s) ? s : void 0, l = !!(r && t.currentDropRect && o && c);
937
- if (k(e, a, n.dropIndicatorActive, l), t.indicatorRegion = l ? c : void 0, l) for (let [t, n] of Object.entries(E)) k(e, a, n, t === c);
938
- else for (let t of D) k(e, a, t, !1);
974
+ 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);
939
977
  }
940
978
  onEnd(e) {
941
979
  let t = e.session;
942
- t && (t.lastIndicatorRegion = t.indicatorRegion ?? "inside", f(t.indicatorEl) && t.indicatorEl.remove(), t.indicatorEl = void 0, t.indicatorRegion = void 0);
980
+ t && (t.lastIndicatorRegion = t.indicatorRegion ?? "inside", m(t.indicatorEl) && t.indicatorEl.remove(), t.indicatorEl = void 0, t.indicatorRegion = void 0);
943
981
  }
944
982
  onDestroy(e, t) {
945
983
  this.onEnd({ session: t });
946
984
  }
947
- }, N = (e) => {
948
- if (!f(e)) return !1;
949
- let n = t.ignoreClickAttr, r = `data-${n}`;
950
- return !!(e.closest?.(`[${n}], [${r}]`) || e.hasAttribute?.(n) || e.hasAttribute?.(r));
951
- }, P = "draggable-dot-wrap", F = "draggable-dot", I = "draggable-rotate", L = t.dragScopeAttr, re = `[${L}], [data-${L}]`;
952
- function ie(e, n = {}) {
985
+ }, j = "draggable-dot-wrap", M = "draggable-dot", N = "draggable-rotate";
986
+ function P(e, n = {}) {
953
987
  let { resizable: r = !0, rotatable: i = !0 } = n, a = e.createElement("div");
954
- if (a.classList.add(P), a.dataset.resizable = String(r), a.dataset.rotatable = String(i), r) for (let [n, r] of [
988
+ if (a.classList.add(j), a.dataset.resizable = String(r), a.dataset.rotatable = String(i), r) for (let [n, r] of [
955
989
  ["nw", "tl"],
956
990
  ["n", "tm"],
957
991
  ["ne", "tr"],
@@ -962,63 +996,83 @@ function ie(e, n = {}) {
962
996
  ["w", "lm"]
963
997
  ]) {
964
998
  let i = e.createElement("div");
965
- i.classList.add(F), i.setAttribute(t.handleResizeAttr, ""), i.dataset.dir = n, i.dataset.pos = r, a.appendChild(i);
999
+ i.classList.add(M), i.setAttribute(t.handleResizeAttr, ""), i.dataset.dir = n, i.dataset.pos = r, a.appendChild(i);
966
1000
  }
967
1001
  if (i) {
968
1002
  let n = e.createElement("div");
969
- n.classList.add(I), n.setAttribute(t.handleRotateAttr, ""), n.dataset.dir = "rotate", a.appendChild(n);
1003
+ n.classList.add(N), n.setAttribute(t.handleRotateAttr, ""), n.dataset.dir = "rotate", a.appendChild(n);
970
1004
  }
971
1005
  return a;
972
1006
  }
973
- function R(e) {
974
- f(e) && e.querySelector?.(`.${P}`)?.remove();
1007
+ function F(e) {
1008
+ m(e) && e.querySelector?.(`.${j}`)?.remove();
975
1009
  }
976
- function z(e) {
977
- if (!f(e)) return;
978
- let n = !!e.closest?.(re), r = e.querySelector?.(".draggable-dot-wrap") || null, i = !!r, a = u(e, t.resizableAttr, !0), o = u(e, t.rotatableAttr, !0), s = a || o;
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;
979
1013
  if (!n) {
980
- i && R(e);
1014
+ i && F(e);
981
1015
  return;
982
1016
  }
983
1017
  if (!s) {
984
- i && R(e);
1018
+ i && F(e);
985
1019
  return;
986
1020
  }
987
1021
  if (r && (String(r.dataset?.resizable) !== String(a) || String(r.dataset?.rotatable) !== String(o)) && (r.remove(), r = null, i = !1), !i) {
988
1022
  let t = getComputedStyle(e).position;
989
- (t === "static" || !t) && (e.style.position = "relative"), e.appendChild(ie(e.ownerDocument || document, {
1023
+ (t === "static" || !t) && (e.style.position = "relative"), e.appendChild(P(e.ownerDocument || document, {
990
1024
  resizable: a,
991
1025
  rotatable: o
992
1026
  }));
993
1027
  }
994
1028
  }
995
- function B(e, t, r, i) {
1029
+ function L(e, t, r, i) {
996
1030
  let a = t.get(i);
997
- a && a !== r && (a.classList.remove(n.active), R(a)), r.classList.add(n.active), z(r), t.set(i, r);
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);
1034
+ }
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);
1040
+ e.set(r, t);
998
1041
  }
999
- function V(e) {
1000
- for (let t of e.values()) t?.classList?.remove?.(n.active), R(t);
1042
+ function z(e, t) {
1043
+ 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
+ }
1050
+ return;
1051
+ }
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);
1001
1054
  e.clear();
1002
1055
  }
1003
- var H = class {
1056
+ var B = class {
1004
1057
  order = -50;
1005
1058
  #e;
1006
1059
  onAttach(e) {
1007
1060
  this.#e = e;
1008
1061
  }
1009
1062
  onRootChange(e, t, n) {
1010
- if (!f(e)) return;
1063
+ if (!m(e)) return;
1011
1064
  let r = this.#e.monitor;
1012
1065
  e.addEventListener("pointerdown", (e) => {
1013
- if (e.button !== 0 || N(e.target)) return;
1066
+ if (e.button !== 0 || h(e.target)) return;
1014
1067
  let t = r.selectedByNs;
1015
1068
  if (!t) return;
1016
1069
  let n = r.adapter.closestDraggable(e.target);
1017
1070
  if (!n) {
1018
- V(t);
1071
+ z(t);
1019
1072
  return;
1020
1073
  }
1021
- B(null, t, n, r.adapter.getNamespace(n));
1074
+ 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);
1022
1076
  }, {
1023
1077
  capture: !0,
1024
1078
  signal: n
@@ -1026,26 +1080,110 @@ var H = class {
1026
1080
  }
1027
1081
  onDown(e, t) {
1028
1082
  let r = e?.session;
1029
- if (!r?.sourceEl || t?.button !== 0 || N(t.target)) return;
1083
+ if (!r?.sourceEl || t?.button !== 0 || h(t.target)) return;
1030
1084
  let i = e.store?.selectedByNs || r.selectedByNs;
1031
1085
  if (!i) return;
1032
1086
  let a = r.namespace || e.adapter.getNamespace(r.sourceEl), o = i.get(a);
1033
- o && o !== r.sourceEl && (e.frame.toggleClass(o, n.active, !1), R(o)), e.frame.toggleClass(r.sourceEl, n.active, !0), z(r.sourceEl), i.set(a, r.sourceEl);
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));
1034
1090
  }
1035
1091
  onDestroy(e, t) {
1036
1092
  let n = t?.selectedByNs;
1037
- n && V(n);
1093
+ n && z(n);
1038
1094
  }
1039
1095
  };
1040
1096
  //#endregion
1041
- //#region src/services/TransformControllerService.js
1042
- function U(e = 0) {
1097
+ //#region src/services/MarqueeSelectionService.js
1098
+ function V(e, t, n, r) {
1099
+ return {
1100
+ left: Math.min(e, n),
1101
+ right: Math.max(e, n),
1102
+ top: Math.min(t, r),
1103
+ bottom: Math.max(t, r),
1104
+ width: Math.abs(n - e),
1105
+ height: Math.abs(r - t)
1106
+ };
1107
+ }
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;
1111
+ }
1112
+ var U = class {
1113
+ order = -40;
1114
+ #e;
1115
+ #t;
1116
+ onAttach(e) {
1117
+ this.#e = e;
1118
+ }
1119
+ 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(_);
1123
+ t && (this.#e.monitor.adapter.closestDraggable(e.target) || this.#n(t, e));
1124
+ }, {
1125
+ capture: !0,
1126
+ signal: n
1127
+ });
1128
+ }
1129
+ #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) {
1142
+ try {
1143
+ l.remove();
1144
+ } catch {}
1145
+ f.abort();
1146
+ }
1147
+ }, h = () => {
1148
+ if (!u) {
1149
+ let e = this.#e.monitor?.selectedByNs;
1150
+ e && z(e, s);
1151
+ }
1152
+ m();
1153
+ };
1154
+ for (let e of p) {
1155
+ if (e.aborted) {
1156
+ m();
1157
+ return;
1158
+ }
1159
+ e.addEventListener("abort", m, { once: !0 });
1160
+ }
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);
1163
+ }
1164
+ #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);
1174
+ }
1175
+ return o;
1176
+ }
1177
+ };
1178
+ //#endregion
1179
+ //#region src/services/transform/utils/geometry.js
1180
+ function W(e = 0) {
1043
1181
  return `${Number.parseInt(String(e), 10) || 0}px`;
1044
1182
  }
1045
- function W(e) {
1183
+ function G(e) {
1046
1184
  return e * Math.PI / 180;
1047
1185
  }
1048
- function G(e, t) {
1186
+ function ue(e, t) {
1049
1187
  return Math.sqrt(e * e + t * t);
1050
1188
  }
1051
1189
  function K(e, t) {
@@ -1063,7 +1201,51 @@ function q(e, t = 1, n) {
1063
1201
  width: r.width / i
1064
1202
  };
1065
1203
  }
1066
- var J = {
1204
+ function J(e, t, n, r) {
1205
+ let i = n - e, a = r - t, o = Math.atan2(a, i) * 180 / Math.PI + 90;
1206
+ return o = (o % 360 + 360) % 360, o;
1207
+ }
1208
+ function de(e, t, n) {
1209
+ let { width: r, height: i } = e;
1210
+ return {
1211
+ height: Math.abs(i),
1212
+ width: Math.abs(r),
1213
+ x: t - Math.abs(r) / 2,
1214
+ y: n - Math.abs(i) / 2
1215
+ };
1216
+ }
1217
+ function fe({ centerX: e, centerY: t, width: n, height: r, angle: i }) {
1218
+ return {
1219
+ angle: i,
1220
+ height: r,
1221
+ width: n,
1222
+ x: e - n / 2,
1223
+ y: t - r / 2
1224
+ };
1225
+ }
1226
+ function Y(e) {
1227
+ let t = getComputedStyle(e), n = {};
1228
+ try {
1229
+ n = new DOMMatrixReadOnly(t.transform);
1230
+ } catch {
1231
+ n = new DOMMatrixReadOnly();
1232
+ }
1233
+ let r = n.m41, i = n.m42, a = Number.parseFloat(t.width), o = Number.parseFloat(t.height);
1234
+ if (!Number.isFinite(a) || !Number.isFinite(o)) {
1235
+ let t = e.getBoundingClientRect();
1236
+ a = t.width, o = t.height;
1237
+ }
1238
+ return {
1239
+ angle: -Math.atan2(n.m21, n.m11) * (180 / Math.PI),
1240
+ height: o,
1241
+ width: a,
1242
+ x: r,
1243
+ y: i
1244
+ };
1245
+ }
1246
+ //#endregion
1247
+ //#region src/services/transform/utils/cursor.js
1248
+ var pe = {
1067
1249
  e: "right",
1068
1250
  n: "top",
1069
1251
  ne: "top-right",
@@ -1072,7 +1254,7 @@ var J = {
1072
1254
  se: "bottom-right",
1073
1255
  sw: "bottom-left",
1074
1256
  w: "left"
1075
- }, ae = [
1257
+ }, me = [
1076
1258
  "n",
1077
1259
  "ne",
1078
1260
  "e",
@@ -1081,7 +1263,7 @@ var J = {
1081
1263
  "sw",
1082
1264
  "w",
1083
1265
  "nw"
1084
- ], oe = {
1266
+ ], he = {
1085
1267
  0: 0,
1086
1268
  1: 1,
1087
1269
  2: 1,
@@ -1094,7 +1276,7 @@ var J = {
1094
1276
  9: 6,
1095
1277
  10: 7,
1096
1278
  11: 7
1097
- }, se = {
1279
+ }, ge = {
1098
1280
  e: 2,
1099
1281
  n: 0,
1100
1282
  ne: 1,
@@ -1104,67 +1286,13 @@ var J = {
1104
1286
  sw: 5,
1105
1287
  w: 6
1106
1288
  };
1107
- function ce(e, t) {
1108
- let n = oe[Math.floor((e % 360 + 360) % 360 / 30)];
1109
- return ae[(se[t] + n) % 8];
1110
- }
1111
- function le(e) {
1112
- let t = e?.querySelector?.(":scope > .draggable-dot-wrap");
1113
- return t ? [...t.querySelectorAll?.(".draggable-dot") || []] : [];
1114
- }
1115
- function ue(e) {
1116
- let t = e?.dataset?.dir;
1117
- return t && J[t] || "right";
1118
- }
1119
- function de(e) {
1120
- return !!e?.hasAttribute?.(t.handleRotateAttr);
1121
- }
1122
- function fe(e) {
1123
- return !!e?.hasAttribute?.(t.handleResizeAttr);
1124
- }
1125
- function Y(e) {
1126
- let t = getComputedStyle(e), n = {};
1127
- try {
1128
- n = new DOMMatrixReadOnly(t.transform);
1129
- } catch {
1130
- n = new DOMMatrixReadOnly();
1131
- }
1132
- let r = n.m41, i = n.m42, a = Number.parseFloat(t.width), o = Number.parseFloat(t.height);
1133
- if (!Number.isFinite(a) || !Number.isFinite(o)) {
1134
- let t = e.getBoundingClientRect();
1135
- a = t.width, o = t.height;
1136
- }
1137
- return {
1138
- angle: -Math.atan2(n.m21, n.m11) * (180 / Math.PI),
1139
- height: o,
1140
- width: a,
1141
- x: r,
1142
- y: i
1143
- };
1289
+ function _e(e, t) {
1290
+ let n = he[Math.floor((e % 360 + 360) % 360 / 30)];
1291
+ return me[(ge[t] + n) % 8];
1144
1292
  }
1145
- function X(e, t, n, r) {
1146
- let i = n - e, a = r - t, o = Math.atan2(a, i) * 180 / Math.PI + 90;
1147
- return o = (o % 360 + 360) % 360, o;
1148
- }
1149
- function pe(e, t, n) {
1150
- let { width: r, height: i } = e;
1151
- return {
1152
- height: Math.abs(i),
1153
- width: Math.abs(r),
1154
- x: t - Math.abs(r) / 2,
1155
- y: n - Math.abs(i) / 2
1156
- };
1157
- }
1158
- function me({ centerX: e, centerY: t, width: n, height: r, angle: i }) {
1159
- return {
1160
- angle: i,
1161
- height: r,
1162
- width: n,
1163
- x: e - n / 2,
1164
- y: t - r / 2
1165
- };
1166
- }
1167
- function he(e, t) {
1293
+ //#endregion
1294
+ //#region src/services/transform/utils/markline.js
1295
+ function ve(e, t) {
1168
1296
  let n = {
1169
1297
  x: [],
1170
1298
  y: []
@@ -1204,61 +1332,63 @@ function he(e, t) {
1204
1332
  });
1205
1333
  }), n;
1206
1334
  }
1207
- function ge(e) {
1335
+ function ye(e) {
1208
1336
  let t = e.querySelector(".draggable-markline-x"), n = e.querySelector(".draggable-markline-y");
1209
1337
  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)), {
1210
1338
  x: t,
1211
1339
  y: n
1212
1340
  };
1213
1341
  }
1214
- function Z(e) {
1342
+ function X(e) {
1215
1343
  e && (e.style.display = "none");
1216
1344
  }
1217
- function Q(e, t, n) {
1345
+ //#endregion
1346
+ //#region src/services/transform/utils/resize.js
1347
+ function Z(e, t, n) {
1218
1348
  let r = e + t;
1219
1349
  return r > n ? e = r : (t = n - e, e = n), {
1220
1350
  deltaW: t,
1221
1351
  width: e
1222
1352
  };
1223
1353
  }
1224
- function $(e, t, n) {
1354
+ function Q(e, t, n) {
1225
1355
  let r = e + t;
1226
1356
  return r > n ? e = r : (t = n - e, e = n), {
1227
1357
  deltaH: t,
1228
1358
  height: e
1229
1359
  };
1230
1360
  }
1231
- function _e(e, t, n, r, i, a, o) {
1361
+ function be(e, t, n, r, i, a, o) {
1232
1362
  let { width: s, height: c, centerX: l, centerY: u, rotateAngle: d } = t, f = s < 0 ? -1 : 1, p = c < 0 ? -1 : 1;
1233
1363
  switch (s = Math.abs(s), c = Math.abs(c), [
1234
1364
  "top-left",
1235
1365
  "top-right",
1236
1366
  "bottom-left",
1237
1367
  "bottom-right"
1238
- ].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) {
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) {
1239
1369
  case "right":
1240
- ({width: s, deltaW: n} = Q(s, n, a)), i ? (r = n / i, c = s / i, l += n / 2 * Math.cos(W(d)) - r / 2 * Math.sin(W(d)), u += n / 2 * Math.sin(W(d)) + r / 2 * Math.cos(W(d))) : (l += n / 2 * Math.cos(W(d)), u += n / 2 * Math.sin(W(d)));
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)));
1241
1371
  break;
1242
1372
  case "top-right":
1243
- l += n / 2 * Math.cos(W(d)) + r / 2 * Math.sin(W(d)), u += n / 2 * Math.sin(W(d)) - r / 2 * Math.cos(W(d));
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));
1244
1374
  break;
1245
1375
  case "bottom-right":
1246
- l += n / 2 * Math.cos(W(d)) - r / 2 * Math.sin(W(d)), u += n / 2 * Math.sin(W(d)) + r / 2 * Math.cos(W(d));
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));
1247
1377
  break;
1248
1378
  case "bottom":
1249
- ({height: c, deltaH: r} = $(c, r, o)), i ? (n = r * i, s = c * i, l += n / 2 * Math.cos(W(d)) - r / 2 * Math.sin(W(d)), u += n / 2 * Math.sin(W(d)) + r / 2 * Math.cos(W(d))) : (l -= r / 2 * Math.sin(W(d)), u += r / 2 * Math.cos(W(d)));
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)));
1250
1380
  break;
1251
1381
  case "bottom-left":
1252
- l -= n / 2 * Math.cos(W(d)) + r / 2 * Math.sin(W(d)), u -= n / 2 * Math.sin(W(d)) - r / 2 * Math.cos(W(d));
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));
1253
1383
  break;
1254
1384
  case "left":
1255
- n = -n, {width: s, deltaW: n} = Q(s, n, a), i ? (c = s / i, r = n / i, l -= n / 2 * Math.cos(W(d)) + r / 2 * Math.sin(W(d)), u -= n / 2 * Math.sin(W(d)) - r / 2 * Math.cos(W(d))) : (l -= n / 2 * Math.cos(W(d)), u -= n / 2 * Math.sin(W(d)));
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)));
1256
1386
  break;
1257
1387
  case "top-left":
1258
- l -= n / 2 * Math.cos(W(d)) - r / 2 * Math.sin(W(d)), u -= n / 2 * Math.sin(W(d)) + r / 2 * Math.cos(W(d));
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));
1259
1389
  break;
1260
1390
  case "top":
1261
- r = -r, {height: c, deltaH: r} = $(c, r, o), i ? (s = c * i, n = r * i, l += n / 2 * Math.cos(W(d)) + r / 2 * Math.sin(W(d)), u += n / 2 * Math.sin(W(d)) - r / 2 * Math.cos(W(d))) : (l += r / 2 * Math.sin(W(d)), u -= r / 2 * Math.cos(W(d)));
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)));
1262
1392
  break;
1263
1393
  default: break;
1264
1394
  }
@@ -1273,7 +1403,25 @@ function _e(e, t, n, r, i, a, o) {
1273
1403
  }
1274
1404
  };
1275
1405
  }
1276
- var ve = class {
1406
+ //#endregion
1407
+ //#region src/services/transform/utils/handles.js
1408
+ function xe(e) {
1409
+ let t = e?.querySelector?.(":scope > .draggable-dot-wrap");
1410
+ return t ? [...t.querySelectorAll?.(".draggable-dot") || []] : [];
1411
+ }
1412
+ function Se(e) {
1413
+ let t = e?.dataset?.dir;
1414
+ return t && pe[t] || "right";
1415
+ }
1416
+ function Ce(e) {
1417
+ return !!e?.hasAttribute?.(t.handleRotateAttr);
1418
+ }
1419
+ function $(e) {
1420
+ return !!e?.hasAttribute?.(t.handleResizeAttr);
1421
+ }
1422
+ //#endregion
1423
+ //#region src/services/TransformControllerService.js
1424
+ var we = class {
1277
1425
  order = 25;
1278
1426
  #e;
1279
1427
  constructor(e = {}) {
@@ -1315,18 +1463,25 @@ var ve = class {
1315
1463
  }
1316
1464
  onDown(e) {
1317
1465
  let t = e?.session;
1318
- if (!t?.isDragScope || !f(t.sourceEl) || !this.#e.resizable) return;
1466
+ if (!t?.isDragScope || !m(t.sourceEl) || !this.#e.resizable) return;
1319
1467
  let { angle: n } = Y(t.sourceEl);
1320
1468
  n && this.#l(t.sourceEl, n);
1321
1469
  }
1322
1470
  onStart(e) {
1323
1471
  let n = e.session;
1324
- if (!n?.active || !n?.started || !n.isDragScope || !f(n.sourceEl) || typeof this.#e.canTransform == "function" && !this.#e.canTransform(n.sourceEl)) return;
1325
- let r = "move", i = "", a = this.#e.rotatable && u(n.sourceEl, t.rotatableAttr, !0), o = this.#e.resizable && u(n.sourceEl, t.resizableAttr, !0);
1326
- de(n.handleEl) && a ? r = "rotate" : fe(n.handleEl) && o && (r = "resize", i = ue(n.handleEl)), this.#e.disableMirrorInScope && this.#p(n), this.#e.disableDropIndicatorInScope && this.#m(n), n.cache.__transform = {
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) {
1475
+ if (i) return;
1476
+ a = "rotate";
1477
+ } else if ($(n.handleEl) && c) {
1478
+ if (i) return;
1479
+ a = "resize", o = Se(n.handleEl);
1480
+ }
1481
+ this.#e.disableMirrorInScope && this.#m(n), this.#e.disableDropIndicatorInScope && this.#h(n), n.cache.__transform = {
1327
1482
  phase: 0,
1328
- type: r,
1329
- side: i,
1483
+ type: a,
1484
+ side: o,
1330
1485
  scaleRatio: void 0,
1331
1486
  container: void 0,
1332
1487
  containerRect: void 0,
@@ -1353,18 +1508,23 @@ var ve = class {
1353
1508
  lastAppliedY: void 0,
1354
1509
  lastAppliedW: void 0,
1355
1510
  lastAppliedH: void 0,
1356
- lastAppliedAngle: void 0
1511
+ lastAppliedAngle: void 0,
1512
+ multiSelection: {
1513
+ enabled: i,
1514
+ elements: [],
1515
+ initialTransforms: []
1516
+ }
1357
1517
  };
1358
1518
  }
1359
1519
  onMeasure(e) {
1360
1520
  let n = e.session, r = n?.cache?.__transform;
1361
1521
  if (!n?.active || !n?.started || !n.isDragScope || !r || r.phase !== 0) return;
1362
- if (!f(n.sourceEl)) {
1522
+ if (!m(n.sourceEl)) {
1363
1523
  n.cache.__transform = void 0;
1364
1524
  return;
1365
1525
  }
1366
1526
  let i = e.adapter.closestDragScope(n.sourceEl);
1367
- if (!f(i)) {
1527
+ if (!m(i)) {
1368
1528
  n.cache.__transform = void 0;
1369
1529
  return;
1370
1530
  }
@@ -1382,7 +1542,7 @@ var ve = class {
1382
1542
  h: Math.max(0, i.clientHeight)
1383
1543
  }), r.type === "rotate") {
1384
1544
  let e = (n.x - s.left) / a, t = (n.y - s.top) / a;
1385
- r.rotateOffset = X(r.center.x, r.center.y, e, t) - r.data.angle;
1545
+ r.rotateOffset = J(r.center.x, r.center.y, e, t) - r.data.angle;
1386
1546
  }
1387
1547
  if (this.#e.snap || this.#e.markline) {
1388
1548
  let o = q(n.sourceEl, a, e.adapter);
@@ -1391,22 +1551,39 @@ var ve = class {
1391
1551
  y: o.top + o.height / 2 - r.center.y
1392
1552
  };
1393
1553
  let s = [...i.querySelectorAll?.(`[${t.dragAttr}]`) || []], c = [];
1394
- for (let t of s) t !== n.sourceEl && f(t) && c.push(q(t, a, e.adapter));
1395
- if (r.lines = he(c, o), this.#e.markline) {
1396
- let e = ge(i);
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);
1397
1557
  r.guideX = e.x, r.guideY = e.y;
1398
1558
  }
1399
1559
  }
1560
+ if (r.multiSelection.enabled) {
1561
+ 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)));
1563
+ }
1400
1564
  r.phase = 1;
1401
1565
  }
1402
1566
  onCompute(e) {
1403
1567
  let t = e.session, n = t?.cache?.__transform;
1404
- !t?.active || !t?.started || !t.isDragScope || !n || n.phase !== 1 || f(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));
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));
1405
1569
  }
1406
1570
  onCommit(e) {
1407
1571
  let t = e.session, n = t?.cache?.__transform;
1408
- if (!t?.active || !t?.started || !t.isDragScope || !n || n.phase !== 1 || !n.didCompute || !f(t.sourceEl)) return;
1409
- this.#u(e, t.sourceEl, n), n.type === "rotate" && this.#e.resizable && n.lastCursorAngle !== n.data?.angle && (n.lastCursorAngle = n.data?.angle, e.frame?.run?.(() => {
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") {
1574
+ let t = n.data.x - n.start.x, r = n.data.y - n.start.y;
1575
+ for (let i = 0; i < n.multiSelection.elements.length; i++) {
1576
+ let a = n.multiSelection.elements[i], o = n.multiSelection.initialTransforms[i], s = {
1577
+ x: o.x + t,
1578
+ y: o.y + r,
1579
+ width: o.width,
1580
+ height: o.height,
1581
+ angle: o.angle
1582
+ };
1583
+ this.#u(e, a, s);
1584
+ }
1585
+ }
1586
+ n.type === "rotate" && this.#e.resizable && n.lastCursorAngle !== n.data?.angle && (n.lastCursorAngle = n.data?.angle, e.frame?.run?.(() => {
1410
1587
  this.#l(t.sourceEl, n.lastCursorAngle || 0);
1411
1588
  })), this.#e.markline && this.#c(e, n);
1412
1589
  let r = e.dnd;
@@ -1424,16 +1601,16 @@ var ve = class {
1424
1601
  }
1425
1602
  onEnd(e, t) {
1426
1603
  let n = e.session, r = n?.cache?.__transform;
1427
- r && (Z(r.guideX), Z(r.guideY), t?.ended && f(n?.sourceEl) && r?.data && e.dnd?.emit?.("draggable:drop", {
1604
+ r && (X(r.guideX), X(r.guideY), t?.ended && m(n?.sourceEl) && r?.data && e.dnd?.emit?.("draggable:drop", {
1428
1605
  type: r.type,
1429
1606
  el: n.sourceEl,
1430
1607
  data: n.data,
1431
1608
  ...r.data
1432
- }), t?.ended && r.type === "rotate" && this.#e.resizable && f(n?.sourceEl) && this.#l(n.sourceEl, r.data?.angle || 0), n.cache.__transform = void 0);
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);
1433
1610
  }
1434
1611
  onDestroy(e, t) {
1435
1612
  let n = t?.cache?.__transform;
1436
- n && (Z(n.guideX), Z(n.guideY), t.cache.__transform = void 0);
1613
+ n && (X(n.guideX), X(n.guideY), t.cache.__transform = void 0);
1437
1614
  }
1438
1615
  #r(e, t) {
1439
1616
  let n = this.#n(t), r = t.start.x + e.dx / n, i = t.start.y + e.dy / n;
@@ -1441,12 +1618,12 @@ var ve = class {
1441
1618
  ...t.data,
1442
1619
  x: r,
1443
1620
  y: i
1444
- }, this.#s(t), this.#d(t.data, t.boundary);
1621
+ }, this.#s(t), this.#f(t.data, t.boundary);
1445
1622
  }
1446
1623
  #i(e, t) {
1447
1624
  let n = this.#n(t), r = t.containerRect;
1448
1625
  if (!r) return;
1449
- let i = (e.x - r.left) / n, a = (e.y - r.top) / n, o = X(t.center.x, t.center.y, i, a) - (t.rotateOffset ?? 0);
1626
+ let i = (e.x - r.left) / n, a = (e.y - r.top) / n, o = J(t.center.x, t.center.y, i, a) - (t.rotateOffset ?? 0);
1450
1627
  if (o = (o % 360 + 360) % 360, this.#e.rotateSnap) {
1451
1628
  let e = Number(this.#e.rotateStep) || 15;
1452
1629
  o = Math.round(o / e) * e;
@@ -1457,13 +1634,13 @@ var ve = class {
1457
1634
  };
1458
1635
  }
1459
1636
  #a(e, t) {
1460
- let n = this.#n(t), r = this.#e.aspectRatio, i = e.dx / n, a = e.dy / n, o = Math.atan2(a, i), s = G(i, a), c = o - W(t.start.angle), l = s * Math.cos(c), u = s * Math.sin(c), d = {
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 = {
1461
1638
  centerX: t.start.x + t.start.width / 2,
1462
1639
  centerY: t.start.y + t.start.height / 2,
1463
1640
  height: t.start.height,
1464
1641
  rotateAngle: t.start.angle,
1465
1642
  width: t.start.width
1466
- }, { position: { centerX: f, centerY: p }, size: { width: m, height: h } } = _e(t.side, d, l, u, r, this.#e.minWidth, this.#e.minHeight), g = me({
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({
1467
1644
  angle: t.data.angle,
1468
1645
  centerX: f,
1469
1646
  centerY: p,
@@ -1471,19 +1648,19 @@ var ve = class {
1471
1648
  width: m
1472
1649
  }), _ = {
1473
1650
  ...t.data,
1474
- ...pe(g, f, p)
1651
+ ...de(g, f, p)
1475
1652
  };
1476
1653
  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) {
1477
1654
  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;
1478
1655
  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;
1479
1656
  }
1480
1657
  let v = _;
1481
- this.#f(v, t.boundary) ? (t.data = v, t.lastValidData = { ...v }) : t.data = t.lastValidData ? { ...t.lastValidData } : { ...t.start }, this.#s(t);
1658
+ this.#p(v, t.boundary) ? (t.data = v, t.lastValidData = { ...v }) : t.data = t.lastValidData ? { ...t.lastValidData } : { ...t.start }, this.#s(t);
1482
1659
  }
1483
1660
  #o(e) {
1484
1661
  let t = e?.data, n = e?.viewportCenterOffset;
1485
1662
  if (!t || !n) return e.startRect;
1486
- let r = W(t.angle || 0), i = Math.cos(r), a = Math.sin(r), o = Math.abs(t.width * i) + Math.abs(t.height * a), s = Math.abs(t.width * a) + Math.abs(t.height * i), c = t.x + t.width / 2 + n.x, l = t.y + t.height / 2 + n.y, u = c - o / 2, d = l - s / 2;
1663
+ let r = G(t.angle || 0), i = Math.cos(r), a = Math.sin(r), o = Math.abs(t.width * i) + Math.abs(t.height * a), s = Math.abs(t.width * a) + Math.abs(t.height * i), c = t.x + t.width / 2 + n.x, l = t.y + t.height / 2 + n.y, u = c - o / 2, d = l - s / 2;
1487
1664
  return {
1488
1665
  bottom: d + s,
1489
1666
  height: s,
@@ -1522,41 +1699,44 @@ var ve = class {
1522
1699
  }
1523
1700
  #c(e, t) {
1524
1701
  let { guideX: n, guideY: r } = t, i = t.mark || {};
1525
- n && (i.left === void 0 ? e.frame?.setStyle?.(n, "display", "none") : (e.frame?.setStyle?.(n, "display", "block"), e.frame?.setStyle?.(n, "transform", `translate(${U(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, ${U(i.top)})`)));
1702
+ 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)})`)));
1526
1703
  }
1527
1704
  #l(e, t) {
1528
- let n = le(e);
1705
+ let n = xe(e);
1529
1706
  for (let e of n) {
1530
1707
  let n = e?.dataset?.dir;
1531
- n && (e.style.cursor = `${ce(t, n)}-resize`);
1708
+ n && (e.style.cursor = `${_e(t, n)}-resize`);
1532
1709
  }
1533
1710
  }
1534
1711
  #u(e, t, n) {
1712
+ e.frame?.setStyle?.(t, "transform", `translate(${W(n.x)}, ${W(n.y)}) rotate(${n.angle}deg)`);
1713
+ }
1714
+ #d(e, t, n) {
1535
1715
  let r = n.data;
1536
- n.lastAppliedW !== r.width && (e.frame?.setStyle?.(t, "width", U(r.width)), n.lastAppliedW = r.width), n.lastAppliedH !== r.height && (e.frame?.setStyle?.(t, "height", U(r.height)), n.lastAppliedH = r.height), (n.lastAppliedX !== r.x || n.lastAppliedY !== r.y || n.lastAppliedAngle !== r.angle) && (e.frame?.setStyle?.(t, "transform", `translate(${U(r.x)}, ${U(r.y)}) rotate(${r.angle}deg)`), n.lastAppliedX = r.x, n.lastAppliedY = r.y, n.lastAppliedAngle = r.angle);
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);
1537
1717
  }
1538
- #d(e, t) {
1718
+ #f(e, t) {
1539
1719
  if (!t) return;
1540
- let n = W(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;
1720
+ 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;
1541
1721
  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)));
1542
1722
  }
1543
- #f(e, t) {
1723
+ #p(e, t) {
1544
1724
  if (!t) return !0;
1545
- let n = W(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;
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;
1546
1726
  return !(l < -.5 || d < -.5 || u > t.w + .5 || f > t.h + .5);
1547
1727
  }
1548
- #p(e) {
1728
+ #m(e) {
1549
1729
  if (e?.mirrorEl) {
1550
1730
  try {
1551
1731
  e.mirrorEl.parentNode?.removeChild?.(e.mirrorEl);
1552
1732
  } catch {}
1553
1733
  e.mirrorEl = void 0;
1554
1734
  }
1555
- if (f(e?.sourceEl)) try {
1735
+ if (m(e?.sourceEl)) try {
1556
1736
  e.sourceEl.style.visibility = "";
1557
1737
  } catch {}
1558
1738
  }
1559
- #m(e) {
1739
+ #h(e) {
1560
1740
  if (e?.indicatorEl) {
1561
1741
  try {
1562
1742
  e.indicatorEl.parentNode?.removeChild?.(e.indicatorEl);
@@ -1565,9 +1745,9 @@ var ve = class {
1565
1745
  }
1566
1746
  e.currentDrop = void 0, e.currentDropRect = void 0, e.currentAllowed = !1;
1567
1747
  }
1568
- }, ye = {
1748
+ }, Te = {
1569
1749
  name: "@ptahjs/dnd",
1570
- version: "0.0.2"
1750
+ version: "0.1.1"
1571
1751
  };
1572
1752
  //#endregion
1573
- export { P as ACTIVE_WRAP_CLASS, H as ActiveSelectionService, ee as AutoScrollService, F as DOT_CLASS, y as Dnd, ye as DndVersion, M as DropIndicatorService, b as DropService, x as MirrorService, I as ROTATE_CLASS, ve as TransformControllerService };
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 };