@ballistix.digital/react-components 2.2.0 → 2.3.0

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.
package/dist/index.js CHANGED
@@ -12,6 +12,7 @@ var proRegularSvgIcons = require('@fortawesome/pro-regular-svg-icons');
12
12
  var proSolidSvgIcons = require('@fortawesome/pro-solid-svg-icons');
13
13
  var proThinSvgIcons = require('@fortawesome/pro-thin-svg-icons');
14
14
  var reactFontawesome = require('@fortawesome/react-fontawesome');
15
+ var ReactDOM = require('react-dom');
15
16
  var react = require('@headlessui/react');
16
17
  var mask = require('@react-input/mask');
17
18
  var outline$2 = require('@heroicons/react/24/outline');
@@ -21,6 +22,26 @@ var set = require('lodash/set');
21
22
  var Datepicker = require('react-tailwindcss-datepicker');
22
23
  var formik = require('formik');
23
24
 
25
+ function _interopNamespaceDefault(e) {
26
+ var n = Object.create(null);
27
+ if (e) {
28
+ Object.keys(e).forEach(function (k) {
29
+ if (k !== 'default') {
30
+ var d = Object.getOwnPropertyDescriptor(e, k);
31
+ Object.defineProperty(n, k, d.get ? d : {
32
+ enumerable: true,
33
+ get: function () { return e[k]; }
34
+ });
35
+ }
36
+ });
37
+ }
38
+ n.default = e;
39
+ return Object.freeze(n);
40
+ }
41
+
42
+ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
43
+ var ReactDOM__namespace = /*#__PURE__*/_interopNamespaceDefault(ReactDOM);
44
+
24
45
  /******************************************************************************
25
46
  Copyright (c) Microsoft Corporation.
26
47
 
@@ -157,10 +178,10 @@ var deepCopyObject = function (object) {
157
178
  var AvatarElement = function (props) {
158
179
  var src = props.src, placeholder = props.placeholder, children = props.children, url = props.url, _a = props.size, size = _a === void 0 ? 'md' : _a, _b = props.figure, figure = _b === void 0 ? 'block' : _b, status = props.status, isDisabled = props.isDisabled, isLoading = props.isLoading, stylesOverrides = props.styles;
159
180
  var handleGenerateStyle = function () {
160
- var result = deepCopyObject(styles$v.base);
161
- var keys = calculateNestedKeys(styles$v.base);
181
+ var result = deepCopyObject(styles$w.base);
182
+ var keys = calculateNestedKeys(styles$w.base);
162
183
  keys.forEach(function (key) {
163
- lodash.set(result, key, toClassName(lodash.get(styles$v.base, key), size && lodash.get(styles$v[size], key), figure && lodash.get(styles$v[figure], key), status && lodash.get(styles$v[status], key), isDisabled && lodash.get(styles$v.disabled, key), isLoading && lodash.get(styles$v.loading, key), lodash.get(stylesOverrides, key)));
184
+ lodash.set(result, key, toClassName(lodash.get(styles$w.base, key), size && lodash.get(styles$w[size], key), figure && lodash.get(styles$w[figure], key), status && lodash.get(styles$w[status], key), isDisabled && lodash.get(styles$w.disabled, key), isLoading && lodash.get(styles$w.loading, key), lodash.get(stylesOverrides, key)));
164
185
  });
165
186
  return result;
166
187
  };
@@ -178,7 +199,7 @@ var AvatarElement = function (props) {
178
199
  return (jsxRuntime.jsx("a", { href: url, children: jsxRuntime.jsxs("div", { className: "flex items-center", children: [jsxRuntime.jsxs("span", { className: "flex items-center justify-center", children: [jsxRuntime.jsx("div", { className: styles.container, style: { backgroundImage: "url(".concat(src, ")") } }), status && jsxRuntime.jsx("span", { className: styles.indicator })] }), children && jsxRuntime.jsx("div", { className: "ml-3", children: children })] }) }));
179
200
  };
180
201
 
181
- var base$r = {
202
+ var base$s = {
182
203
  loading: 'inline-block relative overflow-hidden bg-gray-50 flex items-center justify-center',
183
204
  spinner: 'w-5 h-5 animate-spin text-gray-400',
184
205
  empty: 'inline-block relative overflow-hidden bg-gray-50 text-red-400',
@@ -256,8 +277,8 @@ var online = {
256
277
  var blocked = {
257
278
  indicator: 'bg-red-400',
258
279
  };
259
- var styles$v = {
260
- base: base$r,
280
+ var styles$w = {
281
+ base: base$s,
261
282
  xs: xs$4,
262
283
  sm: sm$5,
263
284
  md: md$4,
@@ -314,10 +335,10 @@ var BadgeElement$1 = function (props) {
314
335
  var title = props.title, message = props.message, _a = props.type, type = _a === void 0 ? 'generic' : _a, _b = props.onClose, onClose = _b === void 0 ? lodash.noop : _b, _c = props.onCollapse, onCollapse = _c === void 0 ? lodash.noop : _c, _d = props.isCollapsible, isCollapsible = _d === void 0 ? false : _d, stylesOverrides = props.styles, iconAccessorOverride = props.iconAccessor;
315
336
  var _e = React.useState(false), isCollapsed = _e[0], setIsCollapsed = _e[1];
316
337
  var handleGenerateStyle = function () {
317
- var result = deepCopyObject(styles$u.base);
318
- var keys = calculateNestedKeys(styles$u.base);
338
+ var result = deepCopyObject(styles$v.base);
339
+ var keys = calculateNestedKeys(styles$v.base);
319
340
  keys.forEach(function (key) {
320
- lodash.set(result, key, toClassName(lodash.get(styles$u.base, key), type && lodash.get(styles$u[type], key), lodash.get(stylesOverrides, key)));
341
+ lodash.set(result, key, toClassName(lodash.get(styles$v.base, key), type && lodash.get(styles$v[type], key), lodash.get(stylesOverrides, key)));
321
342
  });
322
343
  return result;
323
344
  };
@@ -345,7 +366,7 @@ var BadgeElement$1 = function (props) {
345
366
  }, children: jsxRuntime.jsx(IconElement, { className: toClassName(styles.content.action, isCollapsed && styles.content.inverted), accessor: "chevron-up" }) })), jsxRuntime.jsx("div", { onClick: onClose, children: jsxRuntime.jsx(IconElement, { className: styles.content.action, accessor: "times" }) })] })] })] }) }));
346
367
  };
347
368
 
348
- var base$q = {
369
+ var base$r = {
349
370
  container: 'rounded-sm p-4 border-l-4',
350
371
  icon: 'h-5 w-5',
351
372
  content: {
@@ -366,7 +387,7 @@ var generic = {
366
387
  title: 'text-gray-500 rotate',
367
388
  },
368
389
  };
369
- var error$1 = {
390
+ var error$2 = {
370
391
  container: 'bg-red-50 border-red-400',
371
392
  icon: 'text-red-400',
372
393
  content: {
@@ -375,7 +396,7 @@ var error$1 = {
375
396
  title: 'text-red-500',
376
397
  },
377
398
  };
378
- var warn = {
399
+ var warn$1 = {
379
400
  container: 'bg-yellow-50 border-orange-400',
380
401
  icon: 'text-orange-400',
381
402
  content: {
@@ -402,11 +423,11 @@ var info = {
402
423
  title: 'text-blue-500',
403
424
  },
404
425
  };
405
- var styles$u = {
406
- base: base$q,
426
+ var styles$v = {
427
+ base: base$r,
407
428
  generic: generic,
408
- error: error$1,
409
- warn: warn,
429
+ error: error$2,
430
+ warn: warn$1,
410
431
  success: success$1,
411
432
  info: info,
412
433
  };
@@ -414,10 +435,10 @@ var styles$u = {
414
435
  var BadgeElement = function (props) {
415
436
  var children = props.children, _a = props.color, color = _a === void 0 ? 'gray' : _a, _b = props.type, type = _b === void 0 ? 'normal' : _b, _c = props.size, size = _c === void 0 ? 'sm' : _c, _d = props.figure, figure = _d === void 0 ? 'block' : _d, isDisabled = props.isDisabled, isLoading = props.isLoading, onClose = props.onClose, stylesOverrides = props.styles, dataCy = props.dataCy;
416
437
  var handleGenerateStyle = function () {
417
- var result = deepCopyObject(styles$t.base);
418
- var keys = calculateNestedKeys(styles$t.base);
438
+ var result = deepCopyObject(styles$u.base);
439
+ var keys = calculateNestedKeys(styles$u.base);
419
440
  keys.forEach(function (key) {
420
- lodash.set(result, key, toClassName(lodash.get(styles$t.base, key), type && lodash.get(styles$t[type], key), color && lodash.get(styles$t[color], key), size && lodash.get(styles$t[size], key), figure && lodash.get(styles$t[figure], key), isDisabled && lodash.get(styles$t.disabled, key), isLoading && lodash.get(styles$t.loading, key), lodash.get(stylesOverrides, key)));
441
+ lodash.set(result, key, toClassName(lodash.get(styles$u.base, key), type && lodash.get(styles$u[type], key), color && lodash.get(styles$u[color], key), size && lodash.get(styles$u[size], key), figure && lodash.get(styles$u[figure], key), isDisabled && lodash.get(styles$u.disabled, key), isLoading && lodash.get(styles$u.loading, key), lodash.get(stylesOverrides, key)));
421
442
  });
422
443
  return result;
423
444
  };
@@ -429,7 +450,7 @@ var BadgeElement = function (props) {
429
450
  return (jsxRuntime.jsxs("span", { className: styles.container, "data-cy": dataCy, children: [type === 'indicator' && (jsxRuntime.jsx("svg", { className: styles.indicator, fill: "currentColor", viewBox: "0 0 8 8", children: jsxRuntime.jsx("circle", { cx: 4, cy: 4, r: 3 }) })), children, type === 'close' && (jsxRuntime.jsxs("button", { type: "button", className: styles.button, onClick: onClose, children: [jsxRuntime.jsx("span", { className: "sr-only", children: "Remove large option" }), xIcon] }))] }));
430
451
  };
431
452
 
432
- var base$p = {
453
+ var base$q = {
433
454
  container: 'inline-flex items-center font-medium py-0.5',
434
455
  indicator: '',
435
456
  button: 'flex-shrink-0 ml-0.5 h-4 w-4 rounded-full inline-flex items-center justify-center focus:text-white focus:outline-none',
@@ -512,8 +533,8 @@ var disabled$9 = {
512
533
  var loading$1 = {
513
534
  container: 'cursor-progress',
514
535
  };
515
- var styles$t = {
516
- base: base$p,
536
+ var styles$u = {
537
+ base: base$q,
517
538
  normal: normal$8,
518
539
  indicator: indicator,
519
540
  close: close,
@@ -536,6 +557,3556 @@ var styles$t = {
536
557
  loading: loading$1,
537
558
  };
538
559
 
560
+ function getNodeName(node) {
561
+ if (isNode(node)) {
562
+ return (node.nodeName || '').toLowerCase();
563
+ }
564
+ return '#document';
565
+ }
566
+ function getWindow(node) {
567
+ var _node$ownerDocument;
568
+ return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
569
+ }
570
+ function getDocumentElement(node) {
571
+ var _ref;
572
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
573
+ }
574
+ function isNode(value) {
575
+ return value instanceof Node || value instanceof getWindow(value).Node;
576
+ }
577
+ function isElement(value) {
578
+ return value instanceof Element || value instanceof getWindow(value).Element;
579
+ }
580
+ function isHTMLElement(value) {
581
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
582
+ }
583
+ function isShadowRoot(value) {
584
+ if (typeof ShadowRoot === 'undefined') {
585
+ return false;
586
+ }
587
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
588
+ }
589
+ function isOverflowElement(element) {
590
+ const {
591
+ overflow,
592
+ overflowX,
593
+ overflowY,
594
+ display
595
+ } = getComputedStyle(element);
596
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
597
+ }
598
+ function isTableElement(element) {
599
+ return ['table', 'td', 'th'].includes(getNodeName(element));
600
+ }
601
+ function isContainingBlock(element) {
602
+ const webkit = isWebKit();
603
+ const css = getComputedStyle(element);
604
+ return css.transform !== 'none' || css.perspective !== 'none' || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || ['transform', 'perspective', 'filter'].some(value => (css.willChange || '').includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => (css.contain || '').includes(value));
605
+ }
606
+ function getContainingBlock(element) {
607
+ let currentNode = getParentNode(element);
608
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
609
+ if (isContainingBlock(currentNode)) {
610
+ return currentNode;
611
+ }
612
+ currentNode = getParentNode(currentNode);
613
+ }
614
+ return null;
615
+ }
616
+ function isWebKit() {
617
+ if (typeof CSS === 'undefined' || !CSS.supports) return false;
618
+ return CSS.supports('-webkit-backdrop-filter', 'none');
619
+ }
620
+ function isLastTraversableNode(node) {
621
+ return ['html', 'body', '#document'].includes(getNodeName(node));
622
+ }
623
+ function getComputedStyle(element) {
624
+ return getWindow(element).getComputedStyle(element);
625
+ }
626
+ function getNodeScroll(element) {
627
+ if (isElement(element)) {
628
+ return {
629
+ scrollLeft: element.scrollLeft,
630
+ scrollTop: element.scrollTop
631
+ };
632
+ }
633
+ return {
634
+ scrollLeft: element.pageXOffset,
635
+ scrollTop: element.pageYOffset
636
+ };
637
+ }
638
+ function getParentNode(node) {
639
+ if (getNodeName(node) === 'html') {
640
+ return node;
641
+ }
642
+ const result =
643
+ node.assignedSlot ||
644
+ node.parentNode ||
645
+ isShadowRoot(node) && node.host ||
646
+ getDocumentElement(node);
647
+ return isShadowRoot(result) ? result.host : result;
648
+ }
649
+ function getNearestOverflowAncestor(node) {
650
+ const parentNode = getParentNode(node);
651
+ if (isLastTraversableNode(parentNode)) {
652
+ return node.ownerDocument ? node.ownerDocument.body : node.body;
653
+ }
654
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
655
+ return parentNode;
656
+ }
657
+ return getNearestOverflowAncestor(parentNode);
658
+ }
659
+ function getOverflowAncestors(node, list, traverseIframes) {
660
+ var _node$ownerDocument2;
661
+ if (list === void 0) {
662
+ list = [];
663
+ }
664
+ if (traverseIframes === void 0) {
665
+ traverseIframes = true;
666
+ }
667
+ const scrollableAncestor = getNearestOverflowAncestor(node);
668
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
669
+ const win = getWindow(scrollableAncestor);
670
+ if (isBody) {
671
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], win.frameElement && traverseIframes ? getOverflowAncestors(win.frameElement) : []);
672
+ }
673
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
674
+ }
675
+
676
+ function activeElement(doc) {
677
+ let activeElement = doc.activeElement;
678
+ while (((_activeElement = activeElement) == null || (_activeElement = _activeElement.shadowRoot) == null ? void 0 : _activeElement.activeElement) != null) {
679
+ var _activeElement;
680
+ activeElement = activeElement.shadowRoot.activeElement;
681
+ }
682
+ return activeElement;
683
+ }
684
+ function contains(parent, child) {
685
+ if (!parent || !child) {
686
+ return false;
687
+ }
688
+ const rootNode = child.getRootNode == null ? void 0 : child.getRootNode();
689
+ if (parent.contains(child)) {
690
+ return true;
691
+ }
692
+ if (rootNode && isShadowRoot(rootNode)) {
693
+ let next = child;
694
+ while (next) {
695
+ if (parent === next) {
696
+ return true;
697
+ }
698
+ next = next.parentNode || next.host;
699
+ }
700
+ }
701
+ return false;
702
+ }
703
+ function getPlatform() {
704
+ const uaData = navigator.userAgentData;
705
+ if (uaData != null && uaData.platform) {
706
+ return uaData.platform;
707
+ }
708
+ return navigator.platform;
709
+ }
710
+ function getUserAgent() {
711
+ const uaData = navigator.userAgentData;
712
+ if (uaData && Array.isArray(uaData.brands)) {
713
+ return uaData.brands.map(_ref => {
714
+ let {
715
+ brand,
716
+ version
717
+ } = _ref;
718
+ return brand + "/" + version;
719
+ }).join(' ');
720
+ }
721
+ return navigator.userAgent;
722
+ }
723
+ function isVirtualPointerEvent(event) {
724
+ if (isJSDOM()) return false;
725
+ return !isAndroid() && event.width === 0 && event.height === 0 || isAndroid() && event.width === 1 && event.height === 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === 'mouse' ||
726
+ event.width < 1 && event.height < 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === 'touch';
727
+ }
728
+ function isSafari() {
729
+ return /apple/i.test(navigator.vendor);
730
+ }
731
+ function isAndroid() {
732
+ const re = /android/i;
733
+ return re.test(getPlatform()) || re.test(getUserAgent());
734
+ }
735
+ function isMac() {
736
+ return getPlatform().toLowerCase().startsWith('mac') && !navigator.maxTouchPoints;
737
+ }
738
+ function isJSDOM() {
739
+ return getUserAgent().includes('jsdom/');
740
+ }
741
+ function isMouseLikePointerType(pointerType, strict) {
742
+ const values = ['mouse', 'pen'];
743
+ if (!strict) {
744
+ values.push('', undefined);
745
+ }
746
+ return values.includes(pointerType);
747
+ }
748
+ function isReactEvent(event) {
749
+ return 'nativeEvent' in event;
750
+ }
751
+ function isRootElement(element) {
752
+ return element.matches('html,body');
753
+ }
754
+ function getDocument(node) {
755
+ return (node == null ? void 0 : node.ownerDocument) || document;
756
+ }
757
+ function isEventTargetWithin(event, node) {
758
+ if (node == null) {
759
+ return false;
760
+ }
761
+ if ('composedPath' in event) {
762
+ return event.composedPath().includes(node);
763
+ }
764
+ const e = event;
765
+ return e.target != null && node.contains(e.target);
766
+ }
767
+ function getTarget(event) {
768
+ if ('composedPath' in event) {
769
+ return event.composedPath()[0];
770
+ }
771
+ return event.target;
772
+ }
773
+ const TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled])," + "[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
774
+ function isTypeableElement(element) {
775
+ return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
776
+ }
777
+ function stopEvent(event) {
778
+ event.preventDefault();
779
+ event.stopPropagation();
780
+ }
781
+
782
+ const sides = ['top', 'right', 'bottom', 'left'];
783
+ const alignments = ['start', 'end'];
784
+ sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []);
785
+ const min = Math.min;
786
+ const max = Math.max;
787
+ const round = Math.round;
788
+ const floor = Math.floor;
789
+ const createCoords = v => ({
790
+ x: v,
791
+ y: v
792
+ });
793
+ const oppositeSideMap = {
794
+ left: 'right',
795
+ right: 'left',
796
+ bottom: 'top',
797
+ top: 'bottom'
798
+ };
799
+ const oppositeAlignmentMap = {
800
+ start: 'end',
801
+ end: 'start'
802
+ };
803
+ function clamp(start, value, end) {
804
+ return max(start, min(value, end));
805
+ }
806
+ function evaluate(value, param) {
807
+ return typeof value === 'function' ? value(param) : value;
808
+ }
809
+ function getSide(placement) {
810
+ return placement.split('-')[0];
811
+ }
812
+ function getAlignment(placement) {
813
+ return placement.split('-')[1];
814
+ }
815
+ function getOppositeAxis(axis) {
816
+ return axis === 'x' ? 'y' : 'x';
817
+ }
818
+ function getAxisLength(axis) {
819
+ return axis === 'y' ? 'height' : 'width';
820
+ }
821
+ function getSideAxis(placement) {
822
+ return ['top', 'bottom'].includes(getSide(placement)) ? 'y' : 'x';
823
+ }
824
+ function getAlignmentAxis(placement) {
825
+ return getOppositeAxis(getSideAxis(placement));
826
+ }
827
+ function getAlignmentSides(placement, rects, rtl) {
828
+ if (rtl === void 0) {
829
+ rtl = false;
830
+ }
831
+ const alignment = getAlignment(placement);
832
+ const alignmentAxis = getAlignmentAxis(placement);
833
+ const length = getAxisLength(alignmentAxis);
834
+ let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
835
+ if (rects.reference[length] > rects.floating[length]) {
836
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
837
+ }
838
+ return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
839
+ }
840
+ function getExpandedPlacements(placement) {
841
+ const oppositePlacement = getOppositePlacement(placement);
842
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
843
+ }
844
+ function getOppositeAlignmentPlacement(placement) {
845
+ return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
846
+ }
847
+ function getSideList(side, isStart, rtl) {
848
+ const lr = ['left', 'right'];
849
+ const rl = ['right', 'left'];
850
+ const tb = ['top', 'bottom'];
851
+ const bt = ['bottom', 'top'];
852
+ switch (side) {
853
+ case 'top':
854
+ case 'bottom':
855
+ if (rtl) return isStart ? rl : lr;
856
+ return isStart ? lr : rl;
857
+ case 'left':
858
+ case 'right':
859
+ return isStart ? tb : bt;
860
+ default:
861
+ return [];
862
+ }
863
+ }
864
+ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
865
+ const alignment = getAlignment(placement);
866
+ let list = getSideList(getSide(placement), direction === 'start', rtl);
867
+ if (alignment) {
868
+ list = list.map(side => side + "-" + alignment);
869
+ if (flipAlignment) {
870
+ list = list.concat(list.map(getOppositeAlignmentPlacement));
871
+ }
872
+ }
873
+ return list;
874
+ }
875
+ function getOppositePlacement(placement) {
876
+ return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
877
+ }
878
+ function expandPaddingObject(padding) {
879
+ return {
880
+ top: 0,
881
+ right: 0,
882
+ bottom: 0,
883
+ left: 0,
884
+ ...padding
885
+ };
886
+ }
887
+ function getPaddingObject(padding) {
888
+ return typeof padding !== 'number' ? expandPaddingObject(padding) : {
889
+ top: padding,
890
+ right: padding,
891
+ bottom: padding,
892
+ left: padding
893
+ };
894
+ }
895
+ function rectToClientRect(rect) {
896
+ const {
897
+ x,
898
+ y,
899
+ width,
900
+ height
901
+ } = rect;
902
+ return {
903
+ width,
904
+ height,
905
+ top: y,
906
+ left: x,
907
+ right: x + width,
908
+ bottom: y + height,
909
+ x,
910
+ y
911
+ };
912
+ }
913
+
914
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
915
+ let {
916
+ reference,
917
+ floating
918
+ } = _ref;
919
+ const sideAxis = getSideAxis(placement);
920
+ const alignmentAxis = getAlignmentAxis(placement);
921
+ const alignLength = getAxisLength(alignmentAxis);
922
+ const side = getSide(placement);
923
+ const isVertical = sideAxis === 'y';
924
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
925
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
926
+ const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
927
+ let coords;
928
+ switch (side) {
929
+ case 'top':
930
+ coords = {
931
+ x: commonX,
932
+ y: reference.y - floating.height
933
+ };
934
+ break;
935
+ case 'bottom':
936
+ coords = {
937
+ x: commonX,
938
+ y: reference.y + reference.height
939
+ };
940
+ break;
941
+ case 'right':
942
+ coords = {
943
+ x: reference.x + reference.width,
944
+ y: commonY
945
+ };
946
+ break;
947
+ case 'left':
948
+ coords = {
949
+ x: reference.x - floating.width,
950
+ y: commonY
951
+ };
952
+ break;
953
+ default:
954
+ coords = {
955
+ x: reference.x,
956
+ y: reference.y
957
+ };
958
+ }
959
+ switch (getAlignment(placement)) {
960
+ case 'start':
961
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
962
+ break;
963
+ case 'end':
964
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
965
+ break;
966
+ }
967
+ return coords;
968
+ }
969
+ const computePosition$1 = async (reference, floating, config) => {
970
+ const {
971
+ placement = 'bottom',
972
+ strategy = 'absolute',
973
+ middleware = [],
974
+ platform
975
+ } = config;
976
+ const validMiddleware = middleware.filter(Boolean);
977
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
978
+ let rects = await platform.getElementRects({
979
+ reference,
980
+ floating,
981
+ strategy
982
+ });
983
+ let {
984
+ x,
985
+ y
986
+ } = computeCoordsFromPlacement(rects, placement, rtl);
987
+ let statefulPlacement = placement;
988
+ let middlewareData = {};
989
+ let resetCount = 0;
990
+ for (let i = 0; i < validMiddleware.length; i++) {
991
+ const {
992
+ name,
993
+ fn
994
+ } = validMiddleware[i];
995
+ const {
996
+ x: nextX,
997
+ y: nextY,
998
+ data,
999
+ reset
1000
+ } = await fn({
1001
+ x,
1002
+ y,
1003
+ initialPlacement: placement,
1004
+ placement: statefulPlacement,
1005
+ strategy,
1006
+ middlewareData,
1007
+ rects,
1008
+ platform,
1009
+ elements: {
1010
+ reference,
1011
+ floating
1012
+ }
1013
+ });
1014
+ x = nextX != null ? nextX : x;
1015
+ y = nextY != null ? nextY : y;
1016
+ middlewareData = {
1017
+ ...middlewareData,
1018
+ [name]: {
1019
+ ...middlewareData[name],
1020
+ ...data
1021
+ }
1022
+ };
1023
+ if (reset && resetCount <= 50) {
1024
+ resetCount++;
1025
+ if (typeof reset === 'object') {
1026
+ if (reset.placement) {
1027
+ statefulPlacement = reset.placement;
1028
+ }
1029
+ if (reset.rects) {
1030
+ rects = reset.rects === true ? await platform.getElementRects({
1031
+ reference,
1032
+ floating,
1033
+ strategy
1034
+ }) : reset.rects;
1035
+ }
1036
+ ({
1037
+ x,
1038
+ y
1039
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
1040
+ }
1041
+ i = -1;
1042
+ }
1043
+ }
1044
+ return {
1045
+ x,
1046
+ y,
1047
+ placement: statefulPlacement,
1048
+ strategy,
1049
+ middlewareData
1050
+ };
1051
+ };
1052
+ async function detectOverflow(state, options) {
1053
+ var _await$platform$isEle;
1054
+ if (options === void 0) {
1055
+ options = {};
1056
+ }
1057
+ const {
1058
+ x,
1059
+ y,
1060
+ platform,
1061
+ rects,
1062
+ elements,
1063
+ strategy
1064
+ } = state;
1065
+ const {
1066
+ boundary = 'clippingAncestors',
1067
+ rootBoundary = 'viewport',
1068
+ elementContext = 'floating',
1069
+ altBoundary = false,
1070
+ padding = 0
1071
+ } = evaluate(options, state);
1072
+ const paddingObject = getPaddingObject(padding);
1073
+ const altContext = elementContext === 'floating' ? 'reference' : 'floating';
1074
+ const element = elements[altBoundary ? altContext : elementContext];
1075
+ const clippingClientRect = rectToClientRect(await platform.getClippingRect({
1076
+ element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
1077
+ boundary,
1078
+ rootBoundary,
1079
+ strategy
1080
+ }));
1081
+ const rect = elementContext === 'floating' ? {
1082
+ x,
1083
+ y,
1084
+ width: rects.floating.width,
1085
+ height: rects.floating.height
1086
+ } : rects.reference;
1087
+ const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
1088
+ const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
1089
+ x: 1,
1090
+ y: 1
1091
+ } : {
1092
+ x: 1,
1093
+ y: 1
1094
+ };
1095
+ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
1096
+ elements,
1097
+ rect,
1098
+ offsetParent,
1099
+ strategy
1100
+ }) : rect);
1101
+ return {
1102
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
1103
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
1104
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
1105
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
1106
+ };
1107
+ }
1108
+ const arrow$3 = options => ({
1109
+ name: 'arrow',
1110
+ options,
1111
+ async fn(state) {
1112
+ const {
1113
+ x,
1114
+ y,
1115
+ placement,
1116
+ rects,
1117
+ platform,
1118
+ elements,
1119
+ middlewareData
1120
+ } = state;
1121
+ const {
1122
+ element,
1123
+ padding = 0
1124
+ } = evaluate(options, state) || {};
1125
+ if (element == null) {
1126
+ return {};
1127
+ }
1128
+ const paddingObject = getPaddingObject(padding);
1129
+ const coords = {
1130
+ x,
1131
+ y
1132
+ };
1133
+ const axis = getAlignmentAxis(placement);
1134
+ const length = getAxisLength(axis);
1135
+ const arrowDimensions = await platform.getDimensions(element);
1136
+ const isYAxis = axis === 'y';
1137
+ const minProp = isYAxis ? 'top' : 'left';
1138
+ const maxProp = isYAxis ? 'bottom' : 'right';
1139
+ const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
1140
+ const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
1141
+ const startDiff = coords[axis] - rects.reference[axis];
1142
+ const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
1143
+ let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
1144
+ if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
1145
+ clientSize = elements.floating[clientProp] || rects.floating[length];
1146
+ }
1147
+ const centerToReference = endDiff / 2 - startDiff / 2;
1148
+ const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
1149
+ const minPadding = min(paddingObject[minProp], largestPossiblePadding);
1150
+ const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
1151
+ const min$1 = minPadding;
1152
+ const max = clientSize - arrowDimensions[length] - maxPadding;
1153
+ const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
1154
+ const offset = clamp(min$1, center, max);
1155
+ const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
1156
+ const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
1157
+ return {
1158
+ [axis]: coords[axis] + alignmentOffset,
1159
+ data: {
1160
+ [axis]: offset,
1161
+ centerOffset: center - offset - alignmentOffset,
1162
+ ...(shouldAddOffset && {
1163
+ alignmentOffset
1164
+ })
1165
+ },
1166
+ reset: shouldAddOffset
1167
+ };
1168
+ }
1169
+ });
1170
+ const flip$2 = function (options) {
1171
+ if (options === void 0) {
1172
+ options = {};
1173
+ }
1174
+ return {
1175
+ name: 'flip',
1176
+ options,
1177
+ async fn(state) {
1178
+ var _middlewareData$arrow, _middlewareData$flip;
1179
+ const {
1180
+ placement,
1181
+ middlewareData,
1182
+ rects,
1183
+ initialPlacement,
1184
+ platform,
1185
+ elements
1186
+ } = state;
1187
+ const {
1188
+ mainAxis: checkMainAxis = true,
1189
+ crossAxis: checkCrossAxis = true,
1190
+ fallbackPlacements: specifiedFallbackPlacements,
1191
+ fallbackStrategy = 'bestFit',
1192
+ fallbackAxisSideDirection = 'none',
1193
+ flipAlignment = true,
1194
+ ...detectOverflowOptions
1195
+ } = evaluate(options, state);
1196
+ if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
1197
+ return {};
1198
+ }
1199
+ const side = getSide(placement);
1200
+ const isBasePlacement = getSide(initialPlacement) === initialPlacement;
1201
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
1202
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
1203
+ if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== 'none') {
1204
+ fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
1205
+ }
1206
+ const placements = [initialPlacement, ...fallbackPlacements];
1207
+ const overflow = await detectOverflow(state, detectOverflowOptions);
1208
+ const overflows = [];
1209
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
1210
+ if (checkMainAxis) {
1211
+ overflows.push(overflow[side]);
1212
+ }
1213
+ if (checkCrossAxis) {
1214
+ const sides = getAlignmentSides(placement, rects, rtl);
1215
+ overflows.push(overflow[sides[0]], overflow[sides[1]]);
1216
+ }
1217
+ overflowsData = [...overflowsData, {
1218
+ placement,
1219
+ overflows
1220
+ }];
1221
+ if (!overflows.every(side => side <= 0)) {
1222
+ var _middlewareData$flip2, _overflowsData$filter;
1223
+ const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
1224
+ const nextPlacement = placements[nextIndex];
1225
+ if (nextPlacement) {
1226
+ return {
1227
+ data: {
1228
+ index: nextIndex,
1229
+ overflows: overflowsData
1230
+ },
1231
+ reset: {
1232
+ placement: nextPlacement
1233
+ }
1234
+ };
1235
+ }
1236
+ let resetPlacement = (_overflowsData$filter = overflowsData.filter(d => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
1237
+ if (!resetPlacement) {
1238
+ switch (fallbackStrategy) {
1239
+ case 'bestFit':
1240
+ {
1241
+ var _overflowsData$map$so;
1242
+ const placement = (_overflowsData$map$so = overflowsData.map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$map$so[0];
1243
+ if (placement) {
1244
+ resetPlacement = placement;
1245
+ }
1246
+ break;
1247
+ }
1248
+ case 'initialPlacement':
1249
+ resetPlacement = initialPlacement;
1250
+ break;
1251
+ }
1252
+ }
1253
+ if (placement !== resetPlacement) {
1254
+ return {
1255
+ reset: {
1256
+ placement: resetPlacement
1257
+ }
1258
+ };
1259
+ }
1260
+ }
1261
+ return {};
1262
+ }
1263
+ };
1264
+ };
1265
+ async function convertValueToCoords(state, options) {
1266
+ const {
1267
+ placement,
1268
+ platform,
1269
+ elements
1270
+ } = state;
1271
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
1272
+ const side = getSide(placement);
1273
+ const alignment = getAlignment(placement);
1274
+ const isVertical = getSideAxis(placement) === 'y';
1275
+ const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
1276
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
1277
+ const rawValue = evaluate(options, state);
1278
+ let {
1279
+ mainAxis,
1280
+ crossAxis,
1281
+ alignmentAxis
1282
+ } = typeof rawValue === 'number' ? {
1283
+ mainAxis: rawValue,
1284
+ crossAxis: 0,
1285
+ alignmentAxis: null
1286
+ } : {
1287
+ mainAxis: 0,
1288
+ crossAxis: 0,
1289
+ alignmentAxis: null,
1290
+ ...rawValue
1291
+ };
1292
+ if (alignment && typeof alignmentAxis === 'number') {
1293
+ crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
1294
+ }
1295
+ return isVertical ? {
1296
+ x: crossAxis * crossAxisMulti,
1297
+ y: mainAxis * mainAxisMulti
1298
+ } : {
1299
+ x: mainAxis * mainAxisMulti,
1300
+ y: crossAxis * crossAxisMulti
1301
+ };
1302
+ }
1303
+ const offset$2 = function (options) {
1304
+ if (options === void 0) {
1305
+ options = 0;
1306
+ }
1307
+ return {
1308
+ name: 'offset',
1309
+ options,
1310
+ async fn(state) {
1311
+ var _middlewareData$offse, _middlewareData$arrow;
1312
+ const {
1313
+ x,
1314
+ y,
1315
+ placement,
1316
+ middlewareData
1317
+ } = state;
1318
+ const diffCoords = await convertValueToCoords(state, options);
1319
+ if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
1320
+ return {};
1321
+ }
1322
+ return {
1323
+ x: x + diffCoords.x,
1324
+ y: y + diffCoords.y,
1325
+ data: {
1326
+ ...diffCoords,
1327
+ placement
1328
+ }
1329
+ };
1330
+ }
1331
+ };
1332
+ };
1333
+ const shift$2 = function (options) {
1334
+ if (options === void 0) {
1335
+ options = {};
1336
+ }
1337
+ return {
1338
+ name: 'shift',
1339
+ options,
1340
+ async fn(state) {
1341
+ const {
1342
+ x,
1343
+ y,
1344
+ placement
1345
+ } = state;
1346
+ const {
1347
+ mainAxis: checkMainAxis = true,
1348
+ crossAxis: checkCrossAxis = false,
1349
+ limiter = {
1350
+ fn: _ref => {
1351
+ let {
1352
+ x,
1353
+ y
1354
+ } = _ref;
1355
+ return {
1356
+ x,
1357
+ y
1358
+ };
1359
+ }
1360
+ },
1361
+ ...detectOverflowOptions
1362
+ } = evaluate(options, state);
1363
+ const coords = {
1364
+ x,
1365
+ y
1366
+ };
1367
+ const overflow = await detectOverflow(state, detectOverflowOptions);
1368
+ const crossAxis = getSideAxis(getSide(placement));
1369
+ const mainAxis = getOppositeAxis(crossAxis);
1370
+ let mainAxisCoord = coords[mainAxis];
1371
+ let crossAxisCoord = coords[crossAxis];
1372
+ if (checkMainAxis) {
1373
+ const minSide = mainAxis === 'y' ? 'top' : 'left';
1374
+ const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
1375
+ const min = mainAxisCoord + overflow[minSide];
1376
+ const max = mainAxisCoord - overflow[maxSide];
1377
+ mainAxisCoord = clamp(min, mainAxisCoord, max);
1378
+ }
1379
+ if (checkCrossAxis) {
1380
+ const minSide = crossAxis === 'y' ? 'top' : 'left';
1381
+ const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
1382
+ const min = crossAxisCoord + overflow[minSide];
1383
+ const max = crossAxisCoord - overflow[maxSide];
1384
+ crossAxisCoord = clamp(min, crossAxisCoord, max);
1385
+ }
1386
+ const limitedCoords = limiter.fn({
1387
+ ...state,
1388
+ [mainAxis]: mainAxisCoord,
1389
+ [crossAxis]: crossAxisCoord
1390
+ });
1391
+ return {
1392
+ ...limitedCoords,
1393
+ data: {
1394
+ x: limitedCoords.x - x,
1395
+ y: limitedCoords.y - y
1396
+ }
1397
+ };
1398
+ }
1399
+ };
1400
+ };
1401
+
1402
+ function getCssDimensions(element) {
1403
+ const css = getComputedStyle(element);
1404
+ let width = parseFloat(css.width) || 0;
1405
+ let height = parseFloat(css.height) || 0;
1406
+ const hasOffset = isHTMLElement(element);
1407
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
1408
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
1409
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
1410
+ if (shouldFallback) {
1411
+ width = offsetWidth;
1412
+ height = offsetHeight;
1413
+ }
1414
+ return {
1415
+ width,
1416
+ height,
1417
+ $: shouldFallback
1418
+ };
1419
+ }
1420
+ function unwrapElement(element) {
1421
+ return !isElement(element) ? element.contextElement : element;
1422
+ }
1423
+ function getScale(element) {
1424
+ const domElement = unwrapElement(element);
1425
+ if (!isHTMLElement(domElement)) {
1426
+ return createCoords(1);
1427
+ }
1428
+ const rect = domElement.getBoundingClientRect();
1429
+ const {
1430
+ width,
1431
+ height,
1432
+ $
1433
+ } = getCssDimensions(domElement);
1434
+ let x = ($ ? round(rect.width) : rect.width) / width;
1435
+ let y = ($ ? round(rect.height) : rect.height) / height;
1436
+ if (!x || !Number.isFinite(x)) {
1437
+ x = 1;
1438
+ }
1439
+ if (!y || !Number.isFinite(y)) {
1440
+ y = 1;
1441
+ }
1442
+ return {
1443
+ x,
1444
+ y
1445
+ };
1446
+ }
1447
+ const noOffsets = createCoords(0);
1448
+ function getVisualOffsets(element) {
1449
+ const win = getWindow(element);
1450
+ if (!isWebKit() || !win.visualViewport) {
1451
+ return noOffsets;
1452
+ }
1453
+ return {
1454
+ x: win.visualViewport.offsetLeft,
1455
+ y: win.visualViewport.offsetTop
1456
+ };
1457
+ }
1458
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
1459
+ if (isFixed === void 0) {
1460
+ isFixed = false;
1461
+ }
1462
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
1463
+ return false;
1464
+ }
1465
+ return isFixed;
1466
+ }
1467
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
1468
+ if (includeScale === void 0) {
1469
+ includeScale = false;
1470
+ }
1471
+ if (isFixedStrategy === void 0) {
1472
+ isFixedStrategy = false;
1473
+ }
1474
+ const clientRect = element.getBoundingClientRect();
1475
+ const domElement = unwrapElement(element);
1476
+ let scale = createCoords(1);
1477
+ if (includeScale) {
1478
+ if (offsetParent) {
1479
+ if (isElement(offsetParent)) {
1480
+ scale = getScale(offsetParent);
1481
+ }
1482
+ } else {
1483
+ scale = getScale(element);
1484
+ }
1485
+ }
1486
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
1487
+ let x = (clientRect.left + visualOffsets.x) / scale.x;
1488
+ let y = (clientRect.top + visualOffsets.y) / scale.y;
1489
+ let width = clientRect.width / scale.x;
1490
+ let height = clientRect.height / scale.y;
1491
+ if (domElement) {
1492
+ const win = getWindow(domElement);
1493
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
1494
+ let currentWin = win;
1495
+ let currentIFrame = currentWin.frameElement;
1496
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
1497
+ const iframeScale = getScale(currentIFrame);
1498
+ const iframeRect = currentIFrame.getBoundingClientRect();
1499
+ const css = getComputedStyle(currentIFrame);
1500
+ const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
1501
+ const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
1502
+ x *= iframeScale.x;
1503
+ y *= iframeScale.y;
1504
+ width *= iframeScale.x;
1505
+ height *= iframeScale.y;
1506
+ x += left;
1507
+ y += top;
1508
+ currentWin = getWindow(currentIFrame);
1509
+ currentIFrame = currentWin.frameElement;
1510
+ }
1511
+ }
1512
+ return rectToClientRect({
1513
+ width,
1514
+ height,
1515
+ x,
1516
+ y
1517
+ });
1518
+ }
1519
+ const topLayerSelectors = [':popover-open', ':modal'];
1520
+ function isTopLayer(element) {
1521
+ return topLayerSelectors.some(selector => {
1522
+ try {
1523
+ return element.matches(selector);
1524
+ } catch (e) {
1525
+ return false;
1526
+ }
1527
+ });
1528
+ }
1529
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1530
+ let {
1531
+ elements,
1532
+ rect,
1533
+ offsetParent,
1534
+ strategy
1535
+ } = _ref;
1536
+ const isFixed = strategy === 'fixed';
1537
+ const documentElement = getDocumentElement(offsetParent);
1538
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
1539
+ if (offsetParent === documentElement || topLayer && isFixed) {
1540
+ return rect;
1541
+ }
1542
+ let scroll = {
1543
+ scrollLeft: 0,
1544
+ scrollTop: 0
1545
+ };
1546
+ let scale = createCoords(1);
1547
+ const offsets = createCoords(0);
1548
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1549
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1550
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1551
+ scroll = getNodeScroll(offsetParent);
1552
+ }
1553
+ if (isHTMLElement(offsetParent)) {
1554
+ const offsetRect = getBoundingClientRect(offsetParent);
1555
+ scale = getScale(offsetParent);
1556
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1557
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1558
+ }
1559
+ }
1560
+ return {
1561
+ width: rect.width * scale.x,
1562
+ height: rect.height * scale.y,
1563
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x,
1564
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y
1565
+ };
1566
+ }
1567
+ function getClientRects(element) {
1568
+ return Array.from(element.getClientRects());
1569
+ }
1570
+ function getWindowScrollBarX(element) {
1571
+ return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
1572
+ }
1573
+ function getDocumentRect(element) {
1574
+ const html = getDocumentElement(element);
1575
+ const scroll = getNodeScroll(element);
1576
+ const body = element.ownerDocument.body;
1577
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
1578
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
1579
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
1580
+ const y = -scroll.scrollTop;
1581
+ if (getComputedStyle(body).direction === 'rtl') {
1582
+ x += max(html.clientWidth, body.clientWidth) - width;
1583
+ }
1584
+ return {
1585
+ width,
1586
+ height,
1587
+ x,
1588
+ y
1589
+ };
1590
+ }
1591
+ function getViewportRect(element, strategy) {
1592
+ const win = getWindow(element);
1593
+ const html = getDocumentElement(element);
1594
+ const visualViewport = win.visualViewport;
1595
+ let width = html.clientWidth;
1596
+ let height = html.clientHeight;
1597
+ let x = 0;
1598
+ let y = 0;
1599
+ if (visualViewport) {
1600
+ width = visualViewport.width;
1601
+ height = visualViewport.height;
1602
+ const visualViewportBased = isWebKit();
1603
+ if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
1604
+ x = visualViewport.offsetLeft;
1605
+ y = visualViewport.offsetTop;
1606
+ }
1607
+ }
1608
+ return {
1609
+ width,
1610
+ height,
1611
+ x,
1612
+ y
1613
+ };
1614
+ }
1615
+ function getInnerBoundingClientRect(element, strategy) {
1616
+ const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
1617
+ const top = clientRect.top + element.clientTop;
1618
+ const left = clientRect.left + element.clientLeft;
1619
+ const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
1620
+ const width = element.clientWidth * scale.x;
1621
+ const height = element.clientHeight * scale.y;
1622
+ const x = left * scale.x;
1623
+ const y = top * scale.y;
1624
+ return {
1625
+ width,
1626
+ height,
1627
+ x,
1628
+ y
1629
+ };
1630
+ }
1631
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
1632
+ let rect;
1633
+ if (clippingAncestor === 'viewport') {
1634
+ rect = getViewportRect(element, strategy);
1635
+ } else if (clippingAncestor === 'document') {
1636
+ rect = getDocumentRect(getDocumentElement(element));
1637
+ } else if (isElement(clippingAncestor)) {
1638
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
1639
+ } else {
1640
+ const visualOffsets = getVisualOffsets(element);
1641
+ rect = {
1642
+ ...clippingAncestor,
1643
+ x: clippingAncestor.x - visualOffsets.x,
1644
+ y: clippingAncestor.y - visualOffsets.y
1645
+ };
1646
+ }
1647
+ return rectToClientRect(rect);
1648
+ }
1649
+ function hasFixedPositionAncestor(element, stopNode) {
1650
+ const parentNode = getParentNode(element);
1651
+ if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
1652
+ return false;
1653
+ }
1654
+ return getComputedStyle(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
1655
+ }
1656
+ function getClippingElementAncestors(element, cache) {
1657
+ const cachedResult = cache.get(element);
1658
+ if (cachedResult) {
1659
+ return cachedResult;
1660
+ }
1661
+ let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
1662
+ let currentContainingBlockComputedStyle = null;
1663
+ const elementIsFixed = getComputedStyle(element).position === 'fixed';
1664
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
1665
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
1666
+ const computedStyle = getComputedStyle(currentNode);
1667
+ const currentNodeIsContaining = isContainingBlock(currentNode);
1668
+ if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
1669
+ currentContainingBlockComputedStyle = null;
1670
+ }
1671
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && ['absolute', 'fixed'].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
1672
+ if (shouldDropCurrentNode) {
1673
+ result = result.filter(ancestor => ancestor !== currentNode);
1674
+ } else {
1675
+ currentContainingBlockComputedStyle = computedStyle;
1676
+ }
1677
+ currentNode = getParentNode(currentNode);
1678
+ }
1679
+ cache.set(element, result);
1680
+ return result;
1681
+ }
1682
+ function getClippingRect(_ref) {
1683
+ let {
1684
+ element,
1685
+ boundary,
1686
+ rootBoundary,
1687
+ strategy
1688
+ } = _ref;
1689
+ const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
1690
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
1691
+ const firstClippingAncestor = clippingAncestors[0];
1692
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1693
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1694
+ accRect.top = max(rect.top, accRect.top);
1695
+ accRect.right = min(rect.right, accRect.right);
1696
+ accRect.bottom = min(rect.bottom, accRect.bottom);
1697
+ accRect.left = max(rect.left, accRect.left);
1698
+ return accRect;
1699
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
1700
+ return {
1701
+ width: clippingRect.right - clippingRect.left,
1702
+ height: clippingRect.bottom - clippingRect.top,
1703
+ x: clippingRect.left,
1704
+ y: clippingRect.top
1705
+ };
1706
+ }
1707
+ function getDimensions(element) {
1708
+ const {
1709
+ width,
1710
+ height
1711
+ } = getCssDimensions(element);
1712
+ return {
1713
+ width,
1714
+ height
1715
+ };
1716
+ }
1717
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
1718
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1719
+ const documentElement = getDocumentElement(offsetParent);
1720
+ const isFixed = strategy === 'fixed';
1721
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
1722
+ let scroll = {
1723
+ scrollLeft: 0,
1724
+ scrollTop: 0
1725
+ };
1726
+ const offsets = createCoords(0);
1727
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1728
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1729
+ scroll = getNodeScroll(offsetParent);
1730
+ }
1731
+ if (isOffsetParentAnElement) {
1732
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
1733
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1734
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1735
+ } else if (documentElement) {
1736
+ offsets.x = getWindowScrollBarX(documentElement);
1737
+ }
1738
+ }
1739
+ const x = rect.left + scroll.scrollLeft - offsets.x;
1740
+ const y = rect.top + scroll.scrollTop - offsets.y;
1741
+ return {
1742
+ x,
1743
+ y,
1744
+ width: rect.width,
1745
+ height: rect.height
1746
+ };
1747
+ }
1748
+ function isStaticPositioned(element) {
1749
+ return getComputedStyle(element).position === 'static';
1750
+ }
1751
+ function getTrueOffsetParent(element, polyfill) {
1752
+ if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
1753
+ return null;
1754
+ }
1755
+ if (polyfill) {
1756
+ return polyfill(element);
1757
+ }
1758
+ return element.offsetParent;
1759
+ }
1760
+ function getOffsetParent(element, polyfill) {
1761
+ const win = getWindow(element);
1762
+ if (isTopLayer(element)) {
1763
+ return win;
1764
+ }
1765
+ if (!isHTMLElement(element)) {
1766
+ let svgOffsetParent = getParentNode(element);
1767
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
1768
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
1769
+ return svgOffsetParent;
1770
+ }
1771
+ svgOffsetParent = getParentNode(svgOffsetParent);
1772
+ }
1773
+ return win;
1774
+ }
1775
+ let offsetParent = getTrueOffsetParent(element, polyfill);
1776
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
1777
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
1778
+ }
1779
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
1780
+ return win;
1781
+ }
1782
+ return offsetParent || getContainingBlock(element) || win;
1783
+ }
1784
+ const getElementRects = async function (data) {
1785
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
1786
+ const getDimensionsFn = this.getDimensions;
1787
+ const floatingDimensions = await getDimensionsFn(data.floating);
1788
+ return {
1789
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
1790
+ floating: {
1791
+ x: 0,
1792
+ y: 0,
1793
+ width: floatingDimensions.width,
1794
+ height: floatingDimensions.height
1795
+ }
1796
+ };
1797
+ };
1798
+ function isRTL(element) {
1799
+ return getComputedStyle(element).direction === 'rtl';
1800
+ }
1801
+ const platform = {
1802
+ convertOffsetParentRelativeRectToViewportRelativeRect,
1803
+ getDocumentElement,
1804
+ getClippingRect,
1805
+ getOffsetParent,
1806
+ getElementRects,
1807
+ getClientRects,
1808
+ getDimensions,
1809
+ getScale,
1810
+ isElement,
1811
+ isRTL
1812
+ };
1813
+ function observeMove(element, onMove) {
1814
+ let io = null;
1815
+ let timeoutId;
1816
+ const root = getDocumentElement(element);
1817
+ function cleanup() {
1818
+ var _io;
1819
+ clearTimeout(timeoutId);
1820
+ (_io = io) == null || _io.disconnect();
1821
+ io = null;
1822
+ }
1823
+ function refresh(skip, threshold) {
1824
+ if (skip === void 0) {
1825
+ skip = false;
1826
+ }
1827
+ if (threshold === void 0) {
1828
+ threshold = 1;
1829
+ }
1830
+ cleanup();
1831
+ const {
1832
+ left,
1833
+ top,
1834
+ width,
1835
+ height
1836
+ } = element.getBoundingClientRect();
1837
+ if (!skip) {
1838
+ onMove();
1839
+ }
1840
+ if (!width || !height) {
1841
+ return;
1842
+ }
1843
+ const insetTop = floor(top);
1844
+ const insetRight = floor(root.clientWidth - (left + width));
1845
+ const insetBottom = floor(root.clientHeight - (top + height));
1846
+ const insetLeft = floor(left);
1847
+ const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
1848
+ const options = {
1849
+ rootMargin,
1850
+ threshold: max(0, min(1, threshold)) || 1
1851
+ };
1852
+ let isFirstUpdate = true;
1853
+ function handleObserve(entries) {
1854
+ const ratio = entries[0].intersectionRatio;
1855
+ if (ratio !== threshold) {
1856
+ if (!isFirstUpdate) {
1857
+ return refresh();
1858
+ }
1859
+ if (!ratio) {
1860
+ timeoutId = setTimeout(() => {
1861
+ refresh(false, 1e-7);
1862
+ }, 1000);
1863
+ } else {
1864
+ refresh(false, ratio);
1865
+ }
1866
+ }
1867
+ isFirstUpdate = false;
1868
+ }
1869
+ try {
1870
+ io = new IntersectionObserver(handleObserve, {
1871
+ ...options,
1872
+ root: root.ownerDocument
1873
+ });
1874
+ } catch (e) {
1875
+ io = new IntersectionObserver(handleObserve, options);
1876
+ }
1877
+ io.observe(element);
1878
+ }
1879
+ refresh(true);
1880
+ return cleanup;
1881
+ }
1882
+ function autoUpdate(reference, floating, update, options) {
1883
+ if (options === void 0) {
1884
+ options = {};
1885
+ }
1886
+ const {
1887
+ ancestorScroll = true,
1888
+ ancestorResize = true,
1889
+ elementResize = typeof ResizeObserver === 'function',
1890
+ layoutShift = typeof IntersectionObserver === 'function',
1891
+ animationFrame = false
1892
+ } = options;
1893
+ const referenceEl = unwrapElement(reference);
1894
+ const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
1895
+ ancestors.forEach(ancestor => {
1896
+ ancestorScroll && ancestor.addEventListener('scroll', update, {
1897
+ passive: true
1898
+ });
1899
+ ancestorResize && ancestor.addEventListener('resize', update);
1900
+ });
1901
+ const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
1902
+ let reobserveFrame = -1;
1903
+ let resizeObserver = null;
1904
+ if (elementResize) {
1905
+ resizeObserver = new ResizeObserver(_ref => {
1906
+ let [firstEntry] = _ref;
1907
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
1908
+ resizeObserver.unobserve(floating);
1909
+ cancelAnimationFrame(reobserveFrame);
1910
+ reobserveFrame = requestAnimationFrame(() => {
1911
+ var _resizeObserver;
1912
+ (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
1913
+ });
1914
+ }
1915
+ update();
1916
+ });
1917
+ if (referenceEl && !animationFrame) {
1918
+ resizeObserver.observe(referenceEl);
1919
+ }
1920
+ resizeObserver.observe(floating);
1921
+ }
1922
+ let frameId;
1923
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
1924
+ if (animationFrame) {
1925
+ frameLoop();
1926
+ }
1927
+ function frameLoop() {
1928
+ const nextRefRect = getBoundingClientRect(reference);
1929
+ if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
1930
+ update();
1931
+ }
1932
+ prevRefRect = nextRefRect;
1933
+ frameId = requestAnimationFrame(frameLoop);
1934
+ }
1935
+ update();
1936
+ return () => {
1937
+ var _resizeObserver2;
1938
+ ancestors.forEach(ancestor => {
1939
+ ancestorScroll && ancestor.removeEventListener('scroll', update);
1940
+ ancestorResize && ancestor.removeEventListener('resize', update);
1941
+ });
1942
+ cleanupIo == null || cleanupIo();
1943
+ (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
1944
+ resizeObserver = null;
1945
+ if (animationFrame) {
1946
+ cancelAnimationFrame(frameId);
1947
+ }
1948
+ };
1949
+ }
1950
+ const offset$1 = offset$2;
1951
+ const shift$1 = shift$2;
1952
+ const flip$1 = flip$2;
1953
+ const arrow$2 = arrow$3;
1954
+ const computePosition = (reference, floating, options) => {
1955
+ const cache = new Map();
1956
+ const mergedOptions = {
1957
+ platform,
1958
+ ...options
1959
+ };
1960
+ const platformWithCache = {
1961
+ ...mergedOptions.platform,
1962
+ _c: cache
1963
+ };
1964
+ return computePosition$1(reference, floating, {
1965
+ ...mergedOptions,
1966
+ platform: platformWithCache
1967
+ });
1968
+ };
1969
+
1970
+ var index$1 = typeof document !== 'undefined' ? React.useLayoutEffect : React.useEffect;
1971
+ function deepEqual(a, b) {
1972
+ if (a === b) {
1973
+ return true;
1974
+ }
1975
+ if (typeof a !== typeof b) {
1976
+ return false;
1977
+ }
1978
+ if (typeof a === 'function' && a.toString() === b.toString()) {
1979
+ return true;
1980
+ }
1981
+ let length;
1982
+ let i;
1983
+ let keys;
1984
+ if (a && b && typeof a === 'object') {
1985
+ if (Array.isArray(a)) {
1986
+ length = a.length;
1987
+ if (length !== b.length) return false;
1988
+ for (i = length; i-- !== 0;) {
1989
+ if (!deepEqual(a[i], b[i])) {
1990
+ return false;
1991
+ }
1992
+ }
1993
+ return true;
1994
+ }
1995
+ keys = Object.keys(a);
1996
+ length = keys.length;
1997
+ if (length !== Object.keys(b).length) {
1998
+ return false;
1999
+ }
2000
+ for (i = length; i-- !== 0;) {
2001
+ if (!{}.hasOwnProperty.call(b, keys[i])) {
2002
+ return false;
2003
+ }
2004
+ }
2005
+ for (i = length; i-- !== 0;) {
2006
+ const key = keys[i];
2007
+ if (key === '_owner' && a.$$typeof) {
2008
+ continue;
2009
+ }
2010
+ if (!deepEqual(a[key], b[key])) {
2011
+ return false;
2012
+ }
2013
+ }
2014
+ return true;
2015
+ }
2016
+ return a !== a && b !== b;
2017
+ }
2018
+ function getDPR(element) {
2019
+ if (typeof window === 'undefined') {
2020
+ return 1;
2021
+ }
2022
+ const win = element.ownerDocument.defaultView || window;
2023
+ return win.devicePixelRatio || 1;
2024
+ }
2025
+ function roundByDPR(element, value) {
2026
+ const dpr = getDPR(element);
2027
+ return Math.round(value * dpr) / dpr;
2028
+ }
2029
+ function useLatestRef$1(value) {
2030
+ const ref = React__namespace.useRef(value);
2031
+ index$1(() => {
2032
+ ref.current = value;
2033
+ });
2034
+ return ref;
2035
+ }
2036
+ function useFloating$1(options) {
2037
+ if (options === void 0) {
2038
+ options = {};
2039
+ }
2040
+ const {
2041
+ placement = 'bottom',
2042
+ strategy = 'absolute',
2043
+ middleware = [],
2044
+ platform,
2045
+ elements: {
2046
+ reference: externalReference,
2047
+ floating: externalFloating
2048
+ } = {},
2049
+ transform = true,
2050
+ whileElementsMounted,
2051
+ open
2052
+ } = options;
2053
+ const [data, setData] = React__namespace.useState({
2054
+ x: 0,
2055
+ y: 0,
2056
+ strategy,
2057
+ placement,
2058
+ middlewareData: {},
2059
+ isPositioned: false
2060
+ });
2061
+ const [latestMiddleware, setLatestMiddleware] = React__namespace.useState(middleware);
2062
+ if (!deepEqual(latestMiddleware, middleware)) {
2063
+ setLatestMiddleware(middleware);
2064
+ }
2065
+ const [_reference, _setReference] = React__namespace.useState(null);
2066
+ const [_floating, _setFloating] = React__namespace.useState(null);
2067
+ const setReference = React__namespace.useCallback(node => {
2068
+ if (node !== referenceRef.current) {
2069
+ referenceRef.current = node;
2070
+ _setReference(node);
2071
+ }
2072
+ }, []);
2073
+ const setFloating = React__namespace.useCallback(node => {
2074
+ if (node !== floatingRef.current) {
2075
+ floatingRef.current = node;
2076
+ _setFloating(node);
2077
+ }
2078
+ }, []);
2079
+ const referenceEl = externalReference || _reference;
2080
+ const floatingEl = externalFloating || _floating;
2081
+ const referenceRef = React__namespace.useRef(null);
2082
+ const floatingRef = React__namespace.useRef(null);
2083
+ const dataRef = React__namespace.useRef(data);
2084
+ const hasWhileElementsMounted = whileElementsMounted != null;
2085
+ const whileElementsMountedRef = useLatestRef$1(whileElementsMounted);
2086
+ const platformRef = useLatestRef$1(platform);
2087
+ const update = React__namespace.useCallback(() => {
2088
+ if (!referenceRef.current || !floatingRef.current) {
2089
+ return;
2090
+ }
2091
+ const config = {
2092
+ placement,
2093
+ strategy,
2094
+ middleware: latestMiddleware
2095
+ };
2096
+ if (platformRef.current) {
2097
+ config.platform = platformRef.current;
2098
+ }
2099
+ computePosition(referenceRef.current, floatingRef.current, config).then(data => {
2100
+ const fullData = {
2101
+ ...data,
2102
+ isPositioned: true
2103
+ };
2104
+ if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
2105
+ dataRef.current = fullData;
2106
+ ReactDOM__namespace.flushSync(() => {
2107
+ setData(fullData);
2108
+ });
2109
+ }
2110
+ });
2111
+ }, [latestMiddleware, placement, strategy, platformRef]);
2112
+ index$1(() => {
2113
+ if (open === false && dataRef.current.isPositioned) {
2114
+ dataRef.current.isPositioned = false;
2115
+ setData(data => ({
2116
+ ...data,
2117
+ isPositioned: false
2118
+ }));
2119
+ }
2120
+ }, [open]);
2121
+ const isMountedRef = React__namespace.useRef(false);
2122
+ index$1(() => {
2123
+ isMountedRef.current = true;
2124
+ return () => {
2125
+ isMountedRef.current = false;
2126
+ };
2127
+ }, []);
2128
+ index$1(() => {
2129
+ if (referenceEl) referenceRef.current = referenceEl;
2130
+ if (floatingEl) floatingRef.current = floatingEl;
2131
+ if (referenceEl && floatingEl) {
2132
+ if (whileElementsMountedRef.current) {
2133
+ return whileElementsMountedRef.current(referenceEl, floatingEl, update);
2134
+ }
2135
+ update();
2136
+ }
2137
+ }, [referenceEl, floatingEl, update, whileElementsMountedRef, hasWhileElementsMounted]);
2138
+ const refs = React__namespace.useMemo(() => ({
2139
+ reference: referenceRef,
2140
+ floating: floatingRef,
2141
+ setReference,
2142
+ setFloating
2143
+ }), [setReference, setFloating]);
2144
+ const elements = React__namespace.useMemo(() => ({
2145
+ reference: referenceEl,
2146
+ floating: floatingEl
2147
+ }), [referenceEl, floatingEl]);
2148
+ const floatingStyles = React__namespace.useMemo(() => {
2149
+ const initialStyles = {
2150
+ position: strategy,
2151
+ left: 0,
2152
+ top: 0
2153
+ };
2154
+ if (!elements.floating) {
2155
+ return initialStyles;
2156
+ }
2157
+ const x = roundByDPR(elements.floating, data.x);
2158
+ const y = roundByDPR(elements.floating, data.y);
2159
+ if (transform) {
2160
+ return {
2161
+ ...initialStyles,
2162
+ transform: "translate(" + x + "px, " + y + "px)",
2163
+ ...(getDPR(elements.floating) >= 1.5 && {
2164
+ willChange: 'transform'
2165
+ })
2166
+ };
2167
+ }
2168
+ return {
2169
+ position: strategy,
2170
+ left: x,
2171
+ top: y
2172
+ };
2173
+ }, [strategy, transform, elements.floating, data.x, data.y]);
2174
+ return React__namespace.useMemo(() => ({
2175
+ ...data,
2176
+ update,
2177
+ refs,
2178
+ elements,
2179
+ floatingStyles
2180
+ }), [data, update, refs, elements, floatingStyles]);
2181
+ }
2182
+ const arrow$1 = options => {
2183
+ function isRef(value) {
2184
+ return {}.hasOwnProperty.call(value, 'current');
2185
+ }
2186
+ return {
2187
+ name: 'arrow',
2188
+ options,
2189
+ fn(state) {
2190
+ const {
2191
+ element,
2192
+ padding
2193
+ } = typeof options === 'function' ? options(state) : options;
2194
+ if (element && isRef(element)) {
2195
+ if (element.current != null) {
2196
+ return arrow$2({
2197
+ element: element.current,
2198
+ padding
2199
+ }).fn(state);
2200
+ }
2201
+ return {};
2202
+ }
2203
+ if (element) {
2204
+ return arrow$2({
2205
+ element,
2206
+ padding
2207
+ }).fn(state);
2208
+ }
2209
+ return {};
2210
+ }
2211
+ };
2212
+ };
2213
+ const offset = (options, deps) => ({
2214
+ ...offset$1(options),
2215
+ options: [options, deps]
2216
+ });
2217
+ const shift = (options, deps) => ({
2218
+ ...shift$1(options),
2219
+ options: [options, deps]
2220
+ });
2221
+ const flip = (options, deps) => ({
2222
+ ...flip$1(options),
2223
+ options: [options, deps]
2224
+ });
2225
+ const arrow = (options, deps) => ({
2226
+ ...arrow$1(options),
2227
+ options: [options, deps]
2228
+ });
2229
+
2230
+ function useMergeRefs(refs) {
2231
+ return React__namespace.useMemo(() => {
2232
+ if (refs.every(ref => ref == null)) {
2233
+ return null;
2234
+ }
2235
+ return value => {
2236
+ refs.forEach(ref => {
2237
+ if (typeof ref === 'function') {
2238
+ ref(value);
2239
+ } else if (ref != null) {
2240
+ ref.current = value;
2241
+ }
2242
+ });
2243
+ };
2244
+ }, refs);
2245
+ }
2246
+ const SafeReact = {
2247
+ ...React__namespace
2248
+ };
2249
+ const useInsertionEffect = SafeReact.useInsertionEffect;
2250
+ const useSafeInsertionEffect = useInsertionEffect || (fn => fn());
2251
+ function useEffectEvent(callback) {
2252
+ const ref = React__namespace.useRef(() => {
2253
+ if (process.env.NODE_ENV !== "production") {
2254
+ throw new Error('Cannot call an event handler while rendering.');
2255
+ }
2256
+ });
2257
+ useSafeInsertionEffect(() => {
2258
+ ref.current = callback;
2259
+ });
2260
+ return React__namespace.useCallback(function () {
2261
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2262
+ args[_key] = arguments[_key];
2263
+ }
2264
+ return ref.current == null ? void 0 : ref.current(...args);
2265
+ }, []);
2266
+ }
2267
+ const ARROW_UP = 'ArrowUp';
2268
+ const ARROW_DOWN = 'ArrowDown';
2269
+ const ARROW_LEFT = 'ArrowLeft';
2270
+ const ARROW_RIGHT = 'ArrowRight';
2271
+ function isDifferentRow(index, cols, prevRow) {
2272
+ return Math.floor(index / cols) !== prevRow;
2273
+ }
2274
+ function isIndexOutOfBounds(listRef, index) {
2275
+ return index < 0 || index >= listRef.current.length;
2276
+ }
2277
+ function getMinIndex(listRef, disabledIndices) {
2278
+ return findNonDisabledIndex(listRef, {
2279
+ disabledIndices
2280
+ });
2281
+ }
2282
+ function getMaxIndex(listRef, disabledIndices) {
2283
+ return findNonDisabledIndex(listRef, {
2284
+ decrement: true,
2285
+ startingIndex: listRef.current.length,
2286
+ disabledIndices
2287
+ });
2288
+ }
2289
+ function findNonDisabledIndex(listRef, _temp) {
2290
+ let {
2291
+ startingIndex = -1,
2292
+ decrement = false,
2293
+ disabledIndices,
2294
+ amount = 1
2295
+ } = _temp === void 0 ? {} : _temp;
2296
+ const list = listRef.current;
2297
+ let index = startingIndex;
2298
+ do {
2299
+ index += decrement ? -amount : amount;
2300
+ } while (index >= 0 && index <= list.length - 1 && isDisabled(list, index, disabledIndices));
2301
+ return index;
2302
+ }
2303
+ function getGridNavigatedIndex(elementsRef, _ref) {
2304
+ let {
2305
+ event,
2306
+ orientation,
2307
+ loop,
2308
+ cols,
2309
+ disabledIndices,
2310
+ minIndex,
2311
+ maxIndex,
2312
+ prevIndex,
2313
+ stopEvent: stop = false
2314
+ } = _ref;
2315
+ let nextIndex = prevIndex;
2316
+ if (event.key === ARROW_UP) {
2317
+ stop && stopEvent(event);
2318
+ if (prevIndex === -1) {
2319
+ nextIndex = maxIndex;
2320
+ } else {
2321
+ nextIndex = findNonDisabledIndex(elementsRef, {
2322
+ startingIndex: nextIndex,
2323
+ amount: cols,
2324
+ decrement: true,
2325
+ disabledIndices
2326
+ });
2327
+ if (loop && (prevIndex - cols < minIndex || nextIndex < 0)) {
2328
+ const col = prevIndex % cols;
2329
+ const maxCol = maxIndex % cols;
2330
+ const offset = maxIndex - (maxCol - col);
2331
+ if (maxCol === col) {
2332
+ nextIndex = maxIndex;
2333
+ } else {
2334
+ nextIndex = maxCol > col ? offset : offset - cols;
2335
+ }
2336
+ }
2337
+ }
2338
+ if (isIndexOutOfBounds(elementsRef, nextIndex)) {
2339
+ nextIndex = prevIndex;
2340
+ }
2341
+ }
2342
+ if (event.key === ARROW_DOWN) {
2343
+ stop && stopEvent(event);
2344
+ if (prevIndex === -1) {
2345
+ nextIndex = minIndex;
2346
+ } else {
2347
+ nextIndex = findNonDisabledIndex(elementsRef, {
2348
+ startingIndex: prevIndex,
2349
+ amount: cols,
2350
+ disabledIndices
2351
+ });
2352
+ if (loop && prevIndex + cols > maxIndex) {
2353
+ nextIndex = findNonDisabledIndex(elementsRef, {
2354
+ startingIndex: prevIndex % cols - cols,
2355
+ amount: cols,
2356
+ disabledIndices
2357
+ });
2358
+ }
2359
+ }
2360
+ if (isIndexOutOfBounds(elementsRef, nextIndex)) {
2361
+ nextIndex = prevIndex;
2362
+ }
2363
+ }
2364
+ if (orientation === 'both') {
2365
+ const prevRow = floor(prevIndex / cols);
2366
+ if (event.key === ARROW_RIGHT) {
2367
+ stop && stopEvent(event);
2368
+ if (prevIndex % cols !== cols - 1) {
2369
+ nextIndex = findNonDisabledIndex(elementsRef, {
2370
+ startingIndex: prevIndex,
2371
+ disabledIndices
2372
+ });
2373
+ if (loop && isDifferentRow(nextIndex, cols, prevRow)) {
2374
+ nextIndex = findNonDisabledIndex(elementsRef, {
2375
+ startingIndex: prevIndex - prevIndex % cols - 1,
2376
+ disabledIndices
2377
+ });
2378
+ }
2379
+ } else if (loop) {
2380
+ nextIndex = findNonDisabledIndex(elementsRef, {
2381
+ startingIndex: prevIndex - prevIndex % cols - 1,
2382
+ disabledIndices
2383
+ });
2384
+ }
2385
+ if (isDifferentRow(nextIndex, cols, prevRow)) {
2386
+ nextIndex = prevIndex;
2387
+ }
2388
+ }
2389
+ if (event.key === ARROW_LEFT) {
2390
+ stop && stopEvent(event);
2391
+ if (prevIndex % cols !== 0) {
2392
+ nextIndex = findNonDisabledIndex(elementsRef, {
2393
+ startingIndex: prevIndex,
2394
+ decrement: true,
2395
+ disabledIndices
2396
+ });
2397
+ if (loop && isDifferentRow(nextIndex, cols, prevRow)) {
2398
+ nextIndex = findNonDisabledIndex(elementsRef, {
2399
+ startingIndex: prevIndex + (cols - prevIndex % cols),
2400
+ decrement: true,
2401
+ disabledIndices
2402
+ });
2403
+ }
2404
+ } else if (loop) {
2405
+ nextIndex = findNonDisabledIndex(elementsRef, {
2406
+ startingIndex: prevIndex + (cols - prevIndex % cols),
2407
+ decrement: true,
2408
+ disabledIndices
2409
+ });
2410
+ }
2411
+ if (isDifferentRow(nextIndex, cols, prevRow)) {
2412
+ nextIndex = prevIndex;
2413
+ }
2414
+ }
2415
+ const lastRow = floor(maxIndex / cols) === prevRow;
2416
+ if (isIndexOutOfBounds(elementsRef, nextIndex)) {
2417
+ if (loop && lastRow) {
2418
+ nextIndex = event.key === ARROW_LEFT ? maxIndex : findNonDisabledIndex(elementsRef, {
2419
+ startingIndex: prevIndex - prevIndex % cols - 1,
2420
+ disabledIndices
2421
+ });
2422
+ } else {
2423
+ nextIndex = prevIndex;
2424
+ }
2425
+ }
2426
+ }
2427
+ return nextIndex;
2428
+ }
2429
+ function buildCellMap(sizes, cols, dense) {
2430
+ const cellMap = [];
2431
+ let startIndex = 0;
2432
+ sizes.forEach((_ref2, index) => {
2433
+ let {
2434
+ width,
2435
+ height
2436
+ } = _ref2;
2437
+ if (width > cols) {
2438
+ if (process.env.NODE_ENV !== "production") {
2439
+ throw new Error("[Floating UI]: Invalid grid - item width at index " + index + " is greater than grid columns");
2440
+ }
2441
+ }
2442
+ let itemPlaced = false;
2443
+ if (dense) {
2444
+ startIndex = 0;
2445
+ }
2446
+ while (!itemPlaced) {
2447
+ const targetCells = [];
2448
+ for (let i = 0; i < width; i++) {
2449
+ for (let j = 0; j < height; j++) {
2450
+ targetCells.push(startIndex + i + j * cols);
2451
+ }
2452
+ }
2453
+ if (startIndex % cols + width <= cols && targetCells.every(cell => cellMap[cell] == null)) {
2454
+ targetCells.forEach(cell => {
2455
+ cellMap[cell] = index;
2456
+ });
2457
+ itemPlaced = true;
2458
+ } else {
2459
+ startIndex++;
2460
+ }
2461
+ }
2462
+ });
2463
+ return [...cellMap];
2464
+ }
2465
+ function getCellIndexOfCorner(index, sizes, cellMap, cols, corner) {
2466
+ if (index === -1) return -1;
2467
+ const firstCellIndex = cellMap.indexOf(index);
2468
+ const sizeItem = sizes[index];
2469
+ switch (corner) {
2470
+ case 'tl':
2471
+ return firstCellIndex;
2472
+ case 'tr':
2473
+ if (!sizeItem) {
2474
+ return firstCellIndex;
2475
+ }
2476
+ return firstCellIndex + sizeItem.width - 1;
2477
+ case 'bl':
2478
+ if (!sizeItem) {
2479
+ return firstCellIndex;
2480
+ }
2481
+ return firstCellIndex + (sizeItem.height - 1) * cols;
2482
+ case 'br':
2483
+ return cellMap.lastIndexOf(index);
2484
+ }
2485
+ }
2486
+ function getCellIndices(indices, cellMap) {
2487
+ return cellMap.flatMap((index, cellIndex) => indices.includes(index) ? [cellIndex] : []);
2488
+ }
2489
+ function isDisabled(list, index, disabledIndices) {
2490
+ if (disabledIndices) {
2491
+ return disabledIndices.includes(index);
2492
+ }
2493
+ const element = list[index];
2494
+ return element == null || element.hasAttribute('disabled') || element.getAttribute('aria-disabled') === 'true';
2495
+ }
2496
+ let rafId = 0;
2497
+ function enqueueFocus(el, options) {
2498
+ if (options === void 0) {
2499
+ options = {};
2500
+ }
2501
+ const {
2502
+ preventScroll = false,
2503
+ cancelPrevious = true,
2504
+ sync = false
2505
+ } = options;
2506
+ cancelPrevious && cancelAnimationFrame(rafId);
2507
+ const exec = () => el == null ? void 0 : el.focus({
2508
+ preventScroll
2509
+ });
2510
+ if (sync) {
2511
+ exec();
2512
+ } else {
2513
+ rafId = requestAnimationFrame(exec);
2514
+ }
2515
+ }
2516
+ var index = typeof document !== 'undefined' ? React.useLayoutEffect : React.useEffect;
2517
+ function sortByDocumentPosition(a, b) {
2518
+ const position = a.compareDocumentPosition(b);
2519
+ if (position & Node.DOCUMENT_POSITION_FOLLOWING || position & Node.DOCUMENT_POSITION_CONTAINED_BY) {
2520
+ return -1;
2521
+ }
2522
+ if (position & Node.DOCUMENT_POSITION_PRECEDING || position & Node.DOCUMENT_POSITION_CONTAINS) {
2523
+ return 1;
2524
+ }
2525
+ return 0;
2526
+ }
2527
+ function areMapsEqual(map1, map2) {
2528
+ if (map1.size !== map2.size) {
2529
+ return false;
2530
+ }
2531
+ for (const [key, value] of map1.entries()) {
2532
+ if (value !== map2.get(key)) {
2533
+ return false;
2534
+ }
2535
+ }
2536
+ return true;
2537
+ }
2538
+ const FloatingListContext = React__namespace.createContext({
2539
+ register: () => {},
2540
+ unregister: () => {},
2541
+ map: new Map(),
2542
+ elementsRef: {
2543
+ current: []
2544
+ }
2545
+ });
2546
+ function FloatingList(props) {
2547
+ const {
2548
+ children,
2549
+ elementsRef,
2550
+ labelsRef
2551
+ } = props;
2552
+ const [map, setMap] = React__namespace.useState(() => new Map());
2553
+ const register = React__namespace.useCallback(node => {
2554
+ setMap(prevMap => new Map(prevMap).set(node, null));
2555
+ }, []);
2556
+ const unregister = React__namespace.useCallback(node => {
2557
+ setMap(prevMap => {
2558
+ const map = new Map(prevMap);
2559
+ map.delete(node);
2560
+ return map;
2561
+ });
2562
+ }, []);
2563
+ index(() => {
2564
+ const newMap = new Map(map);
2565
+ const nodes = Array.from(newMap.keys()).sort(sortByDocumentPosition);
2566
+ nodes.forEach((node, index) => {
2567
+ newMap.set(node, index);
2568
+ });
2569
+ if (!areMapsEqual(map, newMap)) {
2570
+ setMap(newMap);
2571
+ }
2572
+ }, [map]);
2573
+ return React__namespace.createElement(FloatingListContext.Provider, {
2574
+ value: React__namespace.useMemo(() => ({
2575
+ register,
2576
+ unregister,
2577
+ map,
2578
+ elementsRef,
2579
+ labelsRef
2580
+ }), [register, unregister, map, elementsRef, labelsRef])
2581
+ }, children);
2582
+ }
2583
+ function useListItem(props) {
2584
+ if (props === void 0) {
2585
+ props = {};
2586
+ }
2587
+ const {
2588
+ label
2589
+ } = props;
2590
+ const {
2591
+ register,
2592
+ unregister,
2593
+ map,
2594
+ elementsRef,
2595
+ labelsRef
2596
+ } = React__namespace.useContext(FloatingListContext);
2597
+ const [index$1, setIndex] = React__namespace.useState(null);
2598
+ const componentRef = React__namespace.useRef(null);
2599
+ const ref = React__namespace.useCallback(node => {
2600
+ componentRef.current = node;
2601
+ if (index$1 !== null) {
2602
+ elementsRef.current[index$1] = node;
2603
+ if (labelsRef) {
2604
+ var _node$textContent;
2605
+ const isLabelDefined = label !== undefined;
2606
+ labelsRef.current[index$1] = isLabelDefined ? label : (_node$textContent = node == null ? void 0 : node.textContent) != null ? _node$textContent : null;
2607
+ }
2608
+ }
2609
+ }, [index$1, elementsRef, labelsRef, label]);
2610
+ index(() => {
2611
+ const node = componentRef.current;
2612
+ if (node) {
2613
+ register(node);
2614
+ return () => {
2615
+ unregister(node);
2616
+ };
2617
+ }
2618
+ }, [register, unregister]);
2619
+ index(() => {
2620
+ const index = componentRef.current ? map.get(componentRef.current) : null;
2621
+ if (index != null) {
2622
+ setIndex(index);
2623
+ }
2624
+ }, [map]);
2625
+ return React__namespace.useMemo(() => ({
2626
+ ref,
2627
+ index: index$1 == null ? -1 : index$1
2628
+ }), [index$1, ref]);
2629
+ }
2630
+ function renderJsx(render, computedProps) {
2631
+ if (typeof render === 'function') {
2632
+ return render(computedProps);
2633
+ }
2634
+ if (render) {
2635
+ return React__namespace.cloneElement(render, computedProps);
2636
+ }
2637
+ return React__namespace.createElement("div", computedProps);
2638
+ }
2639
+ const CompositeContext = React__namespace.createContext({
2640
+ activeIndex: 0,
2641
+ onNavigate: () => {}
2642
+ });
2643
+ const horizontalKeys = [ARROW_LEFT, ARROW_RIGHT];
2644
+ const verticalKeys = [ARROW_UP, ARROW_DOWN];
2645
+ const allKeys = [...horizontalKeys, ...verticalKeys];
2646
+ React__namespace.forwardRef(function Composite(props, forwardedRef) {
2647
+ const {
2648
+ render,
2649
+ orientation = 'both',
2650
+ loop = true,
2651
+ cols = 1,
2652
+ disabledIndices,
2653
+ activeIndex: externalActiveIndex,
2654
+ onNavigate: externalSetActiveIndex,
2655
+ itemSizes,
2656
+ dense = false,
2657
+ ...domProps
2658
+ } = props;
2659
+ const [internalActiveIndex, internalSetActiveIndex] = React__namespace.useState(0);
2660
+ const activeIndex = externalActiveIndex != null ? externalActiveIndex : internalActiveIndex;
2661
+ const onNavigate = useEffectEvent(externalSetActiveIndex != null ? externalSetActiveIndex : internalSetActiveIndex);
2662
+ const elementsRef = React__namespace.useRef([]);
2663
+ const renderElementProps = render && typeof render !== 'function' ? render.props : {};
2664
+ const contextValue = React__namespace.useMemo(() => ({
2665
+ activeIndex,
2666
+ onNavigate
2667
+ }), [activeIndex, onNavigate]);
2668
+ const isGrid = cols > 1;
2669
+ function handleKeyDown(event) {
2670
+ if (!allKeys.includes(event.key)) return;
2671
+ let nextIndex = activeIndex;
2672
+ const minIndex = getMinIndex(elementsRef, disabledIndices);
2673
+ const maxIndex = getMaxIndex(elementsRef, disabledIndices);
2674
+ if (isGrid) {
2675
+ const sizes = itemSizes || Array.from({
2676
+ length: elementsRef.current.length
2677
+ }, () => ({
2678
+ width: 1,
2679
+ height: 1
2680
+ }));
2681
+ const cellMap = buildCellMap(sizes, cols, dense);
2682
+ const minGridIndex = cellMap.findIndex(index => index != null && !isDisabled(elementsRef.current, index, disabledIndices));
2683
+ const maxGridIndex = cellMap.reduce((foundIndex, index, cellIndex) => index != null && !isDisabled(elementsRef.current, index, disabledIndices) ? cellIndex : foundIndex, -1);
2684
+ nextIndex = cellMap[getGridNavigatedIndex({
2685
+ current: cellMap.map(itemIndex => itemIndex ? elementsRef.current[itemIndex] : null)
2686
+ }, {
2687
+ event,
2688
+ orientation,
2689
+ loop,
2690
+ cols,
2691
+ disabledIndices: getCellIndices([...(disabledIndices || elementsRef.current.map((_, index) => isDisabled(elementsRef.current, index) ? index : undefined)), undefined], cellMap),
2692
+ minIndex: minGridIndex,
2693
+ maxIndex: maxGridIndex,
2694
+ prevIndex: getCellIndexOfCorner(activeIndex > maxIndex ? minIndex : activeIndex, sizes, cellMap, cols,
2695
+ event.key === ARROW_DOWN ? 'bl' : event.key === ARROW_RIGHT ? 'tr' : 'tl')
2696
+ })];
2697
+ }
2698
+ const toEndKeys = {
2699
+ horizontal: [ARROW_RIGHT],
2700
+ vertical: [ARROW_DOWN],
2701
+ both: [ARROW_RIGHT, ARROW_DOWN]
2702
+ }[orientation];
2703
+ const toStartKeys = {
2704
+ horizontal: [ARROW_LEFT],
2705
+ vertical: [ARROW_UP],
2706
+ both: [ARROW_LEFT, ARROW_UP]
2707
+ }[orientation];
2708
+ const preventedKeys = isGrid ? allKeys : {
2709
+ horizontal: horizontalKeys,
2710
+ vertical: verticalKeys,
2711
+ both: allKeys
2712
+ }[orientation];
2713
+ if (nextIndex === activeIndex && [...toEndKeys, ...toStartKeys].includes(event.key)) {
2714
+ if (loop && nextIndex === maxIndex && toEndKeys.includes(event.key)) {
2715
+ nextIndex = minIndex;
2716
+ } else if (loop && nextIndex === minIndex && toStartKeys.includes(event.key)) {
2717
+ nextIndex = maxIndex;
2718
+ } else {
2719
+ nextIndex = findNonDisabledIndex(elementsRef, {
2720
+ startingIndex: nextIndex,
2721
+ decrement: toStartKeys.includes(event.key),
2722
+ disabledIndices
2723
+ });
2724
+ }
2725
+ }
2726
+ if (nextIndex !== activeIndex && !isIndexOutOfBounds(elementsRef, nextIndex)) {
2727
+ event.stopPropagation();
2728
+ if (preventedKeys.includes(event.key)) {
2729
+ event.preventDefault();
2730
+ }
2731
+ onNavigate(nextIndex);
2732
+ queueMicrotask(() => {
2733
+ enqueueFocus(elementsRef.current[nextIndex]);
2734
+ });
2735
+ }
2736
+ }
2737
+ const computedProps = {
2738
+ ...domProps,
2739
+ ...renderElementProps,
2740
+ ref: forwardedRef,
2741
+ 'aria-orientation': orientation === 'both' ? undefined : orientation,
2742
+ onKeyDown(e) {
2743
+ domProps.onKeyDown == null || domProps.onKeyDown(e);
2744
+ renderElementProps.onKeyDown == null || renderElementProps.onKeyDown(e);
2745
+ handleKeyDown(e);
2746
+ }
2747
+ };
2748
+ return React__namespace.createElement(CompositeContext.Provider, {
2749
+ value: contextValue
2750
+ }, React__namespace.createElement(FloatingList, {
2751
+ elementsRef: elementsRef
2752
+ }, renderJsx(render, computedProps)));
2753
+ });
2754
+ React__namespace.forwardRef(function CompositeItem(props, forwardedRef) {
2755
+ const {
2756
+ render,
2757
+ ...domProps
2758
+ } = props;
2759
+ const renderElementProps = render && typeof render !== 'function' ? render.props : {};
2760
+ const {
2761
+ activeIndex,
2762
+ onNavigate
2763
+ } = React__namespace.useContext(CompositeContext);
2764
+ const {
2765
+ ref,
2766
+ index
2767
+ } = useListItem();
2768
+ const mergedRef = useMergeRefs([ref, forwardedRef, renderElementProps.ref]);
2769
+ const isActive = activeIndex === index;
2770
+ const computedProps = {
2771
+ ...domProps,
2772
+ ...renderElementProps,
2773
+ ref: mergedRef,
2774
+ tabIndex: isActive ? 0 : -1,
2775
+ 'data-active': isActive ? '' : undefined,
2776
+ onFocus(e) {
2777
+ domProps.onFocus == null || domProps.onFocus(e);
2778
+ renderElementProps.onFocus == null || renderElementProps.onFocus(e);
2779
+ onNavigate(index);
2780
+ }
2781
+ };
2782
+ return renderJsx(render, computedProps);
2783
+ });
2784
+ function _extends() {
2785
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
2786
+ for (var i = 1; i < arguments.length; i++) {
2787
+ var source = arguments[i];
2788
+ for (var key in source) {
2789
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
2790
+ target[key] = source[key];
2791
+ }
2792
+ }
2793
+ }
2794
+ return target;
2795
+ };
2796
+ return _extends.apply(this, arguments);
2797
+ }
2798
+ let serverHandoffComplete = false;
2799
+ let count = 0;
2800
+ const genId = () =>
2801
+ "floating-ui-" + Math.random().toString(36).slice(2, 6) + count++;
2802
+ function useFloatingId() {
2803
+ const [id, setId] = React__namespace.useState(() => serverHandoffComplete ? genId() : undefined);
2804
+ index(() => {
2805
+ if (id == null) {
2806
+ setId(genId());
2807
+ }
2808
+ }, []);
2809
+ React__namespace.useEffect(() => {
2810
+ serverHandoffComplete = true;
2811
+ }, []);
2812
+ return id;
2813
+ }
2814
+ const useReactId = SafeReact.useId;
2815
+ const useId = useReactId || useFloatingId;
2816
+ let devMessageSet;
2817
+ if (process.env.NODE_ENV !== "production") {
2818
+ devMessageSet = new Set();
2819
+ }
2820
+ function warn() {
2821
+ var _devMessageSet;
2822
+ for (var _len = arguments.length, messages = new Array(_len), _key = 0; _key < _len; _key++) {
2823
+ messages[_key] = arguments[_key];
2824
+ }
2825
+ const message = "Floating UI: " + messages.join(' ');
2826
+ if (!((_devMessageSet = devMessageSet) != null && _devMessageSet.has(message))) {
2827
+ var _devMessageSet2;
2828
+ (_devMessageSet2 = devMessageSet) == null || _devMessageSet2.add(message);
2829
+ console.warn(message);
2830
+ }
2831
+ }
2832
+ function error$1() {
2833
+ var _devMessageSet3;
2834
+ for (var _len2 = arguments.length, messages = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
2835
+ messages[_key2] = arguments[_key2];
2836
+ }
2837
+ const message = "Floating UI: " + messages.join(' ');
2838
+ if (!((_devMessageSet3 = devMessageSet) != null && _devMessageSet3.has(message))) {
2839
+ var _devMessageSet4;
2840
+ (_devMessageSet4 = devMessageSet) == null || _devMessageSet4.add(message);
2841
+ console.error(message);
2842
+ }
2843
+ }
2844
+ const FloatingArrow = React__namespace.forwardRef(function FloatingArrow(props, ref) {
2845
+ const {
2846
+ context: {
2847
+ placement,
2848
+ elements: {
2849
+ floating
2850
+ },
2851
+ middlewareData: {
2852
+ arrow
2853
+ }
2854
+ },
2855
+ width = 14,
2856
+ height = 7,
2857
+ tipRadius = 0,
2858
+ strokeWidth = 0,
2859
+ staticOffset,
2860
+ stroke,
2861
+ d,
2862
+ style: {
2863
+ transform,
2864
+ ...restStyle
2865
+ } = {},
2866
+ ...rest
2867
+ } = props;
2868
+ if (process.env.NODE_ENV !== "production") {
2869
+ if (!ref) {
2870
+ warn('The `ref` prop is required for `FloatingArrow`.');
2871
+ }
2872
+ }
2873
+ const clipPathId = useId();
2874
+ if (!floating) {
2875
+ return null;
2876
+ }
2877
+ const computedStrokeWidth = strokeWidth * 2;
2878
+ const halfStrokeWidth = computedStrokeWidth / 2;
2879
+ const svgX = width / 2 * (tipRadius / -8 + 1);
2880
+ const svgY = height / 2 * tipRadius / 4;
2881
+ const [side, alignment] = placement.split('-');
2882
+ const isRTL = platform.isRTL(floating);
2883
+ const isCustomShape = !!d;
2884
+ const isVerticalSide = side === 'top' || side === 'bottom';
2885
+ const yOffsetProp = staticOffset && alignment === 'end' ? 'bottom' : 'top';
2886
+ let xOffsetProp = staticOffset && alignment === 'end' ? 'right' : 'left';
2887
+ if (staticOffset && isRTL) {
2888
+ xOffsetProp = alignment === 'end' ? 'left' : 'right';
2889
+ }
2890
+ const arrowX = (arrow == null ? void 0 : arrow.x) != null ? staticOffset || arrow.x : '';
2891
+ const arrowY = (arrow == null ? void 0 : arrow.y) != null ? staticOffset || arrow.y : '';
2892
+ const dValue = d || 'M0,0' + (" H" + width) + (" L" + (width - svgX) + "," + (height - svgY)) + (" Q" + width / 2 + "," + height + " " + svgX + "," + (height - svgY)) + ' Z';
2893
+ const rotation = {
2894
+ top: isCustomShape ? 'rotate(180deg)' : '',
2895
+ left: isCustomShape ? 'rotate(90deg)' : 'rotate(-90deg)',
2896
+ bottom: isCustomShape ? '' : 'rotate(180deg)',
2897
+ right: isCustomShape ? 'rotate(-90deg)' : 'rotate(90deg)'
2898
+ }[side];
2899
+ return React__namespace.createElement("svg", _extends({}, rest, {
2900
+ "aria-hidden": true,
2901
+ ref: ref,
2902
+ width: isCustomShape ? width : width + computedStrokeWidth,
2903
+ height: width,
2904
+ viewBox: "0 0 " + width + " " + (height > width ? height : width),
2905
+ style: {
2906
+ position: 'absolute',
2907
+ pointerEvents: 'none',
2908
+ [xOffsetProp]: arrowX,
2909
+ [yOffsetProp]: arrowY,
2910
+ [side]: isVerticalSide || isCustomShape ? '100%' : "calc(100% - " + computedStrokeWidth / 2 + "px)",
2911
+ transform: "" + rotation + (transform != null ? transform : ''),
2912
+ ...restStyle
2913
+ }
2914
+ }), computedStrokeWidth > 0 && React__namespace.createElement("path", {
2915
+ clipPath: "url(#" + clipPathId + ")",
2916
+ fill: "none",
2917
+ stroke: stroke
2918
+ ,
2919
+ strokeWidth: computedStrokeWidth + (d ? 0 : 1),
2920
+ d: dValue
2921
+ }), React__namespace.createElement("path", {
2922
+ stroke: computedStrokeWidth && !d ? rest.fill : 'none',
2923
+ d: dValue
2924
+ }), React__namespace.createElement("clipPath", {
2925
+ id: clipPathId
2926
+ }, React__namespace.createElement("rect", {
2927
+ x: -halfStrokeWidth,
2928
+ y: halfStrokeWidth * (isCustomShape ? -1 : 1),
2929
+ width: width + computedStrokeWidth,
2930
+ height: width
2931
+ })));
2932
+ });
2933
+ function createPubSub() {
2934
+ const map = new Map();
2935
+ return {
2936
+ emit(event, data) {
2937
+ var _map$get;
2938
+ (_map$get = map.get(event)) == null || _map$get.forEach(handler => handler(data));
2939
+ },
2940
+ on(event, listener) {
2941
+ map.set(event, [...(map.get(event) || []), listener]);
2942
+ },
2943
+ off(event, listener) {
2944
+ var _map$get2;
2945
+ map.set(event, ((_map$get2 = map.get(event)) == null ? void 0 : _map$get2.filter(l => l !== listener)) || []);
2946
+ }
2947
+ };
2948
+ }
2949
+ const FloatingNodeContext = React__namespace.createContext(null);
2950
+ const FloatingTreeContext = React__namespace.createContext(null);
2951
+ const useFloatingParentNodeId = () => {
2952
+ var _React$useContext;
2953
+ return ((_React$useContext = React__namespace.useContext(FloatingNodeContext)) == null ? void 0 : _React$useContext.id) || null;
2954
+ };
2955
+ const useFloatingTree = () => React__namespace.useContext(FloatingTreeContext);
2956
+ function createAttribute(name) {
2957
+ return "data-floating-ui-" + name;
2958
+ }
2959
+ function useLatestRef(value) {
2960
+ const ref = React.useRef(value);
2961
+ index(() => {
2962
+ ref.current = value;
2963
+ });
2964
+ return ref;
2965
+ }
2966
+ const safePolygonIdentifier = createAttribute('safe-polygon');
2967
+ function getDelay(value, prop, pointerType) {
2968
+ if (pointerType && !isMouseLikePointerType(pointerType)) {
2969
+ return 0;
2970
+ }
2971
+ if (typeof value === 'number') {
2972
+ return value;
2973
+ }
2974
+ return value == null ? void 0 : value[prop];
2975
+ }
2976
+ function useHover(context, props) {
2977
+ if (props === void 0) {
2978
+ props = {};
2979
+ }
2980
+ const {
2981
+ open,
2982
+ onOpenChange,
2983
+ dataRef,
2984
+ events,
2985
+ elements: {
2986
+ domReference,
2987
+ floating
2988
+ }
2989
+ } = context;
2990
+ const {
2991
+ enabled = true,
2992
+ delay = 0,
2993
+ handleClose = null,
2994
+ mouseOnly = false,
2995
+ restMs = 0,
2996
+ move = true
2997
+ } = props;
2998
+ const tree = useFloatingTree();
2999
+ const parentId = useFloatingParentNodeId();
3000
+ const handleCloseRef = useLatestRef(handleClose);
3001
+ const delayRef = useLatestRef(delay);
3002
+ const pointerTypeRef = React__namespace.useRef();
3003
+ const timeoutRef = React__namespace.useRef(-1);
3004
+ const handlerRef = React__namespace.useRef();
3005
+ const restTimeoutRef = React__namespace.useRef(-1);
3006
+ const blockMouseMoveRef = React__namespace.useRef(true);
3007
+ const performedPointerEventsMutationRef = React__namespace.useRef(false);
3008
+ const unbindMouseMoveRef = React__namespace.useRef(() => {});
3009
+ const isHoverOpen = React__namespace.useCallback(() => {
3010
+ var _dataRef$current$open;
3011
+ const type = (_dataRef$current$open = dataRef.current.openEvent) == null ? void 0 : _dataRef$current$open.type;
3012
+ return (type == null ? void 0 : type.includes('mouse')) && type !== 'mousedown';
3013
+ }, [dataRef]);
3014
+ React__namespace.useEffect(() => {
3015
+ if (!enabled) {
3016
+ return;
3017
+ }
3018
+ function onOpenChange(_ref) {
3019
+ let {
3020
+ open
3021
+ } = _ref;
3022
+ if (!open) {
3023
+ clearTimeout(timeoutRef.current);
3024
+ clearTimeout(restTimeoutRef.current);
3025
+ blockMouseMoveRef.current = true;
3026
+ }
3027
+ }
3028
+ events.on('openchange', onOpenChange);
3029
+ return () => {
3030
+ events.off('openchange', onOpenChange);
3031
+ };
3032
+ }, [enabled, events]);
3033
+ React__namespace.useEffect(() => {
3034
+ if (!enabled || !handleCloseRef.current || !open) {
3035
+ return;
3036
+ }
3037
+ function onLeave(event) {
3038
+ if (isHoverOpen()) {
3039
+ onOpenChange(false, event, 'hover');
3040
+ }
3041
+ }
3042
+ const html = getDocument(floating).documentElement;
3043
+ html.addEventListener('mouseleave', onLeave);
3044
+ return () => {
3045
+ html.removeEventListener('mouseleave', onLeave);
3046
+ };
3047
+ }, [floating, open, onOpenChange, enabled, handleCloseRef, isHoverOpen]);
3048
+ const closeWithDelay = React__namespace.useCallback(function (event, runElseBranch, reason) {
3049
+ if (runElseBranch === void 0) {
3050
+ runElseBranch = true;
3051
+ }
3052
+ if (reason === void 0) {
3053
+ reason = 'hover';
3054
+ }
3055
+ const closeDelay = getDelay(delayRef.current, 'close', pointerTypeRef.current);
3056
+ if (closeDelay && !handlerRef.current) {
3057
+ clearTimeout(timeoutRef.current);
3058
+ timeoutRef.current = window.setTimeout(() => onOpenChange(false, event, reason), closeDelay);
3059
+ } else if (runElseBranch) {
3060
+ clearTimeout(timeoutRef.current);
3061
+ onOpenChange(false, event, reason);
3062
+ }
3063
+ }, [delayRef, onOpenChange]);
3064
+ const cleanupMouseMoveHandler = useEffectEvent(() => {
3065
+ unbindMouseMoveRef.current();
3066
+ handlerRef.current = undefined;
3067
+ });
3068
+ const clearPointerEvents = useEffectEvent(() => {
3069
+ if (performedPointerEventsMutationRef.current) {
3070
+ const body = getDocument(floating).body;
3071
+ body.style.pointerEvents = '';
3072
+ body.removeAttribute(safePolygonIdentifier);
3073
+ performedPointerEventsMutationRef.current = false;
3074
+ }
3075
+ });
3076
+ React__namespace.useEffect(() => {
3077
+ if (!enabled) {
3078
+ return;
3079
+ }
3080
+ function isClickLikeOpenEvent() {
3081
+ return dataRef.current.openEvent ? ['click', 'mousedown'].includes(dataRef.current.openEvent.type) : false;
3082
+ }
3083
+ function onMouseEnter(event) {
3084
+ clearTimeout(timeoutRef.current);
3085
+ blockMouseMoveRef.current = false;
3086
+ if (mouseOnly && !isMouseLikePointerType(pointerTypeRef.current) || restMs > 0 && !getDelay(delayRef.current, 'open')) {
3087
+ return;
3088
+ }
3089
+ const openDelay = getDelay(delayRef.current, 'open', pointerTypeRef.current);
3090
+ if (openDelay) {
3091
+ timeoutRef.current = window.setTimeout(() => {
3092
+ onOpenChange(true, event, 'hover');
3093
+ }, openDelay);
3094
+ } else {
3095
+ onOpenChange(true, event, 'hover');
3096
+ }
3097
+ }
3098
+ function onMouseLeave(event) {
3099
+ if (isClickLikeOpenEvent()) return;
3100
+ unbindMouseMoveRef.current();
3101
+ const doc = getDocument(floating);
3102
+ clearTimeout(restTimeoutRef.current);
3103
+ if (handleCloseRef.current && dataRef.current.floatingContext) {
3104
+ if (!open) {
3105
+ clearTimeout(timeoutRef.current);
3106
+ }
3107
+ handlerRef.current = handleCloseRef.current({
3108
+ ...dataRef.current.floatingContext,
3109
+ tree,
3110
+ x: event.clientX,
3111
+ y: event.clientY,
3112
+ onClose() {
3113
+ clearPointerEvents();
3114
+ cleanupMouseMoveHandler();
3115
+ closeWithDelay(event, true, 'safe-polygon');
3116
+ }
3117
+ });
3118
+ const handler = handlerRef.current;
3119
+ doc.addEventListener('mousemove', handler);
3120
+ unbindMouseMoveRef.current = () => {
3121
+ doc.removeEventListener('mousemove', handler);
3122
+ };
3123
+ return;
3124
+ }
3125
+ const shouldClose = pointerTypeRef.current === 'touch' ? !contains(floating, event.relatedTarget) : true;
3126
+ if (shouldClose) {
3127
+ closeWithDelay(event);
3128
+ }
3129
+ }
3130
+ function onScrollMouseLeave(event) {
3131
+ if (isClickLikeOpenEvent()) return;
3132
+ if (!dataRef.current.floatingContext) return;
3133
+ handleCloseRef.current == null || handleCloseRef.current({
3134
+ ...dataRef.current.floatingContext,
3135
+ tree,
3136
+ x: event.clientX,
3137
+ y: event.clientY,
3138
+ onClose() {
3139
+ clearPointerEvents();
3140
+ cleanupMouseMoveHandler();
3141
+ closeWithDelay(event);
3142
+ }
3143
+ })(event);
3144
+ }
3145
+ if (isElement(domReference)) {
3146
+ const ref = domReference;
3147
+ open && ref.addEventListener('mouseleave', onScrollMouseLeave);
3148
+ floating == null || floating.addEventListener('mouseleave', onScrollMouseLeave);
3149
+ move && ref.addEventListener('mousemove', onMouseEnter, {
3150
+ once: true
3151
+ });
3152
+ ref.addEventListener('mouseenter', onMouseEnter);
3153
+ ref.addEventListener('mouseleave', onMouseLeave);
3154
+ return () => {
3155
+ open && ref.removeEventListener('mouseleave', onScrollMouseLeave);
3156
+ floating == null || floating.removeEventListener('mouseleave', onScrollMouseLeave);
3157
+ move && ref.removeEventListener('mousemove', onMouseEnter);
3158
+ ref.removeEventListener('mouseenter', onMouseEnter);
3159
+ ref.removeEventListener('mouseleave', onMouseLeave);
3160
+ };
3161
+ }
3162
+ }, [domReference, floating, enabled, context, mouseOnly, restMs, move, closeWithDelay, cleanupMouseMoveHandler, clearPointerEvents, onOpenChange, open, tree, delayRef, handleCloseRef, dataRef]);
3163
+ index(() => {
3164
+ var _handleCloseRef$curre;
3165
+ if (!enabled) {
3166
+ return;
3167
+ }
3168
+ if (open && (_handleCloseRef$curre = handleCloseRef.current) != null && _handleCloseRef$curre.__options.blockPointerEvents && isHoverOpen()) {
3169
+ const body = getDocument(floating).body;
3170
+ body.setAttribute(safePolygonIdentifier, '');
3171
+ body.style.pointerEvents = 'none';
3172
+ performedPointerEventsMutationRef.current = true;
3173
+ if (isElement(domReference) && floating) {
3174
+ var _tree$nodesRef$curren;
3175
+ const ref = domReference;
3176
+ const parentFloating = tree == null || (_tree$nodesRef$curren = tree.nodesRef.current.find(node => node.id === parentId)) == null || (_tree$nodesRef$curren = _tree$nodesRef$curren.context) == null ? void 0 : _tree$nodesRef$curren.elements.floating;
3177
+ if (parentFloating) {
3178
+ parentFloating.style.pointerEvents = '';
3179
+ }
3180
+ ref.style.pointerEvents = 'auto';
3181
+ floating.style.pointerEvents = 'auto';
3182
+ return () => {
3183
+ ref.style.pointerEvents = '';
3184
+ floating.style.pointerEvents = '';
3185
+ };
3186
+ }
3187
+ }
3188
+ }, [enabled, open, parentId, floating, domReference, tree, handleCloseRef, isHoverOpen]);
3189
+ index(() => {
3190
+ if (!open) {
3191
+ pointerTypeRef.current = undefined;
3192
+ cleanupMouseMoveHandler();
3193
+ clearPointerEvents();
3194
+ }
3195
+ }, [open, cleanupMouseMoveHandler, clearPointerEvents]);
3196
+ React__namespace.useEffect(() => {
3197
+ return () => {
3198
+ cleanupMouseMoveHandler();
3199
+ clearTimeout(timeoutRef.current);
3200
+ clearTimeout(restTimeoutRef.current);
3201
+ clearPointerEvents();
3202
+ };
3203
+ }, [enabled, domReference, cleanupMouseMoveHandler, clearPointerEvents]);
3204
+ return React__namespace.useMemo(() => {
3205
+ if (!enabled) {
3206
+ return {};
3207
+ }
3208
+ function setPointerRef(event) {
3209
+ pointerTypeRef.current = event.pointerType;
3210
+ }
3211
+ return {
3212
+ reference: {
3213
+ onPointerDown: setPointerRef,
3214
+ onPointerEnter: setPointerRef,
3215
+ onMouseMove(event) {
3216
+ const {
3217
+ nativeEvent
3218
+ } = event;
3219
+ function handleMouseMove() {
3220
+ if (!blockMouseMoveRef.current) {
3221
+ onOpenChange(true, nativeEvent, 'hover');
3222
+ }
3223
+ }
3224
+ if (mouseOnly && !isMouseLikePointerType(pointerTypeRef.current)) {
3225
+ return;
3226
+ }
3227
+ if (open || restMs === 0) {
3228
+ return;
3229
+ }
3230
+ clearTimeout(restTimeoutRef.current);
3231
+ if (pointerTypeRef.current === 'touch') {
3232
+ handleMouseMove();
3233
+ } else {
3234
+ restTimeoutRef.current = window.setTimeout(handleMouseMove, restMs);
3235
+ }
3236
+ }
3237
+ },
3238
+ floating: {
3239
+ onMouseEnter() {
3240
+ clearTimeout(timeoutRef.current);
3241
+ },
3242
+ onMouseLeave(event) {
3243
+ closeWithDelay(event.nativeEvent, false);
3244
+ }
3245
+ }
3246
+ };
3247
+ }, [enabled, mouseOnly, open, restMs, onOpenChange, closeWithDelay]);
3248
+ }
3249
+ const NOOP = () => {};
3250
+ React__namespace.createContext({
3251
+ delay: 0,
3252
+ initialDelay: 0,
3253
+ timeoutMs: 0,
3254
+ currentId: null,
3255
+ setCurrentId: NOOP,
3256
+ setState: NOOP,
3257
+ isInstantPhase: false
3258
+ });
3259
+ function getChildren(nodes, id) {
3260
+ let allChildren = nodes.filter(node => {
3261
+ var _node$context;
3262
+ return node.parentId === id && ((_node$context = node.context) == null ? void 0 : _node$context.open);
3263
+ });
3264
+ let currentChildren = allChildren;
3265
+ while (currentChildren.length) {
3266
+ currentChildren = nodes.filter(node => {
3267
+ var _currentChildren;
3268
+ return (_currentChildren = currentChildren) == null ? void 0 : _currentChildren.some(n => {
3269
+ var _node$context2;
3270
+ return node.parentId === n.id && ((_node$context2 = node.context) == null ? void 0 : _node$context2.open);
3271
+ });
3272
+ });
3273
+ allChildren = allChildren.concat(currentChildren);
3274
+ }
3275
+ return allChildren;
3276
+ }
3277
+ const HIDDEN_STYLES = {
3278
+ border: 0,
3279
+ clip: 'rect(0 0 0 0)',
3280
+ height: '1px',
3281
+ margin: '-1px',
3282
+ overflow: 'hidden',
3283
+ padding: 0,
3284
+ position: 'fixed',
3285
+ whiteSpace: 'nowrap',
3286
+ width: '1px',
3287
+ top: 0,
3288
+ left: 0
3289
+ };
3290
+ let timeoutId;
3291
+ function setActiveElementOnTab(event) {
3292
+ if (event.key === 'Tab') {
3293
+ event.target;
3294
+ clearTimeout(timeoutId);
3295
+ }
3296
+ }
3297
+ React__namespace.forwardRef(function FocusGuard(props, ref) {
3298
+ const [role, setRole] = React__namespace.useState();
3299
+ index(() => {
3300
+ if (isSafari()) {
3301
+ setRole('button');
3302
+ }
3303
+ document.addEventListener('keydown', setActiveElementOnTab);
3304
+ return () => {
3305
+ document.removeEventListener('keydown', setActiveElementOnTab);
3306
+ };
3307
+ }, []);
3308
+ const restProps = {
3309
+ ref,
3310
+ tabIndex: 0,
3311
+ role,
3312
+ 'aria-hidden': role ? undefined : true,
3313
+ [createAttribute('focus-guard')]: '',
3314
+ style: HIDDEN_STYLES
3315
+ };
3316
+ return React__namespace.createElement("span", _extends({}, props, restProps));
3317
+ });
3318
+ React__namespace.createContext(null);
3319
+ React__namespace.forwardRef(function VisuallyHiddenDismiss(props, ref) {
3320
+ return React__namespace.createElement("button", _extends({}, props, {
3321
+ type: "button",
3322
+ ref: ref,
3323
+ tabIndex: -1,
3324
+ style: HIDDEN_STYLES
3325
+ }));
3326
+ });
3327
+ const activeLocks = new Set();
3328
+ React__namespace.forwardRef(function FloatingOverlay(props, ref) {
3329
+ const {
3330
+ lockScroll = false,
3331
+ ...rest
3332
+ } = props;
3333
+ const lockId = useId();
3334
+ index(() => {
3335
+ if (!lockScroll) return;
3336
+ activeLocks.add(lockId);
3337
+ const isIOS = /iP(hone|ad|od)|iOS/.test(getPlatform());
3338
+ const bodyStyle = document.body.style;
3339
+ const scrollbarX = Math.round(document.documentElement.getBoundingClientRect().left) + document.documentElement.scrollLeft;
3340
+ const paddingProp = scrollbarX ? 'paddingLeft' : 'paddingRight';
3341
+ const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
3342
+ const scrollX = bodyStyle.left ? parseFloat(bodyStyle.left) : window.pageXOffset;
3343
+ const scrollY = bodyStyle.top ? parseFloat(bodyStyle.top) : window.pageYOffset;
3344
+ bodyStyle.overflow = 'hidden';
3345
+ if (scrollbarWidth) {
3346
+ bodyStyle[paddingProp] = scrollbarWidth + "px";
3347
+ }
3348
+ if (isIOS) {
3349
+ var _window$visualViewpor, _window$visualViewpor2;
3350
+ const offsetLeft = ((_window$visualViewpor = window.visualViewport) == null ? void 0 : _window$visualViewpor.offsetLeft) || 0;
3351
+ const offsetTop = ((_window$visualViewpor2 = window.visualViewport) == null ? void 0 : _window$visualViewpor2.offsetTop) || 0;
3352
+ Object.assign(bodyStyle, {
3353
+ position: 'fixed',
3354
+ top: -(scrollY - Math.floor(offsetTop)) + "px",
3355
+ left: -(scrollX - Math.floor(offsetLeft)) + "px",
3356
+ right: '0'
3357
+ });
3358
+ }
3359
+ return () => {
3360
+ activeLocks.delete(lockId);
3361
+ if (activeLocks.size === 0) {
3362
+ Object.assign(bodyStyle, {
3363
+ overflow: '',
3364
+ [paddingProp]: ''
3365
+ });
3366
+ if (isIOS) {
3367
+ Object.assign(bodyStyle, {
3368
+ position: '',
3369
+ top: '',
3370
+ left: '',
3371
+ right: ''
3372
+ });
3373
+ window.scrollTo(scrollX, scrollY);
3374
+ }
3375
+ }
3376
+ };
3377
+ }, [lockId, lockScroll]);
3378
+ return React__namespace.createElement("div", _extends({
3379
+ ref: ref
3380
+ }, rest, {
3381
+ style: {
3382
+ position: 'fixed',
3383
+ overflow: 'auto',
3384
+ top: 0,
3385
+ right: 0,
3386
+ bottom: 0,
3387
+ left: 0,
3388
+ ...rest.style
3389
+ }
3390
+ }));
3391
+ });
3392
+ const bubbleHandlerKeys = {
3393
+ pointerdown: 'onPointerDown',
3394
+ mousedown: 'onMouseDown',
3395
+ click: 'onClick'
3396
+ };
3397
+ const captureHandlerKeys = {
3398
+ pointerdown: 'onPointerDownCapture',
3399
+ mousedown: 'onMouseDownCapture',
3400
+ click: 'onClickCapture'
3401
+ };
3402
+ const normalizeProp = normalizable => {
3403
+ var _normalizable$escapeK, _normalizable$outside;
3404
+ return {
3405
+ escapeKey: typeof normalizable === 'boolean' ? normalizable : (_normalizable$escapeK = normalizable == null ? void 0 : normalizable.escapeKey) != null ? _normalizable$escapeK : false,
3406
+ outsidePress: typeof normalizable === 'boolean' ? normalizable : (_normalizable$outside = normalizable == null ? void 0 : normalizable.outsidePress) != null ? _normalizable$outside : true
3407
+ };
3408
+ };
3409
+ function useDismiss(context, props) {
3410
+ if (props === void 0) {
3411
+ props = {};
3412
+ }
3413
+ const {
3414
+ open,
3415
+ onOpenChange,
3416
+ elements: {
3417
+ reference,
3418
+ domReference,
3419
+ floating
3420
+ },
3421
+ dataRef
3422
+ } = context;
3423
+ const {
3424
+ enabled = true,
3425
+ escapeKey = true,
3426
+ outsidePress: unstable_outsidePress = true,
3427
+ outsidePressEvent = 'pointerdown',
3428
+ referencePress = false,
3429
+ referencePressEvent = 'pointerdown',
3430
+ ancestorScroll = false,
3431
+ bubbles,
3432
+ capture
3433
+ } = props;
3434
+ const tree = useFloatingTree();
3435
+ const outsidePressFn = useEffectEvent(typeof unstable_outsidePress === 'function' ? unstable_outsidePress : () => false);
3436
+ const outsidePress = typeof unstable_outsidePress === 'function' ? outsidePressFn : unstable_outsidePress;
3437
+ const insideReactTreeRef = React__namespace.useRef(false);
3438
+ const endedOrStartedInsideRef = React__namespace.useRef(false);
3439
+ const {
3440
+ escapeKey: escapeKeyBubbles,
3441
+ outsidePress: outsidePressBubbles
3442
+ } = normalizeProp(bubbles);
3443
+ const {
3444
+ escapeKey: escapeKeyCapture,
3445
+ outsidePress: outsidePressCapture
3446
+ } = normalizeProp(capture);
3447
+ const closeOnEscapeKeyDown = useEffectEvent(event => {
3448
+ var _dataRef$current$floa;
3449
+ if (!open || !enabled || !escapeKey || event.key !== 'Escape') {
3450
+ return;
3451
+ }
3452
+ const nodeId = (_dataRef$current$floa = dataRef.current.floatingContext) == null ? void 0 : _dataRef$current$floa.nodeId;
3453
+ const children = tree ? getChildren(tree.nodesRef.current, nodeId) : [];
3454
+ if (!escapeKeyBubbles) {
3455
+ event.stopPropagation();
3456
+ if (children.length > 0) {
3457
+ let shouldDismiss = true;
3458
+ children.forEach(child => {
3459
+ var _child$context;
3460
+ if ((_child$context = child.context) != null && _child$context.open && !child.context.dataRef.current.__escapeKeyBubbles) {
3461
+ shouldDismiss = false;
3462
+ return;
3463
+ }
3464
+ });
3465
+ if (!shouldDismiss) {
3466
+ return;
3467
+ }
3468
+ }
3469
+ }
3470
+ onOpenChange(false, isReactEvent(event) ? event.nativeEvent : event, 'escape-key');
3471
+ });
3472
+ const closeOnEscapeKeyDownCapture = useEffectEvent(event => {
3473
+ var _getTarget2;
3474
+ const callback = () => {
3475
+ var _getTarget;
3476
+ closeOnEscapeKeyDown(event);
3477
+ (_getTarget = getTarget(event)) == null || _getTarget.removeEventListener('keydown', callback);
3478
+ };
3479
+ (_getTarget2 = getTarget(event)) == null || _getTarget2.addEventListener('keydown', callback);
3480
+ });
3481
+ const closeOnPressOutside = useEffectEvent(event => {
3482
+ var _dataRef$current$floa2;
3483
+ const insideReactTree = insideReactTreeRef.current;
3484
+ insideReactTreeRef.current = false;
3485
+ const endedOrStartedInside = endedOrStartedInsideRef.current;
3486
+ endedOrStartedInsideRef.current = false;
3487
+ if (outsidePressEvent === 'click' && endedOrStartedInside) {
3488
+ return;
3489
+ }
3490
+ if (insideReactTree) {
3491
+ return;
3492
+ }
3493
+ if (typeof outsidePress === 'function' && !outsidePress(event)) {
3494
+ return;
3495
+ }
3496
+ const target = getTarget(event);
3497
+ const inertSelector = "[" + createAttribute('inert') + "]";
3498
+ const markers = getDocument(floating).querySelectorAll(inertSelector);
3499
+ let targetRootAncestor = isElement(target) ? target : null;
3500
+ while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
3501
+ const nextParent = getParentNode(targetRootAncestor);
3502
+ if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
3503
+ break;
3504
+ }
3505
+ targetRootAncestor = nextParent;
3506
+ }
3507
+ if (markers.length && isElement(target) && !isRootElement(target) &&
3508
+ !contains(target, floating) &&
3509
+ Array.from(markers).every(marker => !contains(targetRootAncestor, marker))) {
3510
+ return;
3511
+ }
3512
+ if (isHTMLElement(target) && floating) {
3513
+ const canScrollX = target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
3514
+ const canScrollY = target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
3515
+ let xCond = canScrollY && event.offsetX > target.clientWidth;
3516
+ if (canScrollY) {
3517
+ const isRTL = getComputedStyle(target).direction === 'rtl';
3518
+ if (isRTL) {
3519
+ xCond = event.offsetX <= target.offsetWidth - target.clientWidth;
3520
+ }
3521
+ }
3522
+ if (xCond || canScrollX && event.offsetY > target.clientHeight) {
3523
+ return;
3524
+ }
3525
+ }
3526
+ const nodeId = (_dataRef$current$floa2 = dataRef.current.floatingContext) == null ? void 0 : _dataRef$current$floa2.nodeId;
3527
+ const targetIsInsideChildren = tree && getChildren(tree.nodesRef.current, nodeId).some(node => {
3528
+ var _node$context;
3529
+ return isEventTargetWithin(event, (_node$context = node.context) == null ? void 0 : _node$context.elements.floating);
3530
+ });
3531
+ if (isEventTargetWithin(event, floating) || isEventTargetWithin(event, domReference) || targetIsInsideChildren) {
3532
+ return;
3533
+ }
3534
+ const children = tree ? getChildren(tree.nodesRef.current, nodeId) : [];
3535
+ if (children.length > 0) {
3536
+ let shouldDismiss = true;
3537
+ children.forEach(child => {
3538
+ var _child$context2;
3539
+ if ((_child$context2 = child.context) != null && _child$context2.open && !child.context.dataRef.current.__outsidePressBubbles) {
3540
+ shouldDismiss = false;
3541
+ return;
3542
+ }
3543
+ });
3544
+ if (!shouldDismiss) {
3545
+ return;
3546
+ }
3547
+ }
3548
+ onOpenChange(false, event, 'outside-press');
3549
+ });
3550
+ const closeOnPressOutsideCapture = useEffectEvent(event => {
3551
+ var _getTarget4;
3552
+ const callback = () => {
3553
+ var _getTarget3;
3554
+ closeOnPressOutside(event);
3555
+ (_getTarget3 = getTarget(event)) == null || _getTarget3.removeEventListener(outsidePressEvent, callback);
3556
+ };
3557
+ (_getTarget4 = getTarget(event)) == null || _getTarget4.addEventListener(outsidePressEvent, callback);
3558
+ });
3559
+ React__namespace.useEffect(() => {
3560
+ if (!open || !enabled) {
3561
+ return;
3562
+ }
3563
+ dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
3564
+ dataRef.current.__outsidePressBubbles = outsidePressBubbles;
3565
+ function onScroll(event) {
3566
+ onOpenChange(false, event, 'ancestor-scroll');
3567
+ }
3568
+ const doc = getDocument(floating);
3569
+ escapeKey && doc.addEventListener('keydown', escapeKeyCapture ? closeOnEscapeKeyDownCapture : closeOnEscapeKeyDown, escapeKeyCapture);
3570
+ outsidePress && doc.addEventListener(outsidePressEvent, outsidePressCapture ? closeOnPressOutsideCapture : closeOnPressOutside, outsidePressCapture);
3571
+ let ancestors = [];
3572
+ if (ancestorScroll) {
3573
+ if (isElement(domReference)) {
3574
+ ancestors = getOverflowAncestors(domReference);
3575
+ }
3576
+ if (isElement(floating)) {
3577
+ ancestors = ancestors.concat(getOverflowAncestors(floating));
3578
+ }
3579
+ if (!isElement(reference) && reference && reference.contextElement) {
3580
+ ancestors = ancestors.concat(getOverflowAncestors(reference.contextElement));
3581
+ }
3582
+ }
3583
+ ancestors = ancestors.filter(ancestor => {
3584
+ var _doc$defaultView;
3585
+ return ancestor !== ((_doc$defaultView = doc.defaultView) == null ? void 0 : _doc$defaultView.visualViewport);
3586
+ });
3587
+ ancestors.forEach(ancestor => {
3588
+ ancestor.addEventListener('scroll', onScroll, {
3589
+ passive: true
3590
+ });
3591
+ });
3592
+ return () => {
3593
+ escapeKey && doc.removeEventListener('keydown', escapeKeyCapture ? closeOnEscapeKeyDownCapture : closeOnEscapeKeyDown, escapeKeyCapture);
3594
+ outsidePress && doc.removeEventListener(outsidePressEvent, outsidePressCapture ? closeOnPressOutsideCapture : closeOnPressOutside, outsidePressCapture);
3595
+ ancestors.forEach(ancestor => {
3596
+ ancestor.removeEventListener('scroll', onScroll);
3597
+ });
3598
+ };
3599
+ }, [dataRef, floating, domReference, reference, escapeKey, outsidePress, outsidePressEvent, open, onOpenChange, ancestorScroll, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, escapeKeyCapture, closeOnEscapeKeyDownCapture, closeOnPressOutside, outsidePressCapture, closeOnPressOutsideCapture]);
3600
+ React__namespace.useEffect(() => {
3601
+ insideReactTreeRef.current = false;
3602
+ }, [outsidePress, outsidePressEvent]);
3603
+ return React__namespace.useMemo(() => {
3604
+ if (!enabled) {
3605
+ return {};
3606
+ }
3607
+ return {
3608
+ reference: {
3609
+ onKeyDown: closeOnEscapeKeyDown,
3610
+ [bubbleHandlerKeys[referencePressEvent]]: event => {
3611
+ if (referencePress) {
3612
+ onOpenChange(false, event.nativeEvent, 'reference-press');
3613
+ }
3614
+ }
3615
+ },
3616
+ floating: {
3617
+ onKeyDown: closeOnEscapeKeyDown,
3618
+ onMouseDown() {
3619
+ endedOrStartedInsideRef.current = true;
3620
+ },
3621
+ onMouseUp() {
3622
+ endedOrStartedInsideRef.current = true;
3623
+ },
3624
+ [captureHandlerKeys[outsidePressEvent]]: () => {
3625
+ insideReactTreeRef.current = true;
3626
+ }
3627
+ }
3628
+ };
3629
+ }, [enabled, referencePress, outsidePressEvent, referencePressEvent, onOpenChange, closeOnEscapeKeyDown]);
3630
+ }
3631
+ function useFloatingRootContext(options) {
3632
+ const {
3633
+ open = false,
3634
+ onOpenChange: onOpenChangeProp,
3635
+ elements: elementsProp
3636
+ } = options;
3637
+ const floatingId = useId();
3638
+ const dataRef = React__namespace.useRef({});
3639
+ const [events] = React__namespace.useState(() => createPubSub());
3640
+ const nested = useFloatingParentNodeId() != null;
3641
+ if (process.env.NODE_ENV !== "production") {
3642
+ const optionDomReference = elementsProp.reference;
3643
+ if (optionDomReference && !isElement(optionDomReference)) {
3644
+ error$1('Cannot pass a virtual element to the `elements.reference` option,', 'as it must be a real DOM element. Use `refs.setPositionReference()`', 'instead.');
3645
+ }
3646
+ }
3647
+ const [positionReference, setPositionReference] = React__namespace.useState(elementsProp.reference);
3648
+ const onOpenChange = useEffectEvent((open, event, reason) => {
3649
+ dataRef.current.openEvent = open ? event : undefined;
3650
+ events.emit('openchange', {
3651
+ open,
3652
+ event,
3653
+ reason,
3654
+ nested
3655
+ });
3656
+ onOpenChangeProp == null || onOpenChangeProp(open, event, reason);
3657
+ });
3658
+ const refs = React__namespace.useMemo(() => ({
3659
+ setPositionReference
3660
+ }), []);
3661
+ const elements = React__namespace.useMemo(() => ({
3662
+ reference: positionReference || elementsProp.reference || null,
3663
+ floating: elementsProp.floating || null,
3664
+ domReference: elementsProp.reference
3665
+ }), [positionReference, elementsProp.reference, elementsProp.floating]);
3666
+ return React__namespace.useMemo(() => ({
3667
+ dataRef,
3668
+ open,
3669
+ onOpenChange,
3670
+ elements,
3671
+ events,
3672
+ floatingId,
3673
+ refs
3674
+ }), [open, onOpenChange, elements, events, floatingId, refs]);
3675
+ }
3676
+ function useFloating(options) {
3677
+ if (options === void 0) {
3678
+ options = {};
3679
+ }
3680
+ const {
3681
+ nodeId
3682
+ } = options;
3683
+ const internalRootContext = useFloatingRootContext({
3684
+ ...options,
3685
+ elements: {
3686
+ reference: null,
3687
+ floating: null,
3688
+ ...options.elements
3689
+ }
3690
+ });
3691
+ const rootContext = options.rootContext || internalRootContext;
3692
+ const computedElements = rootContext.elements;
3693
+ const [_domReference, setDomReference] = React__namespace.useState(null);
3694
+ const [positionReference, _setPositionReference] = React__namespace.useState(null);
3695
+ const optionDomReference = computedElements == null ? void 0 : computedElements.reference;
3696
+ const domReference = optionDomReference || _domReference;
3697
+ const domReferenceRef = React__namespace.useRef(null);
3698
+ const tree = useFloatingTree();
3699
+ index(() => {
3700
+ if (domReference) {
3701
+ domReferenceRef.current = domReference;
3702
+ }
3703
+ }, [domReference]);
3704
+ const position = useFloating$1({
3705
+ ...options,
3706
+ elements: {
3707
+ ...computedElements,
3708
+ ...(positionReference && {
3709
+ reference: positionReference
3710
+ })
3711
+ }
3712
+ });
3713
+ const setPositionReference = React__namespace.useCallback(node => {
3714
+ const computedPositionReference = isElement(node) ? {
3715
+ getBoundingClientRect: () => node.getBoundingClientRect(),
3716
+ contextElement: node
3717
+ } : node;
3718
+ _setPositionReference(computedPositionReference);
3719
+ position.refs.setReference(computedPositionReference);
3720
+ }, [position.refs]);
3721
+ const setReference = React__namespace.useCallback(node => {
3722
+ if (isElement(node) || node === null) {
3723
+ domReferenceRef.current = node;
3724
+ setDomReference(node);
3725
+ }
3726
+ if (isElement(position.refs.reference.current) || position.refs.reference.current === null ||
3727
+ node !== null && !isElement(node)) {
3728
+ position.refs.setReference(node);
3729
+ }
3730
+ }, [position.refs]);
3731
+ const refs = React__namespace.useMemo(() => ({
3732
+ ...position.refs,
3733
+ setReference,
3734
+ setPositionReference,
3735
+ domReference: domReferenceRef
3736
+ }), [position.refs, setReference, setPositionReference]);
3737
+ const elements = React__namespace.useMemo(() => ({
3738
+ ...position.elements,
3739
+ domReference: domReference
3740
+ }), [position.elements, domReference]);
3741
+ const context = React__namespace.useMemo(() => ({
3742
+ ...position,
3743
+ ...rootContext,
3744
+ refs,
3745
+ elements,
3746
+ nodeId
3747
+ }), [position, refs, elements, nodeId, rootContext]);
3748
+ index(() => {
3749
+ rootContext.dataRef.current.floatingContext = context;
3750
+ const node = tree == null ? void 0 : tree.nodesRef.current.find(node => node.id === nodeId);
3751
+ if (node) {
3752
+ node.context = context;
3753
+ }
3754
+ });
3755
+ return React__namespace.useMemo(() => ({
3756
+ ...position,
3757
+ context,
3758
+ refs,
3759
+ elements
3760
+ }), [position, refs, elements, context]);
3761
+ }
3762
+ function useFocus(context, props) {
3763
+ if (props === void 0) {
3764
+ props = {};
3765
+ }
3766
+ const {
3767
+ open,
3768
+ onOpenChange,
3769
+ events,
3770
+ dataRef,
3771
+ elements: {
3772
+ domReference
3773
+ }
3774
+ } = context;
3775
+ const {
3776
+ enabled = true,
3777
+ visibleOnly = true
3778
+ } = props;
3779
+ const blockFocusRef = React__namespace.useRef(false);
3780
+ const timeoutRef = React__namespace.useRef();
3781
+ const keyboardModalityRef = React__namespace.useRef(true);
3782
+ React__namespace.useEffect(() => {
3783
+ if (!enabled) {
3784
+ return;
3785
+ }
3786
+ const win = getWindow(domReference);
3787
+ function onBlur() {
3788
+ if (!open && isHTMLElement(domReference) && domReference === activeElement(getDocument(domReference))) {
3789
+ blockFocusRef.current = true;
3790
+ }
3791
+ }
3792
+ function onKeyDown() {
3793
+ keyboardModalityRef.current = true;
3794
+ }
3795
+ win.addEventListener('blur', onBlur);
3796
+ win.addEventListener('keydown', onKeyDown, true);
3797
+ return () => {
3798
+ win.removeEventListener('blur', onBlur);
3799
+ win.removeEventListener('keydown', onKeyDown, true);
3800
+ };
3801
+ }, [domReference, open, enabled]);
3802
+ React__namespace.useEffect(() => {
3803
+ if (!enabled) {
3804
+ return;
3805
+ }
3806
+ function onOpenChange(_ref) {
3807
+ let {
3808
+ reason
3809
+ } = _ref;
3810
+ if (reason === 'reference-press' || reason === 'escape-key') {
3811
+ blockFocusRef.current = true;
3812
+ }
3813
+ }
3814
+ events.on('openchange', onOpenChange);
3815
+ return () => {
3816
+ events.off('openchange', onOpenChange);
3817
+ };
3818
+ }, [events, enabled]);
3819
+ React__namespace.useEffect(() => {
3820
+ return () => {
3821
+ clearTimeout(timeoutRef.current);
3822
+ };
3823
+ }, []);
3824
+ return React__namespace.useMemo(() => {
3825
+ if (!enabled) {
3826
+ return {};
3827
+ }
3828
+ return {
3829
+ reference: {
3830
+ onPointerDown(event) {
3831
+ if (isVirtualPointerEvent(event.nativeEvent)) return;
3832
+ keyboardModalityRef.current = false;
3833
+ },
3834
+ onMouseLeave() {
3835
+ blockFocusRef.current = false;
3836
+ },
3837
+ onFocus(event) {
3838
+ if (blockFocusRef.current) return;
3839
+ const target = getTarget(event.nativeEvent);
3840
+ if (visibleOnly && isElement(target)) {
3841
+ try {
3842
+ if (isSafari() && isMac()) throw Error();
3843
+ if (!target.matches(':focus-visible')) return;
3844
+ } catch (e) {
3845
+ if (!keyboardModalityRef.current && !isTypeableElement(target)) {
3846
+ return;
3847
+ }
3848
+ }
3849
+ }
3850
+ onOpenChange(true, event.nativeEvent, 'focus');
3851
+ },
3852
+ onBlur(event) {
3853
+ blockFocusRef.current = false;
3854
+ const relatedTarget = event.relatedTarget;
3855
+ const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute('focus-guard')) && relatedTarget.getAttribute('data-type') === 'outside';
3856
+ timeoutRef.current = window.setTimeout(() => {
3857
+ var _dataRef$current$floa;
3858
+ const activeEl = activeElement(domReference ? domReference.ownerDocument : document);
3859
+ if (!relatedTarget && activeEl === domReference) return;
3860
+ if (contains((_dataRef$current$floa = dataRef.current.floatingContext) == null ? void 0 : _dataRef$current$floa.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {
3861
+ return;
3862
+ }
3863
+ onOpenChange(false, event.nativeEvent, 'focus');
3864
+ });
3865
+ }
3866
+ }
3867
+ };
3868
+ }, [enabled, visibleOnly, dataRef, domReference, onOpenChange]);
3869
+ }
3870
+ const ACTIVE_KEY = 'active';
3871
+ const SELECTED_KEY = 'selected';
3872
+ function mergeProps(userProps, propsList, elementKey) {
3873
+ const map = new Map();
3874
+ const isItem = elementKey === 'item';
3875
+ let domUserProps = userProps;
3876
+ if (isItem && userProps) {
3877
+ const {
3878
+ [ACTIVE_KEY]: _,
3879
+ [SELECTED_KEY]: __,
3880
+ ...validProps
3881
+ } = userProps;
3882
+ domUserProps = validProps;
3883
+ }
3884
+ return {
3885
+ ...(elementKey === 'floating' && {
3886
+ tabIndex: -1
3887
+ }),
3888
+ ...domUserProps,
3889
+ ...propsList.map(value => {
3890
+ const propsOrGetProps = value ? value[elementKey] : null;
3891
+ if (typeof propsOrGetProps === 'function') {
3892
+ return userProps ? propsOrGetProps(userProps) : null;
3893
+ }
3894
+ return propsOrGetProps;
3895
+ }).concat(userProps).reduce((acc, props) => {
3896
+ if (!props) {
3897
+ return acc;
3898
+ }
3899
+ Object.entries(props).forEach(_ref => {
3900
+ let [key, value] = _ref;
3901
+ if (isItem && [ACTIVE_KEY, SELECTED_KEY].includes(key)) {
3902
+ return;
3903
+ }
3904
+ if (key.indexOf('on') === 0) {
3905
+ if (!map.has(key)) {
3906
+ map.set(key, []);
3907
+ }
3908
+ if (typeof value === 'function') {
3909
+ var _map$get;
3910
+ (_map$get = map.get(key)) == null || _map$get.push(value);
3911
+ acc[key] = function () {
3912
+ var _map$get2;
3913
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3914
+ args[_key] = arguments[_key];
3915
+ }
3916
+ return (_map$get2 = map.get(key)) == null ? void 0 : _map$get2.map(fn => fn(...args)).find(val => val !== undefined);
3917
+ };
3918
+ }
3919
+ } else {
3920
+ acc[key] = value;
3921
+ }
3922
+ });
3923
+ return acc;
3924
+ }, {})
3925
+ };
3926
+ }
3927
+ function useInteractions(propsList) {
3928
+ if (propsList === void 0) {
3929
+ propsList = [];
3930
+ }
3931
+ const deps = propsList;
3932
+ const getReferenceProps = React__namespace.useCallback(userProps => mergeProps(userProps, propsList, 'reference'),
3933
+ deps);
3934
+ const getFloatingProps = React__namespace.useCallback(userProps => mergeProps(userProps, propsList, 'floating'),
3935
+ deps);
3936
+ const getItemProps = React__namespace.useCallback(userProps => mergeProps(userProps, propsList, 'item'),
3937
+ propsList.map(key => key == null ? void 0 : key.item));
3938
+ return React__namespace.useMemo(() => ({
3939
+ getReferenceProps,
3940
+ getFloatingProps,
3941
+ getItemProps
3942
+ }), [getReferenceProps, getFloatingProps, getItemProps]);
3943
+ }
3944
+ const componentRoleToAriaRoleMap = new Map([['select', 'listbox'], ['combobox', 'listbox'], ['label', false]]);
3945
+ function useRole(context, props) {
3946
+ var _componentRoleToAriaR;
3947
+ if (props === void 0) {
3948
+ props = {};
3949
+ }
3950
+ const {
3951
+ open,
3952
+ floatingId
3953
+ } = context;
3954
+ const {
3955
+ enabled = true,
3956
+ role = 'dialog'
3957
+ } = props;
3958
+ const ariaRole = (_componentRoleToAriaR = componentRoleToAriaRoleMap.get(role)) != null ? _componentRoleToAriaR : role;
3959
+ const referenceId = useId();
3960
+ const parentId = useFloatingParentNodeId();
3961
+ const isNested = parentId != null;
3962
+ return React__namespace.useMemo(() => {
3963
+ if (!enabled) return {};
3964
+ const floatingProps = {
3965
+ id: floatingId,
3966
+ ...(ariaRole && {
3967
+ role: ariaRole
3968
+ })
3969
+ };
3970
+ if (ariaRole === 'tooltip' || role === 'label') {
3971
+ return {
3972
+ reference: {
3973
+ ["aria-" + (role === 'label' ? 'labelledby' : 'describedby')]: open ? floatingId : undefined
3974
+ },
3975
+ floating: floatingProps
3976
+ };
3977
+ }
3978
+ return {
3979
+ reference: {
3980
+ 'aria-expanded': open ? 'true' : 'false',
3981
+ 'aria-haspopup': ariaRole === 'alertdialog' ? 'dialog' : ariaRole,
3982
+ 'aria-controls': open ? floatingId : undefined,
3983
+ ...(ariaRole === 'listbox' && {
3984
+ role: 'combobox'
3985
+ }),
3986
+ ...(ariaRole === 'menu' && {
3987
+ id: referenceId
3988
+ }),
3989
+ ...(ariaRole === 'menu' && isNested && {
3990
+ role: 'menuitem'
3991
+ }),
3992
+ ...(role === 'select' && {
3993
+ 'aria-autocomplete': 'none'
3994
+ }),
3995
+ ...(role === 'combobox' && {
3996
+ 'aria-autocomplete': 'list'
3997
+ })
3998
+ },
3999
+ floating: {
4000
+ ...floatingProps,
4001
+ ...(ariaRole === 'menu' && {
4002
+ 'aria-labelledby': referenceId
4003
+ })
4004
+ },
4005
+ item(_ref) {
4006
+ let {
4007
+ active,
4008
+ selected
4009
+ } = _ref;
4010
+ const commonProps = {
4011
+ role: 'option',
4012
+ ...(active && {
4013
+ id: floatingId + "-option"
4014
+ })
4015
+ };
4016
+ switch (role) {
4017
+ case 'select':
4018
+ return {
4019
+ ...commonProps,
4020
+ 'aria-selected': active && selected
4021
+ };
4022
+ case 'combobox':
4023
+ {
4024
+ return {
4025
+ ...commonProps,
4026
+ ...(active && {
4027
+ 'aria-selected': true
4028
+ })
4029
+ };
4030
+ }
4031
+ }
4032
+ return {};
4033
+ }
4034
+ };
4035
+ }, [enabled, role, ariaRole, open, floatingId, referenceId, isNested]);
4036
+ }
4037
+
4038
+ var TooltipElement = function (props) {
4039
+ var children = props.children,
4040
+ //
4041
+ content = props.content,
4042
+ //
4043
+ placement = props.placement, isHidden = props.isHidden, isPointing = props.isPointing,
4044
+ //
4045
+ stylesOverrides = props.styles, dataCy = props.dataCy;
4046
+ var arrowRef = React.useRef(null);
4047
+ var _a = React.useState(false), isOpen = _a[0], setIsOpen = _a[1];
4048
+ var _b = useFloating({
4049
+ open: isOpen,
4050
+ onOpenChange: setIsOpen,
4051
+ placement: placement,
4052
+ middleware: [
4053
+ offset(10),
4054
+ flip(),
4055
+ shift(),
4056
+ arrow({
4057
+ element: arrowRef,
4058
+ }),
4059
+ ],
4060
+ whileElementsMounted: autoUpdate,
4061
+ }), refs = _b.refs, floatingStyles = _b.floatingStyles, context = _b.context;
4062
+ var hover = useHover(context, { move: false });
4063
+ var focus = useFocus(context);
4064
+ var dismiss = useDismiss(context);
4065
+ var role = useRole(context, {
4066
+ // If your reference element has its own label (text).
4067
+ role: 'tooltip',
4068
+ });
4069
+ // Merge all the interactions into prop getters
4070
+ var _c = useInteractions([
4071
+ hover,
4072
+ focus,
4073
+ dismiss,
4074
+ role,
4075
+ ]), getReferenceProps = _c.getReferenceProps, getFloatingProps = _c.getFloatingProps;
4076
+ var handleGenerateStyle = function () {
4077
+ var result = deepCopyObject(styles$t.base);
4078
+ var keys = calculateNestedKeys(styles$t.base);
4079
+ keys.forEach(function (key) {
4080
+ return lodash.set(result, key, toClassName(lodash.get(styles$t.base, key), lodash.get(stylesOverrides, key)));
4081
+ });
4082
+ return result;
4083
+ };
4084
+ var styles = handleGenerateStyle();
4085
+ var childrenWithProps = React.Children.map(children, function (child) {
4086
+ var props = __assign$1({ ref: refs.setReference }, getReferenceProps());
4087
+ if (React.isValidElement(child)) {
4088
+ return React.cloneElement(child, props);
4089
+ }
4090
+ return child;
4091
+ });
4092
+ if (isHidden)
4093
+ return children;
4094
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [childrenWithProps, isOpen && (jsxRuntime.jsxs("div", __assign$1({ "data-cy": dataCy, ref: refs.setFloating, style: floatingStyles, className: toClassName(styles.content, stylesOverrides === null || stylesOverrides === void 0 ? void 0 : stylesOverrides.content) }, getFloatingProps(), { children: [isPointing && (jsxRuntime.jsx(FloatingArrow, { ref: arrowRef, context: context, fill: styles.arrow.fill, stroke: styles.arrow.stroke, strokeWidth: Number(styles.arrow.strokeWidth) })), content] })))] }));
4095
+ };
4096
+
4097
+ var base$p = {
4098
+ container: 'w-fit h-fit relative group/tooltip',
4099
+ content: 'absolute flex justify-center items-center z-200 tooltip-animate px-4 py-2 border whitespace-nowrap border-palette-grayDarker bg-white font-light text-xs rounded-sm',
4100
+ arrow: {
4101
+ stroke: '#e5e7eb',
4102
+ fill: 'white',
4103
+ strokeWidth: '1',
4104
+ },
4105
+ };
4106
+ var styles$t = {
4107
+ base: base$p,
4108
+ };
4109
+
539
4110
  var ButtonElement = function (props) {
540
4111
  var children = props.children, innerRef = props.innerRef, _a = props.htmlType, htmlType = _a === void 0 ? 'button' : _a, dataCy = props.dataCy, _b = props.type, type = _b === void 0 ? 'primary' : _b, _c = props.size, size = _c === void 0 ? 'md' : _c, _d = props.figure, figure = _d === void 0 ? 'block' : _d, _e = props.status, status = _e === void 0 ? 'idle' : _e, isDisabled = props.isDisabled, stylesOverrides = props.styles, onClick = props.onClick;
541
4112
  var handleGenerateStyle = function () {
@@ -11037,6 +14608,7 @@ exports.TableColumnOptionsCustom = TableColumnOptionsCustom;
11037
14608
  exports.TableExportCustom = TableExcelExportCustom;
11038
14609
  exports.TableList = TableList;
11039
14610
  exports.TableList2 = TableList2;
14611
+ exports.Tooltiplement = TooltipElement;
11040
14612
  exports.VerticalNavigation = VerticalNavigation;
11041
14613
  exports.__DEPRECATED__CheckboxInputGroupForm = CheckboxInputGroupForm;
11042
14614
  exports.createColumnHelper = createColumnHelper;