import { A as e, B as t, E as n, G as r, H as i, I as a, J as o, K as s, M as c, N as l, e as u, f as d, g as f, h as p, i as m, j as h, k as g, l as _, m as v, n as y, o as b, p as x, t as S, u as C, v as w, w as T, y as E, z as D } from "./react.BZZIbN3T.js";
import { useCallback as O } from "react";
var ee = Object.create, k = Object.defineProperty, te = Object.defineProperties, ne = Object.getOwnPropertyDescriptor, re = Object.getOwnPropertyDescriptors, A = Object.getOwnPropertySymbols, ie = Object.prototype.hasOwnProperty, ae = Object.prototype.propertyIsEnumerable, oe = (e, t) => (t = Symbol[e]) ? t : Symbol.for("Symbol." + e), j = (e) => {
	throw TypeError(e);
}, M = (e, t, n) => t in e ? k(e, t, {
	enumerable: !0,
	configurable: !0,
	writable: !0,
	value: n
}) : e[t] = n, se = (e, t) => {
	for (var n in t ||= {}) ie.call(t, n) && M(e, n, t[n]);
	if (A) for (var n of A(t)) ae.call(t, n) && M(e, n, t[n]);
	return e;
}, ce = (e, t) => te(e, re(t)), le = (e, t) => {
	var n = {};
	for (var r in e) ie.call(e, r) && t.indexOf(r) < 0 && (n[r] = e[r]);
	if (e != null && A) for (var r of A(e)) t.indexOf(r) < 0 && ae.call(e, r) && (n[r] = e[r]);
	return n;
}, ue = (e) => {
	var t;
	return [
		,
		,
		,
		ee((t = void 0, null))
	];
}, de = [
	"class",
	"method",
	"getter",
	"setter",
	"accessor",
	"field",
	"value",
	"get",
	"set"
], N = (e) => e !== void 0 && typeof e != "function" ? j("Function expected") : e, fe = (e, t, n, r, i) => ({
	kind: de[e],
	name: t,
	metadata: r,
	addInitializer: (e) => n._ ? j("Already initialized") : i.push(N(e || null))
}), pe = (e, t) => M(t, oe("metadata"), e[3]), P = (e, t, n, r) => {
	for (var i = 0, a = e[t >> 1], o = a && a.length; i < o; i++) t & 1 ? a[i].call(n) : r = a[i].call(n, r);
	return r;
}, me = (e, t, n, r, i, a) => {
	for (var o, s, c, l, u, d = t & 7, f = !1, p = !1, m = e.length + 1, h = de[d + 5], g = e[m - 1] = [], _ = e[m] || (e[m] = []), v = (i = i.prototype, ne({
		get [n]() {
			return F(this, a);
		},
		set [n](e) {
			return L(this, a, e);
		}
	}, n)), y = r.length - 1; y >= 0; y--) l = fe(d, n, c = {}, e[3], _), l.static = f, l.private = p, u = l.access = { has: (e) => n in e }, u.get = (e) => e[n], u.set = (e, t) => e[n] = t, s = (0, r[y])({
		get: v.get,
		set: v.set
	}, l), c._ = 1, s === void 0 ? N(s) && (v[h] = s) : typeof s != "object" || !s ? j("Object expected") : (N(o = s.get) && (v.get = o), N(o = s.set) && (v.set = o), N(o = s.init) && g.unshift(o));
	return v && k(i, n, v), i;
}, he = (e, t, n) => t.has(e) || j("Cannot " + n), F = (e, t, n) => (he(e, t, "read from private field"), t.get(e)), I = (e, t, n) => t.has(e) ? j("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), L = (e, t, n, r) => (he(e, t, "write to private field"), t.set(e, n), n);
function R(e) {
	return e instanceof Q || e instanceof Z;
}
var z = 10, ge = class extends n {
	constructor(n) {
		super(n);
		let i = s(() => {
			let { dragOperation: t } = n;
			if (e(t.activatorEvent) && R(t.source) && t.status.initialized) {
				let e = n.registry.plugins.get(y);
				if (e) return e.disable(), () => e.enable();
			}
		}), a = n.monitor.addEventListener("dragmove", (n, i) => {
			queueMicrotask(() => {
				if (this.disabled || n.defaultPrevented || !n.nativeEvent) return;
				let { dragOperation: a } = i;
				if (!e(n.nativeEvent) || !R(a.source) || !a.shape) return;
				let { actions: o, collisionObserver: s, registry: c } = i, { by: u } = n;
				if (!u) return;
				let d = _e(u), { source: f, target: p } = a, { center: m } = a.shape.current, h = [], g = [];
				l(() => {
					for (let e of c.droppables) {
						let { id: t } = e;
						if (!e.accepts(f) || t === p?.id && R(e) || !e.element) continue;
						let n = e.shape, r = new S(e.element, { getBoundingClientRect: (e) => D(e, void 0, .2) });
						if (!r.height || !r.width) continue;
						(d == "down" && m.y + z < r.center.y || d == "up" && m.y - z > r.center.y || d == "left" && m.x - z > r.center.x || d == "right" && m.x + z < r.center.x) && (h.push(e), e.shape = r, g.push(() => e.shape = n));
					}
				}), n.preventDefault(), s.disable();
				let _ = s.computeCollisions(h, b);
				l(() => g.forEach((e) => e()));
				let [v] = _;
				if (!v) return;
				let { id: y } = v, { index: x, group: C } = f.sortable;
				o.setDropTarget(y).then(() => {
					let { source: e, target: n, shape: i } = a;
					if (!e || !R(e) || !i) return;
					let { index: c, group: l, target: u } = e.sortable, d = x !== c || C !== l, f = d ? u : n?.element;
					if (!f) return;
					t(f);
					let p = new S(f);
					if (!p) return;
					let m = r.delta(p, r.from(i.current.boundingRectangle), e.alignment);
					o.move({ by: m }), d ? o.setDropTarget(e.id).then(() => s.enable()) : s.enable();
				});
			});
		});
		this.destroy = () => {
			a(), i();
		};
	}
};
function _e(e) {
	let { x: t, y: n } = e;
	if (t > 0) return "right";
	if (t < 0) return "left";
	if (n > 0) return "down";
	if (n < 0) return "up";
}
var ve = Object.defineProperty, ye = Object.defineProperties, be = Object.getOwnPropertyDescriptors, B = Object.getOwnPropertySymbols, xe = Object.prototype.hasOwnProperty, Se = Object.prototype.propertyIsEnumerable, V = (e, t, n) => t in e ? ve(e, t, {
	enumerable: !0,
	configurable: !0,
	writable: !0,
	value: n
}) : e[t] = n, Ce = (e, t) => {
	for (var n in t ||= {}) xe.call(t, n) && V(e, n, t[n]);
	if (B) for (var n of B(t)) Se.call(t, n) && V(e, n, t[n]);
	return e;
}, we = (e, t) => ye(e, be(t));
function Te(e, t, n) {
	if (t === n) return e;
	let r = e.slice();
	return r.splice(n, 0, r.splice(t, 1)[0]), r;
}
function Ee(e, t, n) {
	var r, i;
	let { source: a, target: o, canceled: s } = t.operation;
	if (!a || !o || s) return "preventDefault" in t && t.preventDefault(), e;
	let c = (e, t) => e === t || typeof e == "object" && "id" in e && e.id === t;
	if (Array.isArray(e)) {
		let t = e.findIndex((e) => c(e, a.id)), r = e.findIndex((e) => c(e, o.id));
		if (t === -1 || r === -1) return e;
		if (!s && "index" in a && typeof a.index == "number") {
			let r = a.index;
			if (r !== t) return n(e, t, r);
		}
		return n(e, t, r);
	}
	let l = Object.entries(e), u = -1, d, f = -1, p;
	for (let [e, t] of l) if (u === -1 && (u = t.findIndex((e) => c(e, a.id)), u !== -1 && (d = e)), f === -1 && (f = t.findIndex((e) => c(e, o.id)), f !== -1 && (p = e)), u !== -1 && f !== -1) break;
	if (!a.manager) return e;
	let { dragOperation: m } = a.manager, h = (i = (r = m.shape)?.current.center) ?? m.position.current;
	if (p == null && o.id in e) {
		let t = o.shape && h.y > o.shape.center.y ? e[o.id].length : 0;
		p = o.id, f = t;
	}
	if (d == null || p == null || d === p && u === f) return "preventDefault" in t && t.preventDefault(), e;
	if (d === p) return we(Ce({}, e), { [d]: n(e[d], u, f) });
	let g = o.shape && Math.round(h.y) > Math.round(o.shape.center.y), _ = g ? 1 : 0, v = e[d][u];
	return we(Ce({}, e), {
		[d]: [...e[d].slice(0, u), ...e[d].slice(u + 1)],
		[p]: [
			...e[p].slice(0, f + _),
			v,
			...e[p].slice(f + _)
		]
	});
}
function De(e, t) {
	return Ee(e, t, Te);
}
var Oe = "__default__", ke = class extends n {
	constructor(e) {
		super(e);
		let t = () => {
			let t = /* @__PURE__ */ new Map();
			for (let n of e.registry.droppables) if (n instanceof Q) {
				let { sortable: e } = n, { group: r } = e, i = t.get(r);
				i || (i = /* @__PURE__ */ new Set(), t.set(r, i)), i.add(e);
			}
			for (let [e, n] of t) t.set(e, new Set(H(n)));
			return t;
		}, n = [e.monitor.addEventListener("dragover", (e, n) => {
			if (this.disabled) return;
			let { dragOperation: r } = n, { source: i, target: a } = r;
			if (!R(i) || !R(a) || i.sortable === a.sortable) return;
			let o = t(), s = i.sortable.group === a.sortable.group, c = o.get(i.sortable.group), u = s ? c : o.get(a.sortable.group);
			!c || !u || queueMicrotask(() => {
				e.defaultPrevented || n.renderer.rendering.then(() => {
					var r, d, f;
					let p = t();
					for (let [e, t] of o.entries()) {
						let n = Array.from(t).entries();
						for (let [t, i] of n) if (i.index !== t || i.group !== e || !(r = p.get(e))?.has(i)) return;
					}
					let m = i.sortable.element, h = a.sortable.element;
					if (!h || !m || !s && a.id === i.sortable.group) return;
					let g = H(c), _ = s ? g : H(u), v = (d = i.sortable.group) ?? Oe, y = (f = a.sortable.group) ?? Oe, b = {
						[v]: g,
						[y]: _
					}, x = De(b, e);
					if (b === x) return;
					let S = x[y].indexOf(i.sortable), C = x[y].indexOf(a.sortable);
					n.collisionObserver.disable(), Ae(m, S, h, C), l(() => {
						for (let [e, t] of x[v].entries()) t.index = e;
						if (!s) for (let [e, t] of x[y].entries()) t.group = a.sortable.group, t.index = e;
					}), n.actions.setDropTarget(i.id).then(() => n.collisionObserver.enable());
				});
			});
		}), e.monitor.addEventListener("dragend", (e, n) => {
			if (!e.canceled) return;
			let { dragOperation: r } = n, { source: i } = r;
			R(i) && (i.sortable.initialIndex === i.sortable.index && i.sortable.initialGroup === i.sortable.group || queueMicrotask(() => {
				let e = t(), r = e.get(i.sortable.initialGroup);
				r && n.renderer.rendering.then(() => {
					for (let [t, n] of e.entries()) {
						let e = Array.from(n).entries();
						for (let [n, r] of e) if (r.index !== n || r.group !== t) return;
					}
					let t = H(r), n = i.sortable.element, a = t[i.sortable.initialIndex], o = a?.element;
					!a || !o || !n || (Ae(n, a.index, o, i.index), l(() => {
						for (let [t, n] of e.entries()) {
							let e = Array.from(n).values();
							for (let t of e) t.index = t.initialIndex, t.group = t.initialGroup;
						}
					}));
				});
			}));
		})];
		this.destroy = () => {
			for (let e of n) e();
		};
	}
};
function Ae(e, t, n, r) {
	let i = r < t ? "afterend" : "beforebegin";
	n.insertAdjacentElement(i, e);
}
function je(e, t) {
	return e.index - t.index;
}
function H(e) {
	return Array.from(e).sort(je);
}
var Me = [ge, ke], Ne = {
	duration: 250,
	easing: "cubic-bezier(0.25, 1, 0.5, 1)",
	idle: !1
}, U = new i(), Pe, Fe, W, G, K, q, J, Y;
Fe = [o], Pe = [o];
var X = class {
	constructor(e, t) {
		I(this, G, P(W, 8, this)), P(W, 11, this), I(this, K), I(this, q), I(this, J, P(W, 12, this)), P(W, 15, this), I(this, Y), this.register = () => (l(() => {
			var e, t;
			(e = this.manager) == null || e.registry.register(this.droppable), (t = this.manager) == null || t.registry.register(this.draggable);
		}), () => this.unregister()), this.unregister = () => {
			l(() => {
				var e, t;
				(e = this.manager) == null || e.registry.unregister(this.droppable), (t = this.manager) == null || t.registry.unregister(this.draggable);
			});
		}, this.destroy = () => {
			l(() => {
				this.droppable.destroy(), this.draggable.destroy();
			});
		};
		var n = e, { effects: r = () => [], group: i, index: a, sensors: o, type: s, transition: u = Ne, plugins: d = Me } = n, f = le(n, [
			"effects",
			"group",
			"index",
			"sensors",
			"type",
			"transition",
			"plugins"
		]);
		this.droppable = new Q(f, t, this), this.draggable = new Z(ce(se({}, f), {
			effects: () => [
				() => {
					var e, t, n;
					let r = (e = this.manager)?.dragOperation.status;
					r?.initializing && this.id === (n = (t = this.manager)?.dragOperation.source)?.id && U.clear(this.manager), r?.dragging && U.set(this.manager, this.id, c(() => ({
						initialIndex: this.index,
						initialGroup: this.group
					})));
				},
				() => {
					let { index: e, group: t, manager: n } = this, r = F(this, q), i = F(this, K);
					(e !== r || t !== i) && (L(this, q, e), L(this, K, t), this.animate());
				},
				() => {
					let { target: e } = this, { feedback: t, isDragSource: n } = this.draggable;
					t == "move" && n && (this.droppable.disabled = !e);
				},
				() => {
					let { manager: e } = this;
					for (let t of d) e?.registry.register(t);
				},
				...r()
			],
			type: s,
			sensors: o
		}), t, this), L(this, Y, f.element), this.manager = t, this.index = a, L(this, q, a), this.group = i, L(this, K, i), this.type = s, this.transition = u;
	}
	get initialIndex() {
		var e, t;
		return (t = (e = U.get(this.manager, this.id))?.initialIndex) ?? this.index;
	}
	get initialGroup() {
		var e, t;
		return (t = (e = U.get(this.manager, this.id))?.initialGroup) ?? this.group;
	}
	animate() {
		c(() => {
			let { manager: e, transition: t } = this, { shape: n } = this.droppable;
			if (!e) return;
			let { idle: r } = e.dragOperation.status;
			!n || !t || r && !t.idle || e.renderer.rendering.then(() => {
				let { element: r } = this;
				if (!r) return;
				let i = this.refreshShape();
				if (!i) return;
				let a = {
					x: n.boundingRectangle.left - i.boundingRectangle.left,
					y: n.boundingRectangle.top - i.boundingRectangle.top
				}, { translate: o } = E(r), s = T(r, o, !1), c = T(r, o);
				(a.x || a.y) && w({
					element: r,
					keyframes: { translate: [`${s.x + a.x}px ${s.y + a.y}px ${s.z}`, `${c.x}px ${c.y}px ${c.z}`] },
					options: t
				}).then(() => {
					e.dragOperation.status.dragging || (this.droppable.shape = void 0);
				});
			});
		});
	}
	get manager() {
		return this.draggable.manager;
	}
	set manager(e) {
		l(() => {
			this.draggable.manager = e, this.droppable.manager = e;
		});
	}
	set element(e) {
		l(() => {
			let t = F(this, Y), n = this.droppable.element, r = this.draggable.element;
			(!n || n === t) && (this.droppable.element = e), (!r || r === t) && (this.draggable.element = e), L(this, Y, e);
		});
	}
	get element() {
		var e, t;
		let n = F(this, Y);
		if (n) return (t = (e = C.get(n)) ?? n) ?? this.droppable.element;
	}
	set target(e) {
		this.droppable.element = e;
	}
	get target() {
		return this.droppable.element;
	}
	set source(e) {
		this.draggable.element = e;
	}
	get source() {
		return this.draggable.element;
	}
	get disabled() {
		return this.draggable.disabled && this.droppable.disabled;
	}
	set feedback(e) {
		this.draggable.feedback = e;
	}
	set disabled(e) {
		l(() => {
			this.droppable.disabled = e, this.draggable.disabled = e;
		});
	}
	set data(e) {
		l(() => {
			this.droppable.data = e, this.draggable.data = e;
		});
	}
	set handle(e) {
		this.draggable.handle = e;
	}
	set id(e) {
		l(() => {
			this.droppable.id = e, this.draggable.id = e;
		});
	}
	get id() {
		return this.droppable.id;
	}
	set sensors(e) {
		this.draggable.sensors = e;
	}
	set modifiers(e) {
		this.draggable.modifiers = e;
	}
	set collisionPriority(e) {
		this.droppable.collisionPriority = e;
	}
	set collisionDetector(e) {
		this.droppable.collisionDetector = e ?? x;
	}
	set alignment(e) {
		this.draggable.alignment = e;
	}
	get alignment() {
		return this.draggable.alignment;
	}
	set type(e) {
		l(() => {
			this.droppable.type = e, this.draggable.type = e;
		});
	}
	get type() {
		return this.draggable.type;
	}
	set accept(e) {
		this.droppable.accept = e;
	}
	get accept() {
		return this.droppable.accept;
	}
	get isDropTarget() {
		return this.droppable.isDropTarget;
	}
	get isDragSource() {
		return this.draggable.isDragSource;
	}
	get isDragging() {
		return this.draggable.isDragging;
	}
	get isDropping() {
		return this.draggable.isDropping;
	}
	get status() {
		return this.draggable.status;
	}
	refreshShape() {
		return this.droppable.refreshShape();
	}
	accepts(e) {
		return this.droppable.accepts(e);
	}
};
W = ue(), G = /* @__PURE__ */ new WeakMap(), K = /* @__PURE__ */ new WeakMap(), q = /* @__PURE__ */ new WeakMap(), J = /* @__PURE__ */ new WeakMap(), Y = /* @__PURE__ */ new WeakMap(), me(W, 4, "index", Fe, X, G), me(W, 4, "group", Pe, X, J), pe(W, X);
var Z = class extends _ {
	constructor(e, t, n) {
		super(e, t), this.sortable = n;
	}
	get index() {
		return this.sortable.index;
	}
}, Q = class extends v {
	constructor(e, t, n) {
		super(e, t), this.sortable = n;
	}
}, Ie = Object.defineProperty, Le = Object.defineProperties, Re = Object.getOwnPropertyDescriptors, ze = Object.getOwnPropertySymbols, Be = Object.prototype.hasOwnProperty, Ve = Object.prototype.propertyIsEnumerable, He = (e, t, n) => t in e ? Ie(e, t, {
	enumerable: !0,
	configurable: !0,
	writable: !0,
	value: n
}) : e[t] = n, $ = (e, t) => {
	for (var n in t ||= {}) Be.call(t, n) && He(e, n, t[n]);
	if (ze) for (var n of ze(t)) Ve.call(t, n) && He(e, n, t[n]);
	return e;
}, Ue = (e, t) => Le(e, Re(t));
function We(e) {
	let { accept: t, collisionDetector: n, collisionPriority: r, id: i, data: o, element: s, handle: c, index: _, group: v, disabled: y, feedback: b, modifiers: x, sensors: S, target: C, type: w } = e, T = $($({}, Ne), e.transition), E = u((t) => new X(Ue($({}, e), {
		transition: T,
		register: !1,
		handle: g(c),
		element: g(s),
		target: g(C),
		feedback: b
	}), t)), D = d(E, Ge);
	return h(i, () => E.id = i), p(() => {
		l(() => {
			E.group = v, E.index = _;
		});
	}, [
		E,
		v,
		_
	]), h(w, () => E.type = w), h(t, () => E.accept = t, void 0, a), h(o, () => o && (E.data = o)), h(_, () => {
		var e;
		(e = E.manager)?.dragOperation.status.idle && T?.idle && E.refreshShape();
	}, f), m(c, (e) => E.handle = e), m(s, (e) => E.element = e), m(C, (e) => E.target = e), h(y, () => E.disabled = y === !0), h(S, () => E.sensors = S), h(n, () => E.collisionDetector = n), h(r, () => E.collisionPriority = r), h(b, () => E.feedback = b ?? "default"), h(T, () => E.transition = T, void 0, a), h(x, () => E.modifiers = x, void 0, a), h(e.alignment, () => E.alignment = e.alignment), {
		sortable: D,
		get isDragging() {
			return D.isDragging;
		},
		get isDropping() {
			return D.isDropping;
		},
		get isDragSource() {
			return D.isDragSource;
		},
		get isDropTarget() {
			return D.isDropTarget;
		},
		handleRef: O((e) => {
			E.handle = e ?? void 0;
		}, [E]),
		ref: O((e) => {
			var t, n;
			!e && (t = E.element)?.isConnected && !(n = E.manager)?.dragOperation.status.idle || (E.element = e ?? void 0);
		}, [E]),
		sourceRef: O((e) => {
			var t, n;
			!e && (t = E.source)?.isConnected && !(n = E.manager)?.dragOperation.status.idle || (E.source = e ?? void 0);
		}, [E]),
		targetRef: O((e) => {
			var t, n;
			!e && (t = E.target)?.isConnected && !(n = E.manager)?.dragOperation.status.idle || (E.target = e ?? void 0);
		}, [E])
	};
}
function Ge(e, t, n) {
	return !!(e === "isDragSource" && !n && t);
}
export { We as b };

//# sourceMappingURL=sortable.CwZ2HUCK.js.map