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