@vue-dnd-kit/core 1.7.0 → 2.0.0-alpha10

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 (59) hide show
  1. package/README.md +74 -305
  2. package/dist/external/components/DefaultOverlay.vue.d.ts +2 -0
  3. package/dist/external/components/DnDProvider.vue.d.ts +25 -0
  4. package/dist/external/composables/makeAutoScroll.d.ts +13 -0
  5. package/dist/external/composables/makeConstraintArea.d.ts +7 -0
  6. package/dist/external/composables/makeDraggable.d.ts +19 -0
  7. package/dist/external/composables/makeDroppable.d.ts +13 -0
  8. package/dist/external/composables/makeSelectionArea.d.ts +14 -0
  9. package/dist/external/composables/makeSnappedOverlayPosition.d.ts +20 -0
  10. package/dist/external/composables/useDnDProvider.d.ts +2 -0
  11. package/dist/external/env.d.ts +7 -0
  12. package/dist/external/index.d.ts +11 -0
  13. package/dist/external/types/entities.d.ts +157 -0
  14. package/dist/external/types/index.d.ts +4 -0
  15. package/dist/external/types/placement.d.ts +22 -0
  16. package/dist/external/types/pointer.d.ts +10 -0
  17. package/dist/external/types/provider.d.ts +84 -0
  18. package/dist/index.d.ts +2 -2141
  19. package/dist/internal/composables/useDnDProviderEvents.d.ts +2 -0
  20. package/dist/internal/composables/useDnDProviderInternal.d.ts +2 -0
  21. package/dist/internal/composables/useDnDProviderState.d.ts +4 -0
  22. package/dist/internal/composables/useSizeObserver.d.ts +33 -0
  23. package/dist/internal/composables/useViewportAutoScroll.d.ts +9 -0
  24. package/dist/internal/logic/hover.d.ts +7 -0
  25. package/dist/internal/logic/keyboard.d.ts +6 -0
  26. package/dist/internal/logic/payload.d.ts +12 -0
  27. package/dist/internal/logic/pointer.d.ts +9 -0
  28. package/dist/internal/logic/scroll.d.ts +2 -0
  29. package/dist/internal/sensors/default-collision.d.ts +7 -0
  30. package/dist/internal/sensors/index.d.ts +3 -0
  31. package/dist/internal/sensors/sensor.d.ts +68 -0
  32. package/dist/internal/sensors/steps.d.ts +30 -0
  33. package/dist/internal/types/auto-scroll.d.ts +19 -0
  34. package/dist/internal/types/observer.d.ts +11 -0
  35. package/dist/internal/types/provider.d.ts +30 -0
  36. package/dist/internal/utils/auto-scroll.d.ts +13 -0
  37. package/dist/internal/utils/constraints.d.ts +40 -0
  38. package/dist/internal/utils/disabled.d.ts +9 -0
  39. package/dist/internal/utils/dom.d.ts +44 -0
  40. package/dist/internal/utils/drag-activation.d.ts +29 -0
  41. package/dist/internal/utils/events.d.ts +22 -0
  42. package/dist/internal/utils/geometry.d.ts +23 -0
  43. package/dist/internal/utils/groups.d.ts +19 -0
  44. package/dist/internal/utils/hover.d.ts +29 -0
  45. package/dist/internal/utils/keyboard.d.ts +5 -0
  46. package/dist/internal/utils/namespaces.d.ts +18 -0
  47. package/dist/internal/utils/observer.d.ts +27 -0
  48. package/dist/internal/utils/placement.d.ts +22 -0
  49. package/dist/internal/utils/pointer.d.ts +33 -0
  50. package/dist/internal/utils/provider.d.ts +12 -0
  51. package/dist/internal/utils/selection.d.ts +27 -0
  52. package/dist/internal/utils/session.d.ts +5 -0
  53. package/dist/vite.svg +1 -0
  54. package/dist/vue-dnd-kit-core.cjs.js +2 -2
  55. package/dist/vue-dnd-kit-core.es.js +1237 -850
  56. package/package.json +75 -73
  57. package/LICENSE +0 -21
  58. package/dist/vue-dnd-kit-core.cjs.js.map +0 -1
  59. package/dist/vue-dnd-kit-core.es.js.map +0 -1
@@ -1,900 +1,1287 @@
1
- var he = Object.defineProperty;
2
- var pe = (n, e, t) => e in n ? he(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var V = (n, e, t) => pe(n, typeof e != "symbol" ? e + "" : e, t);
4
- import { shallowRef as C, ref as F, computed as O, onMounted as te, onUnmounted as ye, defineComponent as fe, createElementBlock as j, createCommentVNode as Ee, unref as P, openBlock as X, normalizeStyle as re, Fragment as ae, renderList as we, createBlock as J, resolveDynamicComponent as ee, Transition as Pe, withCtx as xe, normalizeProps as le, guardReactiveProps as Me, mergeProps as Ae, createVNode as Le, render as se, useId as be, onBeforeUnmount as ge } from "vue";
5
- import { createGlobalState as me, useMagicKeys as Ie, useThrottleFn as ze } from "@vueuse/core";
6
- const M = class M {
1
+ (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".dnd-kit-default-overlay{transform:translate3d(var(--position-x),var(--position-y),0)}.dnd-kit-overlay-container{position:fixed;top:0;left:0;pointer-events:none;cursor:grabbing}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
2
+ import { ref as U, watch as J, shallowRef as V, reactive as Z, computed as m, onScopeDispose as Ie, onMounted as N, onBeforeUnmount as Y, inject as xe, defineComponent as Ce, unref as C, openBlock as x, createElementBlock as $, normalizeStyle as ye, Fragment as ie, renderList as Ke, createBlock as q, resolveDynamicComponent as re, createCommentVNode as He, useTemplateRef as Ne, provide as Ye, renderSlot as me, Teleport as Xe, createElementVNode as Ze } from "vue";
3
+ const L = {
4
+ SELECT_AREA: "data-dnd-kit-select-area",
5
+ DRAGGABLE: "data-dnd-kit-draggable",
6
+ DROPPABLE: "data-dnd-kit-droppable",
7
+ CONSTRAINT_AREA: "data-dnd-kit-constraint-area"
8
+ }, H = {
9
+ SELECT_AREA: `[${L.SELECT_AREA}]`,
10
+ DRAGGABLE: `[${L.DRAGGABLE}]`,
11
+ CONSTRAINT_AREA: `[${L.CONSTRAINT_AREA}]`
12
+ }, fe = "VueDnDKitProvider", be = (e, t, n, o) => {
13
+ const s = /* @__PURE__ */ new Set();
14
+ return t.forEach((r) => {
15
+ const i = e.get(r), a = o ? o(r) : i?.disabled;
16
+ if (!i || a) return;
17
+ const l = i.modifier?.keys, u = i.modifier?.method;
18
+ if (!l || !u || l.length === 0) {
19
+ s.add(r);
20
+ return;
21
+ }
22
+ l[u]((c) => n.value.has(c)) && s.add(r);
23
+ }), s;
7
24
  };
8
- V(M, "remove", (e, t) => {
9
- if (!e || t === void 0) return;
10
- const [a] = e.splice(t, 1);
11
- return a;
12
- }), V(M, "insert", (e, t, a) => {
13
- !e || t === void 0 || e.splice(t, 0, a);
14
- }), V(M, "move", (e, t, a, l) => {
15
- if (!e || !a || t === void 0 || l === void 0)
16
- return;
17
- const s = M.remove(e, t);
18
- M.insert(a, l, s);
19
- }), V(M, "swap", (e, t, a, l) => {
20
- if (!e || !a || t === void 0 || l === void 0)
21
- return;
22
- const s = e[t], o = a[l];
23
- e[t] = o, a[l] = s;
24
- }), V(M, "copy", (e, t, a, l) => {
25
- if (!e || t === void 0 || !a || l === void 0)
26
- return;
27
- const s = e[t];
28
- M.insert(a, l, s);
29
- }), V(M, "applyTransfer", (e) => {
30
- var l, s, o, g, i, c, d;
31
- const t = e.hovered.element.value, a = e.hovered.zone.value;
32
- if (t) {
33
- const f = (s = (l = e.elementsMap.value.get(t)) == null ? void 0 : l.data) == null ? void 0 : s.source, r = (g = (o = e.elementsMap.value.get(t)) == null ? void 0 : o.data) == null ? void 0 : g.index, v = e.draggingElements.value.values().next().value, u = (i = v == null ? void 0 : v.data) == null ? void 0 : i.index, m = u !== void 0 && r !== void 0 && u > r ? 1 : -1;
34
- Array.from(
35
- e.draggingElements.value.values()
36
- ).sort(
37
- (h, L) => {
38
- var b, z;
39
- return m * ((((b = h.data) == null ? void 0 : b.index) || 0) - (((z = L.data) == null ? void 0 : z.index) || 0));
40
- }
41
- ).forEach(
42
- (h) => {
43
- var L, b;
44
- return M.move(
45
- (L = h.data) == null ? void 0 : L.source,
46
- (b = h.data) == null ? void 0 : b.index,
47
- f,
48
- r
49
- );
50
- }
51
- );
52
- } else if (a) {
53
- const f = (d = (c = e.zonesMap.value.get(a)) == null ? void 0 : c.data) == null ? void 0 : d.source, r = f == null ? void 0 : f.length;
54
- Array.from(
55
- e.draggingElements.value.values()
56
- ).sort((u, m) => {
57
- var p, h;
58
- return (((p = m.data) == null ? void 0 : p.index) || 0) - (((h = u.data) == null ? void 0 : h.index) || 0);
59
- }).forEach(
60
- (u) => {
61
- var m, p;
62
- return M.move(
63
- (m = u.data) == null ? void 0 : m.source,
64
- (p = u.data) == null ? void 0 : p.index,
65
- f,
66
- r
67
- );
68
- }
69
- );
25
+ let Le = "", Ue = "", $e = "";
26
+ const p = (e) => e.value ? e.value instanceof HTMLElement ? e.value : e.value.$el : null, F = (e, t) => e !== t && e.contains(t), Ve = (e, t) => !(e.right < t.left || e.left > t.right || e.bottom < t.top || e.top > t.bottom), ae = () => {
27
+ const e = document.body;
28
+ Le = e.style.userSelect, e.style.userSelect = "none", window.addEventListener("contextmenu", D), window.addEventListener("selectstart", D), window.addEventListener("touchstart", D), window.addEventListener("touchmove", D);
29
+ }, le = () => {
30
+ const e = document.body;
31
+ e.style.userSelect = Le, e.style.touchAction = Ue, e.style.overscrollBehavior = $e, window.removeEventListener("contextmenu", D), window.removeEventListener("selectstart", D), window.removeEventListener("touchstart", D), window.removeEventListener("touchmove", D);
32
+ }, D = (e) => e.preventDefault(), k = (e, t) => {
33
+ if (t.entities.draggableMap.get(e)?.disabled) return !0;
34
+ for (const [o, s] of t.entities.draggableMap)
35
+ if (s.disabled && F(o, e)) return !0;
36
+ return !1;
37
+ }, z = (e, t) => {
38
+ if (t.entities.droppableMap.get(e)?.disabled) return !0;
39
+ for (const [o, s] of t.entities.droppableMap)
40
+ if (s.disabled && F(o, e)) return !0;
41
+ return !1;
42
+ }, de = (e, t) => !e.length || !t.length ? !0 : e.some((n) => t.includes(n));
43
+ function qe(e, t, n, o) {
44
+ const s = /* @__PURE__ */ new Set();
45
+ for (const a of t.keys()) {
46
+ const l = n.get(a);
47
+ for (const u of l?.groups ?? []) s.add(u);
70
48
  }
71
- }), V(M, "applyCopy", (e) => {
72
- var l, s, o, g, i, c;
73
- const t = e.hovered.element.value, a = e.hovered.zone.value;
74
- if (t) {
75
- const d = (s = (l = e.elementsMap.value.get(t)) == null ? void 0 : l.data) == null ? void 0 : s.source, f = (g = (o = e.elementsMap.value.get(t)) == null ? void 0 : o.data) == null ? void 0 : g.index;
76
- Array.from(
77
- e.draggingElements.value.values()
78
- ).sort((v, u) => {
79
- var m, p;
80
- return (((m = u.data) == null ? void 0 : m.index) || 0) - (((p = v.data) == null ? void 0 : p.index) || 0);
81
- }).forEach(
82
- (v) => {
83
- var u, m;
84
- return M.copy(
85
- (u = v.data) == null ? void 0 : u.source,
86
- (m = v.data) == null ? void 0 : m.index,
87
- d,
88
- f
89
- );
90
- }
91
- );
92
- } else if (a) {
93
- const d = (c = (i = e.zonesMap.value.get(a)) == null ? void 0 : i.data) == null ? void 0 : c.source, f = d == null ? void 0 : d.length;
94
- Array.from(
95
- e.draggingElements.value.values()
96
- ).sort((v, u) => {
97
- var m, p;
98
- return (((m = u.data) == null ? void 0 : m.index) || 0) - (((p = v.data) == null ? void 0 : p.index) || 0);
99
- }).forEach(
100
- (v) => {
101
- var u, m;
102
- return M.copy(
103
- (u = v.data) == null ? void 0 : u.source,
104
- (m = v.data) == null ? void 0 : m.index,
105
- d,
106
- f
107
- );
108
- }
109
- );
49
+ const r = [...s], i = /* @__PURE__ */ new Set();
50
+ for (const a of e) {
51
+ const u = o.get(a)?.groups ?? [];
52
+ de(r, u) && i.add(a);
110
53
  }
111
- }), V(M, "applySwap", (e) => {
112
- var l, s, o, g, i, c, d, f;
113
- const t = e.hovered.element.value, a = e.hovered.zone.value;
114
- if (t && e.draggingElements.value.size === 1) {
115
- const r = e.draggingElements.value.values().next().value;
116
- M.swap(
117
- (l = r == null ? void 0 : r.data) == null ? void 0 : l.source,
118
- (s = r == null ? void 0 : r.data) == null ? void 0 : s.index,
119
- (g = (o = e.elementsMap.value.get(t)) == null ? void 0 : o.data) == null ? void 0 : g.source,
120
- (c = (i = e.elementsMap.value.get(t)) == null ? void 0 : i.data) == null ? void 0 : c.index
121
- );
122
- } else if (a) {
123
- const r = (f = (d = e.zonesMap.value.get(a)) == null ? void 0 : d.data) == null ? void 0 : f.source, v = r == null ? void 0 : r.length;
124
- Array.from(
125
- e.draggingElements.value.values()
126
- ).sort((m, p) => {
127
- var h, L;
128
- return (((h = p.data) == null ? void 0 : h.index) || 0) - (((L = m.data) == null ? void 0 : L.index) || 0);
129
- }).forEach(
130
- (m) => {
131
- var p, h;
132
- return M.move(
133
- (p = m.data) == null ? void 0 : p.source,
134
- (h = m.data) == null ? void 0 : h.index,
135
- r,
136
- v
137
- );
138
- }
139
- );
54
+ return i;
55
+ }
56
+ function We(e, t, n) {
57
+ const o = /* @__PURE__ */ new Set();
58
+ for (const i of t.keys()) {
59
+ const a = n.get(i);
60
+ for (const l of a?.groups ?? []) o.add(l);
140
61
  }
141
- }), V(M, "applyRemove", (e) => {
142
- Array.from(
143
- e.draggingElements.value.values()
144
- ).sort((a, l) => {
145
- var s, o;
146
- return (((s = l.data) == null ? void 0 : s.index) || 0) - (((o = a.data) == null ? void 0 : o.index) || 0);
147
- }).forEach((a) => {
148
- var l, s;
149
- (l = a.data) != null && l.source && ((s = a.data) == null ? void 0 : s.index) !== void 0 && M.remove(a.data.source, a.data.index);
150
- });
151
- }), V(M, "applyInsert", (e, t) => {
152
- var s, o, g, i, c, d;
153
- const a = e.hovered.element.value, l = e.hovered.zone.value;
154
- if (a && t.length > 0) {
155
- const f = (o = (s = e.elementsMap.value.get(a)) == null ? void 0 : s.data) == null ? void 0 : o.source, r = (i = (g = e.elementsMap.value.get(a)) == null ? void 0 : g.data) == null ? void 0 : i.index;
156
- t.forEach((v) => {
157
- M.insert(f, r, v);
158
- });
159
- } else if (l) {
160
- const f = (d = (c = e.zonesMap.value.get(l)) == null ? void 0 : c.data) == null ? void 0 : d.source, r = f == null ? void 0 : f.length;
161
- t.forEach((v) => {
162
- M.insert(f, r, v);
62
+ const s = [...o], r = /* @__PURE__ */ new Set();
63
+ for (const i of e) {
64
+ const l = n.get(i)?.groups ?? [];
65
+ de(s, l) && r.add(i);
66
+ }
67
+ return r;
68
+ }
69
+ const ne = (e) => {
70
+ const t = new IntersectionObserver((n) => {
71
+ n.forEach((o) => {
72
+ const s = o.target;
73
+ e[o.isIntersecting ? "add" : "delete"](s);
163
74
  });
75
+ });
76
+ return {
77
+ observe: (n) => t.observe(n),
78
+ unobserve: (n) => t.unobserve(n),
79
+ disconnect: () => t.disconnect()
80
+ };
81
+ }, je = (e) => {
82
+ const t = new ResizeObserver((n) => {
83
+ const o = n[0];
84
+ if (!o) return;
85
+ const { width: s, height: r } = o.contentRect;
86
+ e.value = { width: s, height: r };
87
+ });
88
+ return {
89
+ observe: (n) => t.observe(n),
90
+ unobserve: (n) => t.unobserve(n),
91
+ disconnect: () => t.disconnect()
92
+ };
93
+ }, Je = (e) => {
94
+ const t = U(null), n = je(t), o = J(
95
+ e,
96
+ (r) => {
97
+ n.disconnect(), r && n.observe(r);
98
+ },
99
+ { immediate: !0 }
100
+ );
101
+ return { overlaySize: t, overlaySizeObserver: {
102
+ disconnect: () => {
103
+ o(), n.disconnect();
104
+ }
105
+ } };
106
+ };
107
+ function ce(e, t = 0, n = 0) {
108
+ return {
109
+ start: { x: e.clientX, y: e.clientY },
110
+ current: { x: e.clientX, y: e.clientY },
111
+ offset: { x: t, y: n }
112
+ };
113
+ }
114
+ function ke(e, t) {
115
+ const n = t.getBoundingClientRect(), o = n.width > 0 ? (e.clientX - n.left) / n.width : 0.5, s = n.height > 0 ? (e.clientY - n.top) / n.height : 0.5;
116
+ return { x: o, y: s };
117
+ }
118
+ function Re(e, t) {
119
+ return {
120
+ ...t,
121
+ initialHTML: e.innerHTML,
122
+ initialRect: e.getBoundingClientRect(),
123
+ initialOuterHTML: e.outerHTML
124
+ };
125
+ }
126
+ function Qe(e, t, n) {
127
+ e.forEach((o) => {
128
+ const s = t.get(o);
129
+ n.set(o, Re(o, s));
130
+ }), e.clear();
131
+ }
132
+ function et(e, t, n) {
133
+ n.clear();
134
+ const o = t.get(e);
135
+ n.set(e, Re(e, o));
136
+ }
137
+ function W(e) {
138
+ e.entities.initiatingDraggable && (e.state.value = "dragging", tt(
139
+ e.entities.initiatingDraggable,
140
+ e.entities.selectedSet,
141
+ e.entities.draggableMap,
142
+ e.entities.draggingMap
143
+ ));
144
+ }
145
+ function tt(e, t, n, o) {
146
+ t.has(e) ? Qe(t, n, o) : (t.clear(), et(e, n, o));
147
+ }
148
+ function Pe(e, t, n, o) {
149
+ if (o || !n) return !0;
150
+ const s = e.closest(n);
151
+ return s ? t.contains(s) : !1;
152
+ }
153
+ function nt(e, t) {
154
+ if (!e || !t) return 1;
155
+ const n = Math.abs(e.current.x - e.start.x), o = Math.abs(e.current.y - e.start.y);
156
+ if (typeof t == "number") {
157
+ const u = Math.sqrt(n * n + o * o);
158
+ return Math.min(u / t, 1);
164
159
  }
165
- });
166
- let oe = M;
167
- const Y = me(() => {
168
- const n = C(!1), e = F(
169
- /* @__PURE__ */ new Map()
170
- ), t = O(() => e.value.size > 0), a = {
171
- component: F(null),
172
- ref: C(null),
173
- options: C(null),
174
- props: C(null),
175
- animating: {
176
- enter: C(!1),
177
- leave: C(!1),
178
- appear: C(!1)
160
+ const {
161
+ x: s = 0,
162
+ y: r = 0,
163
+ condition: i = "any"
164
+ } = t;
165
+ if (s === 0 && r === 0) return 1;
166
+ const a = s > 0 ? Math.min(n / s, 1) : 1, l = r > 0 ? Math.min(o / r, 1) : 1;
167
+ return i === "both" ? Math.min(a, l) : Math.max(a, l);
168
+ }
169
+ function Te(e, t, n) {
170
+ if (!n) return !0;
171
+ const o = n.distance != null, s = n.delay != null;
172
+ return !o && !s ? !0 : o && !s ? e >= 1 : !o && s ? t >= 1 : (n.condition ?? "both") === "both" ? e >= 1 && t >= 1 : e >= 1 || t >= 1;
173
+ }
174
+ function ot(e) {
175
+ if (e.state.value !== "activating" || !e.entities.initiatingDraggable)
176
+ return !1;
177
+ const t = e.entities.draggableMap.get(
178
+ e.entities.initiatingDraggable
179
+ );
180
+ return Te(
181
+ e.distanceProgress.value,
182
+ e.delay.progress,
183
+ t?.activation
184
+ ) ? (W(e), !0) : !1;
185
+ }
186
+ function st(e, t) {
187
+ let n = null;
188
+ const o = () => {
189
+ if (e.state.value !== "activating" || !e.entities.initiatingDraggable) {
190
+ n = null;
191
+ return;
179
192
  }
180
- }, l = F(/* @__PURE__ */ new Map()), s = F(/* @__PURE__ */ new Set()), o = F(/* @__PURE__ */ new Map()), g = C(/* @__PURE__ */ new Set()), i = C(/* @__PURE__ */ new Set()), c = typeof window < "u" && "IntersectionObserver" in window, d = c ? new IntersectionObserver((x) => {
181
- x.forEach(
182
- (y) => i.value[y.isIntersecting ? "add" : "delete"](
183
- y.target
184
- )
185
- );
186
- }) : null, f = c ? new IntersectionObserver((x) => {
187
- x.forEach(
188
- (y) => g.value[y.isIntersecting ? "add" : "delete"](
189
- y.target
190
- )
191
- );
192
- }) : null, r = (x, y) => {
193
- d && (x === "add" ? d.observe(y) : (d.unobserve(y), i.value.delete(y)));
194
- }, v = (x, y) => {
195
- f && (x === "add" ? f.observe(y) : (f.unobserve(y), g.value.delete(y)));
196
- }, u = {
197
- start: C(null),
198
- current: C(null),
199
- offset: {
200
- percent: C(null),
201
- pixel: C(null)
193
+ const s = e.entities.draggableMap.get(
194
+ e.entities.initiatingDraggable
195
+ ), r = s?.activation?.delay;
196
+ if (!r) {
197
+ n = null;
198
+ return;
199
+ }
200
+ e.delay.progress = Math.min(
201
+ (Date.now() - e.delay.startTime) / (r * 1e3),
202
+ 1
203
+ ), Te(
204
+ e.distanceProgress.value,
205
+ e.delay.progress,
206
+ s?.activation
207
+ ) ? (t(), n = null) : n = requestAnimationFrame(o);
208
+ };
209
+ return n = requestAnimationFrame(o), {
210
+ cancel: () => {
211
+ n !== null && (cancelAnimationFrame(n), n = null);
202
212
  }
203
- }, { KeyW: m, KeyS: p, KeyA: h, KeyD: L, ctrl: b, shift: z, alt: B, meta: D } = Ie(), w = {
204
- zone: C(null),
205
- element: C(null)
206
213
  };
214
+ }
215
+ function it(e, t) {
216
+ const n = e.closest(
217
+ H.CONSTRAINT_AREA
218
+ );
219
+ return !n || !t.has(n) ? null : {
220
+ element: n,
221
+ entity: t.get(n)
222
+ };
223
+ }
224
+ function rt(e, t, n, o) {
225
+ return n === "x" ? { x: e, y: o.top } : n === "y" ? { x: o.left, y: t } : { x: e, y: t };
226
+ }
227
+ function at(e, t, n, o, s) {
228
+ let r = e, i = t;
229
+ return n !== "y" && (r = Math.max(
230
+ o.left,
231
+ Math.min(o.right - s.width, e)
232
+ )), n !== "x" && (i = Math.max(
233
+ o.top,
234
+ Math.min(o.bottom - s.height, t)
235
+ )), { x: r, y: i };
236
+ }
237
+ function lt(e, t, n, o, s) {
238
+ if (!e || !t)
239
+ return { x: 0, y: 0 };
240
+ const r = t.getBoundingClientRect(), i = r.width || s?.width || 0, a = r.height || s?.height || 0;
241
+ let l = e.current.x - i * e.offset.x, u = e.current.y - a * e.offset.y;
242
+ if (!n)
243
+ return { x: l, y: u };
244
+ const d = it(n, o);
245
+ if (!d)
246
+ return { x: l, y: u };
247
+ const { element: c, entity: g } = d, f = c.getBoundingClientRect(), y = n.getBoundingClientRect(), b = rt(
248
+ l,
249
+ u,
250
+ g.axis || "both",
251
+ y
252
+ );
253
+ return g.restrictToArea ? at(
254
+ b.x,
255
+ b.y,
256
+ g.axis || "both",
257
+ f,
258
+ r
259
+ ) : b;
260
+ }
261
+ const I = {
262
+ forDrag: ["Enter", "Space"],
263
+ forCancel: ["Escape"],
264
+ forDrop: ["Enter", "Space"],
265
+ forMove: [
266
+ "ArrowUp",
267
+ "ArrowDown",
268
+ "ArrowLeft",
269
+ "ArrowRight",
270
+ "KeyW",
271
+ "KeyA",
272
+ "KeyS",
273
+ "KeyD"
274
+ ],
275
+ forMoveFaster: ["ShiftLeft", "ShiftRight"]
276
+ };
277
+ function ct(e, t) {
278
+ const n = V(), o = U(), r = {
279
+ keys: {
280
+ pressedKeys: U(/* @__PURE__ */ new Set()),
281
+ forDrag: [...I.forDrag],
282
+ forCancel: [...I.forCancel],
283
+ forDrop: [...I.forDrop],
284
+ forMove: [...I.forMove],
285
+ forMoveFaster: [...I.forMoveFaster]
286
+ },
287
+ step: 8,
288
+ moveFaster: 4
289
+ }, i = Z({
290
+ draggableMap: /* @__PURE__ */ new Map(),
291
+ droppableMap: /* @__PURE__ */ new Map(),
292
+ selectableAreaMap: /* @__PURE__ */ new Map(),
293
+ constraintsAreaMap: /* @__PURE__ */ new Map(),
294
+ initiatingDraggable: void 0,
295
+ selectingArea: void 0,
296
+ draggingMap: /* @__PURE__ */ new Map(),
297
+ selectedSet: /* @__PURE__ */ new Set(),
298
+ allowedDroppableSet: m(() => n.value ? qe(
299
+ i.visibleDroppableSet,
300
+ i.draggingMap,
301
+ i.draggableMap,
302
+ i.droppableMap
303
+ ) : /* @__PURE__ */ new Set()),
304
+ allowedDraggableSet: m(() => n.value ? We(
305
+ i.visibleDraggableSet,
306
+ i.draggingMap,
307
+ i.draggableMap
308
+ ) : /* @__PURE__ */ new Set()),
309
+ modifiersSelectableAreaSet: m(() => be(
310
+ i.selectableAreaMap,
311
+ i.visibleSelectableAreaSet,
312
+ r.keys.pressedKeys
313
+ )),
314
+ modifiersDraggableSet: m(() => be(
315
+ i.draggableMap,
316
+ i.visibleDraggableSet,
317
+ r.keys.pressedKeys,
318
+ (v) => k(v, { entities: i })
319
+ )),
320
+ visibleDraggableSet: /* @__PURE__ */ new Set(),
321
+ visibleDroppableSet: /* @__PURE__ */ new Set(),
322
+ visibleSelectableAreaSet: /* @__PURE__ */ new Set()
323
+ }), a = Z({
324
+ draggable: /* @__PURE__ */ new Map(),
325
+ droppable: /* @__PURE__ */ new Map()
326
+ }), l = {
327
+ throttle: V(0)
328
+ }, u = Z({
329
+ x: window.scrollX,
330
+ y: window.scrollY
331
+ }), d = Z({
332
+ progress: 0,
333
+ startTime: 0
334
+ }), c = m(() => {
335
+ if (!o.value || !i.initiatingDraggable) return 0;
336
+ const v = i.draggableMap.get(i.initiatingDraggable)?.activation?.distance;
337
+ return v ? nt(o.value, v) : 1;
338
+ }), g = ne(
339
+ i.visibleDraggableSet
340
+ ), f = ne(
341
+ i.visibleDroppableSet
342
+ ), y = ne(
343
+ i.visibleSelectableAreaSet
344
+ ), { overlaySize: b, overlaySizeObserver: R } = Je(e), S = U(), _ = m(() => {
345
+ const h = i.initiatingDraggable;
346
+ return lt(
347
+ o.value,
348
+ e.value,
349
+ h || null,
350
+ i.constraintsAreaMap,
351
+ b.value
352
+ );
353
+ }), E = m({
354
+ get: () => t?.overlayTo,
355
+ set: (h) => E.value = h
356
+ }), X = m(() => t?.autoScrollViewport);
207
357
  return {
208
- draggingElements: e,
209
- isDragging: t,
210
- activeContainer: a,
211
- elementsMap: l,
212
- selectedElements: s,
213
- zonesMap: o,
214
- visibleZones: g,
215
- visibleElements: i,
216
- pointerPosition: u,
217
- keyboard: {
218
- w: m,
219
- s: p,
220
- a: h,
221
- d: L,
222
- ctrl: b,
223
- shift: z,
224
- alt: B,
225
- meta: D
358
+ state: n,
359
+ pointer: o,
360
+ entities: i,
361
+ keyboard: r,
362
+ scrollPosition: u,
363
+ delay: d,
364
+ distanceProgress: c,
365
+ hovered: a,
366
+ collision: l,
367
+ overlay: {
368
+ size: b,
369
+ position: _,
370
+ render: S,
371
+ ref: e,
372
+ to: E
373
+ },
374
+ lib: {
375
+ draggableObserver: g,
376
+ droppableObserver: f,
377
+ selectableAreaObserver: y,
378
+ overlaySizeObserver: R
226
379
  },
227
- hovered: w,
228
- isPending: n,
229
- handleDragElementIntersection: r,
230
- handleDropZoneIntersection: v
380
+ autoScrollViewport: X
231
381
  };
232
- }), Ce = (n) => {
233
- const e = F(null), { draggingElements: t, pointerPosition: a, isDragging: l, activeContainer: s } = Y();
234
- return te(() => {
235
- s.ref = e, s.options.value = n ?? null;
236
- }), ye(() => {
237
- s.ref.value = null, s.options.value = null;
238
- }), {
239
- elementRef: e,
240
- draggingElements: t,
241
- pointerPosition: a,
242
- isDragging: l,
243
- animating: s.animating
382
+ }
383
+ const j = (e) => {
384
+ e.pointer.value = void 0, e.state.value = void 0, e.entities.selectingArea = void 0, e.entities.initiatingDraggable = void 0, e.delay.progress = 0, e.delay.startTime = 0, e.entities.draggingMap.clear(), e.hovered.draggable.clear(), e.hovered.droppable.clear();
385
+ }, ut = (e) => {
386
+ const t = e.entities.initiatingDraggable;
387
+ if (!t) return;
388
+ const o = e.entities.draggableMap.get(t)?.payload;
389
+ if (!o) return;
390
+ const s = o();
391
+ if (!Array.isArray(s) || s.length < 2) return;
392
+ const [r, i, a] = s;
393
+ return {
394
+ index: Number(r),
395
+ items: Array.isArray(i) ? i : [],
396
+ dropData: a
244
397
  };
245
- }, Se = ["innerHTML"], De = /* @__PURE__ */ fe({
246
- __name: "DefaultOverlay",
247
- props: {
248
- styles: {}
249
- },
250
- setup(n) {
251
- const { elementRef: e, pointerPosition: t, isDragging: a, draggingElements: l } = Ce(), s = O(() => {
252
- var o, g, i, c;
398
+ }, gt = (e, t) => {
399
+ const o = e.entities.droppableMap.get(t)?.payload;
400
+ if (!o) return;
401
+ const s = o();
402
+ if (!Array.isArray(s) || s.length < 1) return;
403
+ const [r, i] = s;
404
+ return {
405
+ items: Array.isArray(r) ? r : [],
406
+ userData: i
407
+ };
408
+ }, B = (e) => e.keys().next().value, ft = (e) => e.target.closest(H.DRAGGABLE), M = (e, t) => {
409
+ const n = {
410
+ payload: ut(e),
411
+ provider: e
412
+ };
413
+ return t && (n.dropZonePayload = gt(e, t)), n;
414
+ }, oe = (e, t, n) => {
415
+ const o = ft(t);
416
+ if (!o || !e.entities.draggingMap.has(o)) return;
417
+ const s = M(e);
418
+ e.entities.draggingMap.get(o)?.events?.[n]?.(s);
419
+ }, O = (e, t, n) => {
420
+ if (!t || k(t, e)) return;
421
+ const o = M(e);
422
+ e.entities.draggableMap.get(t)?.events?.[n]?.(o);
423
+ }, w = (e, t) => {
424
+ const n = M(e);
425
+ e.entities.draggableMap.forEach((o, s) => {
426
+ k(s, e) || o.events?.[t]?.(n);
427
+ });
428
+ }, dt = (e, t, n) => {
429
+ if (t !== n) {
430
+ if (t && !z(t, e)) {
431
+ const o = M(e, t);
432
+ e.entities.droppableMap.get(t)?.events?.onLeave?.(o);
433
+ }
434
+ if (n && !z(n, e)) {
435
+ const o = M(e, n);
436
+ e.entities.droppableMap.get(n)?.events?.onEnter?.(o);
437
+ }
438
+ }
439
+ }, yt = (e, t, n) => {
440
+ if (t !== n) {
441
+ const o = M(e);
442
+ t && !k(t, e) && e.entities.draggableMap.get(t)?.events?.onLeave?.(o), n && !k(n, e) && e.entities.draggableMap.get(n)?.events?.onHover?.(o);
443
+ }
444
+ }, mt = (e, t) => {
445
+ const n = B(t.droppable);
446
+ if (n && !z(n, e)) {
447
+ const o = M(e, n);
448
+ e.entities.droppableMap.get(n)?.events?.onLeave?.(o);
449
+ }
450
+ }, Be = (e, t) => {
451
+ const n = B(t.droppable);
452
+ if (n && !z(n, e)) {
453
+ const o = M(e, n);
454
+ e.entities.droppableMap.get(n)?.events?.onLeave?.(o);
455
+ }
456
+ }, bt = (e, t, n) => {
457
+ if (!n) return {};
458
+ const o = n.getBoundingClientRect(), s = Math.max(o.left, Math.min(e.x, t.x)), r = Math.max(o.top, Math.min(e.y, t.y)), i = Math.min(o.right, Math.max(e.x, t.x)), a = Math.min(o.bottom, Math.max(e.y, t.y)), l = Math.max(0, i - s), u = Math.max(0, a - r);
459
+ return {
460
+ left: `${s}px`,
461
+ top: `${r}px`,
462
+ width: `${l}px`,
463
+ height: `${u}px`,
464
+ position: "fixed",
465
+ pointerEvents: "none",
466
+ border: "1px solid #3b82f6",
467
+ backgroundColor: "#3b82f61a"
468
+ };
469
+ }, ht = (e) => {
470
+ if (!e.pointer.value || !e.entities.selectingArea) return;
471
+ const { selectingArea: t } = e.entities, n = pt(
472
+ e.pointer.value.start,
473
+ e.pointer.value.current
474
+ ), o = e.entities.selectableAreaMap.get(t)?.groups ?? [];
475
+ e.entities.visibleDraggableSet.forEach((s) => {
476
+ if (!t.contains(s)) return;
477
+ if (k(s, e)) {
478
+ e.entities.selectedSet.delete(s);
479
+ return;
480
+ }
481
+ const i = e.entities.draggableMap.get(s)?.groups ?? [];
482
+ if (!de(o, i)) {
483
+ e.entities.selectedSet.delete(s);
484
+ return;
485
+ }
486
+ Ve(n, s.getBoundingClientRect()) ? e.entities.selectedSet.add(s) : e.entities.selectedSet.delete(s);
487
+ });
488
+ }, pt = (e, t) => {
489
+ const n = Math.min(e.x, t.x), o = Math.min(e.y, t.y), s = Math.max(e.x, t.x), r = Math.max(e.y, t.y), i = s - n, a = r - o;
490
+ return new DOMRect(n, o, i, a);
491
+ }, Dt = (e, t, n = 5) => {
492
+ const o = n / 2;
493
+ return {
494
+ left: e - o,
495
+ top: t - o,
496
+ width: n,
497
+ height: n
498
+ };
499
+ }, St = (e) => {
500
+ const t = e.pointer.value?.current, n = t?.x ?? 0, o = t?.y ?? 0;
501
+ return Dt(n, o, 5);
502
+ }, T = (e, t, n) => {
503
+ const o = e.left + e.width / 2, s = e.top + e.height / 2;
504
+ if (n) {
505
+ const a = n.top ?? 0, l = n.right ?? 0, u = n.bottom ?? 0, d = n.left ?? 0, c = t.left + d, g = t.right - l, f = t.top + a, y = t.bottom - u;
506
+ if (c < g && f < y && o >= c && o <= g && s >= f && s <= y)
253
507
  return {
254
- transform: `translate3d(${(((o = t.current.value) == null ? void 0 : o.x) ?? 0) - (((g = t.offset.pixel.value) == null ? void 0 : g.x) ?? 0)}px, ${(((i = t.current.value) == null ? void 0 : i.y) ?? 0) - (((c = t.offset.pixel.value) == null ? void 0 : c.y) ?? 0)}px, 0)`,
255
- zIndex: 1e3,
256
- position: "fixed",
257
- top: 0,
258
- left: 0,
259
- transition: "0.3s cubic-bezier(0.165, 0.84, 0.44, 1)",
260
- ...n.styles
508
+ top: !1,
509
+ right: !1,
510
+ bottom: !1,
511
+ left: !1,
512
+ center: !0
261
513
  };
262
- });
263
- return (o, g) => P(a) ? (X(), j("div", {
264
- key: 0,
265
- ref_key: "elementRef",
266
- ref: e,
267
- style: re(s.value)
268
- }, [
269
- (X(!0), j(ae, null, we(P(l), ([i, c]) => {
270
- var d, f;
271
- return X(), j(ae, {
272
- key: c.id
273
- }, [
274
- c.layer ? (X(), J(ee(c.layer), {
275
- key: 0,
276
- node: i,
277
- data: c.data,
278
- id: c.id,
279
- groups: c.groups
280
- }, null, 8, ["node", "data", "id", "groups"])) : (X(), j("div", {
281
- key: 1,
282
- innerHTML: c.initialHTML,
283
- style: re({
284
- width: `${(d = c.initialRect) == null ? void 0 : d.width}px`,
285
- height: `${(f = c.initialRect) == null ? void 0 : f.height}px`
286
- })
287
- }, null, 12, Se))
288
- ], 64);
289
- }), 128))
290
- ], 4)) : Ee("", !0);
291
514
  }
292
- }), ie = /* @__PURE__ */ fe({
293
- __name: "DragOverlay",
294
- props: {
295
- styles: {}
296
- },
297
- setup(n) {
298
- const e = n, { activeContainer: t } = Y(), a = O(() => ({
299
- component: t.component.value ?? De,
300
- props: {
301
- ...e,
302
- ...t.props.value
515
+ const r = t.left + t.width / 2, i = t.top + t.height / 2;
516
+ return {
517
+ top: s < i,
518
+ bottom: s > i,
519
+ left: o < r,
520
+ right: o > r,
521
+ center: !1
522
+ };
523
+ }, vt = (e) => ({
524
+ x: e.left + e.width / 2,
525
+ y: e.top + e.height / 2
526
+ }), K = (e, t) => {
527
+ const n = vt(t);
528
+ return Math.hypot(e.x - n.x, e.y - n.y);
529
+ }, wt = (e, t) => e.find((n) => n !== t && F(t, n)), ue = (e, t, n) => {
530
+ const o = B(t.droppable), s = B(t.draggable);
531
+ t.draggable.clear(), t.droppable.clear();
532
+ const r = St(e), i = n.zones[0], a = n.elements[0];
533
+ if (i && a && i === a && e.entities.droppableMap.has(i) && i) {
534
+ const c = i.getBoundingClientRect(), g = e.entities.draggableMap.get(i)?.placementMargins, f = T(r, c, g);
535
+ if (f.center) {
536
+ t.droppable.set(i, f);
537
+ const y = wt(n.elements, i);
538
+ if (y) {
539
+ const b = y.getBoundingClientRect();
540
+ t.draggable.set(
541
+ y,
542
+ T(r, b, void 0)
543
+ );
303
544
  }
304
- }));
305
- return (l, s) => P(t).options.value ? (X(), J(Pe, {
306
- key: 0,
307
- name: P(t).options.value.name,
308
- duration: P(t).options.value.duration,
309
- "enter-from-class": P(t).options.value.enterFromClass,
310
- "enter-to-class": P(t).options.value.enterToClass,
311
- "enter-active-class": P(t).options.value.enterActiveClass,
312
- "leave-from-class": P(t).options.value.leaveFromClass,
313
- "leave-to-class": P(t).options.value.leaveToClass,
314
- "leave-active-class": P(t).options.value.leaveActiveClass,
315
- "appear-active-class": P(t).options.value.appearActiveClass,
316
- "appear-from-class": P(t).options.value.appearFromClass,
317
- "appear-to-class": P(t).options.value.appearToClass,
318
- mode: P(t).options.value.mode,
319
- type: P(t).options.value.type,
320
- css: P(t).options.value.css,
321
- appear: !0,
322
- persisted: P(t).options.value.persisted,
323
- onEnter: P(t).options.value.onEnter,
324
- onLeave: P(t).options.value.onLeave,
325
- onBeforeEnter: P(t).options.value.onBeforeEnter,
326
- onBeforeLeave: P(t).options.value.onBeforeLeave,
327
- onBeforeAppear: P(t).options.value.onBeforeAppear,
328
- onAfterEnter: P(t).options.value.onAfterEnter,
329
- onAfterLeave: P(t).options.value.onAfterLeave,
330
- onAfterAppear: P(t).options.value.onAfterAppear
331
- }, {
332
- default: xe(() => [
333
- (X(), J(ee(a.value.component || a.value), le(Me(a.value.props || {})), null, 16))
334
- ]),
335
- _: 1
336
- }, 8, ["name", "duration", "enter-from-class", "enter-to-class", "enter-active-class", "leave-from-class", "leave-to-class", "leave-active-class", "appear-active-class", "appear-from-class", "appear-to-class", "mode", "type", "css", "persisted", "onEnter", "onLeave", "onBeforeEnter", "onBeforeLeave", "onBeforeAppear", "onAfterEnter", "onAfterLeave", "onAfterAppear"])) : (X(), J(ee(a.value.component || a.value), le(Ae({ key: 1 }, a.value.props || {})), null, 16));
337
- }
338
- }), He = {
339
- install(n, e) {
340
- n.component("DragOverlay", ie);
341
- const t = n.mount;
342
- n.mount = function(l) {
343
- var g, i, c, d, f, r, v;
344
- const s = t.call(this, l), o = typeof l == "string" ? document.querySelector(l) : l;
345
- if (o && o instanceof Element && !o.querySelector("#vue-dnd-kit-overlay")) {
346
- const u = document.createElement("div");
347
- u.id = "vue-dnd-kit-overlay", u.style.pointerEvents = "none", (g = e == null ? void 0 : e.overlayPosition) != null && g.zIndex && (u.style.zIndex = e.overlayPosition.zIndex.toString()), (i = e == null ? void 0 : e.overlayPosition) != null && i.className && (u.className = e.overlayPosition.className);
348
- const m = ((c = e == null ? void 0 : e.overlayPosition) == null ? void 0 : c.method) || "append", p = (d = e == null ? void 0 : e.overlayPosition) != null && d.target ? typeof e.overlayPosition.target == "string" ? document.querySelector(e.overlayPosition.target) : e.overlayPosition.target : o;
349
- if (p && p instanceof Element)
350
- switch (m) {
351
- case "prepend":
352
- p.insertBefore(
353
- u,
354
- p.firstChild
355
- );
356
- break;
357
- case "after":
358
- (f = p.parentNode) == null || f.insertBefore(
359
- u,
360
- p.nextSibling
361
- );
362
- break;
363
- case "before":
364
- (r = p.parentNode) == null || r.insertBefore(
365
- u,
366
- p
367
- );
368
- break;
369
- case "append":
370
- default:
371
- p.appendChild(u);
372
- break;
545
+ } else
546
+ t.draggable.set(a, f);
547
+ } else {
548
+ if (i) {
549
+ const c = i.getBoundingClientRect();
550
+ t.droppable.set(i, T(r, c));
551
+ }
552
+ if (a)
553
+ if (i)
554
+ if (F(i, a)) {
555
+ const c = a.getBoundingClientRect(), g = e.entities.draggableMap.get(a)?.placementMargins;
556
+ t.draggable.set(
557
+ a,
558
+ T(r, c, g)
559
+ );
560
+ } else {
561
+ const c = e.pointer.value?.current ?? { x: 0, y: 0 }, g = i.getBoundingClientRect(), f = a.getBoundingClientRect(), y = K(c, g);
562
+ if (K(c, f) < y) {
563
+ t.droppable.clear();
564
+ const R = e.entities.draggableMap.get(a)?.placementMargins;
565
+ t.draggable.set(
566
+ a,
567
+ T(r, f, R)
568
+ );
373
569
  }
374
- else
375
- o.appendChild(u);
376
- const h = Le(ie, {
377
- styles: (v = e == null ? void 0 : e.defaultOverlay) == null ? void 0 : v.styles
378
- });
379
- se(h, u), n.__VUE_DND_KIT_OVERLAY__ = {
380
- container: u,
381
- vnode: h,
382
- options: (e == null ? void 0 : e.defaultOverlay) || {}
383
- };
384
- const L = Y();
385
- n.__VUE_DND_KIT_STORE__ = L;
570
+ }
571
+ else {
572
+ const c = a.getBoundingClientRect(), g = e.entities.draggableMap.get(a)?.placementMargins;
573
+ t.draggable.set(
574
+ a,
575
+ T(r, c, g)
576
+ );
386
577
  }
387
- return s;
388
- };
389
- const a = n.unmount;
390
- n.unmount = function() {
391
- return n.__VUE_DND_KIT_OVERLAY__ && (se(null, n.__VUE_DND_KIT_OVERLAY__.container), delete n.__VUE_DND_KIT_OVERLAY__), a.call(this);
392
- };
393
578
  }
394
- }, ue = (n, e) => n.x < e.x + e.width && n.x + n.width > e.x && n.y < e.y + e.height && n.y + n.height > e.y, $ = (n) => {
395
- if (!n)
396
- return {
397
- x: 0,
398
- y: 0,
399
- width: 0,
400
- height: 0,
401
- bottom: 0,
402
- left: 0,
403
- right: 0,
404
- top: 0
405
- };
406
- const e = n.getBoundingClientRect();
579
+ const u = B(t.droppable), d = B(t.draggable);
580
+ dt(e, o, u), yt(e, s, d);
581
+ }, Mt = (e, t) => e.x < t.x + t.width && e.x + e.width > t.x && e.y < t.y + t.height && e.y + e.height > t.y, he = (e) => {
582
+ if (!e)
583
+ return { x: 0, y: 0, width: 0, height: 0, top: 0, left: 0, right: 0, bottom: 0 };
584
+ const t = e.getBoundingClientRect();
407
585
  return {
408
- bottom: e.bottom,
409
- left: e.left,
410
- right: e.right,
411
- top: e.top,
412
- x: e.x,
413
- y: e.y,
414
- width: e.width,
415
- height: e.height
586
+ x: t.x,
587
+ y: t.y,
588
+ width: t.width,
589
+ height: t.height,
590
+ top: t.top,
591
+ left: t.left,
592
+ right: t.right,
593
+ bottom: t.bottom
416
594
  };
417
- }, Q = (n) => ({
418
- x: n.x + n.width / 2,
419
- y: n.y + n.height / 2
420
- }), _e = (n, e) => {
421
- const t = $(n);
422
- return {
423
- pixel: {
424
- x: e.x - t.x,
425
- y: e.y - t.y
426
- },
427
- percent: {
428
- x: (e.x - t.x) / t.width * 100,
429
- y: (e.y - t.y) / t.height * 100
430
- }
431
- };
432
- }, ce = (n, e) => {
433
- const t = e.x - n.x, a = e.y - n.y;
434
- return Math.sqrt(t * t + a * a);
435
- }, ve = (n, e) => {
436
- const t = Math.max(
595
+ }, pe = (e) => ({
596
+ x: e.x + e.width / 2,
597
+ y: e.y + e.height / 2
598
+ }), Et = (e, t) => Math.hypot(t.x - e.x, t.y - e.y), At = (e, t) => {
599
+ const n = Math.max(
437
600
  0,
438
- Math.min(n.x + n.width, e.x + e.width) - Math.max(n.x, e.x)
439
- ), a = Math.max(
601
+ Math.min(e.x + e.width, t.x + t.width) - Math.max(e.x, t.x)
602
+ ), o = Math.max(
440
603
  0,
441
- Math.min(n.y + n.height, e.y + e.height) - Math.max(n.y, e.y)
442
- ), l = t * a, s = n.width * n.height, o = e.width * e.height;
443
- return (l / s * 100 + l / o * 100) / 2;
444
- }, de = "data-vue-dnd-kit-draggable", Z = (n) => {
445
- n.preventDefault();
446
- }, R = (n) => ({
447
- items: Array.from(n.draggingElements.value.values())
448
- }), ke = (n) => {
449
- const {
450
- elementsMap: e,
451
- draggingElements: t,
452
- hovered: a,
453
- selectedElements: l,
454
- isDragging: s,
455
- visibleElements: o,
456
- handleDragElementIntersection: g
457
- } = Y(), i = F(null), c = O(() => a.element.value === i.value), d = C((n == null ? void 0 : n.id) || be()), f = C((n == null ? void 0 : n.disabled) ?? !1), r = O(() => f.value || !i.value || !e.value.has(i.value) ? !1 : t.value.has(i.value)), v = O(() => {
458
- if (f.value || !i.value || !s.value || !o.value.has(i.value)) return !1;
459
- const h = e.value.get(i.value);
460
- return h != null && h.groups.length ? !Array.from(t.value.entries()).some(
461
- ([L, b]) => b.groups.length ? !b.groups.some(
462
- (z) => h.groups.includes(z)
463
- ) : !1
464
- ) : !0;
465
- }), u = O(() => {
466
- if (f.value || !i.value || !s.value || !o.value.has(i.value) || a.element.value !== i.value) return !1;
467
- const h = e.value.get(i.value);
468
- return h != null && h.groups.length ? !Array.from(t.value.entries()).some(
469
- ([L, b]) => b.groups.length ? !b.groups.some(
470
- (z) => h.groups.includes(z)
471
- ) : !1
472
- ) : !0;
473
- });
474
- return {
475
- elementRef: i,
476
- registerElement: () => {
477
- if (!i.value) throw new Error("ElementRef is not set");
478
- e.value.set(i.value, {
479
- node: i.value,
480
- groups: (n == null ? void 0 : n.groups) ?? [],
481
- layer: (n == null ? void 0 : n.layer) ?? null,
482
- defaultLayer: (n == null ? void 0 : n.layer) ?? null,
483
- events: (n == null ? void 0 : n.events) ?? {},
484
- data: (n == null ? void 0 : n.data) ?? null,
485
- id: d.value,
486
- disabled: f ?? !1
487
- }), g("add", i.value), i.value.addEventListener("dragstart", Z), i.value.addEventListener("drag", Z), i.value.setAttribute(de, "true"), i.value.setAttribute("draggable", "false");
604
+ Math.min(e.y + e.height, t.y + t.height) - Math.max(e.y, t.y)
605
+ ), s = n * o, r = e.width * e.height, i = t.width * t.height;
606
+ return r === 0 || i === 0 ? 0 : (s / r * 100 + s / i * 100) / 2;
607
+ }, xt = (e, t, n) => t >= e.x && t <= e.x + e.width && n >= e.y && n <= e.y + e.height, De = () => !0, Se = () => 0, Ct = "separate", Lt = () => {
608
+ const e = {
609
+ filterElements: De,
610
+ filterZones: De,
611
+ sortElements: Se,
612
+ sortZones: Se,
613
+ mergeStrategy: Ct,
614
+ pickClosestBetweenFirst: !1
615
+ }, t = (o, s, r, i, a, l, u) => {
616
+ const d = new Set(i), c = { containerBox: s, pointer: r }, g = [...i].filter((f) => a(f, o)).map((f) => {
617
+ const y = he(f);
618
+ if (!u(y, c)) return null;
619
+ let b = 0;
620
+ for (const S of d)
621
+ S !== f && F(S, f) && b++;
622
+ const R = At(y, s);
623
+ return {
624
+ node: f,
625
+ box: y,
626
+ meta: {
627
+ isPointerInElement: xt(y, r.x, r.y),
628
+ overlapPercent: R,
629
+ depth: b,
630
+ centerDistance: Et(
631
+ pe(s),
632
+ pe(y)
633
+ )
634
+ }
635
+ };
636
+ }).filter((f) => f !== null);
637
+ if (e.minOverlapPercent !== void 0) {
638
+ const f = e.minOverlapPercent, y = g.filter((b) => b.meta.overlapPercent >= f);
639
+ g.length = 0, g.push(...y);
640
+ }
641
+ return g.sort((f, y) => l(f, y, c)), g.map((f) => f.node);
642
+ }, n = {
643
+ container(o) {
644
+ return e.container = o, n;
488
645
  },
489
- unregisterElement: () => {
490
- i.value && (e.value.delete(i.value), l.value.delete(i.value), i.value.removeEventListener("dragstart", Z), i.value.removeEventListener("drag", Z), i.value.removeAttribute(de), i.value.removeAttribute("draggable"));
646
+ containerBox(o) {
647
+ return e.containerBox = o, n;
491
648
  },
492
- isDragging: r,
493
- isOvered: c,
494
- isAllowed: v,
495
- isLazyAllowed: u,
496
- id: d
497
- };
498
- }, k = (n, e) => n ? e.contains(n) : !1, Ke = (n) => {
499
- var d, f;
500
- const e = $(n.activeContainer.ref.value), t = Q(e), a = ((d = n.pointerPosition.current.value) == null ? void 0 : d.x) ?? 0, l = ((f = n.pointerPosition.current.value) == null ? void 0 : f.y) ?? 0, o = !(e && a >= e.x && a <= e.x + e.width && l >= e.y && l <= e.y + e.height), g = Array.from(n.draggingElements.value.keys()), i = Array.from(n.visibleElements.value.entries()).filter(([r, v]) => {
501
- if (!r) return !1;
502
- const u = $(r);
503
- return u && e && ue(u, e);
504
- }).map(([r, v]) => {
505
- const u = $(r), m = Q(u), p = a >= u.x && a <= u.x + u.width && l >= u.y && l <= u.y + u.height, h = ve(u, e), L = ce(t, m);
506
- let b = 0;
507
- for (const [z, B] of n.visibleElements.value.entries())
508
- z !== r && z && r && k(r, z) && b++;
509
- return {
510
- element: v,
511
- node: r,
512
- isPointerInElement: p,
513
- overlapPercent: h,
514
- depth: b,
515
- centerDistance: L
516
- };
517
- }).sort((r, v) => {
518
- if (!o) {
519
- if (r.isPointerInElement && v.isPointerInElement)
520
- return v.depth - r.depth;
521
- if (r.isPointerInElement !== v.isPointerInElement)
522
- return r.isPointerInElement ? -1 : 1;
523
- }
524
- return Math.abs(r.overlapPercent - v.overlapPercent) <= 1 ? r.centerDistance - v.centerDistance : v.overlapPercent - r.overlapPercent;
525
- }), c = Array.from(n.visibleZones.value.entries()).filter(([r, v]) => {
526
- if (!r || g.some(
527
- (m) => m && k(r, m)
528
- ))
529
- return !1;
530
- const u = $(r);
531
- return u && e && ue(u, e);
532
- }).map(([r, v]) => {
533
- const u = $(r), m = Q(u), p = a >= u.x && a <= u.x + u.width && l >= u.y && l <= u.y + u.height, h = ve(u, e), L = ce(t, m);
534
- let b = 0;
535
- for (const [z, B] of n.visibleZones.value.entries())
536
- z !== r && z && r && k(r, z) && b++;
537
- return {
538
- zone: v,
539
- node: r,
540
- isPointerInElement: p,
541
- overlapPercent: h,
542
- depth: b,
543
- centerDistance: L
544
- };
545
- }).sort((r, v) => {
546
- if (!o) {
547
- if (r.isPointerInElement && v.isPointerInElement)
548
- return v.depth - r.depth;
549
- if (r.isPointerInElement !== v.isPointerInElement)
550
- return r.isPointerInElement ? -1 : 1;
551
- }
552
- return Math.abs(r.overlapPercent - v.overlapPercent) <= 1 ? r.centerDistance - v.centerDistance : v.overlapPercent - r.overlapPercent;
553
- });
554
- return [
555
- ...i.map((r) => r.node),
556
- ...c.map((r) => r.node)
557
- ];
558
- }, Te = (n, e) => {
559
- const { pointerPosition: t, keyboard: a } = Y(), l = (e == null ? void 0 : e.moveStep) || 10;
560
- return {
561
- onKeyboardStart: (i) => {
562
- var r;
563
- Z(i);
564
- const c = $(n.value);
565
- (r = n.value) == null || r.blur();
566
- const d = c.x + c.width / 2, f = c.y + c.height / 2;
567
- t.start.value = {
568
- x: d,
569
- y: f
570
- }, t.current.value = {
571
- x: d,
572
- y: f
573
- }, t.offset.pixel.value = {
574
- x: c.width / 2,
575
- y: c.height / 2
576
- }, t.offset.percent.value = {
577
- x: 50,
578
- y: 50
579
- };
649
+ elements(o) {
650
+ return e.elements = o, n;
580
651
  },
581
- onKeyboardMove: () => {
582
- if (!t.current.value) return;
583
- const i = t.current.value.x, c = t.current.value.y;
584
- let d = i, f = c;
585
- a.w.value && (f -= l), a.s.value && (f += l), a.a.value && (d -= l), a.d.value && (d += l), t.current.value = {
586
- x: d,
587
- y: f
588
- };
652
+ zones(o) {
653
+ return e.zones = o, n;
589
654
  },
590
- onKeyboardEnd: () => {
591
- t.current.value = null, t.start.value = null, t.offset.pixel.value = null, t.offset.percent.value = null;
592
- }
593
- };
594
- }, Ze = (n) => {
595
- const e = Y();
596
- return {
597
- onPointerStart: (s) => {
598
- e.pointerPosition.start.value = { x: s.clientX, y: s.clientY }, e.pointerPosition.current.value = {
599
- x: s.clientX,
600
- y: s.clientY
601
- };
602
- const { pixel: o, percent: g } = _e(n.value, {
603
- x: s.clientX,
604
- y: s.clientY
605
- });
606
- e.pointerPosition.offset.pixel.value = o, e.pointerPosition.offset.percent.value = g;
655
+ filterElements(o) {
656
+ return e.filterElements = o, n;
607
657
  },
608
- onPointerMove: (s) => {
609
- e.isPending.value || (e.pointerPosition.current.value = {
610
- x: s.clientX,
611
- y: s.clientY
612
- });
658
+ filterZones(o) {
659
+ return e.filterZones = o, n;
613
660
  },
614
- onPointerEnd: () => {
615
- e.pointerPosition.current.value = null, e.pointerPosition.start.value = null, e.pointerPosition.offset.pixel.value = null, e.pointerPosition.offset.percent.value = null;
616
- }
617
- };
618
- }, Oe = (n, e) => {
619
- var B, D;
620
- const t = Y(), { onPointerStart: a, onPointerMove: l, onPointerEnd: s } = Ze(n), { onKeyboardStart: o, onKeyboardMove: g, onKeyboardEnd: i } = Te(
621
- n,
622
- e == null ? void 0 : e.keyboard
623
- );
624
- let c = null;
625
- const d = (w) => {
626
- var _, S;
627
- if (!w) return /* @__PURE__ */ new Map();
628
- const x = t.selectedElements.value.has(w);
629
- if (t.selectedElements.value.size > 0 && x) {
630
- const U = /* @__PURE__ */ new Map();
631
- return t.selectedElements.value.forEach((G) => {
632
- var A, K;
633
- const E = t.elementsMap.value.get(G);
634
- E && U.set(G, {
635
- ...E,
636
- initialHTML: ((A = E.node) == null ? void 0 : A.outerHTML) ?? "",
637
- initialRect: (K = E.node) == null ? void 0 : K.getBoundingClientRect()
638
- });
639
- }), U;
640
- }
641
- t.selectedElements.value.clear();
642
- const y = t.elementsMap.value.get(w);
643
- if (!y) return /* @__PURE__ */ new Map();
644
- const I = /* @__PURE__ */ new Map();
645
- return I.set(w, {
646
- ...y,
647
- initialHTML: ((_ = y.node) == null ? void 0 : _.outerHTML) ?? "",
648
- initialRect: (S = y.node) == null ? void 0 : S.getBoundingClientRect()
649
- }), I;
650
- }, f = (w) => {
651
- if (!w)
652
- return { element: null, zone: null };
653
- const x = Array.isArray(w) ? w : [w], y = Array.from(t.draggingElements.value.keys()), I = Array.from(t.zonesMap.value.entries()).flatMap(
654
- ([E, A]) => A.disabled ? [E] : []
655
- ), _ = Array.from(
656
- t.elementsMap.value.entries()
657
- ).flatMap(([E, A]) => A.disabled ? [E] : []), S = x.find((E) => {
658
- if (!t.visibleZones.value.has(E)) return !1;
659
- const A = t.zonesMap.value.get(E);
660
- return !(!A || A.disabled || I.some(
661
- (N) => E === N || k(E, N)
662
- ) || y.some(
663
- (N) => N && (N === A.node || k(A.node, N))
664
- ) || A.groups.length && !!Array.from(
665
- t.draggingElements.value.values()
666
- ).some((H) => H.groups.length ? !H.groups.some((T) => A.groups.includes(T)) : !1));
667
- });
668
- return S ? {
669
- element: x.filter((E) => {
670
- if (!t.visibleElements.value.has(E) || !t.elementsMap.value.has(E)) return !1;
671
- const A = t.elementsMap.value.get(E);
672
- if (A != null && A.disabled) return !1;
673
- const K = I.some(
674
- (T) => E === T || k(E, T)
675
- ), N = _.some(
676
- (T) => E === T || k(
677
- E,
678
- T
679
- )
661
+ collision(o) {
662
+ return e.collision = o, n;
663
+ },
664
+ sortElements(o) {
665
+ return e.sortElements = o, n;
666
+ },
667
+ sortZones(o) {
668
+ return e.sortZones = o, n;
669
+ },
670
+ mergeStrategy(o) {
671
+ return e.mergeStrategy = o, n;
672
+ },
673
+ pickClosestBetweenFirst(o) {
674
+ return e.pickClosestBetweenFirst = o, n;
675
+ },
676
+ minOverlapPercent(o) {
677
+ return e.minOverlapPercent = o, n;
678
+ },
679
+ build() {
680
+ const o = e;
681
+ if (!o.container || !o.elements || !o.zones || !o.collision)
682
+ throw new Error(
683
+ "sensor: container, elements, zones, collision are required"
680
684
  );
681
- return K || N ? !1 : !Array.from(
682
- t.draggingElements.value.values()
683
- ).some((T) => T.groups.length ? !T.groups.some(
684
- (W) => {
685
- var q;
686
- return (q = t.elementsMap.value.get(E)) == null ? void 0 : q.groups.includes(W);
685
+ return (s) => {
686
+ const r = o.container(s);
687
+ if (!r) return { elements: [], zones: [] };
688
+ const i = o.containerBox ? o.containerBox(s) : he(r), a = s.pointer.value?.current ?? { x: 0, y: 0 }, l = t(
689
+ s,
690
+ i,
691
+ a,
692
+ o.elements(s),
693
+ o.filterElements,
694
+ o.sortElements,
695
+ o.collision
696
+ ), u = t(
697
+ s,
698
+ i,
699
+ a,
700
+ o.zones(s),
701
+ o.filterZones,
702
+ o.sortZones,
703
+ o.collision
704
+ );
705
+ if (o.mergeStrategy === "unified-closest") {
706
+ const d = [
707
+ ...l.map((g) => ({ node: g, isZone: !1, distance: 0 })),
708
+ ...u.map((g) => ({ node: g, isZone: !0, distance: 0 }))
709
+ ];
710
+ if (d.length === 0) return { elements: [], zones: [] };
711
+ for (const g of d) {
712
+ const f = g.node.getBoundingClientRect();
713
+ g.distance = K(a, f);
687
714
  }
688
- ) : !1);
689
- }).find((E) => y.some(
690
- (K) => K && (K === E || k(E, K) || k(K, E))
691
- ) ? !1 : E === S || k(
692
- E,
693
- S
694
- )) || null,
695
- zone: S
696
- } : { element: null, zone: null };
697
- }, r = ((B = e == null ? void 0 : e.sensor) == null ? void 0 : B.setup) || Ke, v = (w) => {
698
- var S, U, G, E, A, K, N, H, T, W, q, ne;
699
- const x = t.hovered.element.value, y = t.hovered.zone.value, I = w.element, _ = w.zone;
700
- t.hovered.element.value = I, t.hovered.zone.value = _, x !== I && (x && ((G = (U = (S = t.elementsMap.value.get(x)) == null ? void 0 : S.events) == null ? void 0 : U.onLeave) == null || G.call(U, t, R(t))), I && ((K = (A = (E = t.elementsMap.value.get(I)) == null ? void 0 : E.events) == null ? void 0 : A.onHover) == null || K.call(A, t, R(t)))), y !== _ && (y && ((T = (H = (N = t.zonesMap.value.get(y)) == null ? void 0 : N.events) == null ? void 0 : H.onLeave) == null || T.call(H, t, R(t))), _ && ((ne = (q = (W = t.zonesMap.value.get(_)) == null ? void 0 : W.events) == null ? void 0 : q.onHover) == null || ne.call(q, t, R(t))));
701
- }, u = ze(() => {
702
- const w = r(t), x = f(w);
703
- v(x);
704
- }, ((D = e == null ? void 0 : e.sensor) == null ? void 0 : D.throttle) ?? 0), m = () => {
705
- u(), c = requestAnimationFrame(m);
706
- }, p = () => m(), h = () => {
707
- c !== null && (s(), i(), cancelAnimationFrame(c), c = null);
708
- };
709
- return {
710
- activate: (w) => {
711
- t.draggingElements.value = d(n.value), t.draggingElements.value.forEach(
712
- (x) => {
713
- var y, I;
714
- return (I = (y = x.events).onStart) == null ? void 0 : I.call(y, t, R(t));
715
+ const c = d.reduce(
716
+ (g, f) => f.distance < g.distance ? f : g
717
+ );
718
+ return c.isZone ? { elements: [], zones: [c.node] } : { elements: [c.node], zones: [] };
715
719
  }
716
- ), w instanceof PointerEvent ? a(w) : o(w), p();
717
- },
718
- track: (w) => {
719
- t.draggingElements.value.forEach(
720
- (x) => {
721
- var y, I;
722
- return (I = (y = x.events).onMove) == null ? void 0 : I.call(y, t, R(t));
720
+ if (o.pickClosestBetweenFirst && l[0] && u[0]) {
721
+ const d = K(
722
+ a,
723
+ u[0].getBoundingClientRect()
724
+ );
725
+ return K(
726
+ a,
727
+ l[0].getBoundingClientRect()
728
+ ) < d ? { elements: l, zones: [] } : { elements: [], zones: u };
723
729
  }
724
- ), w instanceof KeyboardEvent ? g() : l(w);
725
- },
726
- deactivate: async (w = !0) => {
727
- var x, y;
728
- if (t.hovered.zone.value) {
729
- const I = t.zonesMap.value.get(t.hovered.zone.value), _ = (y = I == null ? void 0 : (x = I.events).onDrop) == null ? void 0 : y.call(x, t, R(t));
730
- if (_ instanceof Promise)
731
- try {
732
- t.isPending.value = !0;
733
- const S = await _;
734
- return S && (w && t.selectedElements.value.clear(), t.draggingElements.value.clear(), t.hovered.zone.value = null, t.hovered.element.value = null, h()), S;
735
- } catch {
736
- return !1;
737
- } finally {
738
- t.isPending.value = !1;
739
- }
740
- else
741
- w && t.selectedElements.value.clear(), t.draggingElements.value.clear(), t.hovered.zone.value = null, t.hovered.element.value = null, h();
742
- } else
743
- t.draggingElements.value.forEach(
744
- (I) => {
745
- var _, S;
746
- return (S = (_ = I.events).onEnd) == null ? void 0 : S.call(_, t, R(t));
747
- }
748
- ), w && t.selectedElements.value.clear(), t.draggingElements.value.clear(), t.hovered.zone.value = null, t.hovered.element.value = null, h();
730
+ return { elements: l, zones: u };
731
+ };
749
732
  }
750
733
  };
751
- }, Ne = me(() => {
752
- let n = "", e = "", t = "", a = null, l = null, s = null, o = null, g = null;
753
- const { activeContainer: i, isPending: c, elementsMap: d } = Y(), f = () => {
754
- const m = document.body;
755
- n = m.style.userSelect, m.style.userSelect = "none", window.addEventListener("contextmenu", Z), window.addEventListener("selectstart", Z), window.addEventListener("touchstart", Z), window.addEventListener("touchmove", Z);
756
- }, r = () => {
757
- const m = document.body;
758
- m.style.userSelect = n, m.style.touchAction = e, m.style.overscrollBehavior = t, window.removeEventListener("contextmenu", Z), window.removeEventListener("selectstart", Z), window.removeEventListener("touchstart", Z), window.removeEventListener("touchmove", Z);
759
- }, v = () => {
760
- a && (document.removeEventListener("pointermove", a), a = null), l && (document.removeEventListener("pointerup", l), l = null), s && (s = null), o && (document.removeEventListener("wheel", o), o = null), g && (document.removeEventListener("keydown", g), document.removeEventListener("keypress", g), document.removeEventListener("keyup", g), g = null);
761
- };
734
+ return n;
735
+ }, kt = () => Lt(), Rt = (e) => e.overlay.ref?.value ?? null, Pt = (e) => {
736
+ const t = e.overlay.position?.value ?? { x: 0, y: 0 }, n = e.overlay.size?.value ?? null, { x: o, y: s } = t, r = n?.width ?? 0, i = n?.height ?? 0;
762
737
  return {
763
- handleDragStart: (m, p, h) => {
764
- if (!p.value || c.value) return;
765
- const L = d.value.get(p.value);
766
- if (L != null && L.disabled) return;
767
- v(), m.target.blur(), h != null && h.container && (i.component.value = h.container), h != null && h.containerProps && (i.props.value = h.containerProps);
768
- const { activate: b, track: z, deactivate: B } = Oe(p, h);
769
- l = () => {
770
- B(!0).then((D) => {
771
- D !== !1 && (i.component.value = null, r(), B(!0), v());
772
- });
773
- }, s = () => {
774
- i.component.value = null, r(), B(!1), v();
775
- }, a = (D) => z(D), o = (D) => z(D), g = (D) => {
776
- D.type === "keyup" && (D.code === "Escape" && (s == null || s()), D.code === "Enter" && (l == null || l())), z(D);
777
- }, f(), b(m), document.addEventListener("pointermove", a), document.addEventListener("pointerup", l), document.addEventListener("wheel", o), document.addEventListener("keydown", g), document.addEventListener("keypress", g), document.addEventListener("keyup", g);
738
+ x: o,
739
+ y: s,
740
+ width: r,
741
+ height: i,
742
+ top: s,
743
+ left: o,
744
+ right: o + r,
745
+ bottom: s + i
746
+ };
747
+ }, Tt = (e) => e.entities.allowedDraggableSet, Bt = (e) => e.entities.allowedDroppableSet, Ot = (e, t) => !t.entities.draggingMap.has(e), zt = (e, t) => ![...t.entities.draggingMap.keys()].some(
748
+ (n) => F(n, e)
749
+ ), Ft = (e, t) => t.entities.draggableMap.has(e) ? !k(e, t) : t.entities.droppableMap.has(e) ? !z(e, t) : !0, ve = (e, t) => Ot(e, t) && zt(e, t) && Ft(e, t), _t = (e, t) => Mt(e, t.containerBox), we = (e, t, n) => {
750
+ if (n.pointer.x >= n.containerBox.x && n.pointer.x <= n.containerBox.x + n.containerBox.width && n.pointer.y >= n.containerBox.y && n.pointer.y <= n.containerBox.y + n.containerBox.height) {
751
+ if (e.meta.isPointerInElement && t.meta.isPointerInElement)
752
+ return t.meta.depth - e.meta.depth;
753
+ if (e.meta.isPointerInElement !== t.meta.isPointerInElement)
754
+ return e.meta.isPointerInElement ? -1 : 1;
755
+ }
756
+ return Math.abs(e.meta.overlapPercent - t.meta.overlapPercent) <= 1 ? e.meta.centerDistance - t.meta.centerDistance : t.meta.overlapPercent - e.meta.overlapPercent;
757
+ }, ge = kt().container(Rt).containerBox(Pt).elements(Tt).zones(Bt).filterElements(ve).filterZones(ve).collision(_t).minOverlapPercent(10).sortElements(we).sortZones(we).build();
758
+ function Me(e) {
759
+ const n = (e.collision?.run ?? ge)(e);
760
+ ue(e, e.hovered, n);
761
+ }
762
+ function Gt(e, t) {
763
+ const n = e.collision?.throttle?.value ?? 0;
764
+ if (n <= 0) {
765
+ Me(e);
766
+ return;
767
+ }
768
+ const o = Date.now();
769
+ o - t.value >= n && (t.value = o, Me(e));
770
+ }
771
+ async function Oe(e) {
772
+ const t = e.hovered.droppable.keys().next().value;
773
+ if (!t || z(t, e)) return !0;
774
+ const n = e.entities.droppableMap.get(t), o = M(e, t), s = n?.events?.onDrop?.(o);
775
+ if (s != null && typeof s.then == "function")
776
+ try {
777
+ return await s, !0;
778
+ } catch {
779
+ const i = e.entities.initiatingDraggable;
780
+ return O(e, i, "onSelfDragCancel"), w(e, "onDragCancel"), Be(e, e.hovered), !1;
781
+ }
782
+ return !0;
783
+ }
784
+ function ze(e) {
785
+ const t = e.entities.initiatingDraggable;
786
+ O(e, t, "onSelfDragEnd"), w(e, "onDragEnd"), mt(e, e.hovered);
787
+ }
788
+ function It(e) {
789
+ const t = e.entities.selectingArea;
790
+ if (!t) return;
791
+ const n = e.entities.selectableAreaMap.get(t), o = [...e.entities.selectedSet];
792
+ n?.events?.onSelected?.(o);
793
+ }
794
+ const Kt = (e) => {
795
+ const t = {
796
+ current: null
797
+ }, n = { value: 0 }, o = async () => {
798
+ le(), t.current?.cancel(), t.current = null;
799
+ const a = e.state.value;
800
+ if (a === "dragging") {
801
+ if (!await Oe(e)) {
802
+ j(e), document.removeEventListener("pointerup", o), document.removeEventListener("pointermove", s);
803
+ return;
804
+ }
805
+ ze(e);
806
+ } else a === "selecting" && It(e);
807
+ j(e), document.removeEventListener("pointerup", o), document.removeEventListener("pointermove", s);
808
+ }, s = (a) => {
809
+ if (e.pointer.value) {
810
+ if (e.pointer.value.current = { x: a.clientX, y: a.clientY }, ot(e)) {
811
+ oe(e, a, "onSelfDragStart"), w(e, "onDragStart");
812
+ return;
813
+ }
814
+ if (e.state.value === "dragging") {
815
+ Gt(e, n);
816
+ const l = e.entities.initiatingDraggable;
817
+ O(e, l, "onSelfDragMove"), w(e, "onDragMove");
818
+ }
819
+ e.state.value === "selecting" && ht(e);
778
820
  }
779
821
  };
780
- }), Re = (n) => {
781
- const {
782
- id: e,
783
- elementRef: t,
784
- isDragging: a,
785
- isOvered: l,
786
- isAllowed: s,
787
- isLazyAllowed: o,
788
- registerElement: g,
789
- unregisterElement: i
790
- } = ke(n), { pointerPosition: c } = Y(), { handleDragStart: d } = Ne(), f = (r) => d(r, t, n);
791
- return te(g), ge(i), {
792
- pointerPosition: c,
793
- elementRef: t,
794
- isDragging: a,
795
- isOvered: l,
796
- isAllowed: s,
797
- isLazyAllowed: o,
798
- handleDragStart: f,
799
- id: e
822
+ return { pointerDown: (a) => {
823
+ document.addEventListener("pointerup", o), document.addEventListener("pointermove", s);
824
+ const l = a.target, u = l.closest(
825
+ H.SELECT_AREA
826
+ ), d = l.closest(
827
+ H.DRAGGABLE
828
+ );
829
+ if (e.entities.modifiersSelectableAreaSet.size > 0 && e.entities.modifiersSelectableAreaSet.has(u)) {
830
+ ae(), e.pointer.value = ce(a), e.state.value = "selecting", e.entities.selectingArea = u;
831
+ return;
832
+ }
833
+ if (e.entities.modifiersDraggableSet.size > 0 && e.entities.modifiersDraggableSet.has(d)) {
834
+ const c = e.entities.draggableMap.get(d);
835
+ if (!Pe(l, d, c?.dragHandle))
836
+ return;
837
+ ae(), e.entities.initiatingDraggable = d;
838
+ const g = ke(a, d);
839
+ e.pointer.value = ce(a, g.x, g.y), c?.activation?.distance || c?.activation?.delay ? (e.state.value = "activating", c?.activation?.delay && (e.delay.startTime = Date.now(), t.current = st(e, () => {
840
+ W(e), oe(e, a, "onSelfDragStart"), w(e, "onDragStart");
841
+ }))) : (W(e), oe(e, a, "onSelfDragStart"), w(e, "onDragStart"));
842
+ }
843
+ }, pointerUp: o, pointerMove: s, cleanup: () => {
844
+ t.current?.cancel(), document.removeEventListener("pointerup", o), document.removeEventListener("pointermove", s), e.lib.draggableObserver.disconnect(), e.lib.droppableObserver.disconnect(), e.lib.selectableAreaObserver.disconnect(), e.lib.overlaySizeObserver.disconnect();
845
+ } };
846
+ }, Ht = {
847
+ ArrowUp: { dx: 0, dy: -1 },
848
+ ArrowDown: { dx: 0, dy: 1 },
849
+ ArrowLeft: { dx: -1, dy: 0 },
850
+ ArrowRight: { dx: 1, dy: 0 },
851
+ KeyW: { dx: 0, dy: -1 },
852
+ KeyA: { dx: -1, dy: 0 },
853
+ KeyS: { dx: 0, dy: 1 },
854
+ KeyD: { dx: 1, dy: 0 }
855
+ }, Nt = (e) => (t) => {
856
+ const { keys: n } = e.keyboard;
857
+ if (n.pressedKeys.value.add(t.code), e.state.value === "dragging") {
858
+ if (n.forCancel.includes(t.code)) {
859
+ t.preventDefault(), le(), O(
860
+ e,
861
+ e.entities.initiatingDraggable,
862
+ "onSelfDragCancel"
863
+ ), w(e, "onDragCancel"), Be(e, e.hovered), j(e);
864
+ return;
865
+ }
866
+ if (n.forDrop.includes(t.code)) {
867
+ t.preventDefault(), (async () => (await Oe(e) && ze(e), le(), j(e)))();
868
+ return;
869
+ }
870
+ const s = Ht[t.code];
871
+ if (s && n.forMove.includes(t.code) && e.pointer.value) {
872
+ t.preventDefault();
873
+ const r = n.forMoveFaster.some(
874
+ (u) => n.pressedKeys.value.has(u)
875
+ ), i = e.keyboard.step * (r ? e.keyboard.moveFaster : 1);
876
+ e.pointer.value.current = {
877
+ x: e.pointer.value.current.x + s.dx * i,
878
+ y: e.pointer.value.current.y + s.dy * i
879
+ };
880
+ const l = (e.collision?.run ?? ge)(e);
881
+ ue(e, e.hovered, l), O(
882
+ e,
883
+ e.entities.initiatingDraggable,
884
+ "onSelfDragMove"
885
+ ), w(e, "onDragMove");
886
+ return;
887
+ }
888
+ return;
889
+ }
890
+ if (n.forDrag.includes(t.code)) {
891
+ const s = document.activeElement;
892
+ if (!s) return;
893
+ const r = s.closest(
894
+ H.DRAGGABLE
895
+ );
896
+ if (!r || e.entities.modifiersDraggableSet.size === 0 || !e.entities.modifiersDraggableSet.has(r))
897
+ return;
898
+ const i = e.entities.draggableMap.get(r);
899
+ if (!Pe(s, r, i?.dragHandle, !0))
900
+ return;
901
+ t.preventDefault(), ae();
902
+ const a = r.getBoundingClientRect(), l = a.left + a.width / 2, u = a.top + a.height / 2, d = {
903
+ clientX: l,
904
+ clientY: u
905
+ };
906
+ e.entities.initiatingDraggable = r;
907
+ const c = ke(d, r);
908
+ e.pointer.value = ce(
909
+ d,
910
+ c.x,
911
+ c.y
912
+ ), W(e);
913
+ const f = (e.collision?.run ?? ge)(e);
914
+ ue(e, e.hovered, f), O(e, r, "onSelfDragStart"), w(e, "onDragStart");
915
+ }
916
+ }, Yt = (e) => (t) => {
917
+ e.keyboard.keys.pressedKeys.value.delete(t.code);
918
+ }, Xt = (e) => () => {
919
+ e.keyboard.keys.pressedKeys.value.clear();
920
+ }, se = {
921
+ keyDown: Nt,
922
+ keyUp: Yt,
923
+ clear: Xt
924
+ }, Zt = (e) => () => {
925
+ e.state.value && (e.scrollPosition.x = window.scrollX, e.scrollPosition.y = window.scrollY);
926
+ }, A = 50, Ut = 144, Ee = 1e3 / Ut;
927
+ function $t(e) {
928
+ return e == null ? {
929
+ top: A,
930
+ right: A,
931
+ bottom: A,
932
+ left: A
933
+ } : typeof e == "number" ? {
934
+ top: e,
935
+ right: e,
936
+ bottom: e,
937
+ left: e
938
+ } : {
939
+ top: e.top ?? A,
940
+ right: e.right ?? A,
941
+ bottom: e.bottom ?? A,
942
+ left: e.left ?? A
800
943
  };
801
- }, Ve = (n) => {
802
- const {
803
- zonesMap: e,
804
- hovered: t,
805
- draggingElements: a,
806
- isDragging: l,
807
- handleDropZoneIntersection: s
808
- } = Y(), o = F(null), g = O(
809
- () => t.zone.value === o.value
810
- ), i = O(() => {
811
- if (!o.value || !l.value) return !1;
812
- const r = e.value.get(o.value);
813
- return r != null && r.groups.length ? !Array.from(a.value.values()).some((v) => v.groups.length ? !v.groups.some(
814
- (u) => r.groups.includes(u)
815
- ) : !1) : !0;
816
- }), c = O(() => {
817
- if (!o.value || !l.value || t.zone.value !== o.value) return !1;
818
- const r = e.value.get(o.value);
819
- return r != null && r.groups.length ? !Array.from(a.value.values()).some((v) => !v.groups.some(
820
- (u) => r.groups.includes(u)
821
- )) : !0;
822
- });
823
- return {
824
- elementRef: o,
825
- registerZone: () => {
826
- if (!o.value) throw new Error("elementRef is not set");
827
- s("add", o.value), e.value.set(o.value, {
828
- node: o.value,
829
- groups: (n == null ? void 0 : n.groups) ?? [],
830
- events: (n == null ? void 0 : n.events) ?? {},
831
- data: (n == null ? void 0 : n.data) ?? void 0,
832
- disabled: (n == null ? void 0 : n.disabled) ?? !1
833
- }), o.value.setAttribute("data-dnd-droppable", "true");
944
+ }
945
+ const Vt = {
946
+ getScrollState(e) {
947
+ return {
948
+ scrollTop: e.scrollTop,
949
+ scrollLeft: e.scrollLeft,
950
+ rect: e.getBoundingClientRect()
951
+ };
952
+ },
953
+ setScroll(e, t, n) {
954
+ e.scrollTop = t, e.scrollLeft = n;
955
+ }
956
+ };
957
+ function Fe(e, t, n, o = Vt, s) {
958
+ const { speed: r = 10, disabled: i = !1 } = t, a = $t(t.threshold);
959
+ let l = null, u = null, d = null, c = 0, g = 0;
960
+ const f = (S) => {
961
+ s && (s.value = S);
962
+ }, y = (S) => {
963
+ const _ = e.value, E = n();
964
+ if (!_ || !E || i) {
965
+ f(!1);
966
+ return;
967
+ }
968
+ u || (u = S);
969
+ const X = S - u;
970
+ if (X < Ee) {
971
+ l = requestAnimationFrame(y);
972
+ return;
973
+ }
974
+ const h = r * (X / Ee);
975
+ u = S;
976
+ const {
977
+ scrollTop: v,
978
+ scrollLeft: G,
979
+ rect: Ge
980
+ } = o.getScrollState(_);
981
+ (!d || c !== v || g !== G) && (d = Ge, c = v, g = G);
982
+ let P = !1, ee = v, te = G;
983
+ a.top > 0 && E.y - d.top < a.top ? (ee = v - h, P = !0) : a.bottom > 0 && d.bottom - E.y < a.bottom && (ee = v + h, P = !0), a.left > 0 && E.x - d.left < a.left ? (te = G - h, P = !0) : a.right > 0 && d.right - E.x < a.right && (te = G + h, P = !0), P && o.setScroll(_, ee, te), f(P), l = requestAnimationFrame(y);
984
+ };
985
+ return { run: () => {
986
+ u = null, l = requestAnimationFrame(y);
987
+ }, stop: () => {
988
+ l && (cancelAnimationFrame(l), l = null), d = null, c = 0, g = 0, u = null, f(!1);
989
+ } };
990
+ }
991
+ const qt = {
992
+ getScrollState() {
993
+ return {
994
+ scrollTop: window.scrollY ?? document.documentElement.scrollTop,
995
+ scrollLeft: window.scrollX ?? document.documentElement.scrollLeft,
996
+ rect: new DOMRect(0, 0, window.innerWidth, window.innerHeight)
997
+ };
998
+ },
999
+ setScroll(e, t, n) {
1000
+ window.scrollTo(n, t);
1001
+ }
1002
+ }, Wt = {
1003
+ get value() {
1004
+ return typeof document < "u" ? document.documentElement : null;
1005
+ }
1006
+ };
1007
+ function jt(e, t) {
1008
+ const n = V(!1), s = Fe(
1009
+ Wt,
1010
+ t ?? {},
1011
+ () => {
1012
+ if (e.state.value !== "dragging") return null;
1013
+ const a = e.overlay.position.value, l = e.overlay.size.value;
1014
+ return a ? l?.width && l?.height ? {
1015
+ x: a.x + l.width / 2,
1016
+ y: a.y + l.height / 2
1017
+ } : a : null;
834
1018
  },
835
- unregisterZone: () => {
836
- o.value && (s("remove", o.value), e.value.delete(o.value));
1019
+ qt,
1020
+ n
1021
+ ), r = J(
1022
+ () => e.state.value,
1023
+ (a) => {
1024
+ a === "dragging" ? s.run() : s.stop();
1025
+ }
1026
+ ), i = () => {
1027
+ r(), s.stop();
1028
+ };
1029
+ return Ie(i), { isScrolling: n, stop: i };
1030
+ }
1031
+ const Jt = (e) => {
1032
+ const t = Kt(e), n = se.keyDown(e), o = se.keyUp(e), s = se.clear(e), r = Zt(e);
1033
+ let i = null;
1034
+ J(
1035
+ e.autoScrollViewport,
1036
+ (a) => {
1037
+ i?.(), i = null, (a === !0 || a && typeof a == "object") && (i = jt(
1038
+ e,
1039
+ a === !0 ? {} : a
1040
+ ).stop);
837
1041
  },
838
- isOvered: g,
839
- isAllowed: i,
840
- isLazyAllowed: c
1042
+ { immediate: !0 }
1043
+ ), N(() => {
1044
+ document.addEventListener("pointerdown", t.pointerDown), document.addEventListener("keydown", n), document.addEventListener("keyup", o), document.addEventListener("blur", s), document.addEventListener("scroll", r, !0);
1045
+ }), Y(() => {
1046
+ document.removeEventListener("pointerdown", t.pointerDown), document.removeEventListener("pointerup", t.pointerUp), document.removeEventListener("pointermove", t.pointerMove), document.removeEventListener("keydown", n), document.removeEventListener("keyup", o), document.removeEventListener("blur", s), document.removeEventListener("scroll", r, !0), i?.(), t.cleanup();
1047
+ });
1048
+ }, Q = () => {
1049
+ const e = xe(fe);
1050
+ if (!e) throw Error("DnD provider not found");
1051
+ return e;
1052
+ }, _e = () => {
1053
+ const e = Q();
1054
+ return {
1055
+ overlay: e.overlay,
1056
+ delay: e.delay,
1057
+ distanceProgress: e.distanceProgress,
1058
+ entities: e.entities,
1059
+ pointer: e.pointer,
1060
+ state: e.state,
1061
+ scrollPosition: e.scrollPosition,
1062
+ keyboard: e.keyboard,
1063
+ hovered: e.hovered,
1064
+ collision: e.collision,
1065
+ autoScrollViewport: e.autoScrollViewport
841
1066
  };
842
- }, Fe = (n) => {
843
- const {
844
- elementRef: e,
845
- registerZone: t,
846
- unregisterZone: a,
847
- isOvered: l,
848
- isAllowed: s,
849
- isLazyAllowed: o
850
- } = Ve(n);
851
- return te(t), ge(a), { elementRef: e, isOvered: l, isAllowed: s, isLazyAllowed: o };
852
- }, Xe = (n) => {
853
- const { selectedElements: e, elementsMap: t } = Y(), a = O(
854
- () => n.value ? e.value.has(n.value) : !1
855
- ), l = O(() => {
856
- if (!n.value) return !1;
857
- for (const c of e.value)
858
- if (c && k(c, n.value))
859
- return !0;
860
- return !1;
861
- }), s = O(() => {
862
- if (!n.value) return !1;
863
- for (const c of e.value)
864
- if (c && k(n.value, c))
865
- return !0;
866
- return !1;
867
- }), o = () => {
868
- n.value && e.value.delete(n.value);
869
- }, g = () => {
870
- if (!(!n.value || !t.value.get(n.value))) {
871
- if (l.value)
872
- for (const d of e.value)
873
- d && k(d, n.value) && e.value.delete(d);
874
- if (s.value)
875
- for (const d of e.value)
876
- d && k(n.value, d) && e.value.delete(d);
877
- e.value.add(n.value);
1067
+ }, Qt = /* @__PURE__ */ Ce({
1068
+ __name: "DefaultOverlay",
1069
+ setup(e) {
1070
+ const { entities: t, state: n, overlay: o } = _e();
1071
+ return (s, r) => C(n) === "dragging" ? (x(), $("div", {
1072
+ key: 0,
1073
+ class: "dnd-kit-default-overlay",
1074
+ style: ye({
1075
+ "--position-x": C(o).position.value.x + "px",
1076
+ "--position-y": C(o).position.value.y + "px"
1077
+ })
1078
+ }, [
1079
+ (x(!0), $(ie, null, Ke(C(t).draggingMap, ([i, a]) => (x(), $(ie, null, [
1080
+ C(t).draggableMap.get(i)?.render ? (x(), q(re(C(t).draggableMap.get(i)?.render), { key: 0 })) : (x(), q(re(i.tagName), {
1081
+ key: 1,
1082
+ innerHTML: a.initialOuterHTML,
1083
+ style: ye({
1084
+ width: a.initialRect.width + "px",
1085
+ height: a.initialRect.height + "px"
1086
+ })
1087
+ }, null, 8, ["innerHTML", "style"]))
1088
+ ], 64))), 256))
1089
+ ], 4)) : He("", !0);
1090
+ }
1091
+ }), tn = /* @__PURE__ */ Ce({
1092
+ __name: "DnDProvider",
1093
+ props: {
1094
+ autoScrollViewport: { type: [Object, Boolean, null] },
1095
+ overlayTo: { type: [String, Boolean, null] }
1096
+ },
1097
+ setup(e) {
1098
+ const t = e, n = Ne("overlayRef"), o = ct(n, t);
1099
+ Jt(o);
1100
+ const s = m(
1101
+ () => o.overlay.render.value ?? Qt
1102
+ );
1103
+ return Ye(fe, o), (r, i) => (x(), $(ie, null, [
1104
+ me(r.$slots, "default"),
1105
+ (x(), q(Xe, {
1106
+ to: C(o).overlay.to.value || "body"
1107
+ }, [
1108
+ Ze("div", {
1109
+ ref_key: "overlayRef",
1110
+ ref: n,
1111
+ class: "dnd-kit-overlay-container"
1112
+ }, [
1113
+ me(r.$slots, "overlay", { overlay: s.value }, () => [
1114
+ (x(), q(re(s.value)))
1115
+ ])
1116
+ ], 512)
1117
+ ], 8, ["to"]))
1118
+ ], 64));
1119
+ }
1120
+ });
1121
+ function nn(e, t, n) {
1122
+ const o = Q();
1123
+ let s, r, i;
1124
+ typeof t == "function" ? (s = {}, r = t) : (s = t ?? {}, r = n);
1125
+ const a = m({
1126
+ get() {
1127
+ const c = p(e);
1128
+ return c ? o.entities.selectedSet.has(c) : !1;
1129
+ },
1130
+ set(c) {
1131
+ const g = p(e);
1132
+ g && o.entities.selectedSet[c ? "add" : "delete"](g);
878
1133
  }
1134
+ }), l = m(() => {
1135
+ const c = p(e);
1136
+ return c ? o.entities.draggingMap.has(c) : !1;
1137
+ }), u = m(() => {
1138
+ const c = p(e);
1139
+ return c ? o.entities.allowedDraggableSet.has(c) : !1;
1140
+ }), d = m(() => {
1141
+ const c = p(e);
1142
+ return c ? o.hovered.draggable.get(c) : {
1143
+ bottom: !1,
1144
+ left: !1,
1145
+ right: !1,
1146
+ top: !1,
1147
+ center: !1
1148
+ };
1149
+ });
1150
+ return N(() => {
1151
+ i = p(e), i && (i.addEventListener("dragstart", D), i.addEventListener("drag", D), i.addEventListener("dragend", D), i.setAttribute(L.DRAGGABLE, ""), o.lib.draggableObserver.observe(i), o.entities.draggableMap.set(i, {
1152
+ render: s.render,
1153
+ disabled: s.disabled ?? !1,
1154
+ groups: s.groups ?? [],
1155
+ modifier: s.modifier,
1156
+ events: s.events,
1157
+ payload: r,
1158
+ dragHandle: s.dragHandle,
1159
+ activation: s.activation,
1160
+ placementMargins: s.placementMargins
1161
+ }));
1162
+ }), Y(() => {
1163
+ i && (o.lib.draggableObserver.unobserve(i), o.entities.visibleDraggableSet.delete(i), o.entities.draggableMap.delete(i), o.entities.modifiersDraggableSet.delete(i));
1164
+ }), {
1165
+ selected: a,
1166
+ isDragging: l,
1167
+ isAllowed: u,
1168
+ isDragOver: d
879
1169
  };
1170
+ }
1171
+ const on = (e, t) => {
1172
+ const n = Q(), o = m(() => e.value === n.entities.selectingArea);
1173
+ let s = null;
1174
+ N(() => {
1175
+ s = p(e), s && (s.setAttribute(L.SELECT_AREA, ""), n.lib.selectableAreaObserver.observe(s), n.entities.selectableAreaMap.set(s, {
1176
+ modifier: t?.modifier ?? {
1177
+ keys: ["ControlLeft"],
1178
+ method: "every"
1179
+ },
1180
+ events: t?.events,
1181
+ disabled: t?.disabled ?? !1,
1182
+ groups: t?.groups ?? []
1183
+ }));
1184
+ }), Y(() => {
1185
+ s && (n.lib.selectableAreaObserver.unobserve(s), n.entities.visibleSelectableAreaSet.delete(s), n.entities.modifiersSelectableAreaSet.delete(s), n.entities.selectableAreaMap.delete(s));
1186
+ });
1187
+ const r = m(() => {
1188
+ n.scrollPosition.x, n.scrollPosition.y;
1189
+ const i = n.pointer.value;
1190
+ return !i || n.state.value !== "selecting" || !s ? {} : bt(i.start, i.current, s);
1191
+ });
880
1192
  return {
881
- handleUnselect: o,
882
- handleSelect: g,
883
- handleToggleSelect: () => {
884
- n.value && (e.value.has(n.value) ? o() : g());
885
- },
886
- isSelected: a,
887
- isParentOfSelected: l
1193
+ isSelecting: o,
1194
+ style: r
1195
+ };
1196
+ };
1197
+ function sn(e, t) {
1198
+ const n = xe(fe);
1199
+ if (!n) throw Error("DnD provider not found");
1200
+ let o = null;
1201
+ return N(() => {
1202
+ o = p(e), o && (o.setAttribute(L.CONSTRAINT_AREA, ""), n.entities.constraintsAreaMap.set(o, {
1203
+ axis: t?.axis || "both",
1204
+ restrictToArea: t?.restrictToArea || !1
1205
+ }));
1206
+ }), Y(() => {
1207
+ o && n.entities.constraintsAreaMap.delete(o);
1208
+ }), {};
1209
+ }
1210
+ function rn(e, t, n) {
1211
+ const o = Q();
1212
+ let s = null, r, i;
1213
+ typeof t == "function" ? (r = {}, i = t) : (r = t ?? {}, i = n);
1214
+ const a = m(() => {
1215
+ const u = p(e);
1216
+ return u ? o.entities.allowedDroppableSet.has(u) : !1;
1217
+ }), l = m(() => {
1218
+ const u = p(e);
1219
+ return u ? o.hovered.droppable.get(u) : {
1220
+ bottom: !1,
1221
+ left: !1,
1222
+ right: !1,
1223
+ top: !1,
1224
+ center: !1
1225
+ };
1226
+ });
1227
+ return N(() => {
1228
+ s = p(e), s && (s.setAttribute(L.DROPPABLE, ""), o.lib.droppableObserver.observe(s), o.entities.droppableMap.set(s, {
1229
+ disabled: r.disabled ?? !1,
1230
+ groups: r.groups ?? [],
1231
+ events: r.events,
1232
+ payload: i
1233
+ }));
1234
+ }), Y(() => {
1235
+ s && (o.lib.droppableObserver.unobserve(s), o.entities.visibleDroppableSet.delete(s), o.entities.droppableMap.delete(s));
1236
+ }), {
1237
+ isAllowed: a,
1238
+ isDragOver: l
888
1239
  };
1240
+ }
1241
+ const an = (e, t) => {
1242
+ const n = _e(), o = V(!1), r = Fe(
1243
+ e,
1244
+ t ?? {},
1245
+ () => {
1246
+ if (n.state.value !== "dragging") return null;
1247
+ const i = n.overlay.position.value, a = n.overlay.size.value;
1248
+ return i ? a?.width && a?.height ? {
1249
+ x: i.x + a.width / 2,
1250
+ y: i.y + a.height / 2
1251
+ } : i : null;
1252
+ },
1253
+ void 0,
1254
+ o
1255
+ );
1256
+ return J(
1257
+ () => n.state.value,
1258
+ (i) => {
1259
+ i === "dragging" ? r.run() : r.stop();
1260
+ }
1261
+ ), { isScrolling: o };
889
1262
  };
1263
+ function Ae(e, t) {
1264
+ return t <= 0 ? e : Math.round(e / t) * t;
1265
+ }
1266
+ function ln(e, t) {
1267
+ const n = t && "grid" in t && t.grid != null, o = t ? n ? t.grid : t.gridX : 1, s = t ? n ? t.grid : t.gridY : 1;
1268
+ return m(() => {
1269
+ const { x: r, y: i } = e.value;
1270
+ return {
1271
+ x: Ae(r, o),
1272
+ y: Ae(i, s)
1273
+ };
1274
+ });
1275
+ }
890
1276
  export {
891
- oe as DnDOperations,
892
- He as default,
893
- $ as getBoundingBox,
894
- Y as useDnDStore,
895
- Ce as useDragContainer,
896
- Re as useDraggable,
897
- Fe as useDroppable,
898
- Xe as useSelection
1277
+ tn as DnDProvider,
1278
+ kt as createSensor,
1279
+ ge as defaultCollisionDetection,
1280
+ an as makeAutoScroll,
1281
+ sn as makeConstraintArea,
1282
+ nn as makeDraggable,
1283
+ rn as makeDroppable,
1284
+ on as makeSelectionArea,
1285
+ ln as makeSnappedOverlayPosition,
1286
+ _e as useDnDProvider
899
1287
  };
900
- //# sourceMappingURL=vue-dnd-kit-core.es.js.map