UNPKG

@lanaco/lnc-react-ui

Version:

React component library

2,162 lines 128 kB
import { jsx as we, jsxs as Gn } from "react/jsx-runtime"; import se, { useEffect as W, useRef as Q, useMemo as ee, useLayoutEffect as pi, useCallback as Ne, useState as he, createContext as xn, memo as Ro, useReducer as vi, useContext as Yt, cloneElement as bi, forwardRef as Qn } from "react"; import { r as rn } from "./index-B2yaYXE2.js"; import { c as an, r as tn, C as nn } from "./utils-BUdHa0nB.js"; import { c as co } from "./index-fN7hCOo3.js"; import { s as cn } from "./emotion-styled.browser.esm-DfbrHHed.js"; import { u as Jr } from "./emotion-element-f0de968e.browser.esm-CkCiQliQ.js"; import { H as yi, K as mi } from "./KanbanCard-ffmclwO4.js"; import { c as Xt, g as Oo } from "./_commonjsHelpers-BkfeUUK-.js"; import wi from "./KanbanHeader.js"; import { u as xi } from "./useUpdateEffect-CuYWz7EA.js"; var Ci = function(e) { W(e, []); }; function _i() { for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++) t[n] = arguments[n]; return ee( () => (o) => { t.forEach((a) => a(o)); }, // eslint-disable-next-line react-hooks/exhaustive-deps t ); } const er = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u"; function ln(e) { const t = Object.prototype.toString.call(e); return t === "[object Window]" || // In Electron context the Window object serializes to [object global] t === "[object global]"; } function Vr(e) { return "nodeType" in e; } function We(e) { var t, n; return e ? ln(e) ? e : Vr(e) && (t = (n = e.ownerDocument) == null ? void 0 : n.defaultView) != null ? t : window : window; } function Zr(e) { const { Document: t } = We(e); return e instanceof t; } function Cn(e) { return ln(e) ? !1 : e instanceof We(e).HTMLElement; } function Eo(e) { return e instanceof We(e).SVGElement; } function un(e) { return e ? ln(e) ? e.document : Vr(e) ? Zr(e) ? e : Cn(e) || Eo(e) ? e.ownerDocument : document : document : document; } const bt = er ? pi : W; function tr(e) { const t = Q(e); return bt(() => { t.current = e; }), Ne(function() { for (var n = arguments.length, o = new Array(n), a = 0; a < n; a++) o[a] = arguments[a]; return t.current == null ? void 0 : t.current(...o); }, []); } function Si() { const e = Q(null), t = Ne((o, a) => { e.current = setInterval(o, a); }, []), n = Ne(() => { e.current !== null && (clearInterval(e.current), e.current = null); }, []); return [t, n]; } function wn(e, t) { t === void 0 && (t = [e]); const n = Q(e); return bt(() => { n.current !== e && (n.current = e); }, t), n; } function _n(e, t) { const n = Q(); return ee( () => { const o = e(n.current); return n.current = o, o; }, // eslint-disable-next-line react-hooks/exhaustive-deps [...t] ); } function Xn(e) { const t = tr(e), n = Q(null), o = Ne( (a) => { a !== n.current && (t == null || t(a, n.current)), n.current = a; }, //eslint-disable-next-line [] ); return [n, o]; } function Yn(e) { const t = Q(); return W(() => { t.current = e; }, [e]), t.current; } let Fr = {}; function Sn(e, t) { return ee(() => { if (t) return t; const n = Fr[e] == null ? 0 : Fr[e] + 1; return Fr[e] = n, e + "-" + n; }, [e, t]); } function To(e) { return function(t) { for (var n = arguments.length, o = new Array(n > 1 ? n - 1 : 0), a = 1; a < n; a++) o[a - 1] = arguments[a]; return o.reduce((c, l) => { const u = Object.entries(l); for (const [g, d] of u) { const p = c[g]; p != null && (c[g] = p + e * d); } return c; }, { ...t }); }; } const on = /* @__PURE__ */ To(1), Wn = /* @__PURE__ */ To(-1); function Di(e) { return "clientX" in e && "clientY" in e; } function nr(e) { if (!e) return !1; const { KeyboardEvent: t } = We(e.target); return t && e instanceof t; } function Ai(e) { if (!e) return !1; const { TouchEvent: t } = We(e.target); return t && e instanceof t; } function kn(e) { if (Ai(e)) { if (e.touches && e.touches.length) { const { clientX: t, clientY: n } = e.touches[0]; return { x: t, y: n }; } else if (e.changedTouches && e.changedTouches.length) { const { clientX: t, clientY: n } = e.changedTouches[0]; return { x: t, y: n }; } } return Di(e) ? { x: e.clientX, y: e.clientY } : null; } const Wt = /* @__PURE__ */ Object.freeze({ Translate: { toString(e) { if (!e) return; const { x: t, y: n } = e; return "translate3d(" + (t ? Math.round(t) : 0) + "px, " + (n ? Math.round(n) : 0) + "px, 0)"; } }, Scale: { toString(e) { if (!e) return; const { scaleX: t, scaleY: n } = e; return "scaleX(" + t + ") scaleY(" + n + ")"; } }, Transform: { toString(e) { if (e) return [Wt.Translate.toString(e), Wt.Scale.toString(e)].join(" "); } }, Transition: { toString(e) { let { property: t, duration: n, easing: o } = e; return t + " " + n + "ms " + o; } } }), lo = "a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]"; function Ri(e) { return e.matches(lo) ? e : e.querySelector(lo); } const Oi = { display: "none" }; function Ei(e) { let { id: t, value: n } = e; return se.createElement("div", { id: t, style: Oi }, n); } function Ti(e) { let { id: t, announcement: n, ariaLiveType: o = "assertive" } = e; const a = { position: "fixed", top: 0, left: 0, width: 1, height: 1, margin: -1, border: 0, padding: 0, overflow: "hidden", clip: "rect(0 0 0 0)", clipPath: "inset(100%)", whiteSpace: "nowrap" }; return se.createElement("div", { id: t, style: a, role: "status", "aria-live": o, "aria-atomic": !0 }, n); } function Ii() { const [e, t] = he(""); return { announce: Ne((o) => { o != null && t(o); }, []), announcement: e }; } const Io = /* @__PURE__ */ xn(null); function Ni(e) { const t = Yt(Io); W(() => { if (!t) throw new Error("useDndMonitor must be used within a children of <DndContext>"); return t(e); }, [e, t]); } function Mi() { const [e] = he(() => /* @__PURE__ */ new Set()), t = Ne((o) => (e.add(o), () => e.delete(o)), [e]); return [Ne((o) => { let { type: a, event: c } = o; e.forEach((l) => { var u; return (u = l[a]) == null ? void 0 : u.call(l, c); }); }, [e]), t]; } const Li = { 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. ` }, Pi = { 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 $i(e) { let { announcements: t = Pi, container: n, hiddenTextDescribedById: o, screenReaderInstructions: a = Li } = e; const { announce: c, announcement: l } = Ii(), u = Sn("DndLiveRegion"), [g, d] = he(!1); if (W(() => { d(!0); }, []), Ni(ee(() => ({ onDragStart(v) { let { active: w } = v; c(t.onDragStart({ active: w })); }, onDragMove(v) { let { active: w, over: m } = v; t.onDragMove && c(t.onDragMove({ active: w, over: m })); }, onDragOver(v) { let { active: w, over: m } = v; c(t.onDragOver({ active: w, over: m })); }, onDragEnd(v) { let { active: w, over: m } = v; c(t.onDragEnd({ active: w, over: m })); }, onDragCancel(v) { let { active: w, over: m } = v; c(t.onDragCancel({ active: w, over: m })); } }), [c, t])), !g) return null; const p = se.createElement(se.Fragment, null, se.createElement(Ei, { id: o, value: a.draggable }), se.createElement(Ti, { id: u, announcement: l })); return n ? rn.createPortal(p, n) : p; } var xe; (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"; })(xe || (xe = {})); function qn() { } function zr(e, t) { return ee( () => ({ sensor: e, options: t ?? {} }), // eslint-disable-next-line react-hooks/exhaustive-deps [e, t] ); } function Bi() { for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++) t[n] = arguments[n]; return ee( () => [...t].filter((o) => o != null), // eslint-disable-next-line react-hooks/exhaustive-deps [...t] ); } const yt = /* @__PURE__ */ Object.freeze({ x: 0, y: 0 }); function Qr(e, t) { return Math.sqrt(Math.pow(e.x - t.x, 2) + Math.pow(e.y - t.y, 2)); } function ji(e, t) { const n = kn(e); if (!n) return "0 0"; const o = { x: (n.x - t.left) / t.width * 100, y: (n.y - t.top) / t.height * 100 }; return o.x + "% " + o.y + "%"; } function eo(e, t) { let { data: { value: n } } = e, { data: { value: o } } = t; return n - o; } function Fi(e, t) { let { data: { value: n } } = e, { data: { value: o } } = t; return o - n; } function Gr(e) { let { left: t, top: n, height: o, width: a } = e; return [{ x: t, y: n }, { x: t + a, y: n }, { x: t, y: n + o }, { x: t + a, y: n + o }]; } function to(e, t) { if (!e || e.length === 0) return null; const [n] = e; return t ? n[t] : n; } function uo(e, t, n) { return t === void 0 && (t = e.left), n === void 0 && (n = e.top), { x: t + e.width * 0.5, y: n + e.height * 0.5 }; } const fo = (e) => { let { collisionRect: t, droppableRects: n, droppableContainers: o } = e; const a = uo(t, t.left, t.top), c = []; for (const l of o) { const { id: u } = l, g = n.get(u); if (g) { const d = Qr(uo(g), a); c.push({ id: u, data: { droppableContainer: l, value: d } }); } } return c.sort(eo); }, zi = (e) => { let { collisionRect: t, droppableRects: n, droppableContainers: o } = e; const a = Gr(t), c = []; for (const l of o) { const { id: u } = l, g = n.get(u); if (g) { const d = Gr(g), p = a.reduce((w, m, A) => w + Qr(d[A], m), 0), v = Number((p / 4).toFixed(4)); c.push({ id: u, data: { droppableContainer: l, value: v } }); } } return c.sort(eo); }; function Hi(e, t) { const n = Math.max(t.top, e.top), o = Math.max(t.left, e.left), a = Math.min(t.left + t.width, e.left + e.width), c = Math.min(t.top + t.height, e.top + e.height), l = a - o, u = c - n; if (o < a && n < c) { const g = t.width * t.height, d = e.width * e.height, p = l * u, v = p / (g + d - p); return Number(v.toFixed(4)); } return 0; } const No = (e) => { let { collisionRect: t, droppableRects: n, droppableContainers: o } = e; const a = []; for (const c of o) { const { id: l } = c, u = n.get(l); if (u) { const g = Hi(u, t); g > 0 && a.push({ id: l, data: { droppableContainer: c, value: g } }); } } return a.sort(Fi); }; function Ki(e, t) { const { top: n, left: o, bottom: a, right: c } = t; return n <= e.y && e.y <= a && o <= e.x && e.x <= c; } const Ui = (e) => { let { droppableContainers: t, droppableRects: n, pointerCoordinates: o } = e; if (!o) return []; const a = []; for (const c of t) { const { id: l } = c, u = n.get(l); if (u && Ki(o, u)) { const d = Gr(u).reduce((v, w) => v + Qr(o, w), 0), p = Number((d / 4).toFixed(4)); a.push({ id: l, data: { droppableContainer: c, value: p } }); } } return a.sort(eo); }; function Gi(e, t, n) { return { ...e, scaleX: t && n ? t.width / n.width : 1, scaleY: t && n ? t.height / n.height : 1 }; } function Mo(e, t) { return e && t ? { x: e.left - t.left, y: e.top - t.top } : yt; } function Xi(e) { return function(n) { for (var o = arguments.length, a = new Array(o > 1 ? o - 1 : 0), c = 1; c < o; c++) a[c - 1] = arguments[c]; return a.reduce((l, u) => ({ ...l, top: l.top + e * u.y, bottom: l.bottom + e * u.y, left: l.left + e * u.x, right: l.right + e * u.x }), { ...n }); }; } const Yi = /* @__PURE__ */ Xi(1); function Lo(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 Wi(e, t, n) { const o = Lo(t); if (!o) return e; const { scaleX: a, scaleY: c, x: l, y: u } = o, g = e.left - l - (1 - a) * parseFloat(n), d = e.top - u - (1 - c) * parseFloat(n.slice(n.indexOf(" ") + 1)), p = a ? e.width / a : e.width, v = c ? e.height / c : e.height; return { width: p, height: v, top: d, right: g + p, bottom: d + v, left: g }; } const ki = { ignoreTransform: !1 }; function dn(e, t) { t === void 0 && (t = ki); let n = e.getBoundingClientRect(); if (t.ignoreTransform) { const { transform: d, transformOrigin: p } = We(e).getComputedStyle(e); d && (n = Wi(n, d, p)); } const { top: o, left: a, width: c, height: l, bottom: u, right: g } = n; return { top: o, left: a, width: c, height: l, bottom: u, right: g }; } function go(e) { return dn(e, { ignoreTransform: !0 }); } function qi(e) { const t = e.innerWidth, n = e.innerHeight; return { top: 0, left: 0, right: t, bottom: n, width: t, height: n }; } function Ji(e, t) { return t === void 0 && (t = We(e).getComputedStyle(e)), t.position === "fixed"; } function Vi(e, t) { t === void 0 && (t = We(e).getComputedStyle(e)); const n = /(auto|scroll|overlay)/; return ["overflow", "overflowX", "overflowY"].some((a) => { const c = t[a]; return typeof c == "string" ? n.test(c) : !1; }); } function no(e, t) { const n = []; function o(a) { if (t != null && n.length >= t || !a) return n; if (Zr(a) && a.scrollingElement != null && !n.includes(a.scrollingElement)) return n.push(a.scrollingElement), n; if (!Cn(a) || Eo(a) || n.includes(a)) return n; const c = We(e).getComputedStyle(a); return a !== e && Vi(a, c) && n.push(a), Ji(a, c) ? n : o(a.parentNode); } return e ? o(e) : n; } function Po(e) { const [t] = no(e, 1); return t ?? null; } function Hr(e) { return !er || !e ? null : ln(e) ? e : Vr(e) ? Zr(e) || e === un(e).scrollingElement ? window : Cn(e) ? e : null : null; } function $o(e) { return ln(e) ? e.scrollX : e.scrollLeft; } function Bo(e) { return ln(e) ? e.scrollY : e.scrollTop; } function Xr(e) { return { x: $o(e), y: Bo(e) }; } var De; (function(e) { e[e.Forward = 1] = "Forward", e[e.Backward = -1] = "Backward"; })(De || (De = {})); function jo(e) { return !er || !e ? !1 : e === document.scrollingElement; } function Fo(e) { const t = { x: 0, y: 0 }, n = jo(e) ? { height: window.innerHeight, width: window.innerWidth } : { height: e.clientHeight, width: e.clientWidth }, o = { x: e.scrollWidth - n.width, y: e.scrollHeight - n.height }, a = e.scrollTop <= t.y, c = e.scrollLeft <= t.x, l = e.scrollTop >= o.y, u = e.scrollLeft >= o.x; return { isTop: a, isLeft: c, isBottom: l, isRight: u, maxScroll: o, minScroll: t }; } const Zi = { x: 0.2, y: 0.2 }; function Qi(e, t, n, o, a) { let { top: c, left: l, right: u, bottom: g } = n; o === void 0 && (o = 10), a === void 0 && (a = Zi); const { isTop: d, isBottom: p, isLeft: v, isRight: w } = Fo(e), m = { x: 0, y: 0 }, A = { x: 0, y: 0 }, x = { height: t.height * a.y, width: t.width * a.x }; return !d && c <= t.top + x.height ? (m.y = De.Backward, A.y = o * Math.abs((t.top + x.height - c) / x.height)) : !p && g >= t.bottom - x.height && (m.y = De.Forward, A.y = o * Math.abs((t.bottom - x.height - g) / x.height)), !w && u >= t.right - x.width ? (m.x = De.Forward, A.x = o * Math.abs((t.right - x.width - u) / x.width)) : !v && l <= t.left + x.width && (m.x = De.Backward, A.x = o * Math.abs((t.left + x.width - l) / x.width)), { direction: m, speed: A }; } function ea(e) { if (e === document.scrollingElement) { const { innerWidth: c, innerHeight: l } = window; return { top: 0, left: 0, right: c, bottom: l, width: c, height: l }; } const { top: t, left: n, right: o, bottom: a } = e.getBoundingClientRect(); return { top: t, left: n, right: o, bottom: a, width: e.clientWidth, height: e.clientHeight }; } function zo(e) { return e.reduce((t, n) => on(t, Xr(n)), yt); } function ta(e) { return e.reduce((t, n) => t + $o(n), 0); } function na(e) { return e.reduce((t, n) => t + Bo(n), 0); } function Ho(e, t) { if (t === void 0 && (t = dn), !e) return; const { top: n, left: o, bottom: a, right: c } = t(e); Po(e) && (a <= 0 || c <= 0 || n >= window.innerHeight || o >= window.innerWidth) && e.scrollIntoView({ block: "center", inline: "center" }); } const ra = [["x", ["left", "right"], ta], ["y", ["top", "bottom"], na]]; class ro { 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 o = no(n), a = zo(o); this.rect = { ...t }, this.width = t.width, this.height = t.height; for (const [c, l, u] of ra) for (const g of l) Object.defineProperty(this, g, { get: () => { const d = u(o), p = a[c] - d; return this.rect[g] + p; }, enumerable: !0 }); Object.defineProperty(this, "rect", { enumerable: !1 }); } } class vn { constructor(t) { this.target = void 0, this.listeners = [], this.removeAll = () => { this.listeners.forEach((n) => { var o; return (o = this.target) == null ? void 0 : o.removeEventListener(...n); }); }, this.target = t; } add(t, n, o) { var a; (a = this.target) == null || a.addEventListener(t, n, o), this.listeners.push([t, n, o]); } } function oa(e) { const { EventTarget: t } = We(e); return e instanceof t ? e : un(e); } function Kr(e, t) { const n = Math.abs(e.x), o = Math.abs(e.y); return typeof t == "number" ? Math.sqrt(n ** 2 + o ** 2) > t : "x" in t && "y" in t ? n > t.x && o > t.y : "x" in t ? n > t.x : "y" in t ? o > t.y : !1; } var ft; (function(e) { e.Click = "click", e.DragStart = "dragstart", e.Keydown = "keydown", e.ContextMenu = "contextmenu", e.Resize = "resize", e.SelectionChange = "selectionchange", e.VisibilityChange = "visibilitychange"; })(ft || (ft = {})); function ho(e) { e.preventDefault(); } function ia(e) { e.stopPropagation(); } var z; (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"; })(z || (z = {})); const Ko = { start: [z.Space, z.Enter], cancel: [z.Esc], end: [z.Space, z.Enter, z.Tab] }, aa = (e, t) => { let { currentCoordinates: n } = t; switch (e.code) { case z.Right: return { ...n, x: n.x + 25 }; case z.Left: return { ...n, x: n.x - 25 }; case z.Down: return { ...n, y: n.y + 25 }; case z.Up: return { ...n, y: n.y - 25 }; } }; class oo { 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 vn(un(n)), this.windowListeners = new vn(We(n)), this.handleKeyDown = this.handleKeyDown.bind(this), this.handleCancel = this.handleCancel.bind(this), this.attach(); } attach() { this.handleStart(), this.windowListeners.add(ft.Resize, this.handleCancel), this.windowListeners.add(ft.VisibilityChange, this.handleCancel), setTimeout(() => this.listeners.add(ft.Keydown, this.handleKeyDown)); } handleStart() { const { activeNode: t, onStart: n } = this.props, o = t.node.current; o && Ho(o), n(yt); } handleKeyDown(t) { if (nr(t)) { const { active: n, context: o, options: a } = this.props, { keyboardCodes: c = Ko, coordinateGetter: l = aa, scrollBehavior: u = "smooth" } = a, { code: g } = t; if (c.end.includes(g)) { this.handleEnd(t); return; } if (c.cancel.includes(g)) { this.handleCancel(t); return; } const { collisionRect: d } = o.current, p = d ? { x: d.left, y: d.top } : yt; this.referenceCoordinates || (this.referenceCoordinates = p); const v = l(t, { active: n, context: o.current, currentCoordinates: p }); if (v) { const w = Wn(v, p), m = { x: 0, y: 0 }, { scrollableAncestors: A } = o.current; for (const x of A) { const S = t.code, { isTop: O, isRight: T, isLeft: E, isBottom: I, maxScroll: P, minScroll: N } = Fo(x), M = ea(x), B = { x: Math.min(S === z.Right ? M.right - M.width / 2 : M.right, Math.max(S === z.Right ? M.left : M.left + M.width / 2, v.x)), y: Math.min(S === z.Down ? M.bottom - M.height / 2 : M.bottom, Math.max(S === z.Down ? M.top : M.top + M.height / 2, v.y)) }, X = S === z.Right && !T || S === z.Left && !E, Y = S === z.Down && !I || S === z.Up && !O; if (X && B.x !== v.x) { const H = x.scrollLeft + w.x, te = S === z.Right && H <= P.x || S === z.Left && H >= N.x; if (te && !w.y) { x.scrollTo({ left: H, behavior: u }); return; } te ? m.x = x.scrollLeft - H : m.x = S === z.Right ? x.scrollLeft - P.x : x.scrollLeft - N.x, m.x && x.scrollBy({ left: -m.x, behavior: u }); break; } else if (Y && B.y !== v.y) { const H = x.scrollTop + w.y, te = S === z.Down && H <= P.y || S === z.Up && H >= N.y; if (te && !w.x) { x.scrollTo({ top: H, behavior: u }); return; } te ? m.y = x.scrollTop - H : m.y = S === z.Down ? x.scrollTop - P.y : x.scrollTop - N.y, m.y && x.scrollBy({ top: -m.y, behavior: u }); break; } } this.handleMove(t, on(Wn(v, this.referenceCoordinates), m)); } } } handleMove(t, n) { const { onMove: o } = this.props; t.preventDefault(), o(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(); } } oo.activators = [{ eventName: "onKeyDown", handler: (e, t, n) => { let { keyboardCodes: o = Ko, onActivation: a } = t, { active: c } = n; const { code: l } = e.nativeEvent; if (o.start.includes(l)) { const u = c.activatorNode.current; return u && e.target !== u ? !1 : (e.preventDefault(), a == null || a({ event: e.nativeEvent }), !0); } return !1; } }]; function po(e) { return !!(e && "distance" in e); } function vo(e) { return !!(e && "delay" in e); } class io { constructor(t, n, o) { var a; o === void 0 && (o = oa(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: c } = t, { target: l } = c; this.props = t, this.events = n, this.document = un(l), this.documentListeners = new vn(this.document), this.listeners = new vn(o), this.windowListeners = new vn(We(l)), this.initialCoordinates = (a = kn(c)) != null ? a : yt, 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: o } } } = 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(ft.Resize, this.handleCancel), this.windowListeners.add(ft.DragStart, ho), this.windowListeners.add(ft.VisibilityChange, this.handleCancel), this.windowListeners.add(ft.ContextMenu, ho), this.documentListeners.add(ft.Keydown, this.handleKeydown), n) { if (o != null && o({ event: this.props.event, activeNode: this.props.activeNode, options: this.props.options })) return this.handleStart(); if (vo(n)) { this.timeoutId = setTimeout(this.handleStart, n.delay), this.handlePending(n); return; } if (po(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: o, onPending: a } = this.props; a(o, t, this.initialCoordinates, n); } handleStart() { const { initialCoordinates: t } = this, { onStart: n } = this.props; t && (this.activated = !0, this.documentListeners.add(ft.Click, ia, { capture: !0 }), this.removeTextSelection(), this.documentListeners.add(ft.SelectionChange, this.removeTextSelection), n(t)); } handleMove(t) { var n; const { activated: o, initialCoordinates: a, props: c } = this, { onMove: l, options: { activationConstraint: u } } = c; if (!a) return; const g = (n = kn(t)) != null ? n : yt, d = Wn(a, g); if (!o && u) { if (po(u)) { if (u.tolerance != null && Kr(d, u.tolerance)) return this.handleCancel(); if (Kr(d, u.distance)) return this.handleStart(); } if (vo(u) && Kr(d, u.tolerance)) return this.handleCancel(); this.handlePending(u, d); return; } t.cancelable && t.preventDefault(), l(g); } 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 === z.Esc && this.handleCancel(); } removeTextSelection() { var t; (t = this.document.getSelection()) == null || t.removeAllRanges(); } } const sa = { cancel: { name: "pointercancel" }, move: { name: "pointermove" }, end: { name: "pointerup" } }; class Uo extends io { constructor(t) { const { event: n } = t, o = un(n.target); super(t, sa, o); } } Uo.activators = [{ eventName: "onPointerDown", handler: (e, t) => { let { nativeEvent: n } = e, { onActivation: o } = t; return !n.isPrimary || n.button !== 0 ? !1 : (o == null || o({ event: n }), !0); } }]; const ca = { move: { name: "mousemove" }, end: { name: "mouseup" } }; var Yr; (function(e) { e[e.RightClick = 2] = "RightClick"; })(Yr || (Yr = {})); class Go extends io { constructor(t) { super(t, ca, un(t.event.target)); } } Go.activators = [{ eventName: "onMouseDown", handler: (e, t) => { let { nativeEvent: n } = e, { onActivation: o } = t; return n.button === Yr.RightClick ? !1 : (o == null || o({ event: n }), !0); } }]; const Ur = { cancel: { name: "touchcancel" }, move: { name: "touchmove" }, end: { name: "touchend" } }; class Xo extends io { constructor(t) { super(t, Ur); } static setup() { return window.addEventListener(Ur.move.name, t, { capture: !1, passive: !1 }), function() { window.removeEventListener(Ur.move.name, t); }; function t() { } } } Xo.activators = [{ eventName: "onTouchStart", handler: (e, t) => { let { nativeEvent: n } = e, { onActivation: o } = t; const { touches: a } = n; return a.length > 1 ? !1 : (o == null || o({ event: n }), !0); } }]; var bn; (function(e) { e[e.Pointer = 0] = "Pointer", e[e.DraggableRect = 1] = "DraggableRect"; })(bn || (bn = {})); var Jn; (function(e) { e[e.TreeOrder = 0] = "TreeOrder", e[e.ReversedTreeOrder = 1] = "ReversedTreeOrder"; })(Jn || (Jn = {})); function la(e) { let { acceleration: t, activator: n = bn.Pointer, canScroll: o, draggingRect: a, enabled: c, interval: l = 5, order: u = Jn.TreeOrder, pointerCoordinates: g, scrollableAncestors: d, scrollableAncestorRects: p, delta: v, threshold: w } = e; const m = da({ delta: v, disabled: !c }), [A, x] = Si(), S = Q({ x: 0, y: 0 }), O = Q({ x: 0, y: 0 }), T = ee(() => { switch (n) { case bn.Pointer: return g ? { top: g.y, bottom: g.y, left: g.x, right: g.x } : null; case bn.DraggableRect: return a; } }, [n, a, g]), E = Q(null), I = Ne(() => { const N = E.current; if (!N) return; const M = S.current.x * O.current.x, B = S.current.y * O.current.y; N.scrollBy(M, B); }, []), P = ee(() => u === Jn.TreeOrder ? [...d].reverse() : d, [u, d]); W( () => { if (!c || !d.length || !T) { x(); return; } for (const N of P) { if ((o == null ? void 0 : o(N)) === !1) continue; const M = d.indexOf(N), B = p[M]; if (!B) continue; const { direction: X, speed: Y } = Qi(N, B, T, t, w); for (const H of ["x", "y"]) m[H][X[H]] || (Y[H] = 0, X[H] = 0); if (Y.x > 0 || Y.y > 0) { x(), E.current = N, A(I, l), S.current = Y, O.current = X; return; } } S.current = { x: 0, y: 0 }, O.current = { x: 0, y: 0 }, x(); }, // eslint-disable-next-line react-hooks/exhaustive-deps [ t, I, o, x, c, l, // eslint-disable-next-line react-hooks/exhaustive-deps JSON.stringify(T), // eslint-disable-next-line react-hooks/exhaustive-deps JSON.stringify(m), A, d, P, p, // eslint-disable-next-line react-hooks/exhaustive-deps JSON.stringify(w) ] ); } const ua = { x: { [De.Backward]: !1, [De.Forward]: !1 }, y: { [De.Backward]: !1, [De.Forward]: !1 } }; function da(e) { let { delta: t, disabled: n } = e; const o = Yn(t); return _n((a) => { if (n || !o || !a) return ua; const c = { x: Math.sign(t.x - o.x), y: Math.sign(t.y - o.y) }; return { x: { [De.Backward]: a.x[De.Backward] || c.x === -1, [De.Forward]: a.x[De.Forward] || c.x === 1 }, y: { [De.Backward]: a.y[De.Backward] || c.y === -1, [De.Forward]: a.y[De.Forward] || c.y === 1 } }; }, [n, t, o]); } function fa(e, t) { const n = t != null ? e.get(t) : void 0, o = n ? n.node.current : null; return _n((a) => { var c; return t == null ? null : (c = o ?? a) != null ? c : null; }, [o, t]); } function ga(e, t) { return ee(() => e.reduce((n, o) => { const { sensor: a } = o, c = a.activators.map((l) => ({ eventName: l.eventName, handler: t(l.handler, o) })); return [...n, ...c]; }, []), [e, t]); } var sn; (function(e) { e[e.Always = 0] = "Always", e[e.BeforeDragging = 1] = "BeforeDragging", e[e.WhileDragging = 2] = "WhileDragging"; })(sn || (sn = {})); var Wr; (function(e) { e.Optimized = "optimized"; })(Wr || (Wr = {})); const bo = /* @__PURE__ */ new Map(); function ha(e, t) { let { dragging: n, dependencies: o, config: a } = t; const [c, l] = he(null), { frequency: u, measure: g, strategy: d } = a, p = Q(e), v = S(), w = wn(v), m = Ne(function(O) { O === void 0 && (O = []), !w.current && l((T) => T === null ? O : T.concat(O.filter((E) => !T.includes(E)))); }, [w]), A = Q(null), x = _n((O) => { if (v && !n) return bo; if (!O || O === bo || p.current !== e || c != null) { const T = /* @__PURE__ */ new Map(); for (let E of e) { if (!E) continue; if (c && c.length > 0 && !c.includes(E.id) && E.rect.current) { T.set(E.id, E.rect.current); continue; } const I = E.node.current, P = I ? new ro(g(I), I) : null; E.rect.current = P, P && T.set(E.id, P); } return T; } return O; }, [e, c, n, v, g]); return W(() => { p.current = e; }, [e]), W( () => { v || m(); }, // eslint-disable-next-line react-hooks/exhaustive-deps [n, v] ), W( () => { c && c.length > 0 && l(null); }, //eslint-disable-next-line react-hooks/exhaustive-deps [JSON.stringify(c)] ), W( () => { v || typeof u != "number" || A.current !== null || (A.current = setTimeout(() => { m(), A.current = null; }, u)); }, // eslint-disable-next-line react-hooks/exhaustive-deps [u, v, m, ...o] ), { droppableRects: x, measureDroppableContainers: m, measuringScheduled: c != null }; function S() { switch (d) { case sn.Always: return !1; case sn.BeforeDragging: return n; default: return !n; } } } function ao(e, t) { return _n((n) => e ? n || (typeof t == "function" ? t(e) : e) : null, [t, e]); } function pa(e, t) { return ao(e, t); } function va(e) { let { callback: t, disabled: n } = e; const o = tr(t), a = ee(() => { if (n || typeof window > "u" || typeof window.MutationObserver > "u") return; const { MutationObserver: c } = window; return new c(o); }, [o, n]); return W(() => () => a == null ? void 0 : a.disconnect(), [a]), a; } function rr(e) { let { callback: t, disabled: n } = e; const o = tr(t), a = ee( () => { if (n || typeof window > "u" || typeof window.ResizeObserver > "u") return; const { ResizeObserver: c } = window; return new c(o); }, // eslint-disable-next-line react-hooks/exhaustive-deps [n] ); return W(() => () => a == null ? void 0 : a.disconnect(), [a]), a; } function ba(e) { return new ro(dn(e), e); } function yo(e, t, n) { t === void 0 && (t = ba); const [o, a] = he(null); function c() { a((g) => { if (!e) return null; if (e.isConnected === !1) { var d; return (d = g ?? n) != null ? d : null; } const p = t(e); return JSON.stringify(g) === JSON.stringify(p) ? g : p; }); } const l = va({ callback(g) { if (e) for (const d of g) { const { type: p, target: v } = d; if (p === "childList" && v instanceof HTMLElement && v.contains(e)) { c(); break; } } } }), u = rr({ callback: c }); return bt(() => { c(), e ? (u == null || u.observe(e), l == null || l.observe(document.body, { childList: !0, subtree: !0 })) : (u == null || u.disconnect(), l == null || l.disconnect()); }, [e]), o; } function ya(e) { const t = ao(e); return Mo(e, t); } const mo = []; function ma(e) { const t = Q(e), n = _n((o) => e ? o && o !== mo && e && t.current && e.parentNode === t.current.parentNode ? o : no(e) : mo, [e]); return W(() => { t.current = e; }, [e]), n; } function wa(e) { const [t, n] = he(null), o = Q(e), a = Ne((c) => { const l = Hr(c.target); l && n((u) => u ? (u.set(l, Xr(l)), new Map(u)) : null); }, []); return W(() => { const c = o.current; if (e !== c) { l(c); const u = e.map((g) => { const d = Hr(g); return d ? (d.addEventListener("scroll", a, { passive: !0 }), [d, Xr(d)]) : null; }).filter((g) => g != null); n(u.length ? new Map(u) : null), o.current = e; } return () => { l(e), l(c); }; function l(u) { u.forEach((g) => { const d = Hr(g); d == null || d.removeEventListener("scroll", a); }); } }, [a, e]), ee(() => e.length ? t ? Array.from(t.values()).reduce((c, l) => on(c, l), yt) : zo(e) : yt, [e, t]); } function wo(e, t) { t === void 0 && (t = []); const n = Q(null); return W( () => { n.current = null; }, // eslint-disable-next-line react-hooks/exhaustive-deps t ), W(() => { const o = e !== yt; o && !n.current && (n.current = e), !o && n.current && (n.current = null); }, [e]), n.current ? Wn(e, n.current) : yt; } function xa(e) { W( () => { if (!er) return; const t = e.map((n) => { let { sensor: o } = n; return o.setup == null ? void 0 : o.setup(); }); return () => { for (const n of t) n == null || 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 Ca(e, t) { return ee(() => e.reduce((n, o) => { let { eventName: a, handler: c } = o; return n[a] = (l) => { c(l, t); }, n; }, {}), [e, t]); } function Yo(e) { return ee(() => e ? qi(e) : null, [e]); } const xo = []; function _a(e, t) { t === void 0 && (t = dn); const [n] = e, o = Yo(n ? We(n) : null), [a, c] = he(xo); function l() { c(() => e.length ? e.map((g) => jo(g) ? o : new ro(t(g), g)) : xo); } const u = rr({ callback: l }); return bt(() => { u == null || u.disconnect(), l(), e.forEach((g) => u == null ? void 0 : u.observe(g)); }, [e]), a; } function Wo(e) { if (!e) return null; if (e.children.length > 1) return e; const t = e.children[0]; return Cn(t) ? t : e; } function Sa(e) { let { measure: t } = e; const [n, o] = he(null), a = Ne((d) => { for (const { target: p } of d) if (Cn(p)) { o((v) => { const w = t(p); return v ? { ...v, width: w.width, height: w.height } : w; }); break; } }, [t]), c = rr({ callback: a }), l = Ne((d) => { const p = Wo(d); c == null || c.disconnect(), p && (c == null || c.observe(p)), o(p ? t(p) : null); }, [t, c]), [u, g] = Xn(l); return ee(() => ({ nodeRef: u, rect: n, setRef: g }), [n, u, g]); } const Da = [{ sensor: Uo, options: {} }, { sensor: oo, options: {} }], Aa = { current: {} }, Un = { draggable: { measure: go }, droppable: { measure: go, strategy: sn.WhileDragging, frequency: Wr.Optimized }, dragOverlay: { measure: dn } }; class yn 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, o; return (n = (o = this.get(t)) == null ? void 0 : o.node.current) != null ? n : void 0; } } const Ra = { activatorEvent: null, active: null, activeNode: null, activeNodeRect: null, collisions: null, containerNodeRect: null, draggableNodes: /* @__PURE__ */ new Map(), droppableRects: /* @__PURE__ */ new Map(), droppableContainers: /* @__PURE__ */ new yn(), over: null, dragOverlay: { nodeRef: { current: null }, rect: null, setRef: qn }, scrollableAncestors: [], scrollableAncestorRects: [], measuringConfiguration: Un, measureDroppableContainers: qn, windowRect: null, measuringScheduled: !1 }, ko = { activatorEvent: null, activators: [], active: null, activeNodeRect: null, ariaDescribedById: { draggable: "" }, dispatch: qn, draggableNodes: /* @__PURE__ */ new Map(), over: null, measureDroppableContainers: qn }, Dn = /* @__PURE__ */ xn(ko), qo = /* @__PURE__ */ xn(Ra); function Oa() { return { draggable: { active: null, initialCoordinates: { x: 0, y: 0 }, nodes: /* @__PURE__ */ new Map(), translate: { x: 0, y: 0 } }, droppable: { containers: new yn() } }; } function Ea(e, t) { switch (t.type) { case xe.DragStart: return { ...e, draggable: { ...e.draggable, initialCoordinates: t.initialCoordinates, active: t.active } }; case xe.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 xe.DragEnd: case xe.DragCancel: return { ...e, draggable: { ...e.draggable, active: null, initialCoordinates: { x: 0, y: 0 }, translate: { x: 0, y: 0 } } }; case xe.RegisterDroppable: { const { element: n } = t, { id: o } = n, a = new yn(e.droppable.containers); return a.set(o, n), { ...e, droppable: { ...e.droppable, containers: a } }; } case xe.SetDroppableDisabled: { const { id: n, key: o, disabled: a } = t, c = e.droppable.containers.get(n); if (!c || o !== c.key) return e; const l = new yn(e.droppable.containers); return l.set(n, { ...c, disabled: a }), { ...e, droppable: { ...e.droppable, containers: l } }; } case xe.UnregisterDroppable: { const { id: n, key: o } = t, a = e.droppable.containers.get(n); if (!a || o !== a.key) return e; const c = new yn(e.droppable.containers); return c.delete(n), { ...e, droppable: { ...e.droppable, containers: c } }; } default: return e; } } function Ta(e) { let { disabled: t } = e; const { active: n, activatorEvent: o, draggableNodes: a } = Yt(Dn), c = Yn(o), l = Yn(n == null ? void 0 : n.id); return W(() => { if (!t && !o && c && l != null) { if (!nr(c) || document.activeElement === c.target) return; const u = a.get(l); if (!u) return; const { activatorNode: g, node: d } = u; if (!g.current && !d.current) return; requestAnimationFrame(() => { for (const p of [g.current, d.current]) { if (!p) continue; const v = Ri(p); if (v) { v.focus(); break; } } }); } }, [o, t, a, l, c]), null; } function Jo(e, t) { let { transform: n, ...o } = t; return e != null && e.length ? e.reduce((a, c) => c({ transform: a, ...o }), n) : n; } function Ia(e) { return ee( () => ({ draggable: { ...Un.draggable, ...e == null ? void 0 : e.draggable }, droppable: { ...Un.droppable, ...e == null ? void 0 : e.droppable }, dragOverlay: { ...Un.dragOverlay, ...e == null ? void 0 : e.dragOverlay } }), // eslint-disable-next-line react-hooks/exhaustive-deps [e == null ? void 0 : e.draggable, e == null ? void 0 : e.droppable, e == null ? void 0 : e.dragOverlay] ); } function Na(e) { let { activeNode: t, measure: n, initialRect: o, config: a = !0 } = e; const c = Q(!1), { x: l, y: u } = typeof a == "boolean" ? { x: a, y: a } : a; bt(() => { if (!l && !u || !t) { c.current = !1; return; } if (c.current || !o) return; const d = t == null ? void 0 : t.node.current; if (!d || d.isConnected === !1) return; const p = n(d), v = Mo(p, o); if (l || (v.x = 0), u || (v.y = 0), c.current = !0, Math.abs(v.x) > 0 || Math.abs(v.y) > 0) { const w = Po(d); w && w.scrollBy({ top: v.y, left: v.x }); } }, [t, l, u, o, n]); } const or = /* @__PURE__ */ xn({ ...yt, scaleX: 1, scaleY: 1 }); var Gt; (function(e) { e[e.Uninitialized = 0] = "Uninitialized", e[e.Initializing = 1] = "Initializing", e[e.Initialized = 2] = "Initialized"; })(Gt || (Gt = {})); const Ma = /* @__PURE__ */ Ro(function(t) { var n, o, a, c; let { id: l, accessibility: u, autoScroll: g = !0, children: d, sensors: p = Da, collisionDetection: v = No, measuring: w, modifiers: m, ...A } = t; const x = vi(Ea, void 0, Oa), [S, O] = x, [T, E] = Mi(), [I, P] = he(Gt.Uninitialized), N = I === Gt.Initialized, { draggable: { active: M, nodes: B, translate: X }, droppable: { containers: Y } } = S, H = M != null ? B.get(M) : null, te = Q({ initial: null, translated: null }), Ce = ee(() => { var J; return M != null ? { id: M, // It's possible for the active node to unmount while dragging data: (J = H == null ? void 0 : H.data) != null ? J : Aa, rect: te } : null; }, [M, H]), pe = Q(null), [K, ke] = he(null), [oe, it] = he(null), re = wn(A, Object.values(A)), j = Sn("DndDescribedBy", l), et = ee(() => Y.getEnabled(), [Y]), ce = Ia(w), { droppableRects: ie, measureDroppableContainers: qe, measuringScheduled: Me } = ha(et, { dragging: N, dependencies: [X.x, X.y], config: ce.droppable }), ve = fa(B, M), mt = ee(() => oe ? kn(oe) : null, [oe]), be = Ue(), Ae = pa(ve, ce.draggable.measure); Na({ activeNode: M != null ? B.get(M) : null, config: be.layoutShiftCompensation, initialRect: Ae, measure: ce.draggable.measure }); const U = yo(ve, ce.draggable.measure, Ae), at = yo(ve ? ve.parentElement : null), Le = Q({ activatorEvent: null, active: null, activeNode: v