UNPKG

@lanaco/lnc-react-ui

Version:

React component library

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