"use client";
import H, { memo as cn, useReducer as un, useState as _, useRef as F, useMemo as M, useCallback as Q, useEffect as N, createContext as Ae, useContext as Pe } from "react";
import { unstable_batchedUpdates as ke, createPortal as dn } from "react-dom";
import { useLatestValue as tt, useUniqueId as nt, getEventCoordinates as Je, getWindow as Z, add as pe, useIsomorphicLayoutEffect as be, getOwnerDocument as we, isKeyboardEvent as zt, subtract as ze, useLazyMemo as Me, isHTMLElement as We, useNodeRef as Ve, canUseDOM as rt, useInterval as fn, usePrevious as Ge, findFirstFocusableNode as hn, useEvent as Ft, isWindow as ot, isNode as gn, isDocument as $t, isSVGElement as vn } from "../../utilities/dist/utilities.esm.js";
import { useAnnouncement as pn, HiddenText as bn, LiveRegion as wn } from "../../accessibility/dist/accessibility.esm.js";
const Wt = /* @__PURE__ */ Ae(null);
function yn(e) {
  const t = Pe(Wt);
  N(() => {
    if (!t)
      throw new Error("useDndMonitor must be used within a children of <DndContext>");
    return t(e);
  }, [e, t]);
}
function mn() {
  const [e] = _(() => /* @__PURE__ */ new Set()), t = Q((r) => (e.add(r), () => e.delete(r)), [e]);
  return [Q((r) => {
    let {
      type: o,
      event: i
    } = r;
    e.forEach((s) => {
      var l;
      return (l = s[o]) == null ? void 0 : l.call(s, i);
    });
  }, [e]), t];
}
const Dn = {
  draggable: `
    To pick up a draggable item, press the space bar.
    While dragging, use the arrow keys to move the item.
    Press space again to drop the item in its new position, or press escape to cancel.
  `
}, xn = {
  onDragStart(e) {
    let {
      active: t
    } = e;
    return "Picked up draggable item " + t.id + ".";
  },
  onDragOver(e) {
    let {
      active: t,
      over: n
    } = e;
    return n ? "Draggable item " + t.id + " was moved over droppable area " + n.id + "." : "Draggable item " + t.id + " is no longer over a droppable area.";
  },
  onDragEnd(e) {
    let {
      active: t,
      over: n
    } = e;
    return n ? "Draggable item " + t.id + " was dropped over droppable area " + n.id : "Draggable item " + t.id + " was dropped.";
  },
  onDragCancel(e) {
    let {
      active: t
    } = e;
    return "Dragging was cancelled. Draggable item " + t.id + " was dropped.";
  }
};
function Cn(e) {
  let {
    announcements: t = xn,
    container: n,
    hiddenTextDescribedById: r,
    screenReaderInstructions: o = Dn
  } = e;
  const {
    announce: i,
    announcement: s
  } = pn(), l = nt("DndLiveRegion"), [a, c] = _(!1);
  if (N(() => {
    c(!0);
  }, []), yn(M(() => ({
    onDragStart(u) {
      let {
        active: g
      } = u;
      i(t.onDragStart({
        active: g
      }));
    },
    onDragMove(u) {
      let {
        active: g,
        over: h
      } = u;
      t.onDragMove && i(t.onDragMove({
        active: g,
        over: h
      }));
    },
    onDragOver(u) {
      let {
        active: g,
        over: h
      } = u;
      i(t.onDragOver({
        active: g,
        over: h
      }));
    },
    onDragEnd(u) {
      let {
        active: g,
        over: h
      } = u;
      i(t.onDragEnd({
        active: g,
        over: h
      }));
    },
    onDragCancel(u) {
      let {
        active: g,
        over: h
      } = u;
      i(t.onDragCancel({
        active: g,
        over: h
      }));
    }
  }), [i, t])), !a)
    return null;
  const d = H.createElement(H.Fragment, null, H.createElement(bn, {
    id: r,
    value: o.draggable
  }), H.createElement(wn, {
    id: l,
    announcement: s
  }));
  return n ? dn(d, n) : d;
}
var L;
(function(e) {
  e.DragStart = "dragStart", e.DragMove = "dragMove", e.DragEnd = "dragEnd", e.DragCancel = "dragCancel", e.DragOver = "dragOver", e.RegisterDroppable = "registerDroppable", e.SetDroppableDisabled = "setDroppableDisabled", e.UnregisterDroppable = "unregisterDroppable";
})(L || (L = {}));
function Fe() {
}
const K = /* @__PURE__ */ Object.freeze({
  x: 0,
  y: 0
});
function Sn(e, t) {
  let {
    data: {
      value: n
    }
  } = e, {
    data: {
      value: r
    }
  } = t;
  return r - n;
}
function Rn(e, t) {
  if (!e || e.length === 0)
    return null;
  const [n] = e;
  return n[t];
}
function En(e, t) {
  const n = Math.max(t.top, e.top), r = Math.max(t.left, e.left), o = Math.min(t.left + t.width, e.left + e.width), i = Math.min(t.top + t.height, e.top + e.height), s = o - r, l = i - n;
  if (r < o && n < i) {
    const a = t.width * t.height, c = e.width * e.height, d = s * l, u = d / (a + c - d);
    return Number(u.toFixed(4));
  }
  return 0;
}
const An = (e) => {
  let {
    collisionRect: t,
    droppableRects: n,
    droppableContainers: r
  } = e;
  const o = [];
  for (const i of r) {
    const {
      id: s
    } = i, l = n.get(s);
    if (l) {
      const a = En(l, t);
      a > 0 && o.push({
        id: s,
        data: {
          droppableContainer: i,
          value: a
        }
      });
    }
  }
  return o.sort(Sn);
};
function Mn(e, t, n) {
  return {
    ...e,
    scaleX: t && n ? t.width / n.width : 1,
    scaleY: t && n ? t.height / n.height : 1
  };
}
function Ut(e, t) {
  return e && t ? {
    x: e.left - t.left,
    y: e.top - t.top
  } : K;
}
function Nn(e) {
  return function(n) {
    for (var r = arguments.length, o = new Array(r > 1 ? r - 1 : 0), i = 1; i < r; i++)
      o[i - 1] = arguments[i];
    return o.reduce((s, l) => ({
      ...s,
      top: s.top + e * l.y,
      bottom: s.bottom + e * l.y,
      left: s.left + e * l.x,
      right: s.right + e * l.x
    }), {
      ...n
    });
  };
}
const On = /* @__PURE__ */ Nn(1);
function Ln(e) {
  if (e.startsWith("matrix3d(")) {
    const t = e.slice(9, -1).split(/, /);
    return {
      x: +t[12],
      y: +t[13],
      scaleX: +t[0],
      scaleY: +t[5]
    };
  } else if (e.startsWith("matrix(")) {
    const t = e.slice(7, -1).split(/, /);
    return {
      x: +t[4],
      y: +t[5],
      scaleX: +t[0],
      scaleY: +t[3]
    };
  }
  return null;
}
function Tn(e, t, n) {
  const r = Ln(t);
  if (!r)
    return e;
  const {
    scaleX: o,
    scaleY: i,
    x: s,
    y: l
  } = r, a = e.left - s - (1 - o) * parseFloat(n), c = e.top - l - (1 - i) * parseFloat(n.slice(n.indexOf(" ") + 1)), d = o ? e.width / o : e.width, u = i ? e.height / i : e.height;
  return {
    width: d,
    height: u,
    top: c,
    right: a + d,
    bottom: c + u,
    left: a
  };
}
const In = {
  ignoreTransform: !1
};
function Ne(e, t) {
  t === void 0 && (t = In);
  let n = e.getBoundingClientRect();
  if (t.ignoreTransform) {
    const {
      transform: c,
      transformOrigin: d
    } = Z(e).getComputedStyle(e);
    c && (n = Tn(n, c, d));
  }
  const {
    top: r,
    left: o,
    width: i,
    height: s,
    bottom: l,
    right: a
  } = n;
  return {
    top: r,
    left: o,
    width: i,
    height: s,
    bottom: l,
    right: a
  };
}
function At(e) {
  return Ne(e, {
    ignoreTransform: !0
  });
}
function kn(e) {
  const t = e.innerWidth, n = e.innerHeight;
  return {
    top: 0,
    left: 0,
    right: t,
    bottom: n,
    width: t,
    height: n
  };
}
function Bn(e, t) {
  return t === void 0 && (t = Z(e).getComputedStyle(e)), t.position === "fixed";
}
function Pn(e, t) {
  t === void 0 && (t = Z(e).getComputedStyle(e));
  const n = /(auto|scroll|overlay)/;
  return ["overflow", "overflowX", "overflowY"].some((o) => {
    const i = t[o];
    return typeof i == "string" ? n.test(i) : !1;
  });
}
function it(e, t) {
  const n = [];
  function r(o) {
    if (t != null && n.length >= t || !o)
      return n;
    if ($t(o) && o.scrollingElement != null && !n.includes(o.scrollingElement))
      return n.push(o.scrollingElement), n;
    if (!We(o) || vn(o) || n.includes(o))
      return n;
    const i = Z(e).getComputedStyle(o);
    return o !== e && Pn(o, i) && n.push(o), Bn(o, i) ? n : r(o.parentNode);
  }
  return e ? r(e) : n;
}
function Xt(e) {
  const [t] = it(e, 1);
  return t ?? null;
}
function je(e) {
  return !rt || !e ? null : ot(e) ? e : gn(e) ? $t(e) || e === we(e).scrollingElement ? window : We(e) ? e : null : null;
}
function _t(e) {
  return ot(e) ? e.scrollX : e.scrollLeft;
}
function Kt(e) {
  return ot(e) ? e.scrollY : e.scrollTop;
}
function Qe(e) {
  return {
    x: _t(e),
    y: Kt(e)
  };
}
var R;
(function(e) {
  e[e.Forward = 1] = "Forward", e[e.Backward = -1] = "Backward";
})(R || (R = {}));
function Yt(e) {
  return !rt || !e ? !1 : e === document.scrollingElement;
}
function jt(e) {
  const t = {
    x: 0,
    y: 0
  }, n = Yt(e) ? {
    height: window.innerHeight,
    width: window.innerWidth
  } : {
    height: e.clientHeight,
    width: e.clientWidth
  }, r = {
    x: e.scrollWidth - n.width,
    y: e.scrollHeight - n.height
  }, o = e.scrollTop <= t.y, i = e.scrollLeft <= t.x, s = e.scrollTop >= r.y, l = e.scrollLeft >= r.x;
  return {
    isTop: o,
    isLeft: i,
    isBottom: s,
    isRight: l,
    maxScroll: r,
    minScroll: t
  };
}
const zn = {
  x: 0.2,
  y: 0.2
};
function Fn(e, t, n, r, o) {
  let {
    top: i,
    left: s,
    right: l,
    bottom: a
  } = n;
  r === void 0 && (r = 10), o === void 0 && (o = zn);
  const {
    isTop: c,
    isBottom: d,
    isLeft: u,
    isRight: g
  } = jt(e), h = {
    x: 0,
    y: 0
  }, D = {
    x: 0,
    y: 0
  }, f = {
    height: t.height * o.y,
    width: t.width * o.x
  };
  return !c && i <= t.top + f.height ? (h.y = R.Backward, D.y = r * Math.abs((t.top + f.height - i) / f.height)) : !d && a >= t.bottom - f.height && (h.y = R.Forward, D.y = r * Math.abs((t.bottom - f.height - a) / f.height)), !g && l >= t.right - f.width ? (h.x = R.Forward, D.x = r * Math.abs((t.right - f.width - l) / f.width)) : !u && s <= t.left + f.width && (h.x = R.Backward, D.x = r * Math.abs((t.left + f.width - s) / f.width)), {
    direction: h,
    speed: D
  };
}
function $n(e) {
  if (e === document.scrollingElement) {
    const {
      innerWidth: i,
      innerHeight: s
    } = window;
    return {
      top: 0,
      left: 0,
      right: i,
      bottom: s,
      width: i,
      height: s
    };
  }
  const {
    top: t,
    left: n,
    right: r,
    bottom: o
  } = e.getBoundingClientRect();
  return {
    top: t,
    left: n,
    right: r,
    bottom: o,
    width: e.clientWidth,
    height: e.clientHeight
  };
}
function Ht(e) {
  return e.reduce((t, n) => pe(t, Qe(n)), K);
}
function Wn(e) {
  return e.reduce((t, n) => t + _t(n), 0);
}
function Un(e) {
  return e.reduce((t, n) => t + Kt(n), 0);
}
function Xn(e, t) {
  if (t === void 0 && (t = Ne), !e)
    return;
  const {
    top: n,
    left: r,
    bottom: o,
    right: i
  } = t(e);
  Xt(e) && (o <= 0 || i <= 0 || n >= window.innerHeight || r >= window.innerWidth) && e.scrollIntoView({
    block: "center",
    inline: "center"
  });
}
const _n = [["x", ["left", "right"], Wn], ["y", ["top", "bottom"], Un]];
class st {
  constructor(t, n) {
    this.rect = void 0, this.width = void 0, this.height = void 0, this.top = void 0, this.bottom = void 0, this.right = void 0, this.left = void 0;
    const r = it(n), o = Ht(r);
    this.rect = {
      ...t
    }, this.width = t.width, this.height = t.height;
    for (const [i, s, l] of _n)
      for (const a of s)
        Object.defineProperty(this, a, {
          get: () => {
            const c = l(r), d = o[i] - c;
            return this.rect[a] + d;
          },
          enumerable: !0
        });
    Object.defineProperty(this, "rect", {
      enumerable: !1
    });
  }
}
class Ce {
  constructor(t) {
    this.target = void 0, this.listeners = [], this.removeAll = () => {
      this.listeners.forEach((n) => {
        var r;
        return (r = this.target) == null ? void 0 : r.removeEventListener(...n);
      });
    }, this.target = t;
  }
  add(t, n, r) {
    var o;
    (o = this.target) == null || o.addEventListener(t, n, r), this.listeners.push([t, n, r]);
  }
}
function Kn(e) {
  const {
    EventTarget: t
  } = Z(e);
  return e instanceof t ? e : we(e);
}
function He(e, t) {
  const n = Math.abs(e.x), r = Math.abs(e.y);
  return typeof t == "number" ? Math.sqrt(n ** 2 + r ** 2) > t : "x" in t && "y" in t ? n > t.x && r > t.y : "x" in t ? n > t.x : "y" in t ? r > t.y : !1;
}
var W;
(function(e) {
  e.Click = "click", e.DragStart = "dragstart", e.Keydown = "keydown", e.ContextMenu = "contextmenu", e.Resize = "resize", e.SelectionChange = "selectionchange", e.VisibilityChange = "visibilitychange";
})(W || (W = {}));
function Mt(e) {
  e.preventDefault();
}
function Yn(e) {
  e.stopPropagation();
}
var w;
(function(e) {
  e.Space = "Space", e.Down = "ArrowDown", e.Right = "ArrowRight", e.Left = "ArrowLeft", e.Up = "ArrowUp", e.Esc = "Escape", e.Enter = "Enter", e.Tab = "Tab";
})(w || (w = {}));
const qt = {
  start: [w.Space, w.Enter],
  cancel: [w.Esc],
  end: [w.Space, w.Enter, w.Tab]
}, jn = (e, t) => {
  let {
    currentCoordinates: n
  } = t;
  switch (e.code) {
    case w.Right:
      return {
        ...n,
        x: n.x + 25
      };
    case w.Left:
      return {
        ...n,
        x: n.x - 25
      };
    case w.Down:
      return {
        ...n,
        y: n.y + 25
      };
    case w.Up:
      return {
        ...n,
        y: n.y - 25
      };
  }
};
class Jt {
  constructor(t) {
    this.props = void 0, this.autoScrollEnabled = !1, this.referenceCoordinates = void 0, this.listeners = void 0, this.windowListeners = void 0, this.props = t;
    const {
      event: {
        target: n
      }
    } = t;
    this.props = t, this.listeners = new Ce(we(n)), this.windowListeners = new Ce(Z(n)), this.handleKeyDown = this.handleKeyDown.bind(this), this.handleCancel = this.handleCancel.bind(this), this.attach();
  }
  attach() {
    this.handleStart(), this.windowListeners.add(W.Resize, this.handleCancel), this.windowListeners.add(W.VisibilityChange, this.handleCancel), setTimeout(() => this.listeners.add(W.Keydown, this.handleKeyDown));
  }
  handleStart() {
    const {
      activeNode: t,
      onStart: n
    } = this.props, r = t.node.current;
    r && Xn(r), n(K);
  }
  handleKeyDown(t) {
    if (zt(t)) {
      const {
        active: n,
        context: r,
        options: o
      } = this.props, {
        keyboardCodes: i = qt,
        coordinateGetter: s = jn,
        scrollBehavior: l = "smooth"
      } = o, {
        code: a
      } = t;
      if (i.end.includes(a)) {
        this.handleEnd(t);
        return;
      }
      if (i.cancel.includes(a)) {
        this.handleCancel(t);
        return;
      }
      const {
        collisionRect: c
      } = r.current, d = c ? {
        x: c.left,
        y: c.top
      } : K;
      this.referenceCoordinates || (this.referenceCoordinates = d);
      const u = s(t, {
        active: n,
        context: r.current,
        currentCoordinates: d
      });
      if (u) {
        const g = ze(u, d), h = {
          x: 0,
          y: 0
        }, {
          scrollableAncestors: D
        } = r.current;
        for (const f of D) {
          const v = t.code, {
            isTop: y,
            isRight: m,
            isLeft: x,
            isBottom: k,
            maxScroll: E,
            minScroll: C
          } = jt(f), p = $n(f), b = {
            x: Math.min(v === w.Right ? p.right - p.width / 2 : p.right, Math.max(v === w.Right ? p.left : p.left + p.width / 2, u.x)),
            y: Math.min(v === w.Down ? p.bottom - p.height / 2 : p.bottom, Math.max(v === w.Down ? p.top : p.top + p.height / 2, u.y))
          }, T = v === w.Right && !m || v === w.Left && !x, I = v === w.Down && !k || v === w.Up && !y;
          if (T && b.x !== u.x) {
            const S = f.scrollLeft + g.x, q = v === w.Right && S <= E.x || v === w.Left && S >= C.x;
            if (q && !g.y) {
              f.scrollTo({
                left: S,
                behavior: l
              });
              return;
            }
            q ? h.x = f.scrollLeft - S : h.x = v === w.Right ? f.scrollLeft - E.x : f.scrollLeft - C.x, h.x && f.scrollBy({
              left: -h.x,
              behavior: l
            });
            break;
          } else if (I && b.y !== u.y) {
            const S = f.scrollTop + g.y, q = v === w.Down && S <= E.y || v === w.Up && S >= C.y;
            if (q && !g.x) {
              f.scrollTo({
                top: S,
                behavior: l
              });
              return;
            }
            q ? h.y = f.scrollTop - S : h.y = v === w.Down ? f.scrollTop - E.y : f.scrollTop - C.y, h.y && f.scrollBy({
              top: -h.y,
              behavior: l
            });
            break;
          }
        }
        this.handleMove(t, pe(ze(u, this.referenceCoordinates), h));
      }
    }
  }
  handleMove(t, n) {
    const {
      onMove: r
    } = this.props;
    t.preventDefault(), r(n);
  }
  handleEnd(t) {
    const {
      onEnd: n
    } = this.props;
    t.preventDefault(), this.detach(), n();
  }
  handleCancel(t) {
    const {
      onCancel: n
    } = this.props;
    t.preventDefault(), this.detach(), n();
  }
  detach() {
    this.listeners.removeAll(), this.windowListeners.removeAll();
  }
}
Jt.activators = [{
  eventName: "onKeyDown",
  handler: (e, t, n) => {
    let {
      keyboardCodes: r = qt,
      onActivation: o
    } = t, {
      active: i
    } = n;
    const {
      code: s
    } = e.nativeEvent;
    if (r.start.includes(s)) {
      const l = i.activatorNode.current;
      return l && e.target !== l ? !1 : (e.preventDefault(), o?.({
        event: e.nativeEvent
      }), !0);
    }
    return !1;
  }
}];
function Nt(e) {
  return !!(e && "distance" in e);
}
function Ot(e) {
  return !!(e && "delay" in e);
}
class lt {
  constructor(t, n, r) {
    var o;
    r === void 0 && (r = Kn(t.event.target)), this.props = void 0, this.events = void 0, this.autoScrollEnabled = !0, this.document = void 0, this.activated = !1, this.initialCoordinates = void 0, this.timeoutId = null, this.listeners = void 0, this.documentListeners = void 0, this.windowListeners = void 0, this.props = t, this.events = n;
    const {
      event: i
    } = t, {
      target: s
    } = i;
    this.props = t, this.events = n, this.document = we(s), this.documentListeners = new Ce(this.document), this.listeners = new Ce(r), this.windowListeners = new Ce(Z(s)), this.initialCoordinates = (o = Je(i)) != null ? o : K, this.handleStart = this.handleStart.bind(this), this.handleMove = this.handleMove.bind(this), this.handleEnd = this.handleEnd.bind(this), this.handleCancel = this.handleCancel.bind(this), this.handleKeydown = this.handleKeydown.bind(this), this.removeTextSelection = this.removeTextSelection.bind(this), this.attach();
  }
  attach() {
    const {
      events: t,
      props: {
        options: {
          activationConstraint: n,
          bypassActivationConstraint: r
        }
      }
    } = this;
    if (this.listeners.add(t.move.name, this.handleMove, {
      passive: !1
    }), this.listeners.add(t.end.name, this.handleEnd), t.cancel && this.listeners.add(t.cancel.name, this.handleCancel), this.windowListeners.add(W.Resize, this.handleCancel), this.windowListeners.add(W.DragStart, Mt), this.windowListeners.add(W.VisibilityChange, this.handleCancel), this.windowListeners.add(W.ContextMenu, Mt), this.documentListeners.add(W.Keydown, this.handleKeydown), n) {
      if (r != null && r({
        event: this.props.event,
        activeNode: this.props.activeNode,
        options: this.props.options
      }))
        return this.handleStart();
      if (Ot(n)) {
        this.timeoutId = setTimeout(this.handleStart, n.delay), this.handlePending(n);
        return;
      }
      if (Nt(n)) {
        this.handlePending(n);
        return;
      }
    }
    this.handleStart();
  }
  detach() {
    this.listeners.removeAll(), this.windowListeners.removeAll(), setTimeout(this.documentListeners.removeAll, 50), this.timeoutId !== null && (clearTimeout(this.timeoutId), this.timeoutId = null);
  }
  handlePending(t, n) {
    const {
      active: r,
      onPending: o
    } = this.props;
    o(r, t, this.initialCoordinates, n);
  }
  handleStart() {
    const {
      initialCoordinates: t
    } = this, {
      onStart: n
    } = this.props;
    t && (this.activated = !0, this.documentListeners.add(W.Click, Yn, {
      capture: !0
    }), this.removeTextSelection(), this.documentListeners.add(W.SelectionChange, this.removeTextSelection), n(t));
  }
  handleMove(t) {
    var n;
    const {
      activated: r,
      initialCoordinates: o,
      props: i
    } = this, {
      onMove: s,
      options: {
        activationConstraint: l
      }
    } = i;
    if (!o)
      return;
    const a = (n = Je(t)) != null ? n : K, c = ze(o, a);
    if (!r && l) {
      if (Nt(l)) {
        if (l.tolerance != null && He(c, l.tolerance))
          return this.handleCancel();
        if (He(c, l.distance))
          return this.handleStart();
      }
      if (Ot(l) && He(c, l.tolerance))
        return this.handleCancel();
      this.handlePending(l, c);
      return;
    }
    t.cancelable && t.preventDefault(), s(a);
  }
  handleEnd() {
    const {
      onAbort: t,
      onEnd: n
    } = this.props;
    this.detach(), this.activated || t(this.props.active), n();
  }
  handleCancel() {
    const {
      onAbort: t,
      onCancel: n
    } = this.props;
    this.detach(), this.activated || t(this.props.active), n();
  }
  handleKeydown(t) {
    t.code === w.Esc && this.handleCancel();
  }
  removeTextSelection() {
    var t;
    (t = this.document.getSelection()) == null || t.removeAllRanges();
  }
}
const Hn = {
  cancel: {
    name: "pointercancel"
  },
  move: {
    name: "pointermove"
  },
  end: {
    name: "pointerup"
  }
};
class Vt extends lt {
  constructor(t) {
    const {
      event: n
    } = t, r = we(n.target);
    super(t, Hn, r);
  }
}
Vt.activators = [{
  eventName: "onPointerDown",
  handler: (e, t) => {
    let {
      nativeEvent: n
    } = e, {
      onActivation: r
    } = t;
    return !n.isPrimary || n.button !== 0 ? !1 : (r?.({
      event: n
    }), !0);
  }
}];
const qn = {
  move: {
    name: "mousemove"
  },
  end: {
    name: "mouseup"
  }
};
var Ze;
(function(e) {
  e[e.RightClick = 2] = "RightClick";
})(Ze || (Ze = {}));
class Jn extends lt {
  constructor(t) {
    super(t, qn, we(t.event.target));
  }
}
Jn.activators = [{
  eventName: "onMouseDown",
  handler: (e, t) => {
    let {
      nativeEvent: n
    } = e, {
      onActivation: r
    } = t;
    return n.button === Ze.RightClick ? !1 : (r?.({
      event: n
    }), !0);
  }
}];
const qe = {
  cancel: {
    name: "touchcancel"
  },
  move: {
    name: "touchmove"
  },
  end: {
    name: "touchend"
  }
};
class Vn extends lt {
  constructor(t) {
    super(t, qe);
  }
  static setup() {
    return window.addEventListener(qe.move.name, t, {
      capture: !1,
      passive: !1
    }), function() {
      window.removeEventListener(qe.move.name, t);
    };
    function t() {
    }
  }
}
Vn.activators = [{
  eventName: "onTouchStart",
  handler: (e, t) => {
    let {
      nativeEvent: n
    } = e, {
      onActivation: r
    } = t;
    const {
      touches: o
    } = n;
    return o.length > 1 ? !1 : (r?.({
      event: n
    }), !0);
  }
}];
var Se;
(function(e) {
  e[e.Pointer = 0] = "Pointer", e[e.DraggableRect = 1] = "DraggableRect";
})(Se || (Se = {}));
var $e;
(function(e) {
  e[e.TreeOrder = 0] = "TreeOrder", e[e.ReversedTreeOrder = 1] = "ReversedTreeOrder";
})($e || ($e = {}));
function Gn(e) {
  let {
    acceleration: t,
    activator: n = Se.Pointer,
    canScroll: r,
    draggingRect: o,
    enabled: i,
    interval: s = 5,
    order: l = $e.TreeOrder,
    pointerCoordinates: a,
    scrollableAncestors: c,
    scrollableAncestorRects: d,
    delta: u,
    threshold: g
  } = e;
  const h = Zn({
    delta: u,
    disabled: !i
  }), [D, f] = fn(), v = F({
    x: 0,
    y: 0
  }), y = F({
    x: 0,
    y: 0
  }), m = M(() => {
    switch (n) {
      case Se.Pointer:
        return a ? {
          top: a.y,
          bottom: a.y,
          left: a.x,
          right: a.x
        } : null;
      case Se.DraggableRect:
        return o;
    }
  }, [n, o, a]), x = F(null), k = Q(() => {
    const C = x.current;
    if (!C)
      return;
    const p = v.current.x * y.current.x, b = v.current.y * y.current.y;
    C.scrollBy(p, b);
  }, []), E = M(() => l === $e.TreeOrder ? [...c].reverse() : c, [l, c]);
  N(
    () => {
      if (!i || !c.length || !m) {
        f();
        return;
      }
      for (const C of E) {
        if (r?.(C) === !1)
          continue;
        const p = c.indexOf(C), b = d[p];
        if (!b)
          continue;
        const {
          direction: T,
          speed: I
        } = Fn(C, b, m, t, g);
        for (const S of ["x", "y"])
          h[S][T[S]] || (I[S] = 0, T[S] = 0);
        if (I.x > 0 || I.y > 0) {
          f(), x.current = C, D(k, s), v.current = I, y.current = T;
          return;
        }
      }
      v.current = {
        x: 0,
        y: 0
      }, y.current = {
        x: 0,
        y: 0
      }, f();
    },
    // eslint-disable-next-line react-hooks/exhaustive-deps
    [
      t,
      k,
      r,
      f,
      i,
      s,
      // eslint-disable-next-line react-hooks/exhaustive-deps
      JSON.stringify(m),
      // eslint-disable-next-line react-hooks/exhaustive-deps
      JSON.stringify(h),
      D,
      c,
      E,
      d,
      // eslint-disable-next-line react-hooks/exhaustive-deps
      JSON.stringify(g)
    ]
  );
}
const Qn = {
  x: {
    [R.Backward]: !1,
    [R.Forward]: !1
  },
  y: {
    [R.Backward]: !1,
    [R.Forward]: !1
  }
};
function Zn(e) {
  let {
    delta: t,
    disabled: n
  } = e;
  const r = Ge(t);
  return Me((o) => {
    if (n || !r || !o)
      return Qn;
    const i = {
      x: Math.sign(t.x - r.x),
      y: Math.sign(t.y - r.y)
    };
    return {
      x: {
        [R.Backward]: o.x[R.Backward] || i.x === -1,
        [R.Forward]: o.x[R.Forward] || i.x === 1
      },
      y: {
        [R.Backward]: o.y[R.Backward] || i.y === -1,
        [R.Forward]: o.y[R.Forward] || i.y === 1
      }
    };
  }, [n, t, r]);
}
function er(e, t) {
  const n = t != null ? e.get(t) : void 0, r = n ? n.node.current : null;
  return Me((o) => {
    var i;
    return t == null ? null : (i = r ?? o) != null ? i : null;
  }, [r, t]);
}
function tr(e, t) {
  return M(() => e.reduce((n, r) => {
    const {
      sensor: o
    } = r, i = o.activators.map((s) => ({
      eventName: s.eventName,
      handler: t(s.handler, r)
    }));
    return [...n, ...i];
  }, []), [e, t]);
}
var Ee;
(function(e) {
  e[e.Always = 0] = "Always", e[e.BeforeDragging = 1] = "BeforeDragging", e[e.WhileDragging = 2] = "WhileDragging";
})(Ee || (Ee = {}));
var et;
(function(e) {
  e.Optimized = "optimized";
})(et || (et = {}));
const Lt = /* @__PURE__ */ new Map();
function nr(e, t) {
  let {
    dragging: n,
    dependencies: r,
    config: o
  } = t;
  const [i, s] = _(null), {
    frequency: l,
    measure: a,
    strategy: c
  } = o, d = F(e), u = v(), g = tt(u), h = Q(function(y) {
    y === void 0 && (y = []), !g.current && s((m) => m === null ? y : m.concat(y.filter((x) => !m.includes(x))));
  }, [g]), D = F(null), f = Me((y) => {
    if (u && !n)
      return Lt;
    if (!y || y === Lt || d.current !== e || i != null) {
      const m = /* @__PURE__ */ new Map();
      for (let x of e) {
        if (!x)
          continue;
        if (i && i.length > 0 && !i.includes(x.id) && x.rect.current) {
          m.set(x.id, x.rect.current);
          continue;
        }
        const k = x.node.current, E = k ? new st(a(k), k) : null;
        x.rect.current = E, E && m.set(x.id, E);
      }
      return m;
    }
    return y;
  }, [e, i, n, u, a]);
  return N(() => {
    d.current = e;
  }, [e]), N(
    () => {
      u || h();
    },
    // eslint-disable-next-line react-hooks/exhaustive-deps
    [n, u]
  ), N(
    () => {
      i && i.length > 0 && s(null);
    },
    //eslint-disable-next-line react-hooks/exhaustive-deps
    [JSON.stringify(i)]
  ), N(
    () => {
      u || typeof l != "number" || D.current !== null || (D.current = setTimeout(() => {
        h(), D.current = null;
      }, l));
    },
    // eslint-disable-next-line react-hooks/exhaustive-deps
    [l, u, h, ...r]
  ), {
    droppableRects: f,
    measureDroppableContainers: h,
    measuringScheduled: i != null
  };
  function v() {
    switch (c) {
      case Ee.Always:
        return !1;
      case Ee.BeforeDragging:
        return n;
      default:
        return !n;
    }
  }
}
function Gt(e, t) {
  return Me((n) => e ? n || (typeof t == "function" ? t(e) : e) : null, [t, e]);
}
function rr(e, t) {
  return Gt(e, t);
}
function or(e) {
  let {
    callback: t,
    disabled: n
  } = e;
  const r = Ft(t), o = M(() => {
    if (n || typeof window > "u" || typeof window.MutationObserver > "u")
      return;
    const {
      MutationObserver: i
    } = window;
    return new i(r);
  }, [r, n]);
  return N(() => () => o?.disconnect(), [o]), o;
}
function at(e) {
  let {
    callback: t,
    disabled: n
  } = e;
  const r = Ft(t), o = M(
    () => {
      if (n || typeof window > "u" || typeof window.ResizeObserver > "u")
        return;
      const {
        ResizeObserver: i
      } = window;
      return new i(r);
    },
    // eslint-disable-next-line react-hooks/exhaustive-deps
    [n]
  );
  return N(() => () => o?.disconnect(), [o]), o;
}
function ir(e) {
  return new st(Ne(e), e);
}
function Tt(e, t, n) {
  t === void 0 && (t = ir);
  const [r, o] = _(null);
  function i() {
    o((a) => {
      if (!e)
        return null;
      if (e.isConnected === !1) {
        var c;
        return (c = a ?? n) != null ? c : null;
      }
      const d = t(e);
      return JSON.stringify(a) === JSON.stringify(d) ? a : d;
    });
  }
  const s = or({
    callback(a) {
      if (e)
        for (const c of a) {
          const {
            type: d,
            target: u
          } = c;
          if (d === "childList" && u instanceof HTMLElement && u.contains(e)) {
            i();
            break;
          }
        }
    }
  }), l = at({
    callback: i
  });
  return be(() => {
    i(), e ? (l?.observe(e), s?.observe(document.body, {
      childList: !0,
      subtree: !0
    })) : (l?.disconnect(), s?.disconnect());
  }, [e]), r;
}
function sr(e) {
  const t = Gt(e);
  return Ut(e, t);
}
const It = [];
function lr(e) {
  const t = F(e), n = Me((r) => e ? r && r !== It && e && t.current && e.parentNode === t.current.parentNode ? r : it(e) : It, [e]);
  return N(() => {
    t.current = e;
  }, [e]), n;
}
function ar(e) {
  const [t, n] = _(null), r = F(e), o = Q((i) => {
    const s = je(i.target);
    s && n((l) => l ? (l.set(s, Qe(s)), new Map(l)) : null);
  }, []);
  return N(() => {
    const i = r.current;
    if (e !== i) {
      s(i);
      const l = e.map((a) => {
        const c = je(a);
        return c ? (c.addEventListener("scroll", o, {
          passive: !0
        }), [c, Qe(c)]) : null;
      }).filter((a) => a != null);
      n(l.length ? new Map(l) : null), r.current = e;
    }
    return () => {
      s(e), s(i);
    };
    function s(l) {
      l.forEach((a) => {
        const c = je(a);
        c?.removeEventListener("scroll", o);
      });
    }
  }, [o, e]), M(() => e.length ? t ? Array.from(t.values()).reduce((i, s) => pe(i, s), K) : Ht(e) : K, [e, t]);
}
function kt(e, t) {
  t === void 0 && (t = []);
  const n = F(null);
  return N(
    () => {
      n.current = null;
    },
    // eslint-disable-next-line react-hooks/exhaustive-deps
    t
  ), N(() => {
    const r = e !== K;
    r && !n.current && (n.current = e), !r && n.current && (n.current = null);
  }, [e]), n.current ? ze(e, n.current) : K;
}
function cr(e) {
  N(
    () => {
      if (!rt)
        return;
      const t = e.map((n) => {
        let {
          sensor: r
        } = n;
        return r.setup == null ? void 0 : r.setup();
      });
      return () => {
        for (const n of t)
          n?.();
      };
    },
    // TO-DO: Sensors length could theoretically change which would not be a valid dependency
    // eslint-disable-next-line react-hooks/exhaustive-deps
    e.map((t) => {
      let {
        sensor: n
      } = t;
      return n;
    })
  );
}
function ur(e, t) {
  return M(() => e.reduce((n, r) => {
    let {
      eventName: o,
      handler: i
    } = r;
    return n[o] = (s) => {
      i(s, t);
    }, n;
  }, {}), [e, t]);
}
function Qt(e) {
  return M(() => e ? kn(e) : null, [e]);
}
const Bt = [];
function dr(e, t) {
  t === void 0 && (t = Ne);
  const [n] = e, r = Qt(n ? Z(n) : null), [o, i] = _(Bt);
  function s() {
    i(() => e.length ? e.map((a) => Yt(a) ? r : new st(t(a), a)) : Bt);
  }
  const l = at({
    callback: s
  });
  return be(() => {
    l?.disconnect(), s(), e.forEach((a) => l?.observe(a));
  }, [e]), o;
}
function fr(e) {
  if (!e)
    return null;
  if (e.children.length > 1)
    return e;
  const t = e.children[0];
  return We(t) ? t : e;
}
function hr(e) {
  let {
    measure: t
  } = e;
  const [n, r] = _(null), o = Q((c) => {
    for (const {
      target: d
    } of c)
      if (We(d)) {
        r((u) => {
          const g = t(d);
          return u ? {
            ...u,
            width: g.width,
            height: g.height
          } : g;
        });
        break;
      }
  }, [t]), i = at({
    callback: o
  }), s = Q((c) => {
    const d = fr(c);
    i?.disconnect(), d && i?.observe(d), r(d ? t(d) : null);
  }, [t, i]), [l, a] = Ve(s);
  return M(() => ({
    nodeRef: l,
    rect: n,
    setRef: a
  }), [n, l, a]);
}
const gr = [{
  sensor: Vt,
  options: {}
}, {
  sensor: Jt,
  options: {}
}], vr = {
  current: {}
}, Be = {
  draggable: {
    measure: At
  },
  droppable: {
    measure: At,
    strategy: Ee.WhileDragging,
    frequency: et.Optimized
  },
  dragOverlay: {
    measure: Ne
  }
};
class Re extends Map {
  get(t) {
    var n;
    return t != null && (n = super.get(t)) != null ? n : void 0;
  }
  toArray() {
    return Array.from(this.values());
  }
  getEnabled() {
    return this.toArray().filter((t) => {
      let {
        disabled: n
      } = t;
      return !n;
    });
  }
  getNodeFor(t) {
    var n, r;
    return (n = (r = this.get(t)) == null ? void 0 : r.node.current) != null ? n : void 0;
  }
}
const pr = {
  activatorEvent: null,
  active: null,
  activeNode: null,
  activeNodeRect: null,
  collisions: null,
  containerNodeRect: null,
  draggableNodes: /* @__PURE__ */ new Map(),
  droppableRects: /* @__PURE__ */ new Map(),
  droppableContainers: /* @__PURE__ */ new Re(),
  over: null,
  dragOverlay: {
    nodeRef: {
      current: null
    },
    rect: null,
    setRef: Fe
  },
  scrollableAncestors: [],
  scrollableAncestorRects: [],
  measuringConfiguration: Be,
  measureDroppableContainers: Fe,
  windowRect: null,
  measuringScheduled: !1
}, br = {
  activatorEvent: null,
  activators: [],
  active: null,
  activeNodeRect: null,
  ariaDescribedById: {
    draggable: ""
  },
  dispatch: Fe,
  draggableNodes: /* @__PURE__ */ new Map(),
  over: null,
  measureDroppableContainers: Fe
}, ct = /* @__PURE__ */ Ae(br), wr = /* @__PURE__ */ Ae(pr);
function yr() {
  return {
    draggable: {
      active: null,
      initialCoordinates: {
        x: 0,
        y: 0
      },
      nodes: /* @__PURE__ */ new Map(),
      translate: {
        x: 0,
        y: 0
      }
    },
    droppable: {
      containers: new Re()
    }
  };
}
function mr(e, t) {
  switch (t.type) {
    case L.DragStart:
      return {
        ...e,
        draggable: {
          ...e.draggable,
          initialCoordinates: t.initialCoordinates,
          active: t.active
        }
      };
    case L.DragMove:
      return e.draggable.active == null ? e : {
        ...e,
        draggable: {
          ...e.draggable,
          translate: {
            x: t.coordinates.x - e.draggable.initialCoordinates.x,
            y: t.coordinates.y - e.draggable.initialCoordinates.y
          }
        }
      };
    case L.DragEnd:
    case L.DragCancel:
      return {
        ...e,
        draggable: {
          ...e.draggable,
          active: null,
          initialCoordinates: {
            x: 0,
            y: 0
          },
          translate: {
            x: 0,
            y: 0
          }
        }
      };
    case L.RegisterDroppable: {
      const {
        element: n
      } = t, {
        id: r
      } = n, o = new Re(e.droppable.containers);
      return o.set(r, n), {
        ...e,
        droppable: {
          ...e.droppable,
          containers: o
        }
      };
    }
    case L.SetDroppableDisabled: {
      const {
        id: n,
        key: r,
        disabled: o
      } = t, i = e.droppable.containers.get(n);
      if (!i || r !== i.key)
        return e;
      const s = new Re(e.droppable.containers);
      return s.set(n, {
        ...i,
        disabled: o
      }), {
        ...e,
        droppable: {
          ...e.droppable,
          containers: s
        }
      };
    }
    case L.UnregisterDroppable: {
      const {
        id: n,
        key: r
      } = t, o = e.droppable.containers.get(n);
      if (!o || r !== o.key)
        return e;
      const i = new Re(e.droppable.containers);
      return i.delete(n), {
        ...e,
        droppable: {
          ...e.droppable,
          containers: i
        }
      };
    }
    default:
      return e;
  }
}
function Dr(e) {
  let {
    disabled: t
  } = e;
  const {
    active: n,
    activatorEvent: r,
    draggableNodes: o
  } = Pe(ct), i = Ge(r), s = Ge(n?.id);
  return N(() => {
    if (!t && !r && i && s != null) {
      if (!zt(i) || document.activeElement === i.target)
        return;
      const l = o.get(s);
      if (!l)
        return;
      const {
        activatorNode: a,
        node: c
      } = l;
      if (!a.current && !c.current)
        return;
      requestAnimationFrame(() => {
        for (const d of [a.current, c.current]) {
          if (!d)
            continue;
          const u = hn(d);
          if (u) {
            u.focus();
            break;
          }
        }
      });
    }
  }, [r, t, o, s, i]), null;
}
function xr(e, t) {
  let {
    transform: n,
    ...r
  } = t;
  return e != null && e.length ? e.reduce((o, i) => i({
    transform: o,
    ...r
  }), n) : n;
}
function Cr(e) {
  return M(
    () => ({
      draggable: {
        ...Be.draggable,
        ...e?.draggable
      },
      droppable: {
        ...Be.droppable,
        ...e?.droppable
      },
      dragOverlay: {
        ...Be.dragOverlay,
        ...e?.dragOverlay
      }
    }),
    // eslint-disable-next-line react-hooks/exhaustive-deps
    [e?.draggable, e?.droppable, e?.dragOverlay]
  );
}
function Sr(e) {
  let {
    activeNode: t,
    measure: n,
    initialRect: r,
    config: o = !0
  } = e;
  const i = F(!1), {
    x: s,
    y: l
  } = typeof o == "boolean" ? {
    x: o,
    y: o
  } : o;
  be(() => {
    if (!s && !l || !t) {
      i.current = !1;
      return;
    }
    if (i.current || !r)
      return;
    const c = t?.node.current;
    if (!c || c.isConnected === !1)
      return;
    const d = n(c), u = Ut(d, r);
    if (s || (u.x = 0), l || (u.y = 0), i.current = !0, Math.abs(u.x) > 0 || Math.abs(u.y) > 0) {
      const g = Xt(c);
      g && g.scrollBy({
        top: u.y,
        left: u.x
      });
    }
  }, [t, s, l, r, n]);
}
const Zt = /* @__PURE__ */ Ae({
  ...K,
  scaleX: 1,
  scaleY: 1
});
var se;
(function(e) {
  e[e.Uninitialized = 0] = "Uninitialized", e[e.Initializing = 1] = "Initializing", e[e.Initialized = 2] = "Initialized";
})(se || (se = {}));
const Lr = /* @__PURE__ */ cn(function(t) {
  var n, r, o, i;
  let {
    id: s,
    accessibility: l,
    autoScroll: a = !0,
    children: c,
    sensors: d = gr,
    collisionDetection: u = An,
    measuring: g,
    modifiers: h,
    ...D
  } = t;
  const f = un(mr, void 0, yr), [v, y] = f, [m, x] = mn(), [k, E] = _(se.Uninitialized), C = k === se.Initialized, {
    draggable: {
      active: p,
      nodes: b,
      translate: T
    },
    droppable: {
      containers: I
    }
  } = v, S = p != null ? b.get(p) : null, q = F({
    initial: null,
    translated: null
  }), J = M(() => {
    var O;
    return p != null ? {
      id: p,
      // It's possible for the active node to unmount while dragging
      data: (O = S?.data) != null ? O : vr,
      rect: q
    } : null;
  }, [p, S]), ee = F(null), [ut, dt] = _(null), [V, ft] = _(null), le = tt(D, Object.values(D)), Ue = nt("DndDescribedBy", s), ht = M(() => I.getEnabled(), [I]), ae = Cr(g), {
    droppableRects: de,
    measureDroppableContainers: Oe,
    measuringScheduled: gt
  } = nr(ht, {
    dragging: C,
    dependencies: [T.x, T.y],
    config: ae.droppable
  }), U = er(b, p), vt = M(() => V ? Je(V) : null, [V]), pt = an(), bt = rr(U, ae.draggable.measure);
  Sr({
    activeNode: p != null ? b.get(p) : null,
    config: pt.layoutShiftCompensation,
    initialRect: bt,
    measure: ae.draggable.measure
  });
  const X = Tt(U, ae.draggable.measure, bt), Xe = Tt(U ? U.parentElement : null), ce = F({
    activatorEvent: null,
    active: null,
    activeNode: U,
    collisionRect: null,
    collisions: null,
    droppableRects: de,
    draggableNodes: b,
    draggingNode: null,
    draggingNodeRect: null,
    droppableContainers: I,
    over: null,
    scrollableAncestors: [],
    scrollAdjustedTranslate: null
  }), wt = I.getNodeFor((n = ce.current.over) == null ? void 0 : n.id), ue = hr({
    measure: ae.dragOverlay.measure
  }), Le = (r = ue.nodeRef.current) != null ? r : U, fe = C ? (o = ue.rect) != null ? o : X : null, yt = !!(ue.nodeRef.current && ue.rect), mt = sr(yt ? null : X), _e = Qt(Le ? Z(Le) : null), te = lr(C ? wt ?? U : null), Te = dr(te), Ie = xr(h, {
    transform: {
      x: T.x - mt.x,
      y: T.y - mt.y,
      scaleX: 1,
      scaleY: 1
    },
    activatorEvent: V,
    active: J,
    activeNodeRect: X,
    containerNodeRect: Xe,
    draggingNodeRect: fe,
    over: ce.current.over,
    overlayNodeRect: ue.rect,
    scrollableAncestors: te,
    scrollableAncestorRects: Te,
    windowRect: _e
  }), Dt = vt ? pe(vt, T) : null, xt = ar(te), en = kt(xt), tn = kt(xt, [X]), he = pe(Ie, en), ge = fe ? On(fe, Ie) : null, ye = J && ge ? u({
    active: J,
    collisionRect: ge,
    droppableRects: de,
    droppableContainers: ht,
    pointerCoordinates: Dt
  }) : null, Ct = Rn(ye, "id"), [ne, St] = _(null), nn = yt ? Ie : pe(Ie, tn), rn = Mn(nn, (i = ne?.rect) != null ? i : null, X), Ke = F(null), Rt = Q(
    (O, B) => {
      let {
        sensor: P,
        options: re
      } = B;
      if (ee.current == null)
        return;
      const $ = b.get(ee.current);
      if (!$)
        return;
      const z = O.nativeEvent, Y = new P({
        active: ee.current,
        activeNode: $,
        event: z,
        options: re,
        // Sensors need to be instantiated with refs for arguments that change over time
        // otherwise they are frozen in time with the stale arguments
        context: ce,
        onAbort(A) {
          if (!b.get(A))
            return;
          const {
            onDragAbort: j
          } = le.current, G = {
            id: A
          };
          j?.(G), m({
            type: "onDragAbort",
            event: G
          });
        },
        onPending(A, oe, j, G) {
          if (!b.get(A))
            return;
          const {
            onDragPending: De
          } = le.current, ie = {
            id: A,
            constraint: oe,
            initialCoordinates: j,
            offset: G
          };
          De?.(ie), m({
            type: "onDragPending",
            event: ie
          });
        },
        onStart(A) {
          const oe = ee.current;
          if (oe == null)
            return;
          const j = b.get(oe);
          if (!j)
            return;
          const {
            onDragStart: G
          } = le.current, me = {
            activatorEvent: z,
            active: {
              id: oe,
              data: j.data,
              rect: q
            }
          };
          ke(() => {
            G?.(me), E(se.Initializing), y({
              type: L.DragStart,
              initialCoordinates: A,
              active: oe
            }), m({
              type: "onDragStart",
              event: me
            }), dt(Ke.current), ft(z);
          });
        },
        onMove(A) {
          y({
            type: L.DragMove,
            coordinates: A
          });
        },
        onEnd: ve(L.DragEnd),
        onCancel: ve(L.DragCancel)
      });
      Ke.current = Y;
      function ve(A) {
        return async function() {
          const {
            active: j,
            collisions: G,
            over: me,
            scrollAdjustedTranslate: De
          } = ce.current;
          let ie = null;
          if (j && De) {
            const {
              cancelDrop: xe
            } = le.current;
            ie = {
              activatorEvent: z,
              active: j,
              collisions: G,
              delta: De,
              over: me
            }, A === L.DragEnd && typeof xe == "function" && await Promise.resolve(xe(ie)) && (A = L.DragCancel);
          }
          ee.current = null, ke(() => {
            y({
              type: A
            }), E(se.Uninitialized), St(null), dt(null), ft(null), Ke.current = null;
            const xe = A === L.DragEnd ? "onDragEnd" : "onDragCancel";
            if (ie) {
              const Ye = le.current[xe];
              Ye?.(ie), m({
                type: xe,
                event: ie
              });
            }
          });
        };
      }
    },
    // eslint-disable-next-line react-hooks/exhaustive-deps
    [b]
  ), on = Q((O, B) => (P, re) => {
    const $ = P.nativeEvent, z = b.get(re);
    if (
      // Another sensor is already instantiating
      ee.current !== null || // No active draggable
      !z || // Event has already been captured
      $.dndKit || $.defaultPrevented
    )
      return;
    const Y = {
      active: z
    };
    O(P, B.options, Y) === !0 && ($.dndKit = {
      capturedBy: B.sensor
    }, ee.current = re, Rt(P, B));
  }, [b, Rt]), Et = tr(d, on);
  cr(d), be(() => {
    X && k === se.Initializing && E(se.Initialized);
  }, [X, k]), N(
    () => {
      const {
        onDragMove: O
      } = le.current, {
        active: B,
        activatorEvent: P,
        collisions: re,
        over: $
      } = ce.current;
      if (!B || !P)
        return;
      const z = {
        active: B,
        activatorEvent: P,
        collisions: re,
        delta: {
          x: he.x,
          y: he.y
        },
        over: $
      };
      ke(() => {
        O?.(z), m({
          type: "onDragMove",
          event: z
        });
      });
    },
    // eslint-disable-next-line react-hooks/exhaustive-deps
    [he.x, he.y]
  ), N(
    () => {
      const {
        active: O,
        activatorEvent: B,
        collisions: P,
        droppableContainers: re,
        scrollAdjustedTranslate: $
      } = ce.current;
      if (!O || ee.current == null || !B || !$)
        return;
      const {
        onDragOver: z
      } = le.current, Y = re.get(Ct), ve = Y && Y.rect.current ? {
        id: Y.id,
        rect: Y.rect.current,
        data: Y.data,
        disabled: Y.disabled
      } : null, A = {
        active: O,
        activatorEvent: B,
        collisions: P,
        delta: {
          x: $.x,
          y: $.y
        },
        over: ve
      };
      ke(() => {
        St(ve), z?.(A), m({
          type: "onDragOver",
          event: A
        });
      });
    },
    // eslint-disable-next-line react-hooks/exhaustive-deps
    [Ct]
  ), be(() => {
    ce.current = {
      activatorEvent: V,
      active: J,
      activeNode: U,
      collisionRect: ge,
      collisions: ye,
      droppableRects: de,
      draggableNodes: b,
      draggingNode: Le,
      draggingNodeRect: fe,
      droppableContainers: I,
      over: ne,
      scrollableAncestors: te,
      scrollAdjustedTranslate: he
    }, q.current = {
      initial: fe,
      translated: ge
    };
  }, [J, U, ye, ge, b, Le, fe, de, I, ne, te, he]), Gn({
    ...pt,
    delta: T,
    draggingRect: ge,
    pointerCoordinates: Dt,
    scrollableAncestors: te,
    scrollableAncestorRects: Te
  });
  const sn = M(() => ({
    active: J,
    activeNode: U,
    activeNodeRect: X,
    activatorEvent: V,
    collisions: ye,
    containerNodeRect: Xe,
    dragOverlay: ue,
    draggableNodes: b,
    droppableContainers: I,
    droppableRects: de,
    over: ne,
    measureDroppableContainers: Oe,
    scrollableAncestors: te,
    scrollableAncestorRects: Te,
    measuringConfiguration: ae,
    measuringScheduled: gt,
    windowRect: _e
  }), [J, U, X, V, ye, Xe, ue, b, I, de, ne, Oe, te, Te, ae, gt, _e]), ln = M(() => ({
    activatorEvent: V,
    activators: Et,
    active: J,
    activeNodeRect: X,
    ariaDescribedById: {
      draggable: Ue
    },
    dispatch: y,
    draggableNodes: b,
    over: ne,
    measureDroppableContainers: Oe
  }), [V, Et, J, X, y, Ue, b, ne, Oe]);
  return H.createElement(Wt.Provider, {
    value: x
  }, H.createElement(ct.Provider, {
    value: ln
  }, H.createElement(wr.Provider, {
    value: sn
  }, H.createElement(Zt.Provider, {
    value: rn
  }, c)), H.createElement(Dr, {
    disabled: l?.restoreFocus === !1
  })), H.createElement(Cn, {
    ...l,
    hiddenTextDescribedById: Ue
  }));
  function an() {
    const O = ut?.autoScrollEnabled === !1, B = typeof a == "object" ? a.enabled === !1 : a === !1, P = C && !O && !B;
    return typeof a == "object" ? {
      ...a,
      enabled: P
    } : {
      enabled: P
    };
  }
}), Rr = /* @__PURE__ */ Ae(null), Pt = "button", Er = "Draggable";
function Tr(e) {
  let {
    id: t,
    data: n,
    disabled: r = !1,
    attributes: o
  } = e;
  const i = nt(Er), {
    activators: s,
    activatorEvent: l,
    active: a,
    activeNodeRect: c,
    ariaDescribedById: d,
    draggableNodes: u,
    over: g
  } = Pe(ct), {
    role: h = Pt,
    roleDescription: D = "draggable",
    tabIndex: f = 0
  } = o ?? {}, v = a?.id === t, y = Pe(v ? Zt : Rr), [m, x] = Ve(), [k, E] = Ve(), C = ur(s, t), p = tt(n);
  be(
    () => (u.set(t, {
      id: t,
      key: i,
      node: m,
      activatorNode: k,
      data: p
    }), () => {
      const T = u.get(t);
      T && T.key === i && u.delete(t);
    }),
    // eslint-disable-next-line react-hooks/exhaustive-deps
    [u, t]
  );
  const b = M(() => ({
    role: h,
    tabIndex: f,
    "aria-disabled": r,
    "aria-pressed": v && h === Pt ? !0 : void 0,
    "aria-roledescription": D,
    "aria-describedby": d.draggable
  }), [r, h, f, v, D, d.draggable]);
  return {
    active: a,
    activatorEvent: l,
    activeNodeRect: c,
    attributes: b,
    isDragging: v,
    listeners: r ? void 0 : C,
    node: m,
    over: g,
    setNodeRef: x,
    setActivatorNodeRef: E,
    transform: y
  };
}
export {
  Se as AutoScrollActivator,
  Lr as DndContext,
  w as KeyboardCode,
  Jt as KeyboardSensor,
  et as MeasuringFrequency,
  Ee as MeasuringStrategy,
  Jn as MouseSensor,
  Vt as PointerSensor,
  Vn as TouchSensor,
  $e as TraversalOrder,
  xr as applyModifiers,
  xn as defaultAnnouncements,
  K as defaultCoordinates,
  jn as defaultKeyboardCoordinateGetter,
  Dn as defaultScreenReaderInstructions,
  Ne as getClientRect,
  Rn as getFirstCollision,
  it as getScrollableAncestors,
  An as rectIntersection,
  yn as useDndMonitor,
  Tr as useDraggable
};
