unifyedx-storybook-new 0.1.31 → 0.1.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,10 @@
1
1
  import require$$1, { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
2
  import * as React$1 from 'react';
3
- import React__default, { forwardRef, createElement, useState, useMemo, useId as useId$1, createContext, useContext, useCallback, useRef, useLayoutEffect, useEffect, Fragment as Fragment$1, useImperativeHandle } from 'react';
3
+ import React__default, { forwardRef, createElement, useState, useMemo, useId as useId$1, createContext, useContext, useCallback, useRef, useLayoutEffect, useEffect, Fragment as Fragment$1, useImperativeHandle, memo, useReducer } from 'react';
4
4
  import { Popover as Popover$1, PopoverButton, PopoverPanel, Transition, Dialog, TransitionChild, DialogPanel, DialogTitle, TabGroup, TabList, Tab, TabPanels, RadioGroup as RadioGroup$1, Listbox, ListboxButton, ListboxOptions, ListboxOption, SwitchGroup, Switch, Menu as Menu$1, MenuButton, Portal, MenuItems, MenuItem } from '@headlessui/react';
5
5
  import { motion, AnimatePresence } from 'framer-motion';
6
6
  import { useFloating, offset as offset$2, flip as flip$2, shift as shift$2, autoUpdate as autoUpdate$1, useClick, useDismiss, useInteractions, FloatingPortal } from '@floating-ui/react';
7
+ import { unstable_batchedUpdates, createPortal } from 'react-dom';
7
8
 
8
9
  /**
9
10
  * @license lucide-react v0.525.0 - ISC
@@ -122,11 +123,11 @@ const createLucideIcon = (iconName, iconNode) => {
122
123
  */
123
124
 
124
125
 
125
- const __iconNode$m = [
126
+ const __iconNode$o = [
126
127
  ["path", { d: "m12 19-7-7 7-7", key: "1l729n" }],
127
128
  ["path", { d: "M19 12H5", key: "x3x0zl" }]
128
129
  ];
129
- const ArrowLeft = createLucideIcon("arrow-left", __iconNode$m);
130
+ const ArrowLeft = createLucideIcon("arrow-left", __iconNode$o);
130
131
 
131
132
  /**
132
133
  * @license lucide-react v0.525.0 - ISC
@@ -136,13 +137,13 @@ const ArrowLeft = createLucideIcon("arrow-left", __iconNode$m);
136
137
  */
137
138
 
138
139
 
139
- const __iconNode$l = [
140
+ const __iconNode$n = [
140
141
  ["path", { d: "M8 2v4", key: "1cmpym" }],
141
142
  ["path", { d: "M16 2v4", key: "4m81vk" }],
142
143
  ["rect", { width: "18", height: "18", x: "3", y: "4", rx: "2", key: "1hopcy" }],
143
144
  ["path", { d: "M3 10h18", key: "8toen8" }]
144
145
  ];
145
- const Calendar$1 = createLucideIcon("calendar", __iconNode$l);
146
+ const Calendar$1 = createLucideIcon("calendar", __iconNode$n);
146
147
 
147
148
  /**
148
149
  * @license lucide-react v0.525.0 - ISC
@@ -152,8 +153,8 @@ const Calendar$1 = createLucideIcon("calendar", __iconNode$l);
152
153
  */
153
154
 
154
155
 
155
- const __iconNode$k = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
156
- const Check = createLucideIcon("check", __iconNode$k);
156
+ const __iconNode$m = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
157
+ const Check = createLucideIcon("check", __iconNode$m);
157
158
 
158
159
  /**
159
160
  * @license lucide-react v0.525.0 - ISC
@@ -163,8 +164,8 @@ const Check = createLucideIcon("check", __iconNode$k);
163
164
  */
164
165
 
165
166
 
166
- const __iconNode$j = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]];
167
- const ChevronDown = createLucideIcon("chevron-down", __iconNode$j);
167
+ const __iconNode$l = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]];
168
+ const ChevronDown = createLucideIcon("chevron-down", __iconNode$l);
168
169
 
169
170
  /**
170
171
  * @license lucide-react v0.525.0 - ISC
@@ -174,11 +175,11 @@ const ChevronDown = createLucideIcon("chevron-down", __iconNode$j);
174
175
  */
175
176
 
176
177
 
177
- const __iconNode$i = [
178
+ const __iconNode$k = [
178
179
  ["path", { d: "m17 18-6-6 6-6", key: "1yerx2" }],
179
180
  ["path", { d: "M7 6v12", key: "1p53r6" }]
180
181
  ];
181
- const ChevronFirst = createLucideIcon("chevron-first", __iconNode$i);
182
+ const ChevronFirst = createLucideIcon("chevron-first", __iconNode$k);
182
183
 
183
184
  /**
184
185
  * @license lucide-react v0.525.0 - ISC
@@ -188,11 +189,11 @@ const ChevronFirst = createLucideIcon("chevron-first", __iconNode$i);
188
189
  */
189
190
 
190
191
 
191
- const __iconNode$h = [
192
+ const __iconNode$j = [
192
193
  ["path", { d: "m7 18 6-6-6-6", key: "lwmzdw" }],
193
194
  ["path", { d: "M17 6v12", key: "1o0aio" }]
194
195
  ];
195
- const ChevronLast = createLucideIcon("chevron-last", __iconNode$h);
196
+ const ChevronLast = createLucideIcon("chevron-last", __iconNode$j);
196
197
 
197
198
  /**
198
199
  * @license lucide-react v0.525.0 - ISC
@@ -202,8 +203,8 @@ const ChevronLast = createLucideIcon("chevron-last", __iconNode$h);
202
203
  */
203
204
 
204
205
 
205
- const __iconNode$g = [["path", { d: "m15 18-6-6 6-6", key: "1wnfg3" }]];
206
- const ChevronLeft = createLucideIcon("chevron-left", __iconNode$g);
206
+ const __iconNode$i = [["path", { d: "m15 18-6-6 6-6", key: "1wnfg3" }]];
207
+ const ChevronLeft = createLucideIcon("chevron-left", __iconNode$i);
207
208
 
208
209
  /**
209
210
  * @license lucide-react v0.525.0 - ISC
@@ -213,8 +214,8 @@ const ChevronLeft = createLucideIcon("chevron-left", __iconNode$g);
213
214
  */
214
215
 
215
216
 
216
- const __iconNode$f = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]];
217
- const ChevronRight = createLucideIcon("chevron-right", __iconNode$f);
217
+ const __iconNode$h = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]];
218
+ const ChevronRight = createLucideIcon("chevron-right", __iconNode$h);
218
219
 
219
220
  /**
220
221
  * @license lucide-react v0.525.0 - ISC
@@ -224,11 +225,11 @@ const ChevronRight = createLucideIcon("chevron-right", __iconNode$f);
224
225
  */
225
226
 
226
227
 
227
- const __iconNode$e = [
228
+ const __iconNode$g = [
228
229
  ["path", { d: "m7 15 5 5 5-5", key: "1hf1tw" }],
229
230
  ["path", { d: "m7 9 5-5 5 5", key: "sgt6xg" }]
230
231
  ];
231
- const ChevronsUpDown = createLucideIcon("chevrons-up-down", __iconNode$e);
232
+ const ChevronsUpDown = createLucideIcon("chevrons-up-down", __iconNode$g);
232
233
 
233
234
  /**
234
235
  * @license lucide-react v0.525.0 - ISC
@@ -238,11 +239,11 @@ const ChevronsUpDown = createLucideIcon("chevrons-up-down", __iconNode$e);
238
239
  */
239
240
 
240
241
 
241
- const __iconNode$d = [
242
+ const __iconNode$f = [
242
243
  ["path", { d: "M21.801 10A10 10 0 1 1 17 3.335", key: "yps3ct" }],
243
244
  ["path", { d: "m9 11 3 3L22 4", key: "1pflzl" }]
244
245
  ];
245
- const CircleCheckBig = createLucideIcon("circle-check-big", __iconNode$d);
246
+ const CircleCheckBig = createLucideIcon("circle-check-big", __iconNode$f);
246
247
 
247
248
  /**
248
249
  * @license lucide-react v0.525.0 - ISC
@@ -252,12 +253,12 @@ const CircleCheckBig = createLucideIcon("circle-check-big", __iconNode$d);
252
253
  */
253
254
 
254
255
 
255
- const __iconNode$c = [
256
+ const __iconNode$e = [
256
257
  ["path", { d: "M12 13v8", key: "1l5pq0" }],
257
258
  ["path", { d: "M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242", key: "1pljnt" }],
258
259
  ["path", { d: "m8 17 4-4 4 4", key: "1quai1" }]
259
260
  ];
260
- const CloudUpload = createLucideIcon("cloud-upload", __iconNode$c);
261
+ const CloudUpload = createLucideIcon("cloud-upload", __iconNode$e);
261
262
 
262
263
  /**
263
264
  * @license lucide-react v0.525.0 - ISC
@@ -267,12 +268,12 @@ const CloudUpload = createLucideIcon("cloud-upload", __iconNode$c);
267
268
  */
268
269
 
269
270
 
270
- const __iconNode$b = [
271
+ const __iconNode$d = [
271
272
  ["circle", { cx: "12", cy: "12", r: "1", key: "41hilf" }],
272
273
  ["circle", { cx: "12", cy: "5", r: "1", key: "gxeob9" }],
273
274
  ["circle", { cx: "12", cy: "19", r: "1", key: "lyex9k" }]
274
275
  ];
275
- const EllipsisVertical = createLucideIcon("ellipsis-vertical", __iconNode$b);
276
+ const EllipsisVertical = createLucideIcon("ellipsis-vertical", __iconNode$d);
276
277
 
277
278
  /**
278
279
  * @license lucide-react v0.525.0 - ISC
@@ -282,12 +283,49 @@ const EllipsisVertical = createLucideIcon("ellipsis-vertical", __iconNode$b);
282
283
  */
283
284
 
284
285
 
285
- const __iconNode$a = [
286
+ const __iconNode$c = [
286
287
  ["path", { d: "M12 17h.01", key: "p32p05" }],
287
288
  ["path", { d: "M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z", key: "1mlx9k" }],
288
289
  ["path", { d: "M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3", key: "mhlwft" }]
289
290
  ];
290
- const FileQuestionMark = createLucideIcon("file-question-mark", __iconNode$a);
291
+ const FileQuestionMark = createLucideIcon("file-question-mark", __iconNode$c);
292
+
293
+ /**
294
+ * @license lucide-react v0.525.0 - ISC
295
+ *
296
+ * This source code is licensed under the ISC license.
297
+ * See the LICENSE file in the root directory of this source tree.
298
+ */
299
+
300
+
301
+ const __iconNode$b = [
302
+ [
303
+ "path",
304
+ {
305
+ d: "M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",
306
+ key: "1kt360"
307
+ }
308
+ ]
309
+ ];
310
+ const Folder = createLucideIcon("folder", __iconNode$b);
311
+
312
+ /**
313
+ * @license lucide-react v0.525.0 - ISC
314
+ *
315
+ * This source code is licensed under the ISC license.
316
+ * See the LICENSE file in the root directory of this source tree.
317
+ */
318
+
319
+
320
+ const __iconNode$a = [
321
+ ["circle", { cx: "9", cy: "12", r: "1", key: "1vctgf" }],
322
+ ["circle", { cx: "9", cy: "5", r: "1", key: "hp0tcf" }],
323
+ ["circle", { cx: "9", cy: "19", r: "1", key: "fkjjf6" }],
324
+ ["circle", { cx: "15", cy: "12", r: "1", key: "1tmaij" }],
325
+ ["circle", { cx: "15", cy: "5", r: "1", key: "19l28e" }],
326
+ ["circle", { cx: "15", cy: "19", r: "1", key: "f4zoj3" }]
327
+ ];
328
+ const GripVertical = createLucideIcon("grip-vertical", __iconNode$a);
291
329
 
292
330
  /**
293
331
  * @license lucide-react v0.525.0 - ISC
@@ -2763,10 +2801,10 @@ function addMonths$1(date, amount, options) {
2763
2801
  }
2764
2802
  }
2765
2803
 
2766
- let defaultOptions$2 = {};
2804
+ let defaultOptions$3 = {};
2767
2805
 
2768
2806
  function getDefaultOptions$1() {
2769
- return defaultOptions$2;
2807
+ return defaultOptions$3;
2770
2808
  }
2771
2809
 
2772
2810
  /**
@@ -14328,12 +14366,12 @@ function getValueForCheckbox(currentValue, checked, valueProp) {
14328
14366
  // @see https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85
14329
14367
 
14330
14368
 
14331
- var useIsomorphicLayoutEffect$1 = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined' ? useLayoutEffect : useEffect;
14369
+ var useIsomorphicLayoutEffect$2 = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined' ? useLayoutEffect : useEffect;
14332
14370
 
14333
14371
  function useEventCallback(fn) {
14334
14372
  var ref = useRef(fn); // we copy a ref to the callback scoped to the current state/props on each render
14335
14373
 
14336
- useIsomorphicLayoutEffect$1(function () {
14374
+ useIsomorphicLayoutEffect$2(function () {
14337
14375
  ref.current = fn;
14338
14376
  });
14339
14377
  return useCallback(function () {
@@ -14376,7 +14414,7 @@ var DayCell = {};
14376
14414
 
14377
14415
  var dateFns = {};
14378
14416
 
14379
- var add = {};
14417
+ var add$1 = {};
14380
14418
 
14381
14419
  var addDays = {};
14382
14420
 
@@ -14882,9 +14920,9 @@ function requireAddMonths () {
14882
14920
  var hasRequiredAdd;
14883
14921
 
14884
14922
  function requireAdd () {
14885
- if (hasRequiredAdd) return add;
14923
+ if (hasRequiredAdd) return add$1;
14886
14924
  hasRequiredAdd = 1;
14887
- add.add = add$1;
14925
+ add$1.add = add;
14888
14926
  var _index = /*@__PURE__*/ requireAddDays();
14889
14927
  var _index2 = /*@__PURE__*/ requireAddMonths();
14890
14928
  var _index3 = /*@__PURE__*/ requireConstructFrom();
@@ -14924,7 +14962,7 @@ function requireAdd () {
14924
14962
  * })
14925
14963
  * //=> Thu Jun 15 2017 15:29:20
14926
14964
  */
14927
- function add$1(date, duration, options) {
14965
+ function add(date, duration, options) {
14928
14966
  const {
14929
14967
  years = 0,
14930
14968
  months = 0,
@@ -14958,7 +14996,7 @@ function requireAdd () {
14958
14996
  +dateWithDays + msToAdd,
14959
14997
  );
14960
14998
  }
14961
- return add;
14999
+ return add$1;
14962
15000
  }
14963
15001
 
14964
15002
  var addBusinessDays = {};
@@ -15262,15 +15300,15 @@ var startOfISOWeek = {};
15262
15300
 
15263
15301
  var startOfWeek = {};
15264
15302
 
15265
- var defaultOptions$1 = {};
15303
+ var defaultOptions$2 = {};
15266
15304
 
15267
15305
  var hasRequiredDefaultOptions;
15268
15306
 
15269
15307
  function requireDefaultOptions () {
15270
- if (hasRequiredDefaultOptions) return defaultOptions$1;
15308
+ if (hasRequiredDefaultOptions) return defaultOptions$2;
15271
15309
  hasRequiredDefaultOptions = 1;
15272
- defaultOptions$1.getDefaultOptions = getDefaultOptions;
15273
- defaultOptions$1.setDefaultOptions = setDefaultOptions;
15310
+ defaultOptions$2.getDefaultOptions = getDefaultOptions;
15311
+ defaultOptions$2.setDefaultOptions = setDefaultOptions;
15274
15312
 
15275
15313
  let defaultOptions = {};
15276
15314
 
@@ -15281,7 +15319,7 @@ function requireDefaultOptions () {
15281
15319
  function setDefaultOptions(newOptions) {
15282
15320
  defaultOptions = newOptions;
15283
15321
  }
15284
- return defaultOptions$1;
15322
+ return defaultOptions$2;
15285
15323
  }
15286
15324
 
15287
15325
  var hasRequiredStartOfWeek;
@@ -41758,7 +41796,7 @@ function hasWindow() {
41758
41796
  return typeof window !== 'undefined';
41759
41797
  }
41760
41798
  function getNodeName(node) {
41761
- if (isNode(node)) {
41799
+ if (isNode$1(node)) {
41762
41800
  return (node.nodeName || '').toLowerCase();
41763
41801
  }
41764
41802
  // Mocked nodes in testing environments may not be instances of Node. By
@@ -41766,37 +41804,37 @@ function getNodeName(node) {
41766
41804
  // https://github.com/floating-ui/floating-ui/issues/2317
41767
41805
  return '#document';
41768
41806
  }
41769
- function getWindow(node) {
41807
+ function getWindow$1(node) {
41770
41808
  var _node$ownerDocument;
41771
41809
  return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
41772
41810
  }
41773
41811
  function getDocumentElement(node) {
41774
41812
  var _ref;
41775
- return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
41813
+ return (_ref = (isNode$1(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
41776
41814
  }
41777
- function isNode(value) {
41815
+ function isNode$1(value) {
41778
41816
  if (!hasWindow()) {
41779
41817
  return false;
41780
41818
  }
41781
- return value instanceof Node || value instanceof getWindow(value).Node;
41819
+ return value instanceof Node || value instanceof getWindow$1(value).Node;
41782
41820
  }
41783
41821
  function isElement(value) {
41784
41822
  if (!hasWindow()) {
41785
41823
  return false;
41786
41824
  }
41787
- return value instanceof Element || value instanceof getWindow(value).Element;
41825
+ return value instanceof Element || value instanceof getWindow$1(value).Element;
41788
41826
  }
41789
- function isHTMLElement$1(value) {
41827
+ function isHTMLElement$2(value) {
41790
41828
  if (!hasWindow()) {
41791
41829
  return false;
41792
41830
  }
41793
- return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
41831
+ return value instanceof HTMLElement || value instanceof getWindow$1(value).HTMLElement;
41794
41832
  }
41795
41833
  function isShadowRoot(value) {
41796
41834
  if (!hasWindow() || typeof ShadowRoot === 'undefined') {
41797
41835
  return false;
41798
41836
  }
41799
- return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
41837
+ return value instanceof ShadowRoot || value instanceof getWindow$1(value).ShadowRoot;
41800
41838
  }
41801
41839
  const invalidOverflowDisplayValues = /*#__PURE__*/new Set(['inline', 'contents']);
41802
41840
  function isOverflowElement(element) {
@@ -41835,7 +41873,7 @@ function isContainingBlock(elementOrCss) {
41835
41873
  }
41836
41874
  function getContainingBlock(element) {
41837
41875
  let currentNode = getParentNode(element);
41838
- while (isHTMLElement$1(currentNode) && !isLastTraversableNode(currentNode)) {
41876
+ while (isHTMLElement$2(currentNode) && !isLastTraversableNode(currentNode)) {
41839
41877
  if (isContainingBlock(currentNode)) {
41840
41878
  return currentNode;
41841
41879
  } else if (isTopLayer(currentNode)) {
@@ -41854,7 +41892,7 @@ function isLastTraversableNode(node) {
41854
41892
  return lastTraversableNodeNames.has(getNodeName(node));
41855
41893
  }
41856
41894
  function getComputedStyle$1(element) {
41857
- return getWindow(element).getComputedStyle(element);
41895
+ return getWindow$1(element).getComputedStyle(element);
41858
41896
  }
41859
41897
  function getNodeScroll(element) {
41860
41898
  if (isElement(element)) {
@@ -41888,7 +41926,7 @@ function getNearestOverflowAncestor(node) {
41888
41926
  if (isLastTraversableNode(parentNode)) {
41889
41927
  return node.ownerDocument ? node.ownerDocument.body : node.body;
41890
41928
  }
41891
- if (isHTMLElement$1(parentNode) && isOverflowElement(parentNode)) {
41929
+ if (isHTMLElement$2(parentNode) && isOverflowElement(parentNode)) {
41892
41930
  return parentNode;
41893
41931
  }
41894
41932
  return getNearestOverflowAncestor(parentNode);
@@ -41903,7 +41941,7 @@ function getOverflowAncestors(node, list, traverseIframes) {
41903
41941
  }
41904
41942
  const scrollableAncestor = getNearestOverflowAncestor(node);
41905
41943
  const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
41906
- const win = getWindow(scrollableAncestor);
41944
+ const win = getWindow$1(scrollableAncestor);
41907
41945
  if (isBody) {
41908
41946
  const frameElement = getFrameElement(win);
41909
41947
  return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
@@ -41920,7 +41958,7 @@ function getCssDimensions(element) {
41920
41958
  // strings for SVG elements, returning NaN. Fallback to `0` in this case.
41921
41959
  let width = parseFloat(css.width) || 0;
41922
41960
  let height = parseFloat(css.height) || 0;
41923
- const hasOffset = isHTMLElement$1(element);
41961
+ const hasOffset = isHTMLElement$2(element);
41924
41962
  const offsetWidth = hasOffset ? element.offsetWidth : width;
41925
41963
  const offsetHeight = hasOffset ? element.offsetHeight : height;
41926
41964
  const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
@@ -41941,7 +41979,7 @@ function unwrapElement(element) {
41941
41979
 
41942
41980
  function getScale(element) {
41943
41981
  const domElement = unwrapElement(element);
41944
- if (!isHTMLElement$1(domElement)) {
41982
+ if (!isHTMLElement$2(domElement)) {
41945
41983
  return createCoords(1);
41946
41984
  }
41947
41985
  const rect = domElement.getBoundingClientRect();
@@ -41969,7 +42007,7 @@ function getScale(element) {
41969
42007
 
41970
42008
  const noOffsets = /*#__PURE__*/createCoords(0);
41971
42009
  function getVisualOffsets(element) {
41972
- const win = getWindow(element);
42010
+ const win = getWindow$1(element);
41973
42011
  if (!isWebKit() || !win.visualViewport) {
41974
42012
  return noOffsets;
41975
42013
  }
@@ -41982,7 +42020,7 @@ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
41982
42020
  if (isFixed === void 0) {
41983
42021
  isFixed = false;
41984
42022
  }
41985
- if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
42023
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow$1(element)) {
41986
42024
  return false;
41987
42025
  }
41988
42026
  return isFixed;
@@ -42013,8 +42051,8 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
42013
42051
  let width = clientRect.width / scale.x;
42014
42052
  let height = clientRect.height / scale.y;
42015
42053
  if (domElement) {
42016
- const win = getWindow(domElement);
42017
- const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
42054
+ const win = getWindow$1(domElement);
42055
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow$1(offsetParent) : offsetParent;
42018
42056
  let currentWin = win;
42019
42057
  let currentIFrame = getFrameElement(currentWin);
42020
42058
  while (currentIFrame && offsetParent && offsetWin !== currentWin) {
@@ -42029,7 +42067,7 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
42029
42067
  height *= iframeScale.y;
42030
42068
  x += left;
42031
42069
  y += top;
42032
- currentWin = getWindow(currentIFrame);
42070
+ currentWin = getWindow$1(currentIFrame);
42033
42071
  currentIFrame = getFrameElement(currentWin);
42034
42072
  }
42035
42073
  }
@@ -42085,12 +42123,12 @@ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
42085
42123
  };
42086
42124
  let scale = createCoords(1);
42087
42125
  const offsets = createCoords(0);
42088
- const isOffsetParentAnElement = isHTMLElement$1(offsetParent);
42126
+ const isOffsetParentAnElement = isHTMLElement$2(offsetParent);
42089
42127
  if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
42090
42128
  if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
42091
42129
  scroll = getNodeScroll(offsetParent);
42092
42130
  }
42093
- if (isHTMLElement$1(offsetParent)) {
42131
+ if (isHTMLElement$2(offsetParent)) {
42094
42132
  const offsetRect = getBoundingClientRect(offsetParent);
42095
42133
  scale = getScale(offsetParent);
42096
42134
  offsets.x = offsetRect.x + offsetParent.clientLeft;
@@ -42132,7 +42170,7 @@ function getDocumentRect(element) {
42132
42170
  }
42133
42171
 
42134
42172
  function getViewportRect(element, strategy) {
42135
- const win = getWindow(element);
42173
+ const win = getWindow$1(element);
42136
42174
  const html = getDocumentElement(element);
42137
42175
  const visualViewport = win.visualViewport;
42138
42176
  let width = html.clientWidth;
@@ -42162,7 +42200,7 @@ function getInnerBoundingClientRect(element, strategy) {
42162
42200
  const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
42163
42201
  const top = clientRect.top + element.clientTop;
42164
42202
  const left = clientRect.left + element.clientLeft;
42165
- const scale = isHTMLElement$1(element) ? getScale(element) : createCoords(1);
42203
+ const scale = isHTMLElement$2(element) ? getScale(element) : createCoords(1);
42166
42204
  const width = element.clientWidth * scale.x;
42167
42205
  const height = element.clientHeight * scale.y;
42168
42206
  const x = left * scale.x;
@@ -42275,7 +42313,7 @@ function getDimensions(element) {
42275
42313
  }
42276
42314
 
42277
42315
  function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
42278
- const isOffsetParentAnElement = isHTMLElement$1(offsetParent);
42316
+ const isOffsetParentAnElement = isHTMLElement$2(offsetParent);
42279
42317
  const documentElement = getDocumentElement(offsetParent);
42280
42318
  const isFixed = strategy === 'fixed';
42281
42319
  const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
@@ -42321,7 +42359,7 @@ function isStaticPositioned(element) {
42321
42359
  }
42322
42360
 
42323
42361
  function getTrueOffsetParent(element, polyfill) {
42324
- if (!isHTMLElement$1(element) || getComputedStyle$1(element).position === 'fixed') {
42362
+ if (!isHTMLElement$2(element) || getComputedStyle$1(element).position === 'fixed') {
42325
42363
  return null;
42326
42364
  }
42327
42365
  if (polyfill) {
@@ -42342,11 +42380,11 @@ function getTrueOffsetParent(element, polyfill) {
42342
42380
  // Gets the closest ancestor positioned element. Handles some edge cases,
42343
42381
  // such as table ancestors and cross browser bugs.
42344
42382
  function getOffsetParent(element, polyfill) {
42345
- const win = getWindow(element);
42383
+ const win = getWindow$1(element);
42346
42384
  if (isTopLayer(element)) {
42347
42385
  return win;
42348
42386
  }
42349
- if (!isHTMLElement$1(element)) {
42387
+ if (!isHTMLElement$2(element)) {
42350
42388
  let svgOffsetParent = getParentNode(element);
42351
42389
  while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
42352
42390
  if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
@@ -43374,7 +43412,7 @@ var getProxyFormState = (formState, control, localProxyFormState, isRoot = true)
43374
43412
  return result;
43375
43413
  };
43376
43414
 
43377
- const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? React__default.useLayoutEffect : React__default.useEffect;
43415
+ const useIsomorphicLayoutEffect$1 = typeof window !== 'undefined' ? React__default.useLayoutEffect : React__default.useEffect;
43378
43416
 
43379
43417
  var isString$1 = (value) => typeof value === 'string';
43380
43418
 
@@ -43475,7 +43513,7 @@ var isFileInput = (element) => element.type === 'file';
43475
43513
 
43476
43514
  var isFunction$1 = (value) => typeof value === 'function';
43477
43515
 
43478
- var isHTMLElement = (value) => {
43516
+ var isHTMLElement$1 = (value) => {
43479
43517
  if (!isWeb) {
43480
43518
  return false;
43481
43519
  }
@@ -43490,7 +43528,7 @@ var isRadioInput = (element) => element.type === 'radio';
43490
43528
 
43491
43529
  var isRadioOrCheckbox = (ref) => isRadioInput(ref) || isCheckBoxInput(ref);
43492
43530
 
43493
- var live = (ref) => isHTMLElement(ref) && ref.isConnected;
43531
+ var live = (ref) => isHTMLElement$1(ref) && ref.isConnected;
43494
43532
 
43495
43533
  function baseGet(object, updatePath) {
43496
43534
  const length = updatePath.slice(0, -1).length;
@@ -43851,7 +43889,7 @@ var validateField = async (field, disabledFieldNames, formValues, validateAllFie
43851
43889
  const isEmpty = ((valueAsNumber || isFileInput(ref)) &&
43852
43890
  isUndefined$1(ref.value) &&
43853
43891
  isUndefined$1(inputValue)) ||
43854
- (isHTMLElement(ref) && ref.value === '') ||
43892
+ (isHTMLElement$1(ref) && ref.value === '') ||
43855
43893
  inputValue === '' ||
43856
43894
  (Array.isArray(inputValue) && !inputValue.length);
43857
43895
  const appendErrorsCurry = appendErrors.bind(null, name, validateAllFieldCriteria, error);
@@ -44010,14 +44048,14 @@ var validateField = async (field, disabledFieldNames, formValues, validateAllFie
44010
44048
  return error;
44011
44049
  };
44012
44050
 
44013
- const defaultOptions = {
44051
+ const defaultOptions$1 = {
44014
44052
  mode: VALIDATION_MODE.onSubmit,
44015
44053
  reValidateMode: VALIDATION_MODE.onChange,
44016
44054
  shouldFocusError: true,
44017
44055
  };
44018
44056
  function createFormControl(props = {}) {
44019
44057
  let _options = {
44020
- ...defaultOptions,
44058
+ ...defaultOptions$1,
44021
44059
  ...props,
44022
44060
  };
44023
44061
  let _formState = {
@@ -44335,7 +44373,7 @@ function createFormControl(props = {}) {
44335
44373
  !fieldReference.disabled &&
44336
44374
  set(_formValues, name, getFieldValueAs(value, fieldReference));
44337
44375
  fieldValue =
44338
- isHTMLElement(fieldReference.ref) && isNullOrUndefined(value)
44376
+ isHTMLElement$1(fieldReference.ref) && isNullOrUndefined(value)
44339
44377
  ? ''
44340
44378
  : value;
44341
44379
  if (isMultipleSelect(fieldReference.ref)) {
@@ -44876,7 +44914,7 @@ function createFormControl(props = {}) {
44876
44914
  const fieldReference = Array.isArray(field._f.refs)
44877
44915
  ? field._f.refs[0]
44878
44916
  : field._f.ref;
44879
- if (isHTMLElement(fieldReference)) {
44917
+ if (isHTMLElement$1(fieldReference)) {
44880
44918
  const form = fieldReference.closest('form');
44881
44919
  if (form) {
44882
44920
  form.reset();
@@ -45182,7 +45220,7 @@ function useFieldArray(props) {
45182
45220
  control._names.array.add(name);
45183
45221
  React__default.useMemo(() => rules &&
45184
45222
  control.register(name, rules), [control, rules, name]);
45185
- useIsomorphicLayoutEffect(() => control._subjects.array.subscribe({
45223
+ useIsomorphicLayoutEffect$1(() => control._subjects.array.subscribe({
45186
45224
  next: ({ values, name: fieldArrayName, }) => {
45187
45225
  if (fieldArrayName === name || !fieldArrayName) {
45188
45226
  const fieldValues = get(values, name);
@@ -45443,7 +45481,7 @@ function useForm(props = {}) {
45443
45481
  }
45444
45482
  const control = _formControl.current.control;
45445
45483
  control._options = props;
45446
- useIsomorphicLayoutEffect(() => {
45484
+ useIsomorphicLayoutEffect$1(() => {
45447
45485
  const sub = control._subscribe({
45448
45486
  formState: control._proxyFormState,
45449
45487
  callback: () => updateFormState({ ...control._formState }),
@@ -48567,7 +48605,7 @@ const toObjectSet = (arrayOrString, delimiter) => {
48567
48605
  return obj;
48568
48606
  };
48569
48607
 
48570
- const noop = () => {};
48608
+ const noop$1 = () => {};
48571
48609
 
48572
48610
  const toFiniteNumber = (value, defaultValue) => {
48573
48611
  return value != null && Number.isFinite(value = +value) ? value : defaultValue;
@@ -48705,7 +48743,7 @@ const utils$1 = {
48705
48743
  freezeMethods,
48706
48744
  toObjectSet,
48707
48745
  toCamelCase,
48708
- noop,
48746
+ noop: noop$1,
48709
48747
  toFiniteNumber,
48710
48748
  findKey,
48711
48749
  global: _global,
@@ -70544,5 +70582,4167 @@ MultiSelect.defaultProps = {
70544
70582
  getOptionLabel: (o) => o.name
70545
70583
  };
70546
70584
 
70547
- export { AddUserGroupsRolesModal, Avatar, AvatarGroup, Badge, Breadcrumbs, Button$1 as Button, Checkbox, DatePicker, DateRangePicker$1 as DateRangePicker, FileUploadModal, FullScreenLoader, GenericFilter, Input, Modal, MultiSelect, OptionsMenu, PageHeader, PageLayout, Pagination, RadioGroup, SearchBar, Select, Sidebar, Spinner, Textarea, ToggleSwitch, Tooltip, UnifyedCoreButton, WizardModal, adGroupsListSearchApi, axiosDelete, axiosGet, axiosPatch, axiosPost, axiosPut, cookies$1 as cookies, createHttpClient, directoryPermissionsApi, filePermissionsApi, gateWayUrl, gatewayBase, getBaseUrl, getSnapshot, http, localStore, myDriveGatewayBaseV2, provisioningBase, rbacBase, searchRolesApi, sessionStore, userSearchBase };
70585
+ // https://github.com/facebook/react/blob/master/packages/shared/ExecutionEnvironment.js
70586
+ const canUseDOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
70587
+
70588
+ function isWindow(element) {
70589
+ const elementString = Object.prototype.toString.call(element);
70590
+ return elementString === '[object Window]' || // In Electron context the Window object serializes to [object global]
70591
+ elementString === '[object global]';
70592
+ }
70593
+
70594
+ function isNode(node) {
70595
+ return 'nodeType' in node;
70596
+ }
70597
+
70598
+ function getWindow(target) {
70599
+ var _target$ownerDocument, _target$ownerDocument2;
70600
+
70601
+ if (!target) {
70602
+ return window;
70603
+ }
70604
+
70605
+ if (isWindow(target)) {
70606
+ return target;
70607
+ }
70608
+
70609
+ if (!isNode(target)) {
70610
+ return window;
70611
+ }
70612
+
70613
+ return (_target$ownerDocument = (_target$ownerDocument2 = target.ownerDocument) == null ? void 0 : _target$ownerDocument2.defaultView) != null ? _target$ownerDocument : window;
70614
+ }
70615
+
70616
+ function isDocument(node) {
70617
+ const {
70618
+ Document
70619
+ } = getWindow(node);
70620
+ return node instanceof Document;
70621
+ }
70622
+
70623
+ function isHTMLElement(node) {
70624
+ if (isWindow(node)) {
70625
+ return false;
70626
+ }
70627
+
70628
+ return node instanceof getWindow(node).HTMLElement;
70629
+ }
70630
+
70631
+ function isSVGElement(node) {
70632
+ return node instanceof getWindow(node).SVGElement;
70633
+ }
70634
+
70635
+ function getOwnerDocument(target) {
70636
+ if (!target) {
70637
+ return document;
70638
+ }
70639
+
70640
+ if (isWindow(target)) {
70641
+ return target.document;
70642
+ }
70643
+
70644
+ if (!isNode(target)) {
70645
+ return document;
70646
+ }
70647
+
70648
+ if (isDocument(target)) {
70649
+ return target;
70650
+ }
70651
+
70652
+ if (isHTMLElement(target) || isSVGElement(target)) {
70653
+ return target.ownerDocument;
70654
+ }
70655
+
70656
+ return document;
70657
+ }
70658
+
70659
+ /**
70660
+ * A hook that resolves to useEffect on the server and useLayoutEffect on the client
70661
+ * @param callback {function} Callback function that is invoked when the dependencies of the hook change
70662
+ */
70663
+
70664
+ const useIsomorphicLayoutEffect = canUseDOM ? useLayoutEffect : useEffect;
70665
+
70666
+ function useEvent(handler) {
70667
+ const handlerRef = useRef(handler);
70668
+ useIsomorphicLayoutEffect(() => {
70669
+ handlerRef.current = handler;
70670
+ });
70671
+ return useCallback(function () {
70672
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
70673
+ args[_key] = arguments[_key];
70674
+ }
70675
+
70676
+ return handlerRef.current == null ? void 0 : handlerRef.current(...args);
70677
+ }, []);
70678
+ }
70679
+
70680
+ function useInterval() {
70681
+ const intervalRef = useRef(null);
70682
+ const set = useCallback((listener, duration) => {
70683
+ intervalRef.current = setInterval(listener, duration);
70684
+ }, []);
70685
+ const clear = useCallback(() => {
70686
+ if (intervalRef.current !== null) {
70687
+ clearInterval(intervalRef.current);
70688
+ intervalRef.current = null;
70689
+ }
70690
+ }, []);
70691
+ return [set, clear];
70692
+ }
70693
+
70694
+ function useLatestValue(value, dependencies) {
70695
+ if (dependencies === void 0) {
70696
+ dependencies = [value];
70697
+ }
70698
+
70699
+ const valueRef = useRef(value);
70700
+ useIsomorphicLayoutEffect(() => {
70701
+ if (valueRef.current !== value) {
70702
+ valueRef.current = value;
70703
+ }
70704
+ }, dependencies);
70705
+ return valueRef;
70706
+ }
70707
+
70708
+ function useLazyMemo(callback, dependencies) {
70709
+ const valueRef = useRef();
70710
+ return useMemo(() => {
70711
+ const newValue = callback(valueRef.current);
70712
+ valueRef.current = newValue;
70713
+ return newValue;
70714
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
70715
+ [...dependencies]);
70716
+ }
70717
+
70718
+ function useNodeRef(onChange) {
70719
+ const onChangeHandler = useEvent(onChange);
70720
+ const node = useRef(null);
70721
+ const setNodeRef = useCallback(element => {
70722
+ if (element !== node.current) {
70723
+ onChangeHandler == null ? void 0 : onChangeHandler(element, node.current);
70724
+ }
70725
+
70726
+ node.current = element;
70727
+ }, //eslint-disable-next-line
70728
+ []);
70729
+ return [node, setNodeRef];
70730
+ }
70731
+
70732
+ function usePrevious(value) {
70733
+ const ref = useRef();
70734
+ useEffect(() => {
70735
+ ref.current = value;
70736
+ }, [value]);
70737
+ return ref.current;
70738
+ }
70739
+
70740
+ let ids = {};
70741
+ function useUniqueId(prefix, value) {
70742
+ return useMemo(() => {
70743
+ if (value) {
70744
+ return value;
70745
+ }
70746
+
70747
+ const id = ids[prefix] == null ? 0 : ids[prefix] + 1;
70748
+ ids[prefix] = id;
70749
+ return prefix + "-" + id;
70750
+ }, [prefix, value]);
70751
+ }
70752
+
70753
+ function createAdjustmentFn(modifier) {
70754
+ return function (object) {
70755
+ for (var _len = arguments.length, adjustments = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
70756
+ adjustments[_key - 1] = arguments[_key];
70757
+ }
70758
+
70759
+ return adjustments.reduce((accumulator, adjustment) => {
70760
+ const entries = Object.entries(adjustment);
70761
+
70762
+ for (const [key, valueAdjustment] of entries) {
70763
+ const value = accumulator[key];
70764
+
70765
+ if (value != null) {
70766
+ accumulator[key] = value + modifier * valueAdjustment;
70767
+ }
70768
+ }
70769
+
70770
+ return accumulator;
70771
+ }, { ...object
70772
+ });
70773
+ };
70774
+ }
70775
+
70776
+ const add = /*#__PURE__*/createAdjustmentFn(1);
70777
+ const subtract = /*#__PURE__*/createAdjustmentFn(-1);
70778
+
70779
+ function hasViewportRelativeCoordinates(event) {
70780
+ return 'clientX' in event && 'clientY' in event;
70781
+ }
70782
+
70783
+ function isKeyboardEvent(event) {
70784
+ if (!event) {
70785
+ return false;
70786
+ }
70787
+
70788
+ const {
70789
+ KeyboardEvent
70790
+ } = getWindow(event.target);
70791
+ return KeyboardEvent && event instanceof KeyboardEvent;
70792
+ }
70793
+
70794
+ function isTouchEvent(event) {
70795
+ if (!event) {
70796
+ return false;
70797
+ }
70798
+
70799
+ const {
70800
+ TouchEvent
70801
+ } = getWindow(event.target);
70802
+ return TouchEvent && event instanceof TouchEvent;
70803
+ }
70804
+
70805
+ /**
70806
+ * Returns the normalized x and y coordinates for mouse and touch events.
70807
+ */
70808
+
70809
+ function getEventCoordinates(event) {
70810
+ if (isTouchEvent(event)) {
70811
+ if (event.touches && event.touches.length) {
70812
+ const {
70813
+ clientX: x,
70814
+ clientY: y
70815
+ } = event.touches[0];
70816
+ return {
70817
+ x,
70818
+ y
70819
+ };
70820
+ } else if (event.changedTouches && event.changedTouches.length) {
70821
+ const {
70822
+ clientX: x,
70823
+ clientY: y
70824
+ } = event.changedTouches[0];
70825
+ return {
70826
+ x,
70827
+ y
70828
+ };
70829
+ }
70830
+ }
70831
+
70832
+ if (hasViewportRelativeCoordinates(event)) {
70833
+ return {
70834
+ x: event.clientX,
70835
+ y: event.clientY
70836
+ };
70837
+ }
70838
+
70839
+ return null;
70840
+ }
70841
+
70842
+ const SELECTOR = 'a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]';
70843
+ function findFirstFocusableNode(element) {
70844
+ if (element.matches(SELECTOR)) {
70845
+ return element;
70846
+ }
70847
+
70848
+ return element.querySelector(SELECTOR);
70849
+ }
70850
+
70851
+ const hiddenStyles = {
70852
+ display: 'none'
70853
+ };
70854
+ function HiddenText(_ref) {
70855
+ let {
70856
+ id,
70857
+ value
70858
+ } = _ref;
70859
+ return React__default.createElement("div", {
70860
+ id: id,
70861
+ style: hiddenStyles
70862
+ }, value);
70863
+ }
70864
+
70865
+ function LiveRegion(_ref) {
70866
+ let {
70867
+ id,
70868
+ announcement,
70869
+ ariaLiveType = "assertive"
70870
+ } = _ref;
70871
+ // Hide element visually but keep it readable by screen readers
70872
+ const visuallyHidden = {
70873
+ position: 'fixed',
70874
+ top: 0,
70875
+ left: 0,
70876
+ width: 1,
70877
+ height: 1,
70878
+ margin: -1,
70879
+ border: 0,
70880
+ padding: 0,
70881
+ overflow: 'hidden',
70882
+ clip: 'rect(0 0 0 0)',
70883
+ clipPath: 'inset(100%)',
70884
+ whiteSpace: 'nowrap'
70885
+ };
70886
+ return React__default.createElement("div", {
70887
+ id: id,
70888
+ style: visuallyHidden,
70889
+ role: "status",
70890
+ "aria-live": ariaLiveType,
70891
+ "aria-atomic": true
70892
+ }, announcement);
70893
+ }
70894
+
70895
+ function useAnnouncement() {
70896
+ const [announcement, setAnnouncement] = useState('');
70897
+ const announce = useCallback(value => {
70898
+ if (value != null) {
70899
+ setAnnouncement(value);
70900
+ }
70901
+ }, []);
70902
+ return {
70903
+ announce,
70904
+ announcement
70905
+ };
70906
+ }
70907
+
70908
+ const DndMonitorContext = /*#__PURE__*/createContext(null);
70909
+
70910
+ function useDndMonitor(listener) {
70911
+ const registerListener = useContext(DndMonitorContext);
70912
+ useEffect(() => {
70913
+ if (!registerListener) {
70914
+ throw new Error('useDndMonitor must be used within a children of <DndContext>');
70915
+ }
70916
+
70917
+ const unsubscribe = registerListener(listener);
70918
+ return unsubscribe;
70919
+ }, [listener, registerListener]);
70920
+ }
70921
+
70922
+ function useDndMonitorProvider() {
70923
+ const [listeners] = useState(() => new Set());
70924
+ const registerListener = useCallback(listener => {
70925
+ listeners.add(listener);
70926
+ return () => listeners.delete(listener);
70927
+ }, [listeners]);
70928
+ const dispatch = useCallback(_ref => {
70929
+ let {
70930
+ type,
70931
+ event
70932
+ } = _ref;
70933
+ listeners.forEach(listener => {
70934
+ var _listener$type;
70935
+
70936
+ return (_listener$type = listener[type]) == null ? void 0 : _listener$type.call(listener, event);
70937
+ });
70938
+ }, [listeners]);
70939
+ return [dispatch, registerListener];
70940
+ }
70941
+
70942
+ const defaultScreenReaderInstructions = {
70943
+ draggable: "\n To pick up a draggable item, press the space bar.\n While dragging, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n "
70944
+ };
70945
+ const defaultAnnouncements = {
70946
+ onDragStart(_ref) {
70947
+ let {
70948
+ active
70949
+ } = _ref;
70950
+ return "Picked up draggable item " + active.id + ".";
70951
+ },
70952
+
70953
+ onDragOver(_ref2) {
70954
+ let {
70955
+ active,
70956
+ over
70957
+ } = _ref2;
70958
+
70959
+ if (over) {
70960
+ return "Draggable item " + active.id + " was moved over droppable area " + over.id + ".";
70961
+ }
70962
+
70963
+ return "Draggable item " + active.id + " is no longer over a droppable area.";
70964
+ },
70965
+
70966
+ onDragEnd(_ref3) {
70967
+ let {
70968
+ active,
70969
+ over
70970
+ } = _ref3;
70971
+
70972
+ if (over) {
70973
+ return "Draggable item " + active.id + " was dropped over droppable area " + over.id;
70974
+ }
70975
+
70976
+ return "Draggable item " + active.id + " was dropped.";
70977
+ },
70978
+
70979
+ onDragCancel(_ref4) {
70980
+ let {
70981
+ active
70982
+ } = _ref4;
70983
+ return "Dragging was cancelled. Draggable item " + active.id + " was dropped.";
70984
+ }
70985
+
70986
+ };
70987
+
70988
+ function Accessibility(_ref) {
70989
+ let {
70990
+ announcements = defaultAnnouncements,
70991
+ container,
70992
+ hiddenTextDescribedById,
70993
+ screenReaderInstructions = defaultScreenReaderInstructions
70994
+ } = _ref;
70995
+ const {
70996
+ announce,
70997
+ announcement
70998
+ } = useAnnouncement();
70999
+ const liveRegionId = useUniqueId("DndLiveRegion");
71000
+ const [mounted, setMounted] = useState(false);
71001
+ useEffect(() => {
71002
+ setMounted(true);
71003
+ }, []);
71004
+ useDndMonitor(useMemo(() => ({
71005
+ onDragStart(_ref2) {
71006
+ let {
71007
+ active
71008
+ } = _ref2;
71009
+ announce(announcements.onDragStart({
71010
+ active
71011
+ }));
71012
+ },
71013
+
71014
+ onDragMove(_ref3) {
71015
+ let {
71016
+ active,
71017
+ over
71018
+ } = _ref3;
71019
+
71020
+ if (announcements.onDragMove) {
71021
+ announce(announcements.onDragMove({
71022
+ active,
71023
+ over
71024
+ }));
71025
+ }
71026
+ },
71027
+
71028
+ onDragOver(_ref4) {
71029
+ let {
71030
+ active,
71031
+ over
71032
+ } = _ref4;
71033
+ announce(announcements.onDragOver({
71034
+ active,
71035
+ over
71036
+ }));
71037
+ },
71038
+
71039
+ onDragEnd(_ref5) {
71040
+ let {
71041
+ active,
71042
+ over
71043
+ } = _ref5;
71044
+ announce(announcements.onDragEnd({
71045
+ active,
71046
+ over
71047
+ }));
71048
+ },
71049
+
71050
+ onDragCancel(_ref6) {
71051
+ let {
71052
+ active,
71053
+ over
71054
+ } = _ref6;
71055
+ announce(announcements.onDragCancel({
71056
+ active,
71057
+ over
71058
+ }));
71059
+ }
71060
+
71061
+ }), [announce, announcements]));
71062
+
71063
+ if (!mounted) {
71064
+ return null;
71065
+ }
71066
+
71067
+ const markup = React__default.createElement(React__default.Fragment, null, React__default.createElement(HiddenText, {
71068
+ id: hiddenTextDescribedById,
71069
+ value: screenReaderInstructions.draggable
71070
+ }), React__default.createElement(LiveRegion, {
71071
+ id: liveRegionId,
71072
+ announcement: announcement
71073
+ }));
71074
+ return container ? createPortal(markup, container) : markup;
71075
+ }
71076
+
71077
+ var Action;
71078
+
71079
+ (function (Action) {
71080
+ Action["DragStart"] = "dragStart";
71081
+ Action["DragMove"] = "dragMove";
71082
+ Action["DragEnd"] = "dragEnd";
71083
+ Action["DragCancel"] = "dragCancel";
71084
+ Action["DragOver"] = "dragOver";
71085
+ Action["RegisterDroppable"] = "registerDroppable";
71086
+ Action["SetDroppableDisabled"] = "setDroppableDisabled";
71087
+ Action["UnregisterDroppable"] = "unregisterDroppable";
71088
+ })(Action || (Action = {}));
71089
+
71090
+ function noop() {}
71091
+
71092
+ function useSensor(sensor, options) {
71093
+ return useMemo(() => ({
71094
+ sensor,
71095
+ options: options != null ? options : {}
71096
+ }), // eslint-disable-next-line react-hooks/exhaustive-deps
71097
+ [sensor, options]);
71098
+ }
71099
+
71100
+ function useSensors() {
71101
+ for (var _len = arguments.length, sensors = new Array(_len), _key = 0; _key < _len; _key++) {
71102
+ sensors[_key] = arguments[_key];
71103
+ }
71104
+
71105
+ return useMemo(() => [...sensors].filter(sensor => sensor != null), // eslint-disable-next-line react-hooks/exhaustive-deps
71106
+ [...sensors]);
71107
+ }
71108
+
71109
+ const defaultCoordinates = /*#__PURE__*/Object.freeze({
71110
+ x: 0,
71111
+ y: 0
71112
+ });
71113
+
71114
+ /**
71115
+ * Returns the distance between two points
71116
+ */
71117
+ function distanceBetween(p1, p2) {
71118
+ return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2));
71119
+ }
71120
+
71121
+ /**
71122
+ * Sort collisions from smallest to greatest value
71123
+ */
71124
+ function sortCollisionsAsc(_ref, _ref2) {
71125
+ let {
71126
+ data: {
71127
+ value: a
71128
+ }
71129
+ } = _ref;
71130
+ let {
71131
+ data: {
71132
+ value: b
71133
+ }
71134
+ } = _ref2;
71135
+ return a - b;
71136
+ }
71137
+ /**
71138
+ * Sort collisions from greatest to smallest value
71139
+ */
71140
+
71141
+ function sortCollisionsDesc(_ref3, _ref4) {
71142
+ let {
71143
+ data: {
71144
+ value: a
71145
+ }
71146
+ } = _ref3;
71147
+ let {
71148
+ data: {
71149
+ value: b
71150
+ }
71151
+ } = _ref4;
71152
+ return b - a;
71153
+ }
71154
+ /**
71155
+ * Returns the coordinates of the corners of a given rectangle:
71156
+ * [TopLeft {x, y}, TopRight {x, y}, BottomLeft {x, y}, BottomRight {x, y}]
71157
+ */
71158
+
71159
+ function cornersOfRectangle(_ref5) {
71160
+ let {
71161
+ left,
71162
+ top,
71163
+ height,
71164
+ width
71165
+ } = _ref5;
71166
+ return [{
71167
+ x: left,
71168
+ y: top
71169
+ }, {
71170
+ x: left + width,
71171
+ y: top
71172
+ }, {
71173
+ x: left,
71174
+ y: top + height
71175
+ }, {
71176
+ x: left + width,
71177
+ y: top + height
71178
+ }];
71179
+ }
71180
+ function getFirstCollision(collisions, property) {
71181
+ if (!collisions || collisions.length === 0) {
71182
+ return null;
71183
+ }
71184
+
71185
+ const [firstCollision] = collisions;
71186
+ return firstCollision[property] ;
71187
+ }
71188
+
71189
+ /**
71190
+ * Returns the intersecting rectangle area between two rectangles
71191
+ */
71192
+
71193
+ function getIntersectionRatio(entry, target) {
71194
+ const top = Math.max(target.top, entry.top);
71195
+ const left = Math.max(target.left, entry.left);
71196
+ const right = Math.min(target.left + target.width, entry.left + entry.width);
71197
+ const bottom = Math.min(target.top + target.height, entry.top + entry.height);
71198
+ const width = right - left;
71199
+ const height = bottom - top;
71200
+
71201
+ if (left < right && top < bottom) {
71202
+ const targetArea = target.width * target.height;
71203
+ const entryArea = entry.width * entry.height;
71204
+ const intersectionArea = width * height;
71205
+ const intersectionRatio = intersectionArea / (targetArea + entryArea - intersectionArea);
71206
+ return Number(intersectionRatio.toFixed(4));
71207
+ } // Rectangles do not overlap, or overlap has an area of zero (edge/corner overlap)
71208
+
71209
+
71210
+ return 0;
71211
+ }
71212
+ /**
71213
+ * Returns the rectangles that has the greatest intersection area with a given
71214
+ * rectangle in an array of rectangles.
71215
+ */
71216
+
71217
+ const rectIntersection = _ref => {
71218
+ let {
71219
+ collisionRect,
71220
+ droppableRects,
71221
+ droppableContainers
71222
+ } = _ref;
71223
+ const collisions = [];
71224
+
71225
+ for (const droppableContainer of droppableContainers) {
71226
+ const {
71227
+ id
71228
+ } = droppableContainer;
71229
+ const rect = droppableRects.get(id);
71230
+
71231
+ if (rect) {
71232
+ const intersectionRatio = getIntersectionRatio(rect, collisionRect);
71233
+
71234
+ if (intersectionRatio > 0) {
71235
+ collisions.push({
71236
+ id,
71237
+ data: {
71238
+ droppableContainer,
71239
+ value: intersectionRatio
71240
+ }
71241
+ });
71242
+ }
71243
+ }
71244
+ }
71245
+
71246
+ return collisions.sort(sortCollisionsDesc);
71247
+ };
71248
+
71249
+ /**
71250
+ * Check if a given point is contained within a bounding rectangle
71251
+ */
71252
+
71253
+ function isPointWithinRect(point, rect) {
71254
+ const {
71255
+ top,
71256
+ left,
71257
+ bottom,
71258
+ right
71259
+ } = rect;
71260
+ return top <= point.y && point.y <= bottom && left <= point.x && point.x <= right;
71261
+ }
71262
+ /**
71263
+ * Returns the rectangles that the pointer is hovering over
71264
+ */
71265
+
71266
+
71267
+ const pointerWithin = _ref => {
71268
+ let {
71269
+ droppableContainers,
71270
+ droppableRects,
71271
+ pointerCoordinates
71272
+ } = _ref;
71273
+
71274
+ if (!pointerCoordinates) {
71275
+ return [];
71276
+ }
71277
+
71278
+ const collisions = [];
71279
+
71280
+ for (const droppableContainer of droppableContainers) {
71281
+ const {
71282
+ id
71283
+ } = droppableContainer;
71284
+ const rect = droppableRects.get(id);
71285
+
71286
+ if (rect && isPointWithinRect(pointerCoordinates, rect)) {
71287
+ /* There may be more than a single rectangle intersecting
71288
+ * with the pointer coordinates. In order to sort the
71289
+ * colliding rectangles, we measure the distance between
71290
+ * the pointer and the corners of the intersecting rectangle
71291
+ */
71292
+ const corners = cornersOfRectangle(rect);
71293
+ const distances = corners.reduce((accumulator, corner) => {
71294
+ return accumulator + distanceBetween(pointerCoordinates, corner);
71295
+ }, 0);
71296
+ const effectiveDistance = Number((distances / 4).toFixed(4));
71297
+ collisions.push({
71298
+ id,
71299
+ data: {
71300
+ droppableContainer,
71301
+ value: effectiveDistance
71302
+ }
71303
+ });
71304
+ }
71305
+ }
71306
+
71307
+ return collisions.sort(sortCollisionsAsc);
71308
+ };
71309
+
71310
+ function adjustScale(transform, rect1, rect2) {
71311
+ return { ...transform,
71312
+ scaleX: rect1 && rect2 ? rect1.width / rect2.width : 1,
71313
+ scaleY: rect1 && rect2 ? rect1.height / rect2.height : 1
71314
+ };
71315
+ }
71316
+
71317
+ function getRectDelta(rect1, rect2) {
71318
+ return rect1 && rect2 ? {
71319
+ x: rect1.left - rect2.left,
71320
+ y: rect1.top - rect2.top
71321
+ } : defaultCoordinates;
71322
+ }
71323
+
71324
+ function createRectAdjustmentFn(modifier) {
71325
+ return function adjustClientRect(rect) {
71326
+ for (var _len = arguments.length, adjustments = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
71327
+ adjustments[_key - 1] = arguments[_key];
71328
+ }
71329
+
71330
+ return adjustments.reduce((acc, adjustment) => ({ ...acc,
71331
+ top: acc.top + modifier * adjustment.y,
71332
+ bottom: acc.bottom + modifier * adjustment.y,
71333
+ left: acc.left + modifier * adjustment.x,
71334
+ right: acc.right + modifier * adjustment.x
71335
+ }), { ...rect
71336
+ });
71337
+ };
71338
+ }
71339
+ const getAdjustedRect = /*#__PURE__*/createRectAdjustmentFn(1);
71340
+
71341
+ function parseTransform(transform) {
71342
+ if (transform.startsWith('matrix3d(')) {
71343
+ const transformArray = transform.slice(9, -1).split(/, /);
71344
+ return {
71345
+ x: +transformArray[12],
71346
+ y: +transformArray[13],
71347
+ scaleX: +transformArray[0],
71348
+ scaleY: +transformArray[5]
71349
+ };
71350
+ } else if (transform.startsWith('matrix(')) {
71351
+ const transformArray = transform.slice(7, -1).split(/, /);
71352
+ return {
71353
+ x: +transformArray[4],
71354
+ y: +transformArray[5],
71355
+ scaleX: +transformArray[0],
71356
+ scaleY: +transformArray[3]
71357
+ };
71358
+ }
71359
+
71360
+ return null;
71361
+ }
71362
+
71363
+ function inverseTransform(rect, transform, transformOrigin) {
71364
+ const parsedTransform = parseTransform(transform);
71365
+
71366
+ if (!parsedTransform) {
71367
+ return rect;
71368
+ }
71369
+
71370
+ const {
71371
+ scaleX,
71372
+ scaleY,
71373
+ x: translateX,
71374
+ y: translateY
71375
+ } = parsedTransform;
71376
+ const x = rect.left - translateX - (1 - scaleX) * parseFloat(transformOrigin);
71377
+ const y = rect.top - translateY - (1 - scaleY) * parseFloat(transformOrigin.slice(transformOrigin.indexOf(' ') + 1));
71378
+ const w = scaleX ? rect.width / scaleX : rect.width;
71379
+ const h = scaleY ? rect.height / scaleY : rect.height;
71380
+ return {
71381
+ width: w,
71382
+ height: h,
71383
+ top: y,
71384
+ right: x + w,
71385
+ bottom: y + h,
71386
+ left: x
71387
+ };
71388
+ }
71389
+
71390
+ const defaultOptions = {
71391
+ ignoreTransform: false
71392
+ };
71393
+ /**
71394
+ * Returns the bounding client rect of an element relative to the viewport.
71395
+ */
71396
+
71397
+ function getClientRect(element, options) {
71398
+ if (options === void 0) {
71399
+ options = defaultOptions;
71400
+ }
71401
+
71402
+ let rect = element.getBoundingClientRect();
71403
+
71404
+ if (options.ignoreTransform) {
71405
+ const {
71406
+ transform,
71407
+ transformOrigin
71408
+ } = getWindow(element).getComputedStyle(element);
71409
+
71410
+ if (transform) {
71411
+ rect = inverseTransform(rect, transform, transformOrigin);
71412
+ }
71413
+ }
71414
+
71415
+ const {
71416
+ top,
71417
+ left,
71418
+ width,
71419
+ height,
71420
+ bottom,
71421
+ right
71422
+ } = rect;
71423
+ return {
71424
+ top,
71425
+ left,
71426
+ width,
71427
+ height,
71428
+ bottom,
71429
+ right
71430
+ };
71431
+ }
71432
+ /**
71433
+ * Returns the bounding client rect of an element relative to the viewport.
71434
+ *
71435
+ * @remarks
71436
+ * The ClientRect returned by this method does not take into account transforms
71437
+ * applied to the element it measures.
71438
+ *
71439
+ */
71440
+
71441
+ function getTransformAgnosticClientRect(element) {
71442
+ return getClientRect(element, {
71443
+ ignoreTransform: true
71444
+ });
71445
+ }
71446
+
71447
+ function getWindowClientRect(element) {
71448
+ const width = element.innerWidth;
71449
+ const height = element.innerHeight;
71450
+ return {
71451
+ top: 0,
71452
+ left: 0,
71453
+ right: width,
71454
+ bottom: height,
71455
+ width,
71456
+ height
71457
+ };
71458
+ }
71459
+
71460
+ function isFixed(node, computedStyle) {
71461
+ if (computedStyle === void 0) {
71462
+ computedStyle = getWindow(node).getComputedStyle(node);
71463
+ }
71464
+
71465
+ return computedStyle.position === 'fixed';
71466
+ }
71467
+
71468
+ function isScrollable(element, computedStyle) {
71469
+ if (computedStyle === void 0) {
71470
+ computedStyle = getWindow(element).getComputedStyle(element);
71471
+ }
71472
+
71473
+ const overflowRegex = /(auto|scroll|overlay)/;
71474
+ const properties = ['overflow', 'overflowX', 'overflowY'];
71475
+ return properties.some(property => {
71476
+ const value = computedStyle[property];
71477
+ return typeof value === 'string' ? overflowRegex.test(value) : false;
71478
+ });
71479
+ }
71480
+
71481
+ function getScrollableAncestors(element, limit) {
71482
+ const scrollParents = [];
71483
+
71484
+ function findScrollableAncestors(node) {
71485
+ if (limit != null && scrollParents.length >= limit) {
71486
+ return scrollParents;
71487
+ }
71488
+
71489
+ if (!node) {
71490
+ return scrollParents;
71491
+ }
71492
+
71493
+ if (isDocument(node) && node.scrollingElement != null && !scrollParents.includes(node.scrollingElement)) {
71494
+ scrollParents.push(node.scrollingElement);
71495
+ return scrollParents;
71496
+ }
71497
+
71498
+ if (!isHTMLElement(node) || isSVGElement(node)) {
71499
+ return scrollParents;
71500
+ }
71501
+
71502
+ if (scrollParents.includes(node)) {
71503
+ return scrollParents;
71504
+ }
71505
+
71506
+ const computedStyle = getWindow(element).getComputedStyle(node);
71507
+
71508
+ if (node !== element) {
71509
+ if (isScrollable(node, computedStyle)) {
71510
+ scrollParents.push(node);
71511
+ }
71512
+ }
71513
+
71514
+ if (isFixed(node, computedStyle)) {
71515
+ return scrollParents;
71516
+ }
71517
+
71518
+ return findScrollableAncestors(node.parentNode);
71519
+ }
71520
+
71521
+ if (!element) {
71522
+ return scrollParents;
71523
+ }
71524
+
71525
+ return findScrollableAncestors(element);
71526
+ }
71527
+ function getFirstScrollableAncestor(node) {
71528
+ const [firstScrollableAncestor] = getScrollableAncestors(node, 1);
71529
+ return firstScrollableAncestor != null ? firstScrollableAncestor : null;
71530
+ }
71531
+
71532
+ function getScrollableElement(element) {
71533
+ if (!canUseDOM || !element) {
71534
+ return null;
71535
+ }
71536
+
71537
+ if (isWindow(element)) {
71538
+ return element;
71539
+ }
71540
+
71541
+ if (!isNode(element)) {
71542
+ return null;
71543
+ }
71544
+
71545
+ if (isDocument(element) || element === getOwnerDocument(element).scrollingElement) {
71546
+ return window;
71547
+ }
71548
+
71549
+ if (isHTMLElement(element)) {
71550
+ return element;
71551
+ }
71552
+
71553
+ return null;
71554
+ }
71555
+
71556
+ function getScrollXCoordinate(element) {
71557
+ if (isWindow(element)) {
71558
+ return element.scrollX;
71559
+ }
71560
+
71561
+ return element.scrollLeft;
71562
+ }
71563
+ function getScrollYCoordinate(element) {
71564
+ if (isWindow(element)) {
71565
+ return element.scrollY;
71566
+ }
71567
+
71568
+ return element.scrollTop;
71569
+ }
71570
+ function getScrollCoordinates(element) {
71571
+ return {
71572
+ x: getScrollXCoordinate(element),
71573
+ y: getScrollYCoordinate(element)
71574
+ };
71575
+ }
71576
+
71577
+ var Direction;
71578
+
71579
+ (function (Direction) {
71580
+ Direction[Direction["Forward"] = 1] = "Forward";
71581
+ Direction[Direction["Backward"] = -1] = "Backward";
71582
+ })(Direction || (Direction = {}));
71583
+
71584
+ function isDocumentScrollingElement(element) {
71585
+ if (!canUseDOM || !element) {
71586
+ return false;
71587
+ }
71588
+
71589
+ return element === document.scrollingElement;
71590
+ }
71591
+
71592
+ function getScrollPosition(scrollingContainer) {
71593
+ const minScroll = {
71594
+ x: 0,
71595
+ y: 0
71596
+ };
71597
+ const dimensions = isDocumentScrollingElement(scrollingContainer) ? {
71598
+ height: window.innerHeight,
71599
+ width: window.innerWidth
71600
+ } : {
71601
+ height: scrollingContainer.clientHeight,
71602
+ width: scrollingContainer.clientWidth
71603
+ };
71604
+ const maxScroll = {
71605
+ x: scrollingContainer.scrollWidth - dimensions.width,
71606
+ y: scrollingContainer.scrollHeight - dimensions.height
71607
+ };
71608
+ const isTop = scrollingContainer.scrollTop <= minScroll.y;
71609
+ const isLeft = scrollingContainer.scrollLeft <= minScroll.x;
71610
+ const isBottom = scrollingContainer.scrollTop >= maxScroll.y;
71611
+ const isRight = scrollingContainer.scrollLeft >= maxScroll.x;
71612
+ return {
71613
+ isTop,
71614
+ isLeft,
71615
+ isBottom,
71616
+ isRight,
71617
+ maxScroll,
71618
+ minScroll
71619
+ };
71620
+ }
71621
+
71622
+ const defaultThreshold = {
71623
+ x: 0.2,
71624
+ y: 0.2
71625
+ };
71626
+ function getScrollDirectionAndSpeed(scrollContainer, scrollContainerRect, _ref, acceleration, thresholdPercentage) {
71627
+ let {
71628
+ top,
71629
+ left,
71630
+ right,
71631
+ bottom
71632
+ } = _ref;
71633
+
71634
+ if (acceleration === void 0) {
71635
+ acceleration = 10;
71636
+ }
71637
+
71638
+ if (thresholdPercentage === void 0) {
71639
+ thresholdPercentage = defaultThreshold;
71640
+ }
71641
+
71642
+ const {
71643
+ isTop,
71644
+ isBottom,
71645
+ isLeft,
71646
+ isRight
71647
+ } = getScrollPosition(scrollContainer);
71648
+ const direction = {
71649
+ x: 0,
71650
+ y: 0
71651
+ };
71652
+ const speed = {
71653
+ x: 0,
71654
+ y: 0
71655
+ };
71656
+ const threshold = {
71657
+ height: scrollContainerRect.height * thresholdPercentage.y,
71658
+ width: scrollContainerRect.width * thresholdPercentage.x
71659
+ };
71660
+
71661
+ if (!isTop && top <= scrollContainerRect.top + threshold.height) {
71662
+ // Scroll Up
71663
+ direction.y = Direction.Backward;
71664
+ speed.y = acceleration * Math.abs((scrollContainerRect.top + threshold.height - top) / threshold.height);
71665
+ } else if (!isBottom && bottom >= scrollContainerRect.bottom - threshold.height) {
71666
+ // Scroll Down
71667
+ direction.y = Direction.Forward;
71668
+ speed.y = acceleration * Math.abs((scrollContainerRect.bottom - threshold.height - bottom) / threshold.height);
71669
+ }
71670
+
71671
+ if (!isRight && right >= scrollContainerRect.right - threshold.width) {
71672
+ // Scroll Right
71673
+ direction.x = Direction.Forward;
71674
+ speed.x = acceleration * Math.abs((scrollContainerRect.right - threshold.width - right) / threshold.width);
71675
+ } else if (!isLeft && left <= scrollContainerRect.left + threshold.width) {
71676
+ // Scroll Left
71677
+ direction.x = Direction.Backward;
71678
+ speed.x = acceleration * Math.abs((scrollContainerRect.left + threshold.width - left) / threshold.width);
71679
+ }
71680
+
71681
+ return {
71682
+ direction,
71683
+ speed
71684
+ };
71685
+ }
71686
+
71687
+ function getScrollElementRect(element) {
71688
+ if (element === document.scrollingElement) {
71689
+ const {
71690
+ innerWidth,
71691
+ innerHeight
71692
+ } = window;
71693
+ return {
71694
+ top: 0,
71695
+ left: 0,
71696
+ right: innerWidth,
71697
+ bottom: innerHeight,
71698
+ width: innerWidth,
71699
+ height: innerHeight
71700
+ };
71701
+ }
71702
+
71703
+ const {
71704
+ top,
71705
+ left,
71706
+ right,
71707
+ bottom
71708
+ } = element.getBoundingClientRect();
71709
+ return {
71710
+ top,
71711
+ left,
71712
+ right,
71713
+ bottom,
71714
+ width: element.clientWidth,
71715
+ height: element.clientHeight
71716
+ };
71717
+ }
71718
+
71719
+ function getScrollOffsets(scrollableAncestors) {
71720
+ return scrollableAncestors.reduce((acc, node) => {
71721
+ return add(acc, getScrollCoordinates(node));
71722
+ }, defaultCoordinates);
71723
+ }
71724
+ function getScrollXOffset(scrollableAncestors) {
71725
+ return scrollableAncestors.reduce((acc, node) => {
71726
+ return acc + getScrollXCoordinate(node);
71727
+ }, 0);
71728
+ }
71729
+ function getScrollYOffset(scrollableAncestors) {
71730
+ return scrollableAncestors.reduce((acc, node) => {
71731
+ return acc + getScrollYCoordinate(node);
71732
+ }, 0);
71733
+ }
71734
+
71735
+ function scrollIntoViewIfNeeded(element, measure) {
71736
+ if (measure === void 0) {
71737
+ measure = getClientRect;
71738
+ }
71739
+
71740
+ if (!element) {
71741
+ return;
71742
+ }
71743
+
71744
+ const {
71745
+ top,
71746
+ left,
71747
+ bottom,
71748
+ right
71749
+ } = measure(element);
71750
+ const firstScrollableAncestor = getFirstScrollableAncestor(element);
71751
+
71752
+ if (!firstScrollableAncestor) {
71753
+ return;
71754
+ }
71755
+
71756
+ if (bottom <= 0 || right <= 0 || top >= window.innerHeight || left >= window.innerWidth) {
71757
+ element.scrollIntoView({
71758
+ block: 'center',
71759
+ inline: 'center'
71760
+ });
71761
+ }
71762
+ }
71763
+
71764
+ const properties = [['x', ['left', 'right'], getScrollXOffset], ['y', ['top', 'bottom'], getScrollYOffset]];
71765
+ class Rect {
71766
+ constructor(rect, element) {
71767
+ this.rect = void 0;
71768
+ this.width = void 0;
71769
+ this.height = void 0;
71770
+ this.top = void 0;
71771
+ this.bottom = void 0;
71772
+ this.right = void 0;
71773
+ this.left = void 0;
71774
+ const scrollableAncestors = getScrollableAncestors(element);
71775
+ const scrollOffsets = getScrollOffsets(scrollableAncestors);
71776
+ this.rect = { ...rect
71777
+ };
71778
+ this.width = rect.width;
71779
+ this.height = rect.height;
71780
+
71781
+ for (const [axis, keys, getScrollOffset] of properties) {
71782
+ for (const key of keys) {
71783
+ Object.defineProperty(this, key, {
71784
+ get: () => {
71785
+ const currentOffsets = getScrollOffset(scrollableAncestors);
71786
+ const scrollOffsetsDeltla = scrollOffsets[axis] - currentOffsets;
71787
+ return this.rect[key] + scrollOffsetsDeltla;
71788
+ },
71789
+ enumerable: true
71790
+ });
71791
+ }
71792
+ }
71793
+
71794
+ Object.defineProperty(this, 'rect', {
71795
+ enumerable: false
71796
+ });
71797
+ }
71798
+
71799
+ }
71800
+
71801
+ class Listeners {
71802
+ constructor(target) {
71803
+ this.target = void 0;
71804
+ this.listeners = [];
71805
+
71806
+ this.removeAll = () => {
71807
+ this.listeners.forEach(listener => {
71808
+ var _this$target;
71809
+
71810
+ return (_this$target = this.target) == null ? void 0 : _this$target.removeEventListener(...listener);
71811
+ });
71812
+ };
71813
+
71814
+ this.target = target;
71815
+ }
71816
+
71817
+ add(eventName, handler, options) {
71818
+ var _this$target2;
71819
+
71820
+ (_this$target2 = this.target) == null ? void 0 : _this$target2.addEventListener(eventName, handler, options);
71821
+ this.listeners.push([eventName, handler, options]);
71822
+ }
71823
+
71824
+ }
71825
+
71826
+ function getEventListenerTarget(target) {
71827
+ // If the `event.target` element is removed from the document events will still be targeted
71828
+ // at it, and hence won't always bubble up to the window or document anymore.
71829
+ // If there is any risk of an element being removed while it is being dragged,
71830
+ // the best practice is to attach the event listeners directly to the target.
71831
+ // https://developer.mozilla.org/en-US/docs/Web/API/EventTarget
71832
+ const {
71833
+ EventTarget
71834
+ } = getWindow(target);
71835
+ return target instanceof EventTarget ? target : getOwnerDocument(target);
71836
+ }
71837
+
71838
+ function hasExceededDistance(delta, measurement) {
71839
+ const dx = Math.abs(delta.x);
71840
+ const dy = Math.abs(delta.y);
71841
+
71842
+ if (typeof measurement === 'number') {
71843
+ return Math.sqrt(dx ** 2 + dy ** 2) > measurement;
71844
+ }
71845
+
71846
+ if ('x' in measurement && 'y' in measurement) {
71847
+ return dx > measurement.x && dy > measurement.y;
71848
+ }
71849
+
71850
+ if ('x' in measurement) {
71851
+ return dx > measurement.x;
71852
+ }
71853
+
71854
+ if ('y' in measurement) {
71855
+ return dy > measurement.y;
71856
+ }
71857
+
71858
+ return false;
71859
+ }
71860
+
71861
+ var EventName;
71862
+
71863
+ (function (EventName) {
71864
+ EventName["Click"] = "click";
71865
+ EventName["DragStart"] = "dragstart";
71866
+ EventName["Keydown"] = "keydown";
71867
+ EventName["ContextMenu"] = "contextmenu";
71868
+ EventName["Resize"] = "resize";
71869
+ EventName["SelectionChange"] = "selectionchange";
71870
+ EventName["VisibilityChange"] = "visibilitychange";
71871
+ })(EventName || (EventName = {}));
71872
+
71873
+ function preventDefault(event) {
71874
+ event.preventDefault();
71875
+ }
71876
+ function stopPropagation(event) {
71877
+ event.stopPropagation();
71878
+ }
71879
+
71880
+ var KeyboardCode;
71881
+
71882
+ (function (KeyboardCode) {
71883
+ KeyboardCode["Space"] = "Space";
71884
+ KeyboardCode["Down"] = "ArrowDown";
71885
+ KeyboardCode["Right"] = "ArrowRight";
71886
+ KeyboardCode["Left"] = "ArrowLeft";
71887
+ KeyboardCode["Up"] = "ArrowUp";
71888
+ KeyboardCode["Esc"] = "Escape";
71889
+ KeyboardCode["Enter"] = "Enter";
71890
+ KeyboardCode["Tab"] = "Tab";
71891
+ })(KeyboardCode || (KeyboardCode = {}));
71892
+
71893
+ const defaultKeyboardCodes = {
71894
+ start: [KeyboardCode.Space, KeyboardCode.Enter],
71895
+ cancel: [KeyboardCode.Esc],
71896
+ end: [KeyboardCode.Space, KeyboardCode.Enter, KeyboardCode.Tab]
71897
+ };
71898
+ const defaultKeyboardCoordinateGetter = (event, _ref) => {
71899
+ let {
71900
+ currentCoordinates
71901
+ } = _ref;
71902
+
71903
+ switch (event.code) {
71904
+ case KeyboardCode.Right:
71905
+ return { ...currentCoordinates,
71906
+ x: currentCoordinates.x + 25
71907
+ };
71908
+
71909
+ case KeyboardCode.Left:
71910
+ return { ...currentCoordinates,
71911
+ x: currentCoordinates.x - 25
71912
+ };
71913
+
71914
+ case KeyboardCode.Down:
71915
+ return { ...currentCoordinates,
71916
+ y: currentCoordinates.y + 25
71917
+ };
71918
+
71919
+ case KeyboardCode.Up:
71920
+ return { ...currentCoordinates,
71921
+ y: currentCoordinates.y - 25
71922
+ };
71923
+ }
71924
+
71925
+ return undefined;
71926
+ };
71927
+
71928
+ class KeyboardSensor {
71929
+ constructor(props) {
71930
+ this.props = void 0;
71931
+ this.autoScrollEnabled = false;
71932
+ this.referenceCoordinates = void 0;
71933
+ this.listeners = void 0;
71934
+ this.windowListeners = void 0;
71935
+ this.props = props;
71936
+ const {
71937
+ event: {
71938
+ target
71939
+ }
71940
+ } = props;
71941
+ this.props = props;
71942
+ this.listeners = new Listeners(getOwnerDocument(target));
71943
+ this.windowListeners = new Listeners(getWindow(target));
71944
+ this.handleKeyDown = this.handleKeyDown.bind(this);
71945
+ this.handleCancel = this.handleCancel.bind(this);
71946
+ this.attach();
71947
+ }
71948
+
71949
+ attach() {
71950
+ this.handleStart();
71951
+ this.windowListeners.add(EventName.Resize, this.handleCancel);
71952
+ this.windowListeners.add(EventName.VisibilityChange, this.handleCancel);
71953
+ setTimeout(() => this.listeners.add(EventName.Keydown, this.handleKeyDown));
71954
+ }
71955
+
71956
+ handleStart() {
71957
+ const {
71958
+ activeNode,
71959
+ onStart
71960
+ } = this.props;
71961
+ const node = activeNode.node.current;
71962
+
71963
+ if (node) {
71964
+ scrollIntoViewIfNeeded(node);
71965
+ }
71966
+
71967
+ onStart(defaultCoordinates);
71968
+ }
71969
+
71970
+ handleKeyDown(event) {
71971
+ if (isKeyboardEvent(event)) {
71972
+ const {
71973
+ active,
71974
+ context,
71975
+ options
71976
+ } = this.props;
71977
+ const {
71978
+ keyboardCodes = defaultKeyboardCodes,
71979
+ coordinateGetter = defaultKeyboardCoordinateGetter,
71980
+ scrollBehavior = 'smooth'
71981
+ } = options;
71982
+ const {
71983
+ code
71984
+ } = event;
71985
+
71986
+ if (keyboardCodes.end.includes(code)) {
71987
+ this.handleEnd(event);
71988
+ return;
71989
+ }
71990
+
71991
+ if (keyboardCodes.cancel.includes(code)) {
71992
+ this.handleCancel(event);
71993
+ return;
71994
+ }
71995
+
71996
+ const {
71997
+ collisionRect
71998
+ } = context.current;
71999
+ const currentCoordinates = collisionRect ? {
72000
+ x: collisionRect.left,
72001
+ y: collisionRect.top
72002
+ } : defaultCoordinates;
72003
+
72004
+ if (!this.referenceCoordinates) {
72005
+ this.referenceCoordinates = currentCoordinates;
72006
+ }
72007
+
72008
+ const newCoordinates = coordinateGetter(event, {
72009
+ active,
72010
+ context: context.current,
72011
+ currentCoordinates
72012
+ });
72013
+
72014
+ if (newCoordinates) {
72015
+ const coordinatesDelta = subtract(newCoordinates, currentCoordinates);
72016
+ const scrollDelta = {
72017
+ x: 0,
72018
+ y: 0
72019
+ };
72020
+ const {
72021
+ scrollableAncestors
72022
+ } = context.current;
72023
+
72024
+ for (const scrollContainer of scrollableAncestors) {
72025
+ const direction = event.code;
72026
+ const {
72027
+ isTop,
72028
+ isRight,
72029
+ isLeft,
72030
+ isBottom,
72031
+ maxScroll,
72032
+ minScroll
72033
+ } = getScrollPosition(scrollContainer);
72034
+ const scrollElementRect = getScrollElementRect(scrollContainer);
72035
+ const clampedCoordinates = {
72036
+ x: Math.min(direction === KeyboardCode.Right ? scrollElementRect.right - scrollElementRect.width / 2 : scrollElementRect.right, Math.max(direction === KeyboardCode.Right ? scrollElementRect.left : scrollElementRect.left + scrollElementRect.width / 2, newCoordinates.x)),
72037
+ y: Math.min(direction === KeyboardCode.Down ? scrollElementRect.bottom - scrollElementRect.height / 2 : scrollElementRect.bottom, Math.max(direction === KeyboardCode.Down ? scrollElementRect.top : scrollElementRect.top + scrollElementRect.height / 2, newCoordinates.y))
72038
+ };
72039
+ const canScrollX = direction === KeyboardCode.Right && !isRight || direction === KeyboardCode.Left && !isLeft;
72040
+ const canScrollY = direction === KeyboardCode.Down && !isBottom || direction === KeyboardCode.Up && !isTop;
72041
+
72042
+ if (canScrollX && clampedCoordinates.x !== newCoordinates.x) {
72043
+ const newScrollCoordinates = scrollContainer.scrollLeft + coordinatesDelta.x;
72044
+ const canScrollToNewCoordinates = direction === KeyboardCode.Right && newScrollCoordinates <= maxScroll.x || direction === KeyboardCode.Left && newScrollCoordinates >= minScroll.x;
72045
+
72046
+ if (canScrollToNewCoordinates && !coordinatesDelta.y) {
72047
+ // We don't need to update coordinates, the scroll adjustment alone will trigger
72048
+ // logic to auto-detect the new container we are over
72049
+ scrollContainer.scrollTo({
72050
+ left: newScrollCoordinates,
72051
+ behavior: scrollBehavior
72052
+ });
72053
+ return;
72054
+ }
72055
+
72056
+ if (canScrollToNewCoordinates) {
72057
+ scrollDelta.x = scrollContainer.scrollLeft - newScrollCoordinates;
72058
+ } else {
72059
+ scrollDelta.x = direction === KeyboardCode.Right ? scrollContainer.scrollLeft - maxScroll.x : scrollContainer.scrollLeft - minScroll.x;
72060
+ }
72061
+
72062
+ if (scrollDelta.x) {
72063
+ scrollContainer.scrollBy({
72064
+ left: -scrollDelta.x,
72065
+ behavior: scrollBehavior
72066
+ });
72067
+ }
72068
+
72069
+ break;
72070
+ } else if (canScrollY && clampedCoordinates.y !== newCoordinates.y) {
72071
+ const newScrollCoordinates = scrollContainer.scrollTop + coordinatesDelta.y;
72072
+ const canScrollToNewCoordinates = direction === KeyboardCode.Down && newScrollCoordinates <= maxScroll.y || direction === KeyboardCode.Up && newScrollCoordinates >= minScroll.y;
72073
+
72074
+ if (canScrollToNewCoordinates && !coordinatesDelta.x) {
72075
+ // We don't need to update coordinates, the scroll adjustment alone will trigger
72076
+ // logic to auto-detect the new container we are over
72077
+ scrollContainer.scrollTo({
72078
+ top: newScrollCoordinates,
72079
+ behavior: scrollBehavior
72080
+ });
72081
+ return;
72082
+ }
72083
+
72084
+ if (canScrollToNewCoordinates) {
72085
+ scrollDelta.y = scrollContainer.scrollTop - newScrollCoordinates;
72086
+ } else {
72087
+ scrollDelta.y = direction === KeyboardCode.Down ? scrollContainer.scrollTop - maxScroll.y : scrollContainer.scrollTop - minScroll.y;
72088
+ }
72089
+
72090
+ if (scrollDelta.y) {
72091
+ scrollContainer.scrollBy({
72092
+ top: -scrollDelta.y,
72093
+ behavior: scrollBehavior
72094
+ });
72095
+ }
72096
+
72097
+ break;
72098
+ }
72099
+ }
72100
+
72101
+ this.handleMove(event, add(subtract(newCoordinates, this.referenceCoordinates), scrollDelta));
72102
+ }
72103
+ }
72104
+ }
72105
+
72106
+ handleMove(event, coordinates) {
72107
+ const {
72108
+ onMove
72109
+ } = this.props;
72110
+ event.preventDefault();
72111
+ onMove(coordinates);
72112
+ }
72113
+
72114
+ handleEnd(event) {
72115
+ const {
72116
+ onEnd
72117
+ } = this.props;
72118
+ event.preventDefault();
72119
+ this.detach();
72120
+ onEnd();
72121
+ }
72122
+
72123
+ handleCancel(event) {
72124
+ const {
72125
+ onCancel
72126
+ } = this.props;
72127
+ event.preventDefault();
72128
+ this.detach();
72129
+ onCancel();
72130
+ }
72131
+
72132
+ detach() {
72133
+ this.listeners.removeAll();
72134
+ this.windowListeners.removeAll();
72135
+ }
72136
+
72137
+ }
72138
+ KeyboardSensor.activators = [{
72139
+ eventName: 'onKeyDown',
72140
+ handler: (event, _ref, _ref2) => {
72141
+ let {
72142
+ keyboardCodes = defaultKeyboardCodes,
72143
+ onActivation
72144
+ } = _ref;
72145
+ let {
72146
+ active
72147
+ } = _ref2;
72148
+ const {
72149
+ code
72150
+ } = event.nativeEvent;
72151
+
72152
+ if (keyboardCodes.start.includes(code)) {
72153
+ const activator = active.activatorNode.current;
72154
+
72155
+ if (activator && event.target !== activator) {
72156
+ return false;
72157
+ }
72158
+
72159
+ event.preventDefault();
72160
+ onActivation == null ? void 0 : onActivation({
72161
+ event: event.nativeEvent
72162
+ });
72163
+ return true;
72164
+ }
72165
+
72166
+ return false;
72167
+ }
72168
+ }];
72169
+
72170
+ function isDistanceConstraint(constraint) {
72171
+ return Boolean(constraint && 'distance' in constraint);
72172
+ }
72173
+
72174
+ function isDelayConstraint(constraint) {
72175
+ return Boolean(constraint && 'delay' in constraint);
72176
+ }
72177
+
72178
+ class AbstractPointerSensor {
72179
+ constructor(props, events, listenerTarget) {
72180
+ var _getEventCoordinates;
72181
+
72182
+ if (listenerTarget === void 0) {
72183
+ listenerTarget = getEventListenerTarget(props.event.target);
72184
+ }
72185
+
72186
+ this.props = void 0;
72187
+ this.events = void 0;
72188
+ this.autoScrollEnabled = true;
72189
+ this.document = void 0;
72190
+ this.activated = false;
72191
+ this.initialCoordinates = void 0;
72192
+ this.timeoutId = null;
72193
+ this.listeners = void 0;
72194
+ this.documentListeners = void 0;
72195
+ this.windowListeners = void 0;
72196
+ this.props = props;
72197
+ this.events = events;
72198
+ const {
72199
+ event
72200
+ } = props;
72201
+ const {
72202
+ target
72203
+ } = event;
72204
+ this.props = props;
72205
+ this.events = events;
72206
+ this.document = getOwnerDocument(target);
72207
+ this.documentListeners = new Listeners(this.document);
72208
+ this.listeners = new Listeners(listenerTarget);
72209
+ this.windowListeners = new Listeners(getWindow(target));
72210
+ this.initialCoordinates = (_getEventCoordinates = getEventCoordinates(event)) != null ? _getEventCoordinates : defaultCoordinates;
72211
+ this.handleStart = this.handleStart.bind(this);
72212
+ this.handleMove = this.handleMove.bind(this);
72213
+ this.handleEnd = this.handleEnd.bind(this);
72214
+ this.handleCancel = this.handleCancel.bind(this);
72215
+ this.handleKeydown = this.handleKeydown.bind(this);
72216
+ this.removeTextSelection = this.removeTextSelection.bind(this);
72217
+ this.attach();
72218
+ }
72219
+
72220
+ attach() {
72221
+ const {
72222
+ events,
72223
+ props: {
72224
+ options: {
72225
+ activationConstraint,
72226
+ bypassActivationConstraint
72227
+ }
72228
+ }
72229
+ } = this;
72230
+ this.listeners.add(events.move.name, this.handleMove, {
72231
+ passive: false
72232
+ });
72233
+ this.listeners.add(events.end.name, this.handleEnd);
72234
+
72235
+ if (events.cancel) {
72236
+ this.listeners.add(events.cancel.name, this.handleCancel);
72237
+ }
72238
+
72239
+ this.windowListeners.add(EventName.Resize, this.handleCancel);
72240
+ this.windowListeners.add(EventName.DragStart, preventDefault);
72241
+ this.windowListeners.add(EventName.VisibilityChange, this.handleCancel);
72242
+ this.windowListeners.add(EventName.ContextMenu, preventDefault);
72243
+ this.documentListeners.add(EventName.Keydown, this.handleKeydown);
72244
+
72245
+ if (activationConstraint) {
72246
+ if (bypassActivationConstraint != null && bypassActivationConstraint({
72247
+ event: this.props.event,
72248
+ activeNode: this.props.activeNode,
72249
+ options: this.props.options
72250
+ })) {
72251
+ return this.handleStart();
72252
+ }
72253
+
72254
+ if (isDelayConstraint(activationConstraint)) {
72255
+ this.timeoutId = setTimeout(this.handleStart, activationConstraint.delay);
72256
+ this.handlePending(activationConstraint);
72257
+ return;
72258
+ }
72259
+
72260
+ if (isDistanceConstraint(activationConstraint)) {
72261
+ this.handlePending(activationConstraint);
72262
+ return;
72263
+ }
72264
+ }
72265
+
72266
+ this.handleStart();
72267
+ }
72268
+
72269
+ detach() {
72270
+ this.listeners.removeAll();
72271
+ this.windowListeners.removeAll(); // Wait until the next event loop before removing document listeners
72272
+ // This is necessary because we listen for `click` and `selection` events on the document
72273
+
72274
+ setTimeout(this.documentListeners.removeAll, 50);
72275
+
72276
+ if (this.timeoutId !== null) {
72277
+ clearTimeout(this.timeoutId);
72278
+ this.timeoutId = null;
72279
+ }
72280
+ }
72281
+
72282
+ handlePending(constraint, offset) {
72283
+ const {
72284
+ active,
72285
+ onPending
72286
+ } = this.props;
72287
+ onPending(active, constraint, this.initialCoordinates, offset);
72288
+ }
72289
+
72290
+ handleStart() {
72291
+ const {
72292
+ initialCoordinates
72293
+ } = this;
72294
+ const {
72295
+ onStart
72296
+ } = this.props;
72297
+
72298
+ if (initialCoordinates) {
72299
+ this.activated = true; // Stop propagation of click events once activation constraints are met
72300
+
72301
+ this.documentListeners.add(EventName.Click, stopPropagation, {
72302
+ capture: true
72303
+ }); // Remove any text selection from the document
72304
+
72305
+ this.removeTextSelection(); // Prevent further text selection while dragging
72306
+
72307
+ this.documentListeners.add(EventName.SelectionChange, this.removeTextSelection);
72308
+ onStart(initialCoordinates);
72309
+ }
72310
+ }
72311
+
72312
+ handleMove(event) {
72313
+ var _getEventCoordinates2;
72314
+
72315
+ const {
72316
+ activated,
72317
+ initialCoordinates,
72318
+ props
72319
+ } = this;
72320
+ const {
72321
+ onMove,
72322
+ options: {
72323
+ activationConstraint
72324
+ }
72325
+ } = props;
72326
+
72327
+ if (!initialCoordinates) {
72328
+ return;
72329
+ }
72330
+
72331
+ const coordinates = (_getEventCoordinates2 = getEventCoordinates(event)) != null ? _getEventCoordinates2 : defaultCoordinates;
72332
+ const delta = subtract(initialCoordinates, coordinates); // Constraint validation
72333
+
72334
+ if (!activated && activationConstraint) {
72335
+ if (isDistanceConstraint(activationConstraint)) {
72336
+ if (activationConstraint.tolerance != null && hasExceededDistance(delta, activationConstraint.tolerance)) {
72337
+ return this.handleCancel();
72338
+ }
72339
+
72340
+ if (hasExceededDistance(delta, activationConstraint.distance)) {
72341
+ return this.handleStart();
72342
+ }
72343
+ }
72344
+
72345
+ if (isDelayConstraint(activationConstraint)) {
72346
+ if (hasExceededDistance(delta, activationConstraint.tolerance)) {
72347
+ return this.handleCancel();
72348
+ }
72349
+ }
72350
+
72351
+ this.handlePending(activationConstraint, delta);
72352
+ return;
72353
+ }
72354
+
72355
+ if (event.cancelable) {
72356
+ event.preventDefault();
72357
+ }
72358
+
72359
+ onMove(coordinates);
72360
+ }
72361
+
72362
+ handleEnd() {
72363
+ const {
72364
+ onAbort,
72365
+ onEnd
72366
+ } = this.props;
72367
+ this.detach();
72368
+
72369
+ if (!this.activated) {
72370
+ onAbort(this.props.active);
72371
+ }
72372
+
72373
+ onEnd();
72374
+ }
72375
+
72376
+ handleCancel() {
72377
+ const {
72378
+ onAbort,
72379
+ onCancel
72380
+ } = this.props;
72381
+ this.detach();
72382
+
72383
+ if (!this.activated) {
72384
+ onAbort(this.props.active);
72385
+ }
72386
+
72387
+ onCancel();
72388
+ }
72389
+
72390
+ handleKeydown(event) {
72391
+ if (event.code === KeyboardCode.Esc) {
72392
+ this.handleCancel();
72393
+ }
72394
+ }
72395
+
72396
+ removeTextSelection() {
72397
+ var _this$document$getSel;
72398
+
72399
+ (_this$document$getSel = this.document.getSelection()) == null ? void 0 : _this$document$getSel.removeAllRanges();
72400
+ }
72401
+
72402
+ }
72403
+
72404
+ const events = {
72405
+ cancel: {
72406
+ name: 'pointercancel'
72407
+ },
72408
+ move: {
72409
+ name: 'pointermove'
72410
+ },
72411
+ end: {
72412
+ name: 'pointerup'
72413
+ }
72414
+ };
72415
+ class PointerSensor extends AbstractPointerSensor {
72416
+ constructor(props) {
72417
+ const {
72418
+ event
72419
+ } = props; // Pointer events stop firing if the target is unmounted while dragging
72420
+ // Therefore we attach listeners to the owner document instead
72421
+
72422
+ const listenerTarget = getOwnerDocument(event.target);
72423
+ super(props, events, listenerTarget);
72424
+ }
72425
+
72426
+ }
72427
+ PointerSensor.activators = [{
72428
+ eventName: 'onPointerDown',
72429
+ handler: (_ref, _ref2) => {
72430
+ let {
72431
+ nativeEvent: event
72432
+ } = _ref;
72433
+ let {
72434
+ onActivation
72435
+ } = _ref2;
72436
+
72437
+ if (!event.isPrimary || event.button !== 0) {
72438
+ return false;
72439
+ }
72440
+
72441
+ onActivation == null ? void 0 : onActivation({
72442
+ event
72443
+ });
72444
+ return true;
72445
+ }
72446
+ }];
72447
+
72448
+ const events$1 = {
72449
+ move: {
72450
+ name: 'mousemove'
72451
+ },
72452
+ end: {
72453
+ name: 'mouseup'
72454
+ }
72455
+ };
72456
+ var MouseButton;
72457
+
72458
+ (function (MouseButton) {
72459
+ MouseButton[MouseButton["RightClick"] = 2] = "RightClick";
72460
+ })(MouseButton || (MouseButton = {}));
72461
+
72462
+ class MouseSensor extends AbstractPointerSensor {
72463
+ constructor(props) {
72464
+ super(props, events$1, getOwnerDocument(props.event.target));
72465
+ }
72466
+
72467
+ }
72468
+ MouseSensor.activators = [{
72469
+ eventName: 'onMouseDown',
72470
+ handler: (_ref, _ref2) => {
72471
+ let {
72472
+ nativeEvent: event
72473
+ } = _ref;
72474
+ let {
72475
+ onActivation
72476
+ } = _ref2;
72477
+
72478
+ if (event.button === MouseButton.RightClick) {
72479
+ return false;
72480
+ }
72481
+
72482
+ onActivation == null ? void 0 : onActivation({
72483
+ event
72484
+ });
72485
+ return true;
72486
+ }
72487
+ }];
72488
+
72489
+ const events$2 = {
72490
+ cancel: {
72491
+ name: 'touchcancel'
72492
+ },
72493
+ move: {
72494
+ name: 'touchmove'
72495
+ },
72496
+ end: {
72497
+ name: 'touchend'
72498
+ }
72499
+ };
72500
+ class TouchSensor extends AbstractPointerSensor {
72501
+ constructor(props) {
72502
+ super(props, events$2);
72503
+ }
72504
+
72505
+ static setup() {
72506
+ // Adding a non-capture and non-passive `touchmove` listener in order
72507
+ // to force `event.preventDefault()` calls to work in dynamically added
72508
+ // touchmove event handlers. This is required for iOS Safari.
72509
+ window.addEventListener(events$2.move.name, noop, {
72510
+ capture: false,
72511
+ passive: false
72512
+ });
72513
+ return function teardown() {
72514
+ window.removeEventListener(events$2.move.name, noop);
72515
+ }; // We create a new handler because the teardown function of another sensor
72516
+ // could remove our event listener if we use a referentially equal listener.
72517
+
72518
+ function noop() {}
72519
+ }
72520
+
72521
+ }
72522
+ TouchSensor.activators = [{
72523
+ eventName: 'onTouchStart',
72524
+ handler: (_ref, _ref2) => {
72525
+ let {
72526
+ nativeEvent: event
72527
+ } = _ref;
72528
+ let {
72529
+ onActivation
72530
+ } = _ref2;
72531
+ const {
72532
+ touches
72533
+ } = event;
72534
+
72535
+ if (touches.length > 1) {
72536
+ return false;
72537
+ }
72538
+
72539
+ onActivation == null ? void 0 : onActivation({
72540
+ event
72541
+ });
72542
+ return true;
72543
+ }
72544
+ }];
72545
+
72546
+ var AutoScrollActivator;
72547
+
72548
+ (function (AutoScrollActivator) {
72549
+ AutoScrollActivator[AutoScrollActivator["Pointer"] = 0] = "Pointer";
72550
+ AutoScrollActivator[AutoScrollActivator["DraggableRect"] = 1] = "DraggableRect";
72551
+ })(AutoScrollActivator || (AutoScrollActivator = {}));
72552
+
72553
+ var TraversalOrder;
72554
+
72555
+ (function (TraversalOrder) {
72556
+ TraversalOrder[TraversalOrder["TreeOrder"] = 0] = "TreeOrder";
72557
+ TraversalOrder[TraversalOrder["ReversedTreeOrder"] = 1] = "ReversedTreeOrder";
72558
+ })(TraversalOrder || (TraversalOrder = {}));
72559
+
72560
+ function useAutoScroller(_ref) {
72561
+ let {
72562
+ acceleration,
72563
+ activator = AutoScrollActivator.Pointer,
72564
+ canScroll,
72565
+ draggingRect,
72566
+ enabled,
72567
+ interval = 5,
72568
+ order = TraversalOrder.TreeOrder,
72569
+ pointerCoordinates,
72570
+ scrollableAncestors,
72571
+ scrollableAncestorRects,
72572
+ delta,
72573
+ threshold
72574
+ } = _ref;
72575
+ const scrollIntent = useScrollIntent({
72576
+ delta,
72577
+ disabled: !enabled
72578
+ });
72579
+ const [setAutoScrollInterval, clearAutoScrollInterval] = useInterval();
72580
+ const scrollSpeed = useRef({
72581
+ x: 0,
72582
+ y: 0
72583
+ });
72584
+ const scrollDirection = useRef({
72585
+ x: 0,
72586
+ y: 0
72587
+ });
72588
+ const rect = useMemo(() => {
72589
+ switch (activator) {
72590
+ case AutoScrollActivator.Pointer:
72591
+ return pointerCoordinates ? {
72592
+ top: pointerCoordinates.y,
72593
+ bottom: pointerCoordinates.y,
72594
+ left: pointerCoordinates.x,
72595
+ right: pointerCoordinates.x
72596
+ } : null;
72597
+
72598
+ case AutoScrollActivator.DraggableRect:
72599
+ return draggingRect;
72600
+ }
72601
+ }, [activator, draggingRect, pointerCoordinates]);
72602
+ const scrollContainerRef = useRef(null);
72603
+ const autoScroll = useCallback(() => {
72604
+ const scrollContainer = scrollContainerRef.current;
72605
+
72606
+ if (!scrollContainer) {
72607
+ return;
72608
+ }
72609
+
72610
+ const scrollLeft = scrollSpeed.current.x * scrollDirection.current.x;
72611
+ const scrollTop = scrollSpeed.current.y * scrollDirection.current.y;
72612
+ scrollContainer.scrollBy(scrollLeft, scrollTop);
72613
+ }, []);
72614
+ const sortedScrollableAncestors = useMemo(() => order === TraversalOrder.TreeOrder ? [...scrollableAncestors].reverse() : scrollableAncestors, [order, scrollableAncestors]);
72615
+ useEffect(() => {
72616
+ if (!enabled || !scrollableAncestors.length || !rect) {
72617
+ clearAutoScrollInterval();
72618
+ return;
72619
+ }
72620
+
72621
+ for (const scrollContainer of sortedScrollableAncestors) {
72622
+ if ((canScroll == null ? void 0 : canScroll(scrollContainer)) === false) {
72623
+ continue;
72624
+ }
72625
+
72626
+ const index = scrollableAncestors.indexOf(scrollContainer);
72627
+ const scrollContainerRect = scrollableAncestorRects[index];
72628
+
72629
+ if (!scrollContainerRect) {
72630
+ continue;
72631
+ }
72632
+
72633
+ const {
72634
+ direction,
72635
+ speed
72636
+ } = getScrollDirectionAndSpeed(scrollContainer, scrollContainerRect, rect, acceleration, threshold);
72637
+
72638
+ for (const axis of ['x', 'y']) {
72639
+ if (!scrollIntent[axis][direction[axis]]) {
72640
+ speed[axis] = 0;
72641
+ direction[axis] = 0;
72642
+ }
72643
+ }
72644
+
72645
+ if (speed.x > 0 || speed.y > 0) {
72646
+ clearAutoScrollInterval();
72647
+ scrollContainerRef.current = scrollContainer;
72648
+ setAutoScrollInterval(autoScroll, interval);
72649
+ scrollSpeed.current = speed;
72650
+ scrollDirection.current = direction;
72651
+ return;
72652
+ }
72653
+ }
72654
+
72655
+ scrollSpeed.current = {
72656
+ x: 0,
72657
+ y: 0
72658
+ };
72659
+ scrollDirection.current = {
72660
+ x: 0,
72661
+ y: 0
72662
+ };
72663
+ clearAutoScrollInterval();
72664
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
72665
+ [acceleration, autoScroll, canScroll, clearAutoScrollInterval, enabled, interval, // eslint-disable-next-line react-hooks/exhaustive-deps
72666
+ JSON.stringify(rect), // eslint-disable-next-line react-hooks/exhaustive-deps
72667
+ JSON.stringify(scrollIntent), setAutoScrollInterval, scrollableAncestors, sortedScrollableAncestors, scrollableAncestorRects, // eslint-disable-next-line react-hooks/exhaustive-deps
72668
+ JSON.stringify(threshold)]);
72669
+ }
72670
+ const defaultScrollIntent = {
72671
+ x: {
72672
+ [Direction.Backward]: false,
72673
+ [Direction.Forward]: false
72674
+ },
72675
+ y: {
72676
+ [Direction.Backward]: false,
72677
+ [Direction.Forward]: false
72678
+ }
72679
+ };
72680
+
72681
+ function useScrollIntent(_ref2) {
72682
+ let {
72683
+ delta,
72684
+ disabled
72685
+ } = _ref2;
72686
+ const previousDelta = usePrevious(delta);
72687
+ return useLazyMemo(previousIntent => {
72688
+ if (disabled || !previousDelta || !previousIntent) {
72689
+ // Reset scroll intent tracking when auto-scrolling is disabled
72690
+ return defaultScrollIntent;
72691
+ }
72692
+
72693
+ const direction = {
72694
+ x: Math.sign(delta.x - previousDelta.x),
72695
+ y: Math.sign(delta.y - previousDelta.y)
72696
+ }; // Keep track of the user intent to scroll in each direction for both axis
72697
+
72698
+ return {
72699
+ x: {
72700
+ [Direction.Backward]: previousIntent.x[Direction.Backward] || direction.x === -1,
72701
+ [Direction.Forward]: previousIntent.x[Direction.Forward] || direction.x === 1
72702
+ },
72703
+ y: {
72704
+ [Direction.Backward]: previousIntent.y[Direction.Backward] || direction.y === -1,
72705
+ [Direction.Forward]: previousIntent.y[Direction.Forward] || direction.y === 1
72706
+ }
72707
+ };
72708
+ }, [disabled, delta, previousDelta]);
72709
+ }
72710
+
72711
+ function useCachedNode(draggableNodes, id) {
72712
+ const draggableNode = id != null ? draggableNodes.get(id) : undefined;
72713
+ const node = draggableNode ? draggableNode.node.current : null;
72714
+ return useLazyMemo(cachedNode => {
72715
+ var _ref;
72716
+
72717
+ if (id == null) {
72718
+ return null;
72719
+ } // In some cases, the draggable node can unmount while dragging
72720
+ // This is the case for virtualized lists. In those situations,
72721
+ // we fall back to the last known value for that node.
72722
+
72723
+
72724
+ return (_ref = node != null ? node : cachedNode) != null ? _ref : null;
72725
+ }, [node, id]);
72726
+ }
72727
+
72728
+ function useCombineActivators(sensors, getSyntheticHandler) {
72729
+ return useMemo(() => sensors.reduce((accumulator, sensor) => {
72730
+ const {
72731
+ sensor: Sensor
72732
+ } = sensor;
72733
+ const sensorActivators = Sensor.activators.map(activator => ({
72734
+ eventName: activator.eventName,
72735
+ handler: getSyntheticHandler(activator.handler, sensor)
72736
+ }));
72737
+ return [...accumulator, ...sensorActivators];
72738
+ }, []), [sensors, getSyntheticHandler]);
72739
+ }
72740
+
72741
+ var MeasuringStrategy;
72742
+
72743
+ (function (MeasuringStrategy) {
72744
+ MeasuringStrategy[MeasuringStrategy["Always"] = 0] = "Always";
72745
+ MeasuringStrategy[MeasuringStrategy["BeforeDragging"] = 1] = "BeforeDragging";
72746
+ MeasuringStrategy[MeasuringStrategy["WhileDragging"] = 2] = "WhileDragging";
72747
+ })(MeasuringStrategy || (MeasuringStrategy = {}));
72748
+
72749
+ var MeasuringFrequency;
72750
+
72751
+ (function (MeasuringFrequency) {
72752
+ MeasuringFrequency["Optimized"] = "optimized";
72753
+ })(MeasuringFrequency || (MeasuringFrequency = {}));
72754
+
72755
+ const defaultValue = /*#__PURE__*/new Map();
72756
+ function useDroppableMeasuring(containers, _ref) {
72757
+ let {
72758
+ dragging,
72759
+ dependencies,
72760
+ config
72761
+ } = _ref;
72762
+ const [queue, setQueue] = useState(null);
72763
+ const {
72764
+ frequency,
72765
+ measure,
72766
+ strategy
72767
+ } = config;
72768
+ const containersRef = useRef(containers);
72769
+ const disabled = isDisabled();
72770
+ const disabledRef = useLatestValue(disabled);
72771
+ const measureDroppableContainers = useCallback(function (ids) {
72772
+ if (ids === void 0) {
72773
+ ids = [];
72774
+ }
72775
+
72776
+ if (disabledRef.current) {
72777
+ return;
72778
+ }
72779
+
72780
+ setQueue(value => {
72781
+ if (value === null) {
72782
+ return ids;
72783
+ }
72784
+
72785
+ return value.concat(ids.filter(id => !value.includes(id)));
72786
+ });
72787
+ }, [disabledRef]);
72788
+ const timeoutId = useRef(null);
72789
+ const droppableRects = useLazyMemo(previousValue => {
72790
+ if (disabled && !dragging) {
72791
+ return defaultValue;
72792
+ }
72793
+
72794
+ if (!previousValue || previousValue === defaultValue || containersRef.current !== containers || queue != null) {
72795
+ const map = new Map();
72796
+
72797
+ for (let container of containers) {
72798
+ if (!container) {
72799
+ continue;
72800
+ }
72801
+
72802
+ if (queue && queue.length > 0 && !queue.includes(container.id) && container.rect.current) {
72803
+ // This container does not need to be re-measured
72804
+ map.set(container.id, container.rect.current);
72805
+ continue;
72806
+ }
72807
+
72808
+ const node = container.node.current;
72809
+ const rect = node ? new Rect(measure(node), node) : null;
72810
+ container.rect.current = rect;
72811
+
72812
+ if (rect) {
72813
+ map.set(container.id, rect);
72814
+ }
72815
+ }
72816
+
72817
+ return map;
72818
+ }
72819
+
72820
+ return previousValue;
72821
+ }, [containers, queue, dragging, disabled, measure]);
72822
+ useEffect(() => {
72823
+ containersRef.current = containers;
72824
+ }, [containers]);
72825
+ useEffect(() => {
72826
+ if (disabled) {
72827
+ return;
72828
+ }
72829
+
72830
+ measureDroppableContainers();
72831
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
72832
+ [dragging, disabled]);
72833
+ useEffect(() => {
72834
+ if (queue && queue.length > 0) {
72835
+ setQueue(null);
72836
+ }
72837
+ }, //eslint-disable-next-line react-hooks/exhaustive-deps
72838
+ [JSON.stringify(queue)]);
72839
+ useEffect(() => {
72840
+ if (disabled || typeof frequency !== 'number' || timeoutId.current !== null) {
72841
+ return;
72842
+ }
72843
+
72844
+ timeoutId.current = setTimeout(() => {
72845
+ measureDroppableContainers();
72846
+ timeoutId.current = null;
72847
+ }, frequency);
72848
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
72849
+ [frequency, disabled, measureDroppableContainers, ...dependencies]);
72850
+ return {
72851
+ droppableRects,
72852
+ measureDroppableContainers,
72853
+ measuringScheduled: queue != null
72854
+ };
72855
+
72856
+ function isDisabled() {
72857
+ switch (strategy) {
72858
+ case MeasuringStrategy.Always:
72859
+ return false;
72860
+
72861
+ case MeasuringStrategy.BeforeDragging:
72862
+ return dragging;
72863
+
72864
+ default:
72865
+ return !dragging;
72866
+ }
72867
+ }
72868
+ }
72869
+
72870
+ function useInitialValue(value, computeFn) {
72871
+ return useLazyMemo(previousValue => {
72872
+ if (!value) {
72873
+ return null;
72874
+ }
72875
+
72876
+ if (previousValue) {
72877
+ return previousValue;
72878
+ }
72879
+
72880
+ return typeof computeFn === 'function' ? computeFn(value) : value;
72881
+ }, [computeFn, value]);
72882
+ }
72883
+
72884
+ function useInitialRect(node, measure) {
72885
+ return useInitialValue(node, measure);
72886
+ }
72887
+
72888
+ /**
72889
+ * Returns a new MutationObserver instance.
72890
+ * If `MutationObserver` is undefined in the execution environment, returns `undefined`.
72891
+ */
72892
+
72893
+ function useMutationObserver(_ref) {
72894
+ let {
72895
+ callback,
72896
+ disabled
72897
+ } = _ref;
72898
+ const handleMutations = useEvent(callback);
72899
+ const mutationObserver = useMemo(() => {
72900
+ if (disabled || typeof window === 'undefined' || typeof window.MutationObserver === 'undefined') {
72901
+ return undefined;
72902
+ }
72903
+
72904
+ const {
72905
+ MutationObserver
72906
+ } = window;
72907
+ return new MutationObserver(handleMutations);
72908
+ }, [handleMutations, disabled]);
72909
+ useEffect(() => {
72910
+ return () => mutationObserver == null ? void 0 : mutationObserver.disconnect();
72911
+ }, [mutationObserver]);
72912
+ return mutationObserver;
72913
+ }
72914
+
72915
+ /**
72916
+ * Returns a new ResizeObserver instance bound to the `onResize` callback.
72917
+ * If `ResizeObserver` is undefined in the execution environment, returns `undefined`.
72918
+ */
72919
+
72920
+ function useResizeObserver(_ref) {
72921
+ let {
72922
+ callback,
72923
+ disabled
72924
+ } = _ref;
72925
+ const handleResize = useEvent(callback);
72926
+ const resizeObserver = useMemo(() => {
72927
+ if (disabled || typeof window === 'undefined' || typeof window.ResizeObserver === 'undefined') {
72928
+ return undefined;
72929
+ }
72930
+
72931
+ const {
72932
+ ResizeObserver
72933
+ } = window;
72934
+ return new ResizeObserver(handleResize);
72935
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
72936
+ [disabled]);
72937
+ useEffect(() => {
72938
+ return () => resizeObserver == null ? void 0 : resizeObserver.disconnect();
72939
+ }, [resizeObserver]);
72940
+ return resizeObserver;
72941
+ }
72942
+
72943
+ function defaultMeasure(element) {
72944
+ return new Rect(getClientRect(element), element);
72945
+ }
72946
+
72947
+ function useRect(element, measure, fallbackRect) {
72948
+ if (measure === void 0) {
72949
+ measure = defaultMeasure;
72950
+ }
72951
+
72952
+ const [rect, setRect] = useState(null);
72953
+
72954
+ function measureRect() {
72955
+ setRect(currentRect => {
72956
+ if (!element) {
72957
+ return null;
72958
+ }
72959
+
72960
+ if (element.isConnected === false) {
72961
+ var _ref;
72962
+
72963
+ // Fall back to last rect we measured if the element is
72964
+ // no longer connected to the DOM.
72965
+ return (_ref = currentRect != null ? currentRect : fallbackRect) != null ? _ref : null;
72966
+ }
72967
+
72968
+ const newRect = measure(element);
72969
+
72970
+ if (JSON.stringify(currentRect) === JSON.stringify(newRect)) {
72971
+ return currentRect;
72972
+ }
72973
+
72974
+ return newRect;
72975
+ });
72976
+ }
72977
+
72978
+ const mutationObserver = useMutationObserver({
72979
+ callback(records) {
72980
+ if (!element) {
72981
+ return;
72982
+ }
72983
+
72984
+ for (const record of records) {
72985
+ const {
72986
+ type,
72987
+ target
72988
+ } = record;
72989
+
72990
+ if (type === 'childList' && target instanceof HTMLElement && target.contains(element)) {
72991
+ measureRect();
72992
+ break;
72993
+ }
72994
+ }
72995
+ }
72996
+
72997
+ });
72998
+ const resizeObserver = useResizeObserver({
72999
+ callback: measureRect
73000
+ });
73001
+ useIsomorphicLayoutEffect(() => {
73002
+ measureRect();
73003
+
73004
+ if (element) {
73005
+ resizeObserver == null ? void 0 : resizeObserver.observe(element);
73006
+ mutationObserver == null ? void 0 : mutationObserver.observe(document.body, {
73007
+ childList: true,
73008
+ subtree: true
73009
+ });
73010
+ } else {
73011
+ resizeObserver == null ? void 0 : resizeObserver.disconnect();
73012
+ mutationObserver == null ? void 0 : mutationObserver.disconnect();
73013
+ }
73014
+ }, [element]);
73015
+ return rect;
73016
+ }
73017
+
73018
+ function useRectDelta(rect) {
73019
+ const initialRect = useInitialValue(rect);
73020
+ return getRectDelta(rect, initialRect);
73021
+ }
73022
+
73023
+ const defaultValue$1 = [];
73024
+ function useScrollableAncestors(node) {
73025
+ const previousNode = useRef(node);
73026
+ const ancestors = useLazyMemo(previousValue => {
73027
+ if (!node) {
73028
+ return defaultValue$1;
73029
+ }
73030
+
73031
+ if (previousValue && previousValue !== defaultValue$1 && node && previousNode.current && node.parentNode === previousNode.current.parentNode) {
73032
+ return previousValue;
73033
+ }
73034
+
73035
+ return getScrollableAncestors(node);
73036
+ }, [node]);
73037
+ useEffect(() => {
73038
+ previousNode.current = node;
73039
+ }, [node]);
73040
+ return ancestors;
73041
+ }
73042
+
73043
+ function useScrollOffsets(elements) {
73044
+ const [scrollCoordinates, setScrollCoordinates] = useState(null);
73045
+ const prevElements = useRef(elements); // To-do: Throttle the handleScroll callback
73046
+
73047
+ const handleScroll = useCallback(event => {
73048
+ const scrollingElement = getScrollableElement(event.target);
73049
+
73050
+ if (!scrollingElement) {
73051
+ return;
73052
+ }
73053
+
73054
+ setScrollCoordinates(scrollCoordinates => {
73055
+ if (!scrollCoordinates) {
73056
+ return null;
73057
+ }
73058
+
73059
+ scrollCoordinates.set(scrollingElement, getScrollCoordinates(scrollingElement));
73060
+ return new Map(scrollCoordinates);
73061
+ });
73062
+ }, []);
73063
+ useEffect(() => {
73064
+ const previousElements = prevElements.current;
73065
+
73066
+ if (elements !== previousElements) {
73067
+ cleanup(previousElements);
73068
+ const entries = elements.map(element => {
73069
+ const scrollableElement = getScrollableElement(element);
73070
+
73071
+ if (scrollableElement) {
73072
+ scrollableElement.addEventListener('scroll', handleScroll, {
73073
+ passive: true
73074
+ });
73075
+ return [scrollableElement, getScrollCoordinates(scrollableElement)];
73076
+ }
73077
+
73078
+ return null;
73079
+ }).filter(entry => entry != null);
73080
+ setScrollCoordinates(entries.length ? new Map(entries) : null);
73081
+ prevElements.current = elements;
73082
+ }
73083
+
73084
+ return () => {
73085
+ cleanup(elements);
73086
+ cleanup(previousElements);
73087
+ };
73088
+
73089
+ function cleanup(elements) {
73090
+ elements.forEach(element => {
73091
+ const scrollableElement = getScrollableElement(element);
73092
+ scrollableElement == null ? void 0 : scrollableElement.removeEventListener('scroll', handleScroll);
73093
+ });
73094
+ }
73095
+ }, [handleScroll, elements]);
73096
+ return useMemo(() => {
73097
+ if (elements.length) {
73098
+ return scrollCoordinates ? Array.from(scrollCoordinates.values()).reduce((acc, coordinates) => add(acc, coordinates), defaultCoordinates) : getScrollOffsets(elements);
73099
+ }
73100
+
73101
+ return defaultCoordinates;
73102
+ }, [elements, scrollCoordinates]);
73103
+ }
73104
+
73105
+ function useScrollOffsetsDelta(scrollOffsets, dependencies) {
73106
+ if (dependencies === void 0) {
73107
+ dependencies = [];
73108
+ }
73109
+
73110
+ const initialScrollOffsets = useRef(null);
73111
+ useEffect(() => {
73112
+ initialScrollOffsets.current = null;
73113
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
73114
+ dependencies);
73115
+ useEffect(() => {
73116
+ const hasScrollOffsets = scrollOffsets !== defaultCoordinates;
73117
+
73118
+ if (hasScrollOffsets && !initialScrollOffsets.current) {
73119
+ initialScrollOffsets.current = scrollOffsets;
73120
+ }
73121
+
73122
+ if (!hasScrollOffsets && initialScrollOffsets.current) {
73123
+ initialScrollOffsets.current = null;
73124
+ }
73125
+ }, [scrollOffsets]);
73126
+ return initialScrollOffsets.current ? subtract(scrollOffsets, initialScrollOffsets.current) : defaultCoordinates;
73127
+ }
73128
+
73129
+ function useSensorSetup(sensors) {
73130
+ useEffect(() => {
73131
+ if (!canUseDOM) {
73132
+ return;
73133
+ }
73134
+
73135
+ const teardownFns = sensors.map(_ref => {
73136
+ let {
73137
+ sensor
73138
+ } = _ref;
73139
+ return sensor.setup == null ? void 0 : sensor.setup();
73140
+ });
73141
+ return () => {
73142
+ for (const teardown of teardownFns) {
73143
+ teardown == null ? void 0 : teardown();
73144
+ }
73145
+ };
73146
+ }, // TO-DO: Sensors length could theoretically change which would not be a valid dependency
73147
+ // eslint-disable-next-line react-hooks/exhaustive-deps
73148
+ sensors.map(_ref2 => {
73149
+ let {
73150
+ sensor
73151
+ } = _ref2;
73152
+ return sensor;
73153
+ }));
73154
+ }
73155
+
73156
+ function useSyntheticListeners(listeners, id) {
73157
+ return useMemo(() => {
73158
+ return listeners.reduce((acc, _ref) => {
73159
+ let {
73160
+ eventName,
73161
+ handler
73162
+ } = _ref;
73163
+
73164
+ acc[eventName] = event => {
73165
+ handler(event, id);
73166
+ };
73167
+
73168
+ return acc;
73169
+ }, {});
73170
+ }, [listeners, id]);
73171
+ }
73172
+
73173
+ function useWindowRect(element) {
73174
+ return useMemo(() => element ? getWindowClientRect(element) : null, [element]);
73175
+ }
73176
+
73177
+ const defaultValue$2 = [];
73178
+ function useRects(elements, measure) {
73179
+ if (measure === void 0) {
73180
+ measure = getClientRect;
73181
+ }
73182
+
73183
+ const [firstElement] = elements;
73184
+ const windowRect = useWindowRect(firstElement ? getWindow(firstElement) : null);
73185
+ const [rects, setRects] = useState(defaultValue$2);
73186
+
73187
+ function measureRects() {
73188
+ setRects(() => {
73189
+ if (!elements.length) {
73190
+ return defaultValue$2;
73191
+ }
73192
+
73193
+ return elements.map(element => isDocumentScrollingElement(element) ? windowRect : new Rect(measure(element), element));
73194
+ });
73195
+ }
73196
+
73197
+ const resizeObserver = useResizeObserver({
73198
+ callback: measureRects
73199
+ });
73200
+ useIsomorphicLayoutEffect(() => {
73201
+ resizeObserver == null ? void 0 : resizeObserver.disconnect();
73202
+ measureRects();
73203
+ elements.forEach(element => resizeObserver == null ? void 0 : resizeObserver.observe(element));
73204
+ }, [elements]);
73205
+ return rects;
73206
+ }
73207
+
73208
+ function getMeasurableNode(node) {
73209
+ if (!node) {
73210
+ return null;
73211
+ }
73212
+
73213
+ if (node.children.length > 1) {
73214
+ return node;
73215
+ }
73216
+
73217
+ const firstChild = node.children[0];
73218
+ return isHTMLElement(firstChild) ? firstChild : node;
73219
+ }
73220
+
73221
+ function useDragOverlayMeasuring(_ref) {
73222
+ let {
73223
+ measure
73224
+ } = _ref;
73225
+ const [rect, setRect] = useState(null);
73226
+ const handleResize = useCallback(entries => {
73227
+ for (const {
73228
+ target
73229
+ } of entries) {
73230
+ if (isHTMLElement(target)) {
73231
+ setRect(rect => {
73232
+ const newRect = measure(target);
73233
+ return rect ? { ...rect,
73234
+ width: newRect.width,
73235
+ height: newRect.height
73236
+ } : newRect;
73237
+ });
73238
+ break;
73239
+ }
73240
+ }
73241
+ }, [measure]);
73242
+ const resizeObserver = useResizeObserver({
73243
+ callback: handleResize
73244
+ });
73245
+ const handleNodeChange = useCallback(element => {
73246
+ const node = getMeasurableNode(element);
73247
+ resizeObserver == null ? void 0 : resizeObserver.disconnect();
73248
+
73249
+ if (node) {
73250
+ resizeObserver == null ? void 0 : resizeObserver.observe(node);
73251
+ }
73252
+
73253
+ setRect(node ? measure(node) : null);
73254
+ }, [measure, resizeObserver]);
73255
+ const [nodeRef, setRef] = useNodeRef(handleNodeChange);
73256
+ return useMemo(() => ({
73257
+ nodeRef,
73258
+ rect,
73259
+ setRef
73260
+ }), [rect, nodeRef, setRef]);
73261
+ }
73262
+
73263
+ const defaultSensors = [{
73264
+ sensor: PointerSensor,
73265
+ options: {}
73266
+ }, {
73267
+ sensor: KeyboardSensor,
73268
+ options: {}
73269
+ }];
73270
+ const defaultData = {
73271
+ current: {}
73272
+ };
73273
+ const defaultMeasuringConfiguration = {
73274
+ draggable: {
73275
+ measure: getTransformAgnosticClientRect
73276
+ },
73277
+ droppable: {
73278
+ measure: getTransformAgnosticClientRect,
73279
+ strategy: MeasuringStrategy.WhileDragging,
73280
+ frequency: MeasuringFrequency.Optimized
73281
+ },
73282
+ dragOverlay: {
73283
+ measure: getClientRect
73284
+ }
73285
+ };
73286
+
73287
+ class DroppableContainersMap extends Map {
73288
+ get(id) {
73289
+ var _super$get;
73290
+
73291
+ return id != null ? (_super$get = super.get(id)) != null ? _super$get : undefined : undefined;
73292
+ }
73293
+
73294
+ toArray() {
73295
+ return Array.from(this.values());
73296
+ }
73297
+
73298
+ getEnabled() {
73299
+ return this.toArray().filter(_ref => {
73300
+ let {
73301
+ disabled
73302
+ } = _ref;
73303
+ return !disabled;
73304
+ });
73305
+ }
73306
+
73307
+ getNodeFor(id) {
73308
+ var _this$get$node$curren, _this$get;
73309
+
73310
+ return (_this$get$node$curren = (_this$get = this.get(id)) == null ? void 0 : _this$get.node.current) != null ? _this$get$node$curren : undefined;
73311
+ }
73312
+
73313
+ }
73314
+
73315
+ const defaultPublicContext = {
73316
+ activatorEvent: null,
73317
+ active: null,
73318
+ activeNode: null,
73319
+ activeNodeRect: null,
73320
+ collisions: null,
73321
+ containerNodeRect: null,
73322
+ draggableNodes: /*#__PURE__*/new Map(),
73323
+ droppableRects: /*#__PURE__*/new Map(),
73324
+ droppableContainers: /*#__PURE__*/new DroppableContainersMap(),
73325
+ over: null,
73326
+ dragOverlay: {
73327
+ nodeRef: {
73328
+ current: null
73329
+ },
73330
+ rect: null,
73331
+ setRef: noop
73332
+ },
73333
+ scrollableAncestors: [],
73334
+ scrollableAncestorRects: [],
73335
+ measuringConfiguration: defaultMeasuringConfiguration,
73336
+ measureDroppableContainers: noop,
73337
+ windowRect: null,
73338
+ measuringScheduled: false
73339
+ };
73340
+ const defaultInternalContext = {
73341
+ activatorEvent: null,
73342
+ activators: [],
73343
+ active: null,
73344
+ activeNodeRect: null,
73345
+ ariaDescribedById: {
73346
+ draggable: ''
73347
+ },
73348
+ dispatch: noop,
73349
+ draggableNodes: /*#__PURE__*/new Map(),
73350
+ over: null,
73351
+ measureDroppableContainers: noop
73352
+ };
73353
+ const InternalContext = /*#__PURE__*/createContext(defaultInternalContext);
73354
+ const PublicContext = /*#__PURE__*/createContext(defaultPublicContext);
73355
+
73356
+ function getInitialState() {
73357
+ return {
73358
+ draggable: {
73359
+ active: null,
73360
+ initialCoordinates: {
73361
+ x: 0,
73362
+ y: 0
73363
+ },
73364
+ nodes: new Map(),
73365
+ translate: {
73366
+ x: 0,
73367
+ y: 0
73368
+ }
73369
+ },
73370
+ droppable: {
73371
+ containers: new DroppableContainersMap()
73372
+ }
73373
+ };
73374
+ }
73375
+ function reducer(state, action) {
73376
+ switch (action.type) {
73377
+ case Action.DragStart:
73378
+ return { ...state,
73379
+ draggable: { ...state.draggable,
73380
+ initialCoordinates: action.initialCoordinates,
73381
+ active: action.active
73382
+ }
73383
+ };
73384
+
73385
+ case Action.DragMove:
73386
+ if (state.draggable.active == null) {
73387
+ return state;
73388
+ }
73389
+
73390
+ return { ...state,
73391
+ draggable: { ...state.draggable,
73392
+ translate: {
73393
+ x: action.coordinates.x - state.draggable.initialCoordinates.x,
73394
+ y: action.coordinates.y - state.draggable.initialCoordinates.y
73395
+ }
73396
+ }
73397
+ };
73398
+
73399
+ case Action.DragEnd:
73400
+ case Action.DragCancel:
73401
+ return { ...state,
73402
+ draggable: { ...state.draggable,
73403
+ active: null,
73404
+ initialCoordinates: {
73405
+ x: 0,
73406
+ y: 0
73407
+ },
73408
+ translate: {
73409
+ x: 0,
73410
+ y: 0
73411
+ }
73412
+ }
73413
+ };
73414
+
73415
+ case Action.RegisterDroppable:
73416
+ {
73417
+ const {
73418
+ element
73419
+ } = action;
73420
+ const {
73421
+ id
73422
+ } = element;
73423
+ const containers = new DroppableContainersMap(state.droppable.containers);
73424
+ containers.set(id, element);
73425
+ return { ...state,
73426
+ droppable: { ...state.droppable,
73427
+ containers
73428
+ }
73429
+ };
73430
+ }
73431
+
73432
+ case Action.SetDroppableDisabled:
73433
+ {
73434
+ const {
73435
+ id,
73436
+ key,
73437
+ disabled
73438
+ } = action;
73439
+ const element = state.droppable.containers.get(id);
73440
+
73441
+ if (!element || key !== element.key) {
73442
+ return state;
73443
+ }
73444
+
73445
+ const containers = new DroppableContainersMap(state.droppable.containers);
73446
+ containers.set(id, { ...element,
73447
+ disabled
73448
+ });
73449
+ return { ...state,
73450
+ droppable: { ...state.droppable,
73451
+ containers
73452
+ }
73453
+ };
73454
+ }
73455
+
73456
+ case Action.UnregisterDroppable:
73457
+ {
73458
+ const {
73459
+ id,
73460
+ key
73461
+ } = action;
73462
+ const element = state.droppable.containers.get(id);
73463
+
73464
+ if (!element || key !== element.key) {
73465
+ return state;
73466
+ }
73467
+
73468
+ const containers = new DroppableContainersMap(state.droppable.containers);
73469
+ containers.delete(id);
73470
+ return { ...state,
73471
+ droppable: { ...state.droppable,
73472
+ containers
73473
+ }
73474
+ };
73475
+ }
73476
+
73477
+ default:
73478
+ {
73479
+ return state;
73480
+ }
73481
+ }
73482
+ }
73483
+
73484
+ function RestoreFocus(_ref) {
73485
+ let {
73486
+ disabled
73487
+ } = _ref;
73488
+ const {
73489
+ active,
73490
+ activatorEvent,
73491
+ draggableNodes
73492
+ } = useContext(InternalContext);
73493
+ const previousActivatorEvent = usePrevious(activatorEvent);
73494
+ const previousActiveId = usePrevious(active == null ? void 0 : active.id); // Restore keyboard focus on the activator node
73495
+
73496
+ useEffect(() => {
73497
+ if (disabled) {
73498
+ return;
73499
+ }
73500
+
73501
+ if (!activatorEvent && previousActivatorEvent && previousActiveId != null) {
73502
+ if (!isKeyboardEvent(previousActivatorEvent)) {
73503
+ return;
73504
+ }
73505
+
73506
+ if (document.activeElement === previousActivatorEvent.target) {
73507
+ // No need to restore focus
73508
+ return;
73509
+ }
73510
+
73511
+ const draggableNode = draggableNodes.get(previousActiveId);
73512
+
73513
+ if (!draggableNode) {
73514
+ return;
73515
+ }
73516
+
73517
+ const {
73518
+ activatorNode,
73519
+ node
73520
+ } = draggableNode;
73521
+
73522
+ if (!activatorNode.current && !node.current) {
73523
+ return;
73524
+ }
73525
+
73526
+ requestAnimationFrame(() => {
73527
+ for (const element of [activatorNode.current, node.current]) {
73528
+ if (!element) {
73529
+ continue;
73530
+ }
73531
+
73532
+ const focusableNode = findFirstFocusableNode(element);
73533
+
73534
+ if (focusableNode) {
73535
+ focusableNode.focus();
73536
+ break;
73537
+ }
73538
+ }
73539
+ });
73540
+ }
73541
+ }, [activatorEvent, disabled, draggableNodes, previousActiveId, previousActivatorEvent]);
73542
+ return null;
73543
+ }
73544
+
73545
+ function applyModifiers(modifiers, _ref) {
73546
+ let {
73547
+ transform,
73548
+ ...args
73549
+ } = _ref;
73550
+ return modifiers != null && modifiers.length ? modifiers.reduce((accumulator, modifier) => {
73551
+ return modifier({
73552
+ transform: accumulator,
73553
+ ...args
73554
+ });
73555
+ }, transform) : transform;
73556
+ }
73557
+
73558
+ function useMeasuringConfiguration(config) {
73559
+ return useMemo(() => ({
73560
+ draggable: { ...defaultMeasuringConfiguration.draggable,
73561
+ ...(config == null ? void 0 : config.draggable)
73562
+ },
73563
+ droppable: { ...defaultMeasuringConfiguration.droppable,
73564
+ ...(config == null ? void 0 : config.droppable)
73565
+ },
73566
+ dragOverlay: { ...defaultMeasuringConfiguration.dragOverlay,
73567
+ ...(config == null ? void 0 : config.dragOverlay)
73568
+ }
73569
+ }), // eslint-disable-next-line react-hooks/exhaustive-deps
73570
+ [config == null ? void 0 : config.draggable, config == null ? void 0 : config.droppable, config == null ? void 0 : config.dragOverlay]);
73571
+ }
73572
+
73573
+ function useLayoutShiftScrollCompensation(_ref) {
73574
+ let {
73575
+ activeNode,
73576
+ measure,
73577
+ initialRect,
73578
+ config = true
73579
+ } = _ref;
73580
+ const initialized = useRef(false);
73581
+ const {
73582
+ x,
73583
+ y
73584
+ } = typeof config === 'boolean' ? {
73585
+ x: config,
73586
+ y: config
73587
+ } : config;
73588
+ useIsomorphicLayoutEffect(() => {
73589
+ const disabled = !x && !y;
73590
+
73591
+ if (disabled || !activeNode) {
73592
+ initialized.current = false;
73593
+ return;
73594
+ }
73595
+
73596
+ if (initialized.current || !initialRect) {
73597
+ // Return early if layout shift scroll compensation was already attempted
73598
+ // or if there is no initialRect to compare to.
73599
+ return;
73600
+ } // Get the most up to date node ref for the active draggable
73601
+
73602
+
73603
+ const node = activeNode == null ? void 0 : activeNode.node.current;
73604
+
73605
+ if (!node || node.isConnected === false) {
73606
+ // Return early if there is no attached node ref or if the node is
73607
+ // disconnected from the document.
73608
+ return;
73609
+ }
73610
+
73611
+ const rect = measure(node);
73612
+ const rectDelta = getRectDelta(rect, initialRect);
73613
+
73614
+ if (!x) {
73615
+ rectDelta.x = 0;
73616
+ }
73617
+
73618
+ if (!y) {
73619
+ rectDelta.y = 0;
73620
+ } // Only perform layout shift scroll compensation once
73621
+
73622
+
73623
+ initialized.current = true;
73624
+
73625
+ if (Math.abs(rectDelta.x) > 0 || Math.abs(rectDelta.y) > 0) {
73626
+ const firstScrollableAncestor = getFirstScrollableAncestor(node);
73627
+
73628
+ if (firstScrollableAncestor) {
73629
+ firstScrollableAncestor.scrollBy({
73630
+ top: rectDelta.y,
73631
+ left: rectDelta.x
73632
+ });
73633
+ }
73634
+ }
73635
+ }, [activeNode, x, y, initialRect, measure]);
73636
+ }
73637
+
73638
+ const ActiveDraggableContext = /*#__PURE__*/createContext({ ...defaultCoordinates,
73639
+ scaleX: 1,
73640
+ scaleY: 1
73641
+ });
73642
+ var Status;
73643
+
73644
+ (function (Status) {
73645
+ Status[Status["Uninitialized"] = 0] = "Uninitialized";
73646
+ Status[Status["Initializing"] = 1] = "Initializing";
73647
+ Status[Status["Initialized"] = 2] = "Initialized";
73648
+ })(Status || (Status = {}));
73649
+
73650
+ const DndContext = /*#__PURE__*/memo(function DndContext(_ref) {
73651
+ var _sensorContext$curren, _dragOverlay$nodeRef$, _dragOverlay$rect, _over$rect;
73652
+
73653
+ let {
73654
+ id,
73655
+ accessibility,
73656
+ autoScroll = true,
73657
+ children,
73658
+ sensors = defaultSensors,
73659
+ collisionDetection = rectIntersection,
73660
+ measuring,
73661
+ modifiers,
73662
+ ...props
73663
+ } = _ref;
73664
+ const store = useReducer(reducer, undefined, getInitialState);
73665
+ const [state, dispatch] = store;
73666
+ const [dispatchMonitorEvent, registerMonitorListener] = useDndMonitorProvider();
73667
+ const [status, setStatus] = useState(Status.Uninitialized);
73668
+ const isInitialized = status === Status.Initialized;
73669
+ const {
73670
+ draggable: {
73671
+ active: activeId,
73672
+ nodes: draggableNodes,
73673
+ translate
73674
+ },
73675
+ droppable: {
73676
+ containers: droppableContainers
73677
+ }
73678
+ } = state;
73679
+ const node = activeId != null ? draggableNodes.get(activeId) : null;
73680
+ const activeRects = useRef({
73681
+ initial: null,
73682
+ translated: null
73683
+ });
73684
+ const active = useMemo(() => {
73685
+ var _node$data;
73686
+
73687
+ return activeId != null ? {
73688
+ id: activeId,
73689
+ // It's possible for the active node to unmount while dragging
73690
+ data: (_node$data = node == null ? void 0 : node.data) != null ? _node$data : defaultData,
73691
+ rect: activeRects
73692
+ } : null;
73693
+ }, [activeId, node]);
73694
+ const activeRef = useRef(null);
73695
+ const [activeSensor, setActiveSensor] = useState(null);
73696
+ const [activatorEvent, setActivatorEvent] = useState(null);
73697
+ const latestProps = useLatestValue(props, Object.values(props));
73698
+ const draggableDescribedById = useUniqueId("DndDescribedBy", id);
73699
+ const enabledDroppableContainers = useMemo(() => droppableContainers.getEnabled(), [droppableContainers]);
73700
+ const measuringConfiguration = useMeasuringConfiguration(measuring);
73701
+ const {
73702
+ droppableRects,
73703
+ measureDroppableContainers,
73704
+ measuringScheduled
73705
+ } = useDroppableMeasuring(enabledDroppableContainers, {
73706
+ dragging: isInitialized,
73707
+ dependencies: [translate.x, translate.y],
73708
+ config: measuringConfiguration.droppable
73709
+ });
73710
+ const activeNode = useCachedNode(draggableNodes, activeId);
73711
+ const activationCoordinates = useMemo(() => activatorEvent ? getEventCoordinates(activatorEvent) : null, [activatorEvent]);
73712
+ const autoScrollOptions = getAutoScrollerOptions();
73713
+ const initialActiveNodeRect = useInitialRect(activeNode, measuringConfiguration.draggable.measure);
73714
+ useLayoutShiftScrollCompensation({
73715
+ activeNode: activeId != null ? draggableNodes.get(activeId) : null,
73716
+ config: autoScrollOptions.layoutShiftCompensation,
73717
+ initialRect: initialActiveNodeRect,
73718
+ measure: measuringConfiguration.draggable.measure
73719
+ });
73720
+ const activeNodeRect = useRect(activeNode, measuringConfiguration.draggable.measure, initialActiveNodeRect);
73721
+ const containerNodeRect = useRect(activeNode ? activeNode.parentElement : null);
73722
+ const sensorContext = useRef({
73723
+ activatorEvent: null,
73724
+ active: null,
73725
+ activeNode,
73726
+ collisionRect: null,
73727
+ collisions: null,
73728
+ droppableRects,
73729
+ draggableNodes,
73730
+ draggingNode: null,
73731
+ draggingNodeRect: null,
73732
+ droppableContainers,
73733
+ over: null,
73734
+ scrollableAncestors: [],
73735
+ scrollAdjustedTranslate: null
73736
+ });
73737
+ const overNode = droppableContainers.getNodeFor((_sensorContext$curren = sensorContext.current.over) == null ? void 0 : _sensorContext$curren.id);
73738
+ const dragOverlay = useDragOverlayMeasuring({
73739
+ measure: measuringConfiguration.dragOverlay.measure
73740
+ }); // Use the rect of the drag overlay if it is mounted
73741
+
73742
+ const draggingNode = (_dragOverlay$nodeRef$ = dragOverlay.nodeRef.current) != null ? _dragOverlay$nodeRef$ : activeNode;
73743
+ const draggingNodeRect = isInitialized ? (_dragOverlay$rect = dragOverlay.rect) != null ? _dragOverlay$rect : activeNodeRect : null;
73744
+ const usesDragOverlay = Boolean(dragOverlay.nodeRef.current && dragOverlay.rect); // The delta between the previous and new position of the draggable node
73745
+ // is only relevant when there is no drag overlay
73746
+
73747
+ const nodeRectDelta = useRectDelta(usesDragOverlay ? null : activeNodeRect); // Get the window rect of the dragging node
73748
+
73749
+ const windowRect = useWindowRect(draggingNode ? getWindow(draggingNode) : null); // Get scrollable ancestors of the dragging node
73750
+
73751
+ const scrollableAncestors = useScrollableAncestors(isInitialized ? overNode != null ? overNode : activeNode : null);
73752
+ const scrollableAncestorRects = useRects(scrollableAncestors); // Apply modifiers
73753
+
73754
+ const modifiedTranslate = applyModifiers(modifiers, {
73755
+ transform: {
73756
+ x: translate.x - nodeRectDelta.x,
73757
+ y: translate.y - nodeRectDelta.y,
73758
+ scaleX: 1,
73759
+ scaleY: 1
73760
+ },
73761
+ activatorEvent,
73762
+ active,
73763
+ activeNodeRect,
73764
+ containerNodeRect,
73765
+ draggingNodeRect,
73766
+ over: sensorContext.current.over,
73767
+ overlayNodeRect: dragOverlay.rect,
73768
+ scrollableAncestors,
73769
+ scrollableAncestorRects,
73770
+ windowRect
73771
+ });
73772
+ const pointerCoordinates = activationCoordinates ? add(activationCoordinates, translate) : null;
73773
+ const scrollOffsets = useScrollOffsets(scrollableAncestors); // Represents the scroll delta since dragging was initiated
73774
+
73775
+ const scrollAdjustment = useScrollOffsetsDelta(scrollOffsets); // Represents the scroll delta since the last time the active node rect was measured
73776
+
73777
+ const activeNodeScrollDelta = useScrollOffsetsDelta(scrollOffsets, [activeNodeRect]);
73778
+ const scrollAdjustedTranslate = add(modifiedTranslate, scrollAdjustment);
73779
+ const collisionRect = draggingNodeRect ? getAdjustedRect(draggingNodeRect, modifiedTranslate) : null;
73780
+ const collisions = active && collisionRect ? collisionDetection({
73781
+ active,
73782
+ collisionRect,
73783
+ droppableRects,
73784
+ droppableContainers: enabledDroppableContainers,
73785
+ pointerCoordinates
73786
+ }) : null;
73787
+ const overId = getFirstCollision(collisions, 'id');
73788
+ const [over, setOver] = useState(null); // When there is no drag overlay used, we need to account for the
73789
+ // window scroll delta
73790
+
73791
+ const appliedTranslate = usesDragOverlay ? modifiedTranslate : add(modifiedTranslate, activeNodeScrollDelta);
73792
+ const transform = adjustScale(appliedTranslate, (_over$rect = over == null ? void 0 : over.rect) != null ? _over$rect : null, activeNodeRect);
73793
+ const activeSensorRef = useRef(null);
73794
+ const instantiateSensor = useCallback((event, _ref2) => {
73795
+ let {
73796
+ sensor: Sensor,
73797
+ options
73798
+ } = _ref2;
73799
+
73800
+ if (activeRef.current == null) {
73801
+ return;
73802
+ }
73803
+
73804
+ const activeNode = draggableNodes.get(activeRef.current);
73805
+
73806
+ if (!activeNode) {
73807
+ return;
73808
+ }
73809
+
73810
+ const activatorEvent = event.nativeEvent;
73811
+ const sensorInstance = new Sensor({
73812
+ active: activeRef.current,
73813
+ activeNode,
73814
+ event: activatorEvent,
73815
+ options,
73816
+ // Sensors need to be instantiated with refs for arguments that change over time
73817
+ // otherwise they are frozen in time with the stale arguments
73818
+ context: sensorContext,
73819
+
73820
+ onAbort(id) {
73821
+ const draggableNode = draggableNodes.get(id);
73822
+
73823
+ if (!draggableNode) {
73824
+ return;
73825
+ }
73826
+
73827
+ const {
73828
+ onDragAbort
73829
+ } = latestProps.current;
73830
+ const event = {
73831
+ id
73832
+ };
73833
+ onDragAbort == null ? void 0 : onDragAbort(event);
73834
+ dispatchMonitorEvent({
73835
+ type: 'onDragAbort',
73836
+ event
73837
+ });
73838
+ },
73839
+
73840
+ onPending(id, constraint, initialCoordinates, offset) {
73841
+ const draggableNode = draggableNodes.get(id);
73842
+
73843
+ if (!draggableNode) {
73844
+ return;
73845
+ }
73846
+
73847
+ const {
73848
+ onDragPending
73849
+ } = latestProps.current;
73850
+ const event = {
73851
+ id,
73852
+ constraint,
73853
+ initialCoordinates,
73854
+ offset
73855
+ };
73856
+ onDragPending == null ? void 0 : onDragPending(event);
73857
+ dispatchMonitorEvent({
73858
+ type: 'onDragPending',
73859
+ event
73860
+ });
73861
+ },
73862
+
73863
+ onStart(initialCoordinates) {
73864
+ const id = activeRef.current;
73865
+
73866
+ if (id == null) {
73867
+ return;
73868
+ }
73869
+
73870
+ const draggableNode = draggableNodes.get(id);
73871
+
73872
+ if (!draggableNode) {
73873
+ return;
73874
+ }
73875
+
73876
+ const {
73877
+ onDragStart
73878
+ } = latestProps.current;
73879
+ const event = {
73880
+ activatorEvent,
73881
+ active: {
73882
+ id,
73883
+ data: draggableNode.data,
73884
+ rect: activeRects
73885
+ }
73886
+ };
73887
+ unstable_batchedUpdates(() => {
73888
+ onDragStart == null ? void 0 : onDragStart(event);
73889
+ setStatus(Status.Initializing);
73890
+ dispatch({
73891
+ type: Action.DragStart,
73892
+ initialCoordinates,
73893
+ active: id
73894
+ });
73895
+ dispatchMonitorEvent({
73896
+ type: 'onDragStart',
73897
+ event
73898
+ });
73899
+ setActiveSensor(activeSensorRef.current);
73900
+ setActivatorEvent(activatorEvent);
73901
+ });
73902
+ },
73903
+
73904
+ onMove(coordinates) {
73905
+ dispatch({
73906
+ type: Action.DragMove,
73907
+ coordinates
73908
+ });
73909
+ },
73910
+
73911
+ onEnd: createHandler(Action.DragEnd),
73912
+ onCancel: createHandler(Action.DragCancel)
73913
+ });
73914
+ activeSensorRef.current = sensorInstance;
73915
+
73916
+ function createHandler(type) {
73917
+ return async function handler() {
73918
+ const {
73919
+ active,
73920
+ collisions,
73921
+ over,
73922
+ scrollAdjustedTranslate
73923
+ } = sensorContext.current;
73924
+ let event = null;
73925
+
73926
+ if (active && scrollAdjustedTranslate) {
73927
+ const {
73928
+ cancelDrop
73929
+ } = latestProps.current;
73930
+ event = {
73931
+ activatorEvent,
73932
+ active: active,
73933
+ collisions,
73934
+ delta: scrollAdjustedTranslate,
73935
+ over
73936
+ };
73937
+
73938
+ if (type === Action.DragEnd && typeof cancelDrop === 'function') {
73939
+ const shouldCancel = await Promise.resolve(cancelDrop(event));
73940
+
73941
+ if (shouldCancel) {
73942
+ type = Action.DragCancel;
73943
+ }
73944
+ }
73945
+ }
73946
+
73947
+ activeRef.current = null;
73948
+ unstable_batchedUpdates(() => {
73949
+ dispatch({
73950
+ type
73951
+ });
73952
+ setStatus(Status.Uninitialized);
73953
+ setOver(null);
73954
+ setActiveSensor(null);
73955
+ setActivatorEvent(null);
73956
+ activeSensorRef.current = null;
73957
+ const eventName = type === Action.DragEnd ? 'onDragEnd' : 'onDragCancel';
73958
+
73959
+ if (event) {
73960
+ const handler = latestProps.current[eventName];
73961
+ handler == null ? void 0 : handler(event);
73962
+ dispatchMonitorEvent({
73963
+ type: eventName,
73964
+ event
73965
+ });
73966
+ }
73967
+ });
73968
+ };
73969
+ }
73970
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
73971
+ [draggableNodes]);
73972
+ const bindActivatorToSensorInstantiator = useCallback((handler, sensor) => {
73973
+ return (event, active) => {
73974
+ const nativeEvent = event.nativeEvent;
73975
+ const activeDraggableNode = draggableNodes.get(active);
73976
+
73977
+ if ( // Another sensor is already instantiating
73978
+ activeRef.current !== null || // No active draggable
73979
+ !activeDraggableNode || // Event has already been captured
73980
+ nativeEvent.dndKit || nativeEvent.defaultPrevented) {
73981
+ return;
73982
+ }
73983
+
73984
+ const activationContext = {
73985
+ active: activeDraggableNode
73986
+ };
73987
+ const shouldActivate = handler(event, sensor.options, activationContext);
73988
+
73989
+ if (shouldActivate === true) {
73990
+ nativeEvent.dndKit = {
73991
+ capturedBy: sensor.sensor
73992
+ };
73993
+ activeRef.current = active;
73994
+ instantiateSensor(event, sensor);
73995
+ }
73996
+ };
73997
+ }, [draggableNodes, instantiateSensor]);
73998
+ const activators = useCombineActivators(sensors, bindActivatorToSensorInstantiator);
73999
+ useSensorSetup(sensors);
74000
+ useIsomorphicLayoutEffect(() => {
74001
+ if (activeNodeRect && status === Status.Initializing) {
74002
+ setStatus(Status.Initialized);
74003
+ }
74004
+ }, [activeNodeRect, status]);
74005
+ useEffect(() => {
74006
+ const {
74007
+ onDragMove
74008
+ } = latestProps.current;
74009
+ const {
74010
+ active,
74011
+ activatorEvent,
74012
+ collisions,
74013
+ over
74014
+ } = sensorContext.current;
74015
+
74016
+ if (!active || !activatorEvent) {
74017
+ return;
74018
+ }
74019
+
74020
+ const event = {
74021
+ active,
74022
+ activatorEvent,
74023
+ collisions,
74024
+ delta: {
74025
+ x: scrollAdjustedTranslate.x,
74026
+ y: scrollAdjustedTranslate.y
74027
+ },
74028
+ over
74029
+ };
74030
+ unstable_batchedUpdates(() => {
74031
+ onDragMove == null ? void 0 : onDragMove(event);
74032
+ dispatchMonitorEvent({
74033
+ type: 'onDragMove',
74034
+ event
74035
+ });
74036
+ });
74037
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
74038
+ [scrollAdjustedTranslate.x, scrollAdjustedTranslate.y]);
74039
+ useEffect(() => {
74040
+ const {
74041
+ active,
74042
+ activatorEvent,
74043
+ collisions,
74044
+ droppableContainers,
74045
+ scrollAdjustedTranslate
74046
+ } = sensorContext.current;
74047
+
74048
+ if (!active || activeRef.current == null || !activatorEvent || !scrollAdjustedTranslate) {
74049
+ return;
74050
+ }
74051
+
74052
+ const {
74053
+ onDragOver
74054
+ } = latestProps.current;
74055
+ const overContainer = droppableContainers.get(overId);
74056
+ const over = overContainer && overContainer.rect.current ? {
74057
+ id: overContainer.id,
74058
+ rect: overContainer.rect.current,
74059
+ data: overContainer.data,
74060
+ disabled: overContainer.disabled
74061
+ } : null;
74062
+ const event = {
74063
+ active,
74064
+ activatorEvent,
74065
+ collisions,
74066
+ delta: {
74067
+ x: scrollAdjustedTranslate.x,
74068
+ y: scrollAdjustedTranslate.y
74069
+ },
74070
+ over
74071
+ };
74072
+ unstable_batchedUpdates(() => {
74073
+ setOver(over);
74074
+ onDragOver == null ? void 0 : onDragOver(event);
74075
+ dispatchMonitorEvent({
74076
+ type: 'onDragOver',
74077
+ event
74078
+ });
74079
+ });
74080
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
74081
+ [overId]);
74082
+ useIsomorphicLayoutEffect(() => {
74083
+ sensorContext.current = {
74084
+ activatorEvent,
74085
+ active,
74086
+ activeNode,
74087
+ collisionRect,
74088
+ collisions,
74089
+ droppableRects,
74090
+ draggableNodes,
74091
+ draggingNode,
74092
+ draggingNodeRect,
74093
+ droppableContainers,
74094
+ over,
74095
+ scrollableAncestors,
74096
+ scrollAdjustedTranslate
74097
+ };
74098
+ activeRects.current = {
74099
+ initial: draggingNodeRect,
74100
+ translated: collisionRect
74101
+ };
74102
+ }, [active, activeNode, collisions, collisionRect, draggableNodes, draggingNode, draggingNodeRect, droppableRects, droppableContainers, over, scrollableAncestors, scrollAdjustedTranslate]);
74103
+ useAutoScroller({ ...autoScrollOptions,
74104
+ delta: translate,
74105
+ draggingRect: collisionRect,
74106
+ pointerCoordinates,
74107
+ scrollableAncestors,
74108
+ scrollableAncestorRects
74109
+ });
74110
+ const publicContext = useMemo(() => {
74111
+ const context = {
74112
+ active,
74113
+ activeNode,
74114
+ activeNodeRect,
74115
+ activatorEvent,
74116
+ collisions,
74117
+ containerNodeRect,
74118
+ dragOverlay,
74119
+ draggableNodes,
74120
+ droppableContainers,
74121
+ droppableRects,
74122
+ over,
74123
+ measureDroppableContainers,
74124
+ scrollableAncestors,
74125
+ scrollableAncestorRects,
74126
+ measuringConfiguration,
74127
+ measuringScheduled,
74128
+ windowRect
74129
+ };
74130
+ return context;
74131
+ }, [active, activeNode, activeNodeRect, activatorEvent, collisions, containerNodeRect, dragOverlay, draggableNodes, droppableContainers, droppableRects, over, measureDroppableContainers, scrollableAncestors, scrollableAncestorRects, measuringConfiguration, measuringScheduled, windowRect]);
74132
+ const internalContext = useMemo(() => {
74133
+ const context = {
74134
+ activatorEvent,
74135
+ activators,
74136
+ active,
74137
+ activeNodeRect,
74138
+ ariaDescribedById: {
74139
+ draggable: draggableDescribedById
74140
+ },
74141
+ dispatch,
74142
+ draggableNodes,
74143
+ over,
74144
+ measureDroppableContainers
74145
+ };
74146
+ return context;
74147
+ }, [activatorEvent, activators, active, activeNodeRect, dispatch, draggableDescribedById, draggableNodes, over, measureDroppableContainers]);
74148
+ return React__default.createElement(DndMonitorContext.Provider, {
74149
+ value: registerMonitorListener
74150
+ }, React__default.createElement(InternalContext.Provider, {
74151
+ value: internalContext
74152
+ }, React__default.createElement(PublicContext.Provider, {
74153
+ value: publicContext
74154
+ }, React__default.createElement(ActiveDraggableContext.Provider, {
74155
+ value: transform
74156
+ }, children)), React__default.createElement(RestoreFocus, {
74157
+ disabled: (accessibility == null ? void 0 : accessibility.restoreFocus) === false
74158
+ })), React__default.createElement(Accessibility, { ...accessibility,
74159
+ hiddenTextDescribedById: draggableDescribedById
74160
+ }));
74161
+
74162
+ function getAutoScrollerOptions() {
74163
+ const activeSensorDisablesAutoscroll = (activeSensor == null ? void 0 : activeSensor.autoScrollEnabled) === false;
74164
+ const autoScrollGloballyDisabled = typeof autoScroll === 'object' ? autoScroll.enabled === false : autoScroll === false;
74165
+ const enabled = isInitialized && !activeSensorDisablesAutoscroll && !autoScrollGloballyDisabled;
74166
+
74167
+ if (typeof autoScroll === 'object') {
74168
+ return { ...autoScroll,
74169
+ enabled
74170
+ };
74171
+ }
74172
+
74173
+ return {
74174
+ enabled
74175
+ };
74176
+ }
74177
+ });
74178
+
74179
+ const NullContext = /*#__PURE__*/createContext(null);
74180
+ const defaultRole = 'button';
74181
+ const ID_PREFIX = 'Draggable';
74182
+ function useDraggable(_ref) {
74183
+ let {
74184
+ id,
74185
+ data,
74186
+ disabled = false,
74187
+ attributes
74188
+ } = _ref;
74189
+ const key = useUniqueId(ID_PREFIX);
74190
+ const {
74191
+ activators,
74192
+ activatorEvent,
74193
+ active,
74194
+ activeNodeRect,
74195
+ ariaDescribedById,
74196
+ draggableNodes,
74197
+ over
74198
+ } = useContext(InternalContext);
74199
+ const {
74200
+ role = defaultRole,
74201
+ roleDescription = 'draggable',
74202
+ tabIndex = 0
74203
+ } = attributes != null ? attributes : {};
74204
+ const isDragging = (active == null ? void 0 : active.id) === id;
74205
+ const transform = useContext(isDragging ? ActiveDraggableContext : NullContext);
74206
+ const [node, setNodeRef] = useNodeRef();
74207
+ const [activatorNode, setActivatorNodeRef] = useNodeRef();
74208
+ const listeners = useSyntheticListeners(activators, id);
74209
+ const dataRef = useLatestValue(data);
74210
+ useIsomorphicLayoutEffect(() => {
74211
+ draggableNodes.set(id, {
74212
+ id,
74213
+ key,
74214
+ node,
74215
+ activatorNode,
74216
+ data: dataRef
74217
+ });
74218
+ return () => {
74219
+ const node = draggableNodes.get(id);
74220
+
74221
+ if (node && node.key === key) {
74222
+ draggableNodes.delete(id);
74223
+ }
74224
+ };
74225
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
74226
+ [draggableNodes, id]);
74227
+ const memoizedAttributes = useMemo(() => ({
74228
+ role,
74229
+ tabIndex,
74230
+ 'aria-disabled': disabled,
74231
+ 'aria-pressed': isDragging && role === defaultRole ? true : undefined,
74232
+ 'aria-roledescription': roleDescription,
74233
+ 'aria-describedby': ariaDescribedById.draggable
74234
+ }), [disabled, role, tabIndex, isDragging, roleDescription, ariaDescribedById.draggable]);
74235
+ return {
74236
+ active,
74237
+ activatorEvent,
74238
+ activeNodeRect,
74239
+ attributes: memoizedAttributes,
74240
+ isDragging,
74241
+ listeners: disabled ? undefined : listeners,
74242
+ node,
74243
+ over,
74244
+ setNodeRef,
74245
+ setActivatorNodeRef,
74246
+ transform
74247
+ };
74248
+ }
74249
+
74250
+ const ID_PREFIX$1 = 'Droppable';
74251
+ const defaultResizeObserverConfig = {
74252
+ timeout: 25
74253
+ };
74254
+ function useDroppable(_ref) {
74255
+ let {
74256
+ data,
74257
+ disabled = false,
74258
+ id,
74259
+ resizeObserverConfig
74260
+ } = _ref;
74261
+ const key = useUniqueId(ID_PREFIX$1);
74262
+ const {
74263
+ active,
74264
+ dispatch,
74265
+ over,
74266
+ measureDroppableContainers
74267
+ } = useContext(InternalContext);
74268
+ const previous = useRef({
74269
+ disabled
74270
+ });
74271
+ const resizeObserverConnected = useRef(false);
74272
+ const rect = useRef(null);
74273
+ const callbackId = useRef(null);
74274
+ const {
74275
+ disabled: resizeObserverDisabled,
74276
+ updateMeasurementsFor,
74277
+ timeout: resizeObserverTimeout
74278
+ } = { ...defaultResizeObserverConfig,
74279
+ ...resizeObserverConfig
74280
+ };
74281
+ const ids = useLatestValue(updateMeasurementsFor != null ? updateMeasurementsFor : id);
74282
+ const handleResize = useCallback(() => {
74283
+ if (!resizeObserverConnected.current) {
74284
+ // ResizeObserver invokes the `handleResize` callback as soon as `observe` is called,
74285
+ // assuming the element is rendered and displayed.
74286
+ resizeObserverConnected.current = true;
74287
+ return;
74288
+ }
74289
+
74290
+ if (callbackId.current != null) {
74291
+ clearTimeout(callbackId.current);
74292
+ }
74293
+
74294
+ callbackId.current = setTimeout(() => {
74295
+ measureDroppableContainers(Array.isArray(ids.current) ? ids.current : [ids.current]);
74296
+ callbackId.current = null;
74297
+ }, resizeObserverTimeout);
74298
+ }, //eslint-disable-next-line react-hooks/exhaustive-deps
74299
+ [resizeObserverTimeout]);
74300
+ const resizeObserver = useResizeObserver({
74301
+ callback: handleResize,
74302
+ disabled: resizeObserverDisabled || !active
74303
+ });
74304
+ const handleNodeChange = useCallback((newElement, previousElement) => {
74305
+ if (!resizeObserver) {
74306
+ return;
74307
+ }
74308
+
74309
+ if (previousElement) {
74310
+ resizeObserver.unobserve(previousElement);
74311
+ resizeObserverConnected.current = false;
74312
+ }
74313
+
74314
+ if (newElement) {
74315
+ resizeObserver.observe(newElement);
74316
+ }
74317
+ }, [resizeObserver]);
74318
+ const [nodeRef, setNodeRef] = useNodeRef(handleNodeChange);
74319
+ const dataRef = useLatestValue(data);
74320
+ useEffect(() => {
74321
+ if (!resizeObserver || !nodeRef.current) {
74322
+ return;
74323
+ }
74324
+
74325
+ resizeObserver.disconnect();
74326
+ resizeObserverConnected.current = false;
74327
+ resizeObserver.observe(nodeRef.current);
74328
+ }, [nodeRef, resizeObserver]);
74329
+ useEffect(() => {
74330
+ dispatch({
74331
+ type: Action.RegisterDroppable,
74332
+ element: {
74333
+ id,
74334
+ key,
74335
+ disabled,
74336
+ node: nodeRef,
74337
+ rect,
74338
+ data: dataRef
74339
+ }
74340
+ });
74341
+ return () => dispatch({
74342
+ type: Action.UnregisterDroppable,
74343
+ key,
74344
+ id
74345
+ });
74346
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
74347
+ [id]);
74348
+ useEffect(() => {
74349
+ if (disabled !== previous.current.disabled) {
74350
+ dispatch({
74351
+ type: Action.SetDroppableDisabled,
74352
+ id,
74353
+ key,
74354
+ disabled
74355
+ });
74356
+ previous.current.disabled = disabled;
74357
+ }
74358
+ }, [id, key, disabled, dispatch]);
74359
+ return {
74360
+ active,
74361
+ rect,
74362
+ isOver: (over == null ? void 0 : over.id) === id,
74363
+ node: nodeRef,
74364
+ over,
74365
+ setNodeRef
74366
+ };
74367
+ }
74368
+
74369
+ function restrictToBoundingRect(transform, rect, boundingRect) {
74370
+ const value = { ...transform
74371
+ };
74372
+
74373
+ if (rect.top + transform.y <= boundingRect.top) {
74374
+ value.y = boundingRect.top - rect.top;
74375
+ } else if (rect.bottom + transform.y >= boundingRect.top + boundingRect.height) {
74376
+ value.y = boundingRect.top + boundingRect.height - rect.bottom;
74377
+ }
74378
+
74379
+ if (rect.left + transform.x <= boundingRect.left) {
74380
+ value.x = boundingRect.left - rect.left;
74381
+ } else if (rect.right + transform.x >= boundingRect.left + boundingRect.width) {
74382
+ value.x = boundingRect.left + boundingRect.width - rect.right;
74383
+ }
74384
+
74385
+ return value;
74386
+ }
74387
+
74388
+ const restrictToFirstScrollableAncestor = _ref => {
74389
+ let {
74390
+ draggingNodeRect,
74391
+ transform,
74392
+ scrollableAncestorRects
74393
+ } = _ref;
74394
+ const firstScrollableAncestorRect = scrollableAncestorRects[0];
74395
+
74396
+ if (!draggingNodeRect || !firstScrollableAncestorRect) {
74397
+ return transform;
74398
+ }
74399
+
74400
+ return restrictToBoundingRect(transform, draggingNodeRect, firstScrollableAncestorRect);
74401
+ };
74402
+
74403
+ function DragHandle({ listeners = {}, attributes = {} }) {
74404
+ return /* @__PURE__ */ jsx(
74405
+ "button",
74406
+ {
74407
+ className: "tv-drag",
74408
+ title: "Drag to move",
74409
+ ...listeners,
74410
+ ...attributes,
74411
+ onMouseDown: (e) => e.stopPropagation(),
74412
+ onClick: (e) => e.stopPropagation(),
74413
+ children: /* @__PURE__ */ jsx(GripVertical, { size: 14 })
74414
+ }
74415
+ );
74416
+ }
74417
+
74418
+ function TreeNode({
74419
+ node,
74420
+ depth,
74421
+ expanded,
74422
+ onToggle,
74423
+ onSelect,
74424
+ onCreateChild,
74425
+ onRename,
74426
+ onDelete,
74427
+ renderActions,
74428
+ // optional override
74429
+ dragId,
74430
+ dropId,
74431
+ indent = 24
74432
+ }) {
74433
+ const { setNodeRef: setDropRef, isOver } = useDroppable({ id: dropId });
74434
+ const { attributes, listeners, setNodeRef: setDragRef, transform, isDragging } = useDraggable({ id: dragId });
74435
+ const style = transform ? { transform: `translate3d(${Math.round(transform.x)}px, ${Math.round(transform.y)}px, 0)` } : void 0;
74436
+ const [editing, setEditing] = useState(false);
74437
+ const [value, setValue] = useState(node.name);
74438
+ const commitRename = () => {
74439
+ const next = value.trim();
74440
+ setEditing(false);
74441
+ if (next && next !== node.name) onRename?.(node, next);
74442
+ else setValue(node.name);
74443
+ };
74444
+ const defaultMenu = useMemo(() => {
74445
+ const options = [
74446
+ { action: "create", label: "Create sub-folder" },
74447
+ { action: "rename", label: "Rename" },
74448
+ { action: "delete", label: "Delete" }
74449
+ ];
74450
+ return /* @__PURE__ */ jsx(
74451
+ OptionsMenu,
74452
+ {
74453
+ options,
74454
+ onSelect: (opt) => {
74455
+ if (opt.action === "create") onCreateChild?.(node);
74456
+ else if (opt.action === "rename") setEditing(true);
74457
+ else if (opt.action === "delete") onDelete?.(node);
74458
+ }
74459
+ }
74460
+ );
74461
+ }, [node, onCreateChild, onDelete]);
74462
+ return /* @__PURE__ */ jsxs(
74463
+ "div",
74464
+ {
74465
+ ref: setDropRef,
74466
+ className: `tv-row ${isOver ? "tv-drop-over" : ""} ${isDragging ? "dragging" : ""}`,
74467
+ style: { ...style, paddingLeft: 8 + depth * indent },
74468
+ onClick: (e) => {
74469
+ if (e.target.closest(".tv-toggle") || e.target.tagName === "INPUT") return;
74470
+ onSelect?.(node);
74471
+ },
74472
+ children: [
74473
+ /* @__PURE__ */ jsx("button", { className: "tv-toggle", onClick: onToggle, "aria-label": "toggle", children: node.children?.length ? expanded ? /* @__PURE__ */ jsx(ChevronDown, { size: 16 }) : /* @__PURE__ */ jsx(ChevronRight, { size: 16 }) : /* @__PURE__ */ jsx("span", { className: "tv-spacer" }) }),
74474
+ /* @__PURE__ */ jsx(Folder, { size: 16, className: "tv-folder-ic" }),
74475
+ /* @__PURE__ */ jsx("div", { className: "tv-name", ref: setDragRef, children: editing ? /* @__PURE__ */ jsx(
74476
+ "input",
74477
+ {
74478
+ className: "tv-input",
74479
+ value,
74480
+ onChange: (e) => setValue(e.target.value),
74481
+ onBlur: commitRename,
74482
+ onKeyDown: (e) => {
74483
+ if (e.key === "Enter") commitRename();
74484
+ if (e.key === "Escape") {
74485
+ setEditing(false);
74486
+ setValue(node.name);
74487
+ }
74488
+ },
74489
+ autoFocus: true
74490
+ }
74491
+ ) : /* @__PURE__ */ jsx("span", { onDoubleClick: () => setEditing(true), children: node.name }) }),
74492
+ /* @__PURE__ */ jsx(DragHandle, { listeners, attributes }),
74493
+ /* @__PURE__ */ jsx("div", { className: "tv-actions", children: renderActions ? renderActions(node, {
74494
+ onCreateChild: () => onCreateChild?.(node),
74495
+ onRename: () => setEditing(true),
74496
+ onDelete: () => onDelete?.(node)
74497
+ }) : defaultMenu })
74498
+ ]
74499
+ }
74500
+ );
74501
+ }
74502
+
74503
+ const getIdDefault = (n) => String(n.id ?? n._id);
74504
+ const getParentDefault = (n) => n.parent !== void 0 ? String(n.parent) : n.parentId != null ? String(n.parentId) : "root";
74505
+ const getNameDefault = (n) => n.name ?? n.label ?? "";
74506
+ const isNestedShape = (data) => Array.isArray(data) && data.some((n) => Array.isArray(n.children));
74507
+ function flatToTree(flat, { rootId, getId, getParent, getName }) {
74508
+ const byId = /* @__PURE__ */ new Map();
74509
+ flat.forEach((raw) => {
74510
+ const id = getId(raw);
74511
+ byId.set(id, {
74512
+ ...raw,
74513
+ id,
74514
+ name: getName(raw),
74515
+ parentId: getParent(raw) || rootId,
74516
+ children: []
74517
+ });
74518
+ });
74519
+ const roots = [];
74520
+ byId.forEach((node) => {
74521
+ const pid = node.parentId || rootId;
74522
+ if (pid !== rootId && byId.has(pid)) {
74523
+ byId.get(pid).children.push(node);
74524
+ } else {
74525
+ roots.push(node);
74526
+ }
74527
+ });
74528
+ return { roots, byId };
74529
+ }
74530
+ function nestedNormalize(nested, { rootId, getId, getName }) {
74531
+ const byId = /* @__PURE__ */ new Map();
74532
+ function walk(n, parentId) {
74533
+ const id = getId(n);
74534
+ const node = {
74535
+ ...n,
74536
+ id,
74537
+ name: getName(n),
74538
+ parentId: parentId || rootId,
74539
+ children: (n.children || []).map((c) => walk(c, id))
74540
+ };
74541
+ byId.set(id, node);
74542
+ return node;
74543
+ }
74544
+ const roots = nested.map((n) => walk(n, null));
74545
+ return { roots, byId };
74546
+ }
74547
+ const cloneRoots = (roots) => roots.map((r) => ({ ...r, children: cloneRoots(r.children || []) }));
74548
+ function removeNode(roots, nodeId) {
74549
+ let removed = null;
74550
+ function recur(list) {
74551
+ return list.map((n) => {
74552
+ if (n.id === nodeId) {
74553
+ removed = n;
74554
+ return null;
74555
+ }
74556
+ if (n.children?.length) {
74557
+ const kids = recur(n.children);
74558
+ if (kids !== n.children) return { ...n, children: kids };
74559
+ }
74560
+ return n;
74561
+ }).filter(Boolean);
74562
+ }
74563
+ const newRoots = recur(roots);
74564
+ return { newRoots, removed };
74565
+ }
74566
+ function insertAsChild(roots, parentId, node) {
74567
+ function recur(list) {
74568
+ return list.map((n) => {
74569
+ if (n.id === parentId) {
74570
+ return { ...n, children: [...n.children || [], { ...node, parentId }] };
74571
+ }
74572
+ if (n.children?.length) {
74573
+ const kids = recur(n.children);
74574
+ if (kids !== n.children) return { ...n, children: kids };
74575
+ }
74576
+ return n;
74577
+ });
74578
+ }
74579
+ return recur(roots);
74580
+ }
74581
+ function findNodeAndParent(roots, id, parent = null) {
74582
+ for (const n of roots) {
74583
+ if (n.id === id) return { node: n, parentId: parent };
74584
+ if (n.children?.length) {
74585
+ const res = findNodeAndParent(n.children, id, n.id);
74586
+ if (res) return res;
74587
+ }
74588
+ }
74589
+ return null;
74590
+ }
74591
+ function TreeView({
74592
+ data = [],
74593
+ rootId = "root",
74594
+ title = "Folders",
74595
+ getId = getIdDefault,
74596
+ getParent = getParentDefault,
74597
+ getName = getNameDefault,
74598
+ onSelect,
74599
+ onCreateRoot,
74600
+ onCreateChild,
74601
+ onRename,
74602
+ onDelete,
74603
+ onMove,
74604
+ renderActions,
74605
+ disableMoveToRoot = false,
74606
+ // ← allow root moves by default now
74607
+ indentUnit = 24
74608
+ }) {
74609
+ const { roots } = useMemo(() => {
74610
+ if (isNestedShape(data)) {
74611
+ return nestedNormalize(data, { rootId, getId, getName });
74612
+ }
74613
+ return flatToTree(
74614
+ data.map((d) => ({ ...d })),
74615
+ { rootId, getId, getParent, getName }
74616
+ );
74617
+ }, [data, rootId, getId, getParent, getName]);
74618
+ const [expanded, setExpanded] = useState({});
74619
+ const expandAll = useCallback((nodes) => {
74620
+ const m = {};
74621
+ (function walk(list) {
74622
+ list.forEach((n) => {
74623
+ m[n.id] = true;
74624
+ if (n.children?.length) walk(n.children);
74625
+ });
74626
+ })(nodes);
74627
+ return m;
74628
+ }, []);
74629
+ React__default.useEffect(() => {
74630
+ setExpanded(expandAll(roots));
74631
+ }, [roots, expandAll]);
74632
+ const toggle = useCallback(
74633
+ (id) => setExpanded((m) => ({ ...m, [id]: !m[id] })),
74634
+ []
74635
+ );
74636
+ const [tree, setTree] = useState(() => cloneRoots(roots));
74637
+ React__default.useEffect(() => setTree(cloneRoots(roots)), [roots]);
74638
+ const sensors = useSensors(
74639
+ useSensor(PointerSensor, { activationConstraint: { delay: 250, tolerance: 5 } })
74640
+ );
74641
+ const listRef = useRef(null);
74642
+ const [activeId, setActiveId] = useState(null);
74643
+ const dragDeltaXRef = useRef(0);
74644
+ const handleDragStart = () => {
74645
+ };
74646
+ const handleDragMove = ({ delta }) => {
74647
+ dragDeltaXRef.current = delta?.x ?? 0;
74648
+ };
74649
+ const handleDragEnd = useCallback(
74650
+ ({ active, over }) => {
74651
+ const dx = dragDeltaXRef.current;
74652
+ dragDeltaXRef.current = 0;
74653
+ setActiveId(null);
74654
+ if (!active || !over) return;
74655
+ const sourceId = String(active.id).replace(/^drag-/, "");
74656
+ const overId = String(over.id).replace(/^drop-/, "");
74657
+ if (!sourceId || !overId || sourceId === overId) return;
74658
+ let destParentId = overId;
74659
+ const levelsUp = Math.max(0, Math.floor(-dx / indentUnit));
74660
+ if (levelsUp > 0) {
74661
+ let current2 = overId;
74662
+ for (let i = 0; i < levelsUp; i++) {
74663
+ const res = findNodeAndParent(tree, current2, null);
74664
+ if (!res) break;
74665
+ if (!res.parentId) {
74666
+ destParentId = rootId;
74667
+ break;
74668
+ }
74669
+ destParentId = res.parentId;
74670
+ current2 = res.parentId;
74671
+ }
74672
+ }
74673
+ if (disableMoveToRoot && destParentId === rootId) {
74674
+ setTree(cloneRoots(roots));
74675
+ return;
74676
+ }
74677
+ const current = cloneRoots(tree);
74678
+ const { newRoots, removed } = removeNode(current, sourceId);
74679
+ if (!removed) return;
74680
+ const next = insertAsChild(newRoots, destParentId, removed);
74681
+ setTree(next);
74682
+ onMove?.({ sourceId, destParentId, newTree: next });
74683
+ },
74684
+ [tree, roots, rootId, disableMoveToRoot, indentUnit, onMove]
74685
+ );
74686
+ const renderNodes = useCallback(
74687
+ (nodes, depth = 0) => nodes.map((node) => /* @__PURE__ */ jsxs(React__default.Fragment, { children: [
74688
+ /* @__PURE__ */ jsx(
74689
+ TreeNode,
74690
+ {
74691
+ node,
74692
+ depth,
74693
+ expanded: !!expanded[node.id],
74694
+ onToggle: () => toggle(node.id),
74695
+ onSelect,
74696
+ onCreateChild,
74697
+ onRename,
74698
+ onDelete,
74699
+ renderActions,
74700
+ dragId: `drag-${node.id}`,
74701
+ dropId: `drop-${node.id}`,
74702
+ indent: indentUnit
74703
+ }
74704
+ ),
74705
+ expanded[node.id] && node.children?.length > 0 ? renderNodes(node.children, depth + 1) : null
74706
+ ] }, node.id)),
74707
+ [expanded, indentUnit, onCreateChild, onDelete, onRename, onSelect, renderActions, toggle]
74708
+ );
74709
+ React__default.useMemo(() => {
74710
+ if (!activeId) return null;
74711
+ const id = String(activeId).replace(/^drag-/, "");
74712
+ function find(list) {
74713
+ for (const n of list) {
74714
+ if (n.id === id) return n;
74715
+ const c = n.children?.length ? find(n.children) : null;
74716
+ if (c) return c;
74717
+ }
74718
+ return null;
74719
+ }
74720
+ return find(tree);
74721
+ }, [activeId, tree]);
74722
+ return /* @__PURE__ */ jsxs("div", { className: "tv", children: [
74723
+ title !== false && /* @__PURE__ */ jsxs("div", { className: "tv-header", children: [
74724
+ /* @__PURE__ */ jsx("div", { className: "tv-title", children: title }),
74725
+ /* @__PURE__ */ jsx("button", { className: "tv-btn", onClick: onCreateRoot, children: "+ New folder" })
74726
+ ] }),
74727
+ /* @__PURE__ */ jsxs("div", { className: "tv-root-row", children: [
74728
+ /* @__PURE__ */ jsx(Folder, { size: 16, className: "tv-folder-ic" }),
74729
+ /* @__PURE__ */ jsx("strong", { children: "ROOT" }),
74730
+ /* @__PURE__ */ jsx("button", { className: "tv-icon", title: "Create top-level", onClick: onCreateRoot, children: "+" })
74731
+ ] }),
74732
+ /* @__PURE__ */ jsx(
74733
+ DndContext,
74734
+ {
74735
+ collisionDetection: pointerWithin,
74736
+ sensors,
74737
+ onDragStart: handleDragStart,
74738
+ onDragMove: handleDragMove,
74739
+ onDragEnd: handleDragEnd,
74740
+ modifiers: [restrictToFirstScrollableAncestor],
74741
+ children: /* @__PURE__ */ jsx("div", { ref: listRef, className: "tv-list", children: renderNodes(tree, 0) })
74742
+ }
74743
+ )
74744
+ ] });
74745
+ }
74746
+
74747
+ export { AddUserGroupsRolesModal, Avatar, AvatarGroup, Badge, Breadcrumbs, Button$1 as Button, Checkbox, DatePicker, DateRangePicker$1 as DateRangePicker, FileUploadModal, FullScreenLoader, GenericFilter, Input, Modal, MultiSelect, OptionsMenu, PageHeader, PageLayout, Pagination, RadioGroup, SearchBar, Select, Sidebar, Spinner, Textarea, ToggleSwitch, Tooltip, TreeView, UnifyedCoreButton, WizardModal, adGroupsListSearchApi, axiosDelete, axiosGet, axiosPatch, axiosPost, axiosPut, cookies$1 as cookies, createHttpClient, directoryPermissionsApi, filePermissionsApi, gateWayUrl, gatewayBase, getBaseUrl, getSnapshot, http, localStore, myDriveGatewayBaseV2, provisioningBase, rbacBase, searchRolesApi, sessionStore, userSearchBase };
70548
74748
  //# sourceMappingURL=unifyedx-storybook-new.es.js.map