`, so it can be styled via any CSS solution you prefer.\n * @see https://floating-ui.com/docs/FloatingOverlay\n */\nconst FloatingOverlay = /*#__PURE__*/React.forwardRef(function FloatingOverlay(props, ref) {\n const {\n lockScroll = false,\n ...rest\n } = props;\n index(() => {\n if (!lockScroll) return;\n lockCount++;\n if (lockCount === 1) {\n cleanup = enableScrollLock();\n }\n return () => {\n lockCount--;\n if (lockCount === 0) {\n cleanup();\n }\n };\n }, [lockScroll]);\n return /*#__PURE__*/jsx(\"div\", {\n ref: ref,\n ...rest,\n style: {\n position: 'fixed',\n overflow: 'auto',\n top: 0,\n right: 0,\n bottom: 0,\n left: 0,\n ...rest.style\n }\n });\n});\n\nfunction isButtonTarget(event) {\n return isHTMLElement(event.target) && event.target.tagName === 'BUTTON';\n}\nfunction isSpaceIgnored(element) {\n return isTypeableElement(element);\n}\n/**\n * Opens or closes the floating element when clicking the reference element.\n * @see https://floating-ui.com/docs/useClick\n */\nfunction useClick(context, props) {\n if (props === void 0) {\n props = {};\n }\n const {\n open,\n onOpenChange,\n dataRef,\n elements: {\n domReference\n }\n } = context;\n const {\n enabled = true,\n event: eventOption = 'click',\n toggle = true,\n ignoreMouse = false,\n keyboardHandlers = true,\n stickIfOpen = true\n } = props;\n const pointerTypeRef = React.useRef();\n const didKeyDownRef = React.useRef(false);\n const reference = React.useMemo(() => ({\n onPointerDown(event) {\n pointerTypeRef.current = event.pointerType;\n },\n onMouseDown(event) {\n const pointerType = pointerTypeRef.current;\n\n // Ignore all buttons except for the \"main\" button.\n // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button\n if (event.button !== 0) return;\n if (eventOption === 'click') return;\n if (isMouseLikePointerType(pointerType, true) && ignoreMouse) return;\n if (open && toggle && (dataRef.current.openEvent && stickIfOpen ? dataRef.current.openEvent.type === 'mousedown' : true)) {\n onOpenChange(false, event.nativeEvent, 'click');\n } else {\n // Prevent stealing focus from the floating element\n event.preventDefault();\n onOpenChange(true, event.nativeEvent, 'click');\n }\n },\n onClick(event) {\n const pointerType = pointerTypeRef.current;\n if (eventOption === 'mousedown' && pointerTypeRef.current) {\n pointerTypeRef.current = undefined;\n return;\n }\n if (isMouseLikePointerType(pointerType, true) && ignoreMouse) return;\n if (open && toggle && (dataRef.current.openEvent && stickIfOpen ? dataRef.current.openEvent.type === 'click' : true)) {\n onOpenChange(false, event.nativeEvent, 'click');\n } else {\n onOpenChange(true, event.nativeEvent, 'click');\n }\n },\n onKeyDown(event) {\n pointerTypeRef.current = undefined;\n if (event.defaultPrevented || !keyboardHandlers || isButtonTarget(event)) {\n return;\n }\n if (event.key === ' ' && !isSpaceIgnored(domReference)) {\n // Prevent scrolling\n event.preventDefault();\n didKeyDownRef.current = true;\n }\n if (event.key === 'Enter') {\n if (open && toggle) {\n onOpenChange(false, event.nativeEvent, 'click');\n } else {\n onOpenChange(true, event.nativeEvent, 'click');\n }\n }\n },\n onKeyUp(event) {\n if (event.defaultPrevented || !keyboardHandlers || isButtonTarget(event) || isSpaceIgnored(domReference)) {\n return;\n }\n if (event.key === ' ' && didKeyDownRef.current) {\n didKeyDownRef.current = false;\n if (open && toggle) {\n onOpenChange(false, event.nativeEvent, 'click');\n } else {\n onOpenChange(true, event.nativeEvent, 'click');\n }\n }\n }\n }), [dataRef, domReference, eventOption, ignoreMouse, keyboardHandlers, onOpenChange, open, stickIfOpen, toggle]);\n return React.useMemo(() => enabled ? {\n reference\n } : {}, [enabled, reference]);\n}\n\nfunction createVirtualElement(domElement, data) {\n let offsetX = null;\n let offsetY = null;\n let isAutoUpdateEvent = false;\n return {\n contextElement: domElement || undefined,\n getBoundingClientRect() {\n var _data$dataRef$current;\n const domRect = (domElement == null ? void 0 : domElement.getBoundingClientRect()) || {\n width: 0,\n height: 0,\n x: 0,\n y: 0\n };\n const isXAxis = data.axis === 'x' || data.axis === 'both';\n const isYAxis = data.axis === 'y' || data.axis === 'both';\n const canTrackCursorOnAutoUpdate = ['mouseenter', 'mousemove'].includes(((_data$dataRef$current = data.dataRef.current.openEvent) == null ? void 0 : _data$dataRef$current.type) || '') && data.pointerType !== 'touch';\n let width = domRect.width;\n let height = domRect.height;\n let x = domRect.x;\n let y = domRect.y;\n if (offsetX == null && data.x && isXAxis) {\n offsetX = domRect.x - data.x;\n }\n if (offsetY == null && data.y && isYAxis) {\n offsetY = domRect.y - data.y;\n }\n x -= offsetX || 0;\n y -= offsetY || 0;\n width = 0;\n height = 0;\n if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) {\n width = data.axis === 'y' ? domRect.width : 0;\n height = data.axis === 'x' ? domRect.height : 0;\n x = isXAxis && data.x != null ? data.x : x;\n y = isYAxis && data.y != null ? data.y : y;\n } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) {\n height = data.axis === 'x' ? domRect.height : height;\n width = data.axis === 'y' ? domRect.width : width;\n }\n isAutoUpdateEvent = true;\n return {\n width,\n height,\n x,\n y,\n top: y,\n right: x + width,\n bottom: y + height,\n left: x\n };\n }\n };\n}\nfunction isMouseBasedEvent(event) {\n return event != null && event.clientX != null;\n}\n/**\n * Positions the floating element relative to a client point (in the viewport),\n * such as the mouse position. By default, it follows the mouse cursor.\n * @see https://floating-ui.com/docs/useClientPoint\n */\nfunction useClientPoint(context, props) {\n if (props === void 0) {\n props = {};\n }\n const {\n open,\n dataRef,\n elements: {\n floating,\n domReference\n },\n refs\n } = context;\n const {\n enabled = true,\n axis = 'both',\n x = null,\n y = null\n } = props;\n const initialRef = React.useRef(false);\n const cleanupListenerRef = React.useRef(null);\n const [pointerType, setPointerType] = React.useState();\n const [reactive, setReactive] = React.useState([]);\n const setReference = useEffectEvent((x, y) => {\n if (initialRef.current) return;\n\n // Prevent setting if the open event was not a mouse-like one\n // (e.g. focus to open, then hover over the reference element).\n // Only apply if the event exists.\n if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) {\n return;\n }\n refs.setPositionReference(createVirtualElement(domReference, {\n x,\n y,\n axis,\n dataRef,\n pointerType\n }));\n });\n const handleReferenceEnterOrMove = useEffectEvent(event => {\n if (x != null || y != null) return;\n if (!open) {\n setReference(event.clientX, event.clientY);\n } else if (!cleanupListenerRef.current) {\n // If there's no cleanup, there's no listener, but we want to ensure\n // we add the listener if the cursor landed on the floating element and\n // then back on the reference (i.e. it's interactive).\n setReactive([]);\n }\n });\n\n // If the pointer is a mouse-like pointer, we want to continue following the\n // mouse even if the floating element is transitioning out. On touch\n // devices, this is undesirable because the floating element will move to\n // the dismissal touch point.\n const openCheck = isMouseLikePointerType(pointerType) ? floating : open;\n const addListener = React.useCallback(() => {\n // Explicitly specified `x`/`y` coordinates shouldn't add a listener.\n if (!openCheck || !enabled || x != null || y != null) return;\n const win = getWindow(floating);\n function handleMouseMove(event) {\n const target = getTarget(event);\n if (!contains(floating, target)) {\n setReference(event.clientX, event.clientY);\n } else {\n win.removeEventListener('mousemove', handleMouseMove);\n cleanupListenerRef.current = null;\n }\n }\n if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) {\n win.addEventListener('mousemove', handleMouseMove);\n const cleanup = () => {\n win.removeEventListener('mousemove', handleMouseMove);\n cleanupListenerRef.current = null;\n };\n cleanupListenerRef.current = cleanup;\n return cleanup;\n }\n refs.setPositionReference(domReference);\n }, [openCheck, enabled, x, y, floating, dataRef, refs, domReference, setReference]);\n React.useEffect(() => {\n return addListener();\n }, [addListener, reactive]);\n React.useEffect(() => {\n if (enabled && !floating) {\n initialRef.current = false;\n }\n }, [enabled, floating]);\n React.useEffect(() => {\n if (!enabled && open) {\n initialRef.current = true;\n }\n }, [enabled, open]);\n index(() => {\n if (enabled && (x != null || y != null)) {\n initialRef.current = false;\n setReference(x, y);\n }\n }, [enabled, x, y, setReference]);\n const reference = React.useMemo(() => {\n function setPointerTypeRef(_ref) {\n let {\n pointerType\n } = _ref;\n setPointerType(pointerType);\n }\n return {\n onPointerDown: setPointerTypeRef,\n onPointerEnter: setPointerTypeRef,\n onMouseMove: handleReferenceEnterOrMove,\n onMouseEnter: handleReferenceEnterOrMove\n };\n }, [handleReferenceEnterOrMove]);\n return React.useMemo(() => enabled ? {\n reference\n } : {}, [enabled, reference]);\n}\n\nconst bubbleHandlerKeys = {\n pointerdown: 'onPointerDown',\n mousedown: 'onMouseDown',\n click: 'onClick'\n};\nconst captureHandlerKeys = {\n pointerdown: 'onPointerDownCapture',\n mousedown: 'onMouseDownCapture',\n click: 'onClickCapture'\n};\nconst normalizeProp = normalizable => {\n var _normalizable$escapeK, _normalizable$outside;\n return {\n escapeKey: typeof normalizable === 'boolean' ? normalizable : (_normalizable$escapeK = normalizable == null ? void 0 : normalizable.escapeKey) != null ? _normalizable$escapeK : false,\n outsidePress: typeof normalizable === 'boolean' ? normalizable : (_normalizable$outside = normalizable == null ? void 0 : normalizable.outsidePress) != null ? _normalizable$outside : true\n };\n};\n/**\n * Closes the floating element when a dismissal is requested — by default, when\n * the user presses the `escape` key or outside of the floating element.\n * @see https://floating-ui.com/docs/useDismiss\n */\nfunction useDismiss(context, props) {\n if (props === void 0) {\n props = {};\n }\n const {\n open,\n onOpenChange,\n elements,\n dataRef\n } = context;\n const {\n enabled = true,\n escapeKey = true,\n outsidePress: unstable_outsidePress = true,\n outsidePressEvent = 'pointerdown',\n referencePress = false,\n referencePressEvent = 'pointerdown',\n ancestorScroll = false,\n bubbles,\n capture\n } = props;\n const tree = useFloatingTree();\n const outsidePressFn = useEffectEvent(typeof unstable_outsidePress === 'function' ? unstable_outsidePress : () => false);\n const outsidePress = typeof unstable_outsidePress === 'function' ? outsidePressFn : unstable_outsidePress;\n const insideReactTreeRef = React.useRef(false);\n const endedOrStartedInsideRef = React.useRef(false);\n const {\n escapeKey: escapeKeyBubbles,\n outsidePress: outsidePressBubbles\n } = normalizeProp(bubbles);\n const {\n escapeKey: escapeKeyCapture,\n outsidePress: outsidePressCapture\n } = normalizeProp(capture);\n const isComposingRef = React.useRef(false);\n const closeOnEscapeKeyDown = useEffectEvent(event => {\n var _dataRef$current$floa;\n if (!open || !enabled || !escapeKey || event.key !== 'Escape') {\n return;\n }\n\n // Wait until IME is settled. Pressing `Escape` while composing should\n // close the compose menu, but not the floating element.\n if (isComposingRef.current) {\n return;\n }\n const nodeId = (_dataRef$current$floa = dataRef.current.floatingContext) == null ? void 0 : _dataRef$current$floa.nodeId;\n const children = tree ? getChildren(tree.nodesRef.current, nodeId) : [];\n if (!escapeKeyBubbles) {\n event.stopPropagation();\n if (children.length > 0) {\n let shouldDismiss = true;\n children.forEach(child => {\n var _child$context;\n if ((_child$context = child.context) != null && _child$context.open && !child.context.dataRef.current.__escapeKeyBubbles) {\n shouldDismiss = false;\n return;\n }\n });\n if (!shouldDismiss) {\n return;\n }\n }\n }\n onOpenChange(false, isReactEvent(event) ? event.nativeEvent : event, 'escape-key');\n });\n const closeOnEscapeKeyDownCapture = useEffectEvent(event => {\n var _getTarget2;\n const callback = () => {\n var _getTarget;\n closeOnEscapeKeyDown(event);\n (_getTarget = getTarget(event)) == null || _getTarget.removeEventListener('keydown', callback);\n };\n (_getTarget2 = getTarget(event)) == null || _getTarget2.addEventListener('keydown', callback);\n });\n const closeOnPressOutside = useEffectEvent(event => {\n var _dataRef$current$floa2;\n // Given developers can stop the propagation of the synthetic event,\n // we can only be confident with a positive value.\n const insideReactTree = insideReactTreeRef.current;\n insideReactTreeRef.current = false;\n\n // When click outside is lazy (`click` event), handle dragging.\n // Don't close if:\n // - The click started inside the floating element.\n // - The click ended inside the floating element.\n const endedOrStartedInside = endedOrStartedInsideRef.current;\n endedOrStartedInsideRef.current = false;\n if (outsidePressEvent === 'click' && endedOrStartedInside) {\n return;\n }\n if (insideReactTree) {\n return;\n }\n if (typeof outsidePress === 'function' && !outsidePress(event)) {\n return;\n }\n const target = getTarget(event);\n const inertSelector = \"[\" + createAttribute('inert') + \"]\";\n const markers = getDocument(elements.floating).querySelectorAll(inertSelector);\n let targetRootAncestor = isElement(target) ? target : null;\n while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {\n const nextParent = getParentNode(targetRootAncestor);\n if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {\n break;\n }\n targetRootAncestor = nextParent;\n }\n\n // Check if the click occurred on a third-party element injected after the\n // floating element rendered.\n if (markers.length && isElement(target) && !isRootElement(target) &&\n // Clicked on a direct ancestor (e.g. FloatingOverlay).\n !contains(target, elements.floating) &&\n // If the target root element contains none of the markers, then the\n // element was injected after the floating element rendered.\n Array.from(markers).every(marker => !contains(targetRootAncestor, marker))) {\n return;\n }\n\n // Check if the click occurred on the scrollbar\n if (isHTMLElement(target) && floating) {\n const lastTraversableNode = isLastTraversableNode(target);\n const style = getComputedStyle(target);\n const scrollRe = /auto|scroll/;\n const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);\n const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);\n const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;\n const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;\n const isRTL = style.direction === 'rtl';\n\n // Check click position relative to scrollbar.\n // In some browsers it is possible to change the (or window)\n // scrollbar to the left side, but is very rare and is difficult to\n // check for. Plus, for modal dialogs with backdrops, it is more\n // important that the backdrop is checked but not so much the window.\n const pressedVerticalScrollbar = canScrollY && (isRTL ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);\n const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;\n if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {\n return;\n }\n }\n const nodeId = (_dataRef$current$floa2 = dataRef.current.floatingContext) == null ? void 0 : _dataRef$current$floa2.nodeId;\n const targetIsInsideChildren = tree && getChildren(tree.nodesRef.current, nodeId).some(node => {\n var _node$context;\n return isEventTargetWithin(event, (_node$context = node.context) == null ? void 0 : _node$context.elements.floating);\n });\n if (isEventTargetWithin(event, elements.floating) || isEventTargetWithin(event, elements.domReference) || targetIsInsideChildren) {\n return;\n }\n const children = tree ? getChildren(tree.nodesRef.current, nodeId) : [];\n if (children.length > 0) {\n let shouldDismiss = true;\n children.forEach(child => {\n var _child$context2;\n if ((_child$context2 = child.context) != null && _child$context2.open && !child.context.dataRef.current.__outsidePressBubbles) {\n shouldDismiss = false;\n return;\n }\n });\n if (!shouldDismiss) {\n return;\n }\n }\n onOpenChange(false, event, 'outside-press');\n });\n const closeOnPressOutsideCapture = useEffectEvent(event => {\n var _getTarget4;\n const callback = () => {\n var _getTarget3;\n closeOnPressOutside(event);\n (_getTarget3 = getTarget(event)) == null || _getTarget3.removeEventListener(outsidePressEvent, callback);\n };\n (_getTarget4 = getTarget(event)) == null || _getTarget4.addEventListener(outsidePressEvent, callback);\n });\n React.useEffect(() => {\n if (!open || !enabled) {\n return;\n }\n dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;\n dataRef.current.__outsidePressBubbles = outsidePressBubbles;\n let compositionTimeout = -1;\n function onScroll(event) {\n onOpenChange(false, event, 'ancestor-scroll');\n }\n function handleCompositionStart() {\n window.clearTimeout(compositionTimeout);\n isComposingRef.current = true;\n }\n function handleCompositionEnd() {\n // Safari fires `compositionend` before `keydown`, so we need to wait\n // until the next tick to set `isComposing` to `false`.\n // https://bugs.webkit.org/show_bug.cgi?id=165004\n compositionTimeout = window.setTimeout(() => {\n isComposingRef.current = false;\n },\n // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.\n // Only apply to WebKit for the test to remain 0ms.\n isWebKit() ? 5 : 0);\n }\n const doc = getDocument(elements.floating);\n if (escapeKey) {\n doc.addEventListener('keydown', escapeKeyCapture ? closeOnEscapeKeyDownCapture : closeOnEscapeKeyDown, escapeKeyCapture);\n doc.addEventListener('compositionstart', handleCompositionStart);\n doc.addEventListener('compositionend', handleCompositionEnd);\n }\n outsidePress && doc.addEventListener(outsidePressEvent, outsidePressCapture ? closeOnPressOutsideCapture : closeOnPressOutside, outsidePressCapture);\n let ancestors = [];\n if (ancestorScroll) {\n if (isElement(elements.domReference)) {\n ancestors = getOverflowAncestors(elements.domReference);\n }\n if (isElement(elements.floating)) {\n ancestors = ancestors.concat(getOverflowAncestors(elements.floating));\n }\n if (!isElement(elements.reference) && elements.reference && elements.reference.contextElement) {\n ancestors = ancestors.concat(getOverflowAncestors(elements.reference.contextElement));\n }\n }\n\n // Ignore the visual viewport for scrolling dismissal (allow pinch-zoom)\n ancestors = ancestors.filter(ancestor => {\n var _doc$defaultView;\n return ancestor !== ((_doc$defaultView = doc.defaultView) == null ? void 0 : _doc$defaultView.visualViewport);\n });\n ancestors.forEach(ancestor => {\n ancestor.addEventListener('scroll', onScroll, {\n passive: true\n });\n });\n return () => {\n if (escapeKey) {\n doc.removeEventListener('keydown', escapeKeyCapture ? closeOnEscapeKeyDownCapture : closeOnEscapeKeyDown, escapeKeyCapture);\n doc.removeEventListener('compositionstart', handleCompositionStart);\n doc.removeEventListener('compositionend', handleCompositionEnd);\n }\n outsidePress && doc.removeEventListener(outsidePressEvent, outsidePressCapture ? closeOnPressOutsideCapture : closeOnPressOutside, outsidePressCapture);\n ancestors.forEach(ancestor => {\n ancestor.removeEventListener('scroll', onScroll);\n });\n window.clearTimeout(compositionTimeout);\n };\n }, [dataRef, elements, escapeKey, outsidePress, outsidePressEvent, open, onOpenChange, ancestorScroll, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, escapeKeyCapture, closeOnEscapeKeyDownCapture, closeOnPressOutside, outsidePressCapture, closeOnPressOutsideCapture]);\n React.useEffect(() => {\n insideReactTreeRef.current = false;\n }, [outsidePress, outsidePressEvent]);\n const reference = React.useMemo(() => ({\n onKeyDown: closeOnEscapeKeyDown,\n ...(referencePress && {\n [bubbleHandlerKeys[referencePressEvent]]: event => {\n onOpenChange(false, event.nativeEvent, 'reference-press');\n },\n ...(referencePressEvent !== 'click' && {\n onClick(event) {\n onOpenChange(false, event.nativeEvent, 'reference-press');\n }\n })\n })\n }), [closeOnEscapeKeyDown, onOpenChange, referencePress, referencePressEvent]);\n const floating = React.useMemo(() => ({\n onKeyDown: closeOnEscapeKeyDown,\n onMouseDown() {\n endedOrStartedInsideRef.current = true;\n },\n onMouseUp() {\n endedOrStartedInsideRef.current = true;\n },\n [captureHandlerKeys[outsidePressEvent]]: () => {\n insideReactTreeRef.current = true;\n }\n }), [closeOnEscapeKeyDown, outsidePressEvent]);\n return React.useMemo(() => enabled ? {\n reference,\n floating\n } : {}, [enabled, reference, floating]);\n}\n\nfunction useFloatingRootContext(options) {\n const {\n open = false,\n onOpenChange: onOpenChangeProp,\n elements: elementsProp\n } = options;\n const floatingId = useId();\n const dataRef = React.useRef({});\n const [events] = React.useState(() => createPubSub());\n const nested = useFloatingParentNodeId() != null;\n if (process.env.NODE_ENV !== \"production\") {\n const optionDomReference = elementsProp.reference;\n if (optionDomReference && !isElement(optionDomReference)) {\n error('Cannot pass a virtual element to the `elements.reference` option,', 'as it must be a real DOM element. Use `refs.setPositionReference()`', 'instead.');\n }\n }\n const [positionReference, setPositionReference] = React.useState(elementsProp.reference);\n const onOpenChange = useEffectEvent((open, event, reason) => {\n dataRef.current.openEvent = open ? event : undefined;\n events.emit('openchange', {\n open,\n event,\n reason,\n nested\n });\n onOpenChangeProp == null || onOpenChangeProp(open, event, reason);\n });\n const refs = React.useMemo(() => ({\n setPositionReference\n }), []);\n const elements = React.useMemo(() => ({\n reference: positionReference || elementsProp.reference || null,\n floating: elementsProp.floating || null,\n domReference: elementsProp.reference\n }), [positionReference, elementsProp.reference, elementsProp.floating]);\n return React.useMemo(() => ({\n dataRef,\n open,\n onOpenChange,\n elements,\n events,\n floatingId,\n refs\n }), [open, onOpenChange, elements, events, floatingId, refs]);\n}\n\n/**\n * Provides data to position a floating element and context to add interactions.\n * @see https://floating-ui.com/docs/useFloating\n */\nfunction useFloating(options) {\n if (options === void 0) {\n options = {};\n }\n const {\n nodeId\n } = options;\n const internalRootContext = useFloatingRootContext({\n ...options,\n elements: {\n reference: null,\n floating: null,\n ...options.elements\n }\n });\n const rootContext = options.rootContext || internalRootContext;\n const computedElements = rootContext.elements;\n const [_domReference, setDomReference] = React.useState(null);\n const [positionReference, _setPositionReference] = React.useState(null);\n const optionDomReference = computedElements == null ? void 0 : computedElements.domReference;\n const domReference = optionDomReference || _domReference;\n const domReferenceRef = React.useRef(null);\n const tree = useFloatingTree();\n index(() => {\n if (domReference) {\n domReferenceRef.current = domReference;\n }\n }, [domReference]);\n const position = useFloating$1({\n ...options,\n elements: {\n ...computedElements,\n ...(positionReference && {\n reference: positionReference\n })\n }\n });\n const setPositionReference = React.useCallback(node => {\n const computedPositionReference = isElement(node) ? {\n getBoundingClientRect: () => node.getBoundingClientRect(),\n contextElement: node\n } : node;\n // Store the positionReference in state if the DOM reference is specified externally via the\n // `elements.reference` option. This ensures that it won't be overridden on future renders.\n _setPositionReference(computedPositionReference);\n position.refs.setReference(computedPositionReference);\n }, [position.refs]);\n const setReference = React.useCallback(node => {\n if (isElement(node) || node === null) {\n domReferenceRef.current = node;\n setDomReference(node);\n }\n\n // Backwards-compatibility for passing a virtual element to `reference`\n // after it has set the DOM reference.\n if (isElement(position.refs.reference.current) || position.refs.reference.current === null ||\n // Don't allow setting virtual elements using the old technique back to\n // `null` to support `positionReference` + an unstable `reference`\n // callback ref.\n node !== null && !isElement(node)) {\n position.refs.setReference(node);\n }\n }, [position.refs]);\n const refs = React.useMemo(() => ({\n ...position.refs,\n setReference,\n setPositionReference,\n domReference: domReferenceRef\n }), [position.refs, setReference, setPositionReference]);\n const elements = React.useMemo(() => ({\n ...position.elements,\n domReference: domReference\n }), [position.elements, domReference]);\n const context = React.useMemo(() => ({\n ...position,\n ...rootContext,\n refs,\n elements,\n nodeId\n }), [position, refs, elements, nodeId, rootContext]);\n index(() => {\n rootContext.dataRef.current.floatingContext = context;\n const node = tree == null ? void 0 : tree.nodesRef.current.find(node => node.id === nodeId);\n if (node) {\n node.context = context;\n }\n });\n return React.useMemo(() => ({\n ...position,\n context,\n refs,\n elements\n }), [position, refs, elements, context]);\n}\n\n/**\n * Opens the floating element while the reference element has focus, like CSS\n * `:focus`.\n * @see https://floating-ui.com/docs/useFocus\n */\nfunction useFocus(context, props) {\n if (props === void 0) {\n props = {};\n }\n const {\n open,\n onOpenChange,\n events,\n dataRef,\n elements\n } = context;\n const {\n enabled = true,\n visibleOnly = true\n } = props;\n const blockFocusRef = React.useRef(false);\n const timeoutRef = React.useRef();\n const keyboardModalityRef = React.useRef(true);\n React.useEffect(() => {\n if (!enabled) return;\n const win = getWindow(elements.domReference);\n\n // If the reference was focused and the user left the tab/window, and the\n // floating element was not open, the focus should be blocked when they\n // return to the tab/window.\n function onBlur() {\n if (!open && isHTMLElement(elements.domReference) && elements.domReference === activeElement(getDocument(elements.domReference))) {\n blockFocusRef.current = true;\n }\n }\n function onKeyDown() {\n keyboardModalityRef.current = true;\n }\n win.addEventListener('blur', onBlur);\n win.addEventListener('keydown', onKeyDown, true);\n return () => {\n win.removeEventListener('blur', onBlur);\n win.removeEventListener('keydown', onKeyDown, true);\n };\n }, [elements.domReference, open, enabled]);\n React.useEffect(() => {\n if (!enabled) return;\n function onOpenChange(_ref) {\n let {\n reason\n } = _ref;\n if (reason === 'reference-press' || reason === 'escape-key') {\n blockFocusRef.current = true;\n }\n }\n events.on('openchange', onOpenChange);\n return () => {\n events.off('openchange', onOpenChange);\n };\n }, [events, enabled]);\n React.useEffect(() => {\n return () => {\n clearTimeout(timeoutRef.current);\n };\n }, []);\n const reference = React.useMemo(() => ({\n onPointerDown(event) {\n if (isVirtualPointerEvent(event.nativeEvent)) return;\n keyboardModalityRef.current = false;\n },\n onMouseLeave() {\n blockFocusRef.current = false;\n },\n onFocus(event) {\n if (blockFocusRef.current) return;\n const target = getTarget(event.nativeEvent);\n if (visibleOnly && isElement(target)) {\n try {\n // Mac Safari unreliably matches `:focus-visible` on the reference\n // if focus was outside the page initially - use the fallback\n // instead.\n if (isSafari() && isMac()) throw Error();\n if (!target.matches(':focus-visible')) return;\n } catch (e) {\n // Old browsers will throw an error when using `:focus-visible`.\n if (!keyboardModalityRef.current && !isTypeableElement(target)) {\n return;\n }\n }\n }\n onOpenChange(true, event.nativeEvent, 'focus');\n },\n onBlur(event) {\n blockFocusRef.current = false;\n const relatedTarget = event.relatedTarget;\n const nativeEvent = event.nativeEvent;\n\n // Hit the non-modal focus management portal guard. Focus will be\n // moved into the floating element immediately after.\n const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute('focus-guard')) && relatedTarget.getAttribute('data-type') === 'outside';\n\n // Wait for the window blur listener to fire.\n timeoutRef.current = window.setTimeout(() => {\n var _dataRef$current$floa;\n const activeEl = activeElement(elements.domReference ? elements.domReference.ownerDocument : document);\n\n // Focus left the page, keep it open.\n if (!relatedTarget && activeEl === elements.domReference) return;\n\n // When focusing the reference element (e.g. regular click), then\n // clicking into the floating element, prevent it from hiding.\n // Note: it must be focusable, e.g. `tabindex=\"-1\"`.\n // We can not rely on relatedTarget to point to the correct element\n // as it will only point to the shadow host of the newly focused element\n // and not the element that actually has received focus if it is located\n // inside a shadow root.\n if (contains((_dataRef$current$floa = dataRef.current.floatingContext) == null ? void 0 : _dataRef$current$floa.refs.floating.current, activeEl) || contains(elements.domReference, activeEl) || movedToFocusGuard) {\n return;\n }\n onOpenChange(false, nativeEvent, 'focus');\n });\n }\n }), [dataRef, elements.domReference, onOpenChange, visibleOnly]);\n return React.useMemo(() => enabled ? {\n reference\n } : {}, [enabled, reference]);\n}\n\nconst ACTIVE_KEY = 'active';\nconst SELECTED_KEY = 'selected';\nfunction mergeProps(userProps, propsList, elementKey) {\n const map = new Map();\n const isItem = elementKey === 'item';\n let domUserProps = userProps;\n if (isItem && userProps) {\n const {\n [ACTIVE_KEY]: _,\n [SELECTED_KEY]: __,\n ...validProps\n } = userProps;\n domUserProps = validProps;\n }\n return {\n ...(elementKey === 'floating' && {\n tabIndex: -1,\n [FOCUSABLE_ATTRIBUTE]: ''\n }),\n ...domUserProps,\n ...propsList.map(value => {\n const propsOrGetProps = value ? value[elementKey] : null;\n if (typeof propsOrGetProps === 'function') {\n return userProps ? propsOrGetProps(userProps) : null;\n }\n return propsOrGetProps;\n }).concat(userProps).reduce((acc, props) => {\n if (!props) {\n return acc;\n }\n Object.entries(props).forEach(_ref => {\n let [key, value] = _ref;\n if (isItem && [ACTIVE_KEY, SELECTED_KEY].includes(key)) {\n return;\n }\n if (key.indexOf('on') === 0) {\n if (!map.has(key)) {\n map.set(key, []);\n }\n if (typeof value === 'function') {\n var _map$get;\n (_map$get = map.get(key)) == null || _map$get.push(value);\n acc[key] = function () {\n var _map$get2;\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n return (_map$get2 = map.get(key)) == null ? void 0 : _map$get2.map(fn => fn(...args)).find(val => val !== undefined);\n };\n }\n } else {\n acc[key] = value;\n }\n });\n return acc;\n }, {})\n };\n}\n/**\n * Merges an array of interaction hooks' props into prop getters, allowing\n * event handler functions to be composed together without overwriting one\n * another.\n * @see https://floating-ui.com/docs/useInteractions\n */\nfunction useInteractions(propsList) {\n if (propsList === void 0) {\n propsList = [];\n }\n const referenceDeps = propsList.map(key => key == null ? void 0 : key.reference);\n const floatingDeps = propsList.map(key => key == null ? void 0 : key.floating);\n const itemDeps = propsList.map(key => key == null ? void 0 : key.item);\n const getReferenceProps = React.useCallback(userProps => mergeProps(userProps, propsList, 'reference'),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n referenceDeps);\n const getFloatingProps = React.useCallback(userProps => mergeProps(userProps, propsList, 'floating'),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n floatingDeps);\n const getItemProps = React.useCallback(userProps => mergeProps(userProps, propsList, 'item'),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n itemDeps);\n return React.useMemo(() => ({\n getReferenceProps,\n getFloatingProps,\n getItemProps\n }), [getReferenceProps, getFloatingProps, getItemProps]);\n}\n\nfunction doSwitch(orientation, vertical, horizontal) {\n switch (orientation) {\n case 'vertical':\n return vertical;\n case 'horizontal':\n return horizontal;\n default:\n return vertical || horizontal;\n }\n}\nfunction isMainOrientationKey(key, orientation) {\n const vertical = key === ARROW_UP || key === ARROW_DOWN;\n const horizontal = key === ARROW_LEFT || key === ARROW_RIGHT;\n return doSwitch(orientation, vertical, horizontal);\n}\nfunction isMainOrientationToEndKey(key, orientation, rtl) {\n const vertical = key === ARROW_DOWN;\n const horizontal = rtl ? key === ARROW_LEFT : key === ARROW_RIGHT;\n return doSwitch(orientation, vertical, horizontal) || key === 'Enter' || key === ' ' || key === '';\n}\nfunction isCrossOrientationOpenKey(key, orientation, rtl) {\n const vertical = rtl ? key === ARROW_LEFT : key === ARROW_RIGHT;\n const horizontal = key === ARROW_DOWN;\n return doSwitch(orientation, vertical, horizontal);\n}\nfunction isCrossOrientationCloseKey(key, orientation, rtl) {\n const vertical = rtl ? key === ARROW_RIGHT : key === ARROW_LEFT;\n const horizontal = key === ARROW_UP;\n return doSwitch(orientation, vertical, horizontal);\n}\n/**\n * Adds arrow key-based navigation of a list of items, either using real DOM\n * focus or virtual focus.\n * @see https://floating-ui.com/docs/useListNavigation\n */\nfunction useListNavigation(context, props) {\n const {\n open,\n onOpenChange,\n elements\n } = context;\n const {\n listRef,\n activeIndex,\n onNavigate: unstable_onNavigate = () => {},\n enabled = true,\n selectedIndex = null,\n allowEscape = false,\n loop = false,\n nested = false,\n rtl = false,\n virtual = false,\n focusItemOnOpen = 'auto',\n focusItemOnHover = true,\n openOnArrowKeyDown = true,\n disabledIndices = undefined,\n orientation = 'vertical',\n cols = 1,\n scrollItemIntoView = true,\n virtualItemRef,\n itemSizes,\n dense = false\n } = props;\n if (process.env.NODE_ENV !== \"production\") {\n if (allowEscape) {\n if (!loop) {\n warn('`useListNavigation` looping must be enabled to allow escaping.');\n }\n if (!virtual) {\n warn('`useListNavigation` must be virtual to allow escaping.');\n }\n }\n if (orientation === 'vertical' && cols > 1) {\n warn('In grid list navigation mode (`cols` > 1), the `orientation` should', 'be either \"horizontal\" or \"both\".');\n }\n }\n const floatingFocusElement = getFloatingFocusElement(elements.floating);\n const floatingFocusElementRef = useLatestRef(floatingFocusElement);\n const parentId = useFloatingParentNodeId();\n const tree = useFloatingTree();\n const onNavigate = useEffectEvent(() => {\n unstable_onNavigate(indexRef.current === -1 ? null : indexRef.current);\n });\n const typeableComboboxReference = isTypeableCombobox(elements.domReference);\n const focusItemOnOpenRef = React.useRef(focusItemOnOpen);\n const indexRef = React.useRef(selectedIndex != null ? selectedIndex : -1);\n const keyRef = React.useRef(null);\n const isPointerModalityRef = React.useRef(true);\n const previousOnNavigateRef = React.useRef(onNavigate);\n const previousMountedRef = React.useRef(!!elements.floating);\n const previousOpenRef = React.useRef(open);\n const forceSyncFocusRef = React.useRef(false);\n const forceScrollIntoViewRef = React.useRef(false);\n const disabledIndicesRef = useLatestRef(disabledIndices);\n const latestOpenRef = useLatestRef(open);\n const scrollItemIntoViewRef = useLatestRef(scrollItemIntoView);\n const selectedIndexRef = useLatestRef(selectedIndex);\n const [activeId, setActiveId] = React.useState();\n const [virtualId, setVirtualId] = React.useState();\n const focusItem = useEffectEvent(() => {\n function runFocus(item) {\n if (virtual) {\n setActiveId(item.id);\n tree == null || tree.events.emit('virtualfocus', item);\n if (virtualItemRef) {\n virtualItemRef.current = item;\n }\n } else {\n enqueueFocus(item, {\n sync: forceSyncFocusRef.current,\n preventScroll: true\n });\n }\n }\n const initialItem = listRef.current[indexRef.current];\n if (initialItem) {\n runFocus(initialItem);\n }\n const scheduler = forceSyncFocusRef.current ? v => v() : requestAnimationFrame;\n scheduler(() => {\n const waitedItem = listRef.current[indexRef.current] || initialItem;\n if (!waitedItem) return;\n if (!initialItem) {\n runFocus(waitedItem);\n }\n const scrollIntoViewOptions = scrollItemIntoViewRef.current;\n const shouldScrollIntoView = scrollIntoViewOptions && item && (forceScrollIntoViewRef.current || !isPointerModalityRef.current);\n if (shouldScrollIntoView) {\n // JSDOM doesn't support `.scrollIntoView()` but it's widely supported\n // by all browsers.\n waitedItem.scrollIntoView == null || waitedItem.scrollIntoView(typeof scrollIntoViewOptions === 'boolean' ? {\n block: 'nearest',\n inline: 'nearest'\n } : scrollIntoViewOptions);\n }\n });\n });\n\n // Sync `selectedIndex` to be the `activeIndex` upon opening the floating\n // element. Also, reset `activeIndex` upon closing the floating element.\n index(() => {\n if (!enabled) return;\n if (open && elements.floating) {\n if (focusItemOnOpenRef.current && selectedIndex != null) {\n // Regardless of the pointer modality, we want to ensure the selected\n // item comes into view when the floating element is opened.\n forceScrollIntoViewRef.current = true;\n indexRef.current = selectedIndex;\n onNavigate();\n }\n } else if (previousMountedRef.current) {\n // Since the user can specify `onNavigate` conditionally\n // (onNavigate: open ? setActiveIndex : setSelectedIndex),\n // we store and call the previous function.\n indexRef.current = -1;\n previousOnNavigateRef.current();\n }\n }, [enabled, open, elements.floating, selectedIndex, onNavigate]);\n\n // Sync `activeIndex` to be the focused item while the floating element is\n // open.\n index(() => {\n if (!enabled) return;\n if (!open) return;\n if (!elements.floating) return;\n if (activeIndex == null) {\n forceSyncFocusRef.current = false;\n if (selectedIndexRef.current != null) {\n return;\n }\n\n // Reset while the floating element was open (e.g. the list changed).\n if (previousMountedRef.current) {\n indexRef.current = -1;\n focusItem();\n }\n\n // Initial sync.\n if ((!previousOpenRef.current || !previousMountedRef.current) && focusItemOnOpenRef.current && (keyRef.current != null || focusItemOnOpenRef.current === true && keyRef.current == null)) {\n let runs = 0;\n const waitForListPopulated = () => {\n if (listRef.current[0] == null) {\n // Avoid letting the browser paint if possible on the first try,\n // otherwise use rAF. Don't try more than twice, since something\n // is wrong otherwise.\n if (runs < 2) {\n const scheduler = runs ? requestAnimationFrame : queueMicrotask;\n scheduler(waitForListPopulated);\n }\n runs++;\n } else {\n indexRef.current = keyRef.current == null || isMainOrientationToEndKey(keyRef.current, orientation, rtl) || nested ? getMinIndex(listRef, disabledIndicesRef.current) : getMaxIndex(listRef, disabledIndicesRef.current);\n keyRef.current = null;\n onNavigate();\n }\n };\n waitForListPopulated();\n }\n } else if (!isIndexOutOfBounds(listRef, activeIndex)) {\n indexRef.current = activeIndex;\n focusItem();\n forceScrollIntoViewRef.current = false;\n }\n }, [enabled, open, elements.floating, activeIndex, selectedIndexRef, nested, listRef, orientation, rtl, onNavigate, focusItem, disabledIndicesRef]);\n\n // Ensure the parent floating element has focus when a nested child closes\n // to allow arrow key navigation to work after the pointer leaves the child.\n index(() => {\n var _nodes$find;\n if (!enabled || elements.floating || !tree || virtual || !previousMountedRef.current) {\n return;\n }\n const nodes = tree.nodesRef.current;\n const parent = (_nodes$find = nodes.find(node => node.id === parentId)) == null || (_nodes$find = _nodes$find.context) == null ? void 0 : _nodes$find.elements.floating;\n const activeEl = activeElement(getDocument(elements.floating));\n const treeContainsActiveEl = nodes.some(node => node.context && contains(node.context.elements.floating, activeEl));\n if (parent && !treeContainsActiveEl && isPointerModalityRef.current) {\n parent.focus({\n preventScroll: true\n });\n }\n }, [enabled, elements.floating, tree, parentId, virtual]);\n index(() => {\n if (!enabled) return;\n if (!tree) return;\n if (!virtual) return;\n if (parentId) return;\n function handleVirtualFocus(item) {\n setVirtualId(item.id);\n if (virtualItemRef) {\n virtualItemRef.current = item;\n }\n }\n tree.events.on('virtualfocus', handleVirtualFocus);\n return () => {\n tree.events.off('virtualfocus', handleVirtualFocus);\n };\n }, [enabled, tree, virtual, parentId, virtualItemRef]);\n index(() => {\n previousOnNavigateRef.current = onNavigate;\n previousOpenRef.current = open;\n previousMountedRef.current = !!elements.floating;\n });\n index(() => {\n if (!open) {\n keyRef.current = null;\n }\n }, [open]);\n const hasActiveIndex = activeIndex != null;\n const item = React.useMemo(() => {\n function syncCurrentTarget(currentTarget) {\n if (!open) return;\n const index = listRef.current.indexOf(currentTarget);\n if (index !== -1 && indexRef.current !== index) {\n indexRef.current = index;\n onNavigate();\n }\n }\n const props = {\n onFocus(_ref) {\n let {\n currentTarget\n } = _ref;\n forceSyncFocusRef.current = true;\n syncCurrentTarget(currentTarget);\n },\n onClick: _ref2 => {\n let {\n currentTarget\n } = _ref2;\n return currentTarget.focus({\n preventScroll: true\n });\n },\n // Safari\n ...(focusItemOnHover && {\n onMouseMove(_ref3) {\n let {\n currentTarget\n } = _ref3;\n forceSyncFocusRef.current = true;\n forceScrollIntoViewRef.current = false;\n syncCurrentTarget(currentTarget);\n },\n onPointerLeave(_ref4) {\n let {\n pointerType\n } = _ref4;\n if (!isPointerModalityRef.current || pointerType === 'touch') {\n return;\n }\n forceSyncFocusRef.current = true;\n indexRef.current = -1;\n onNavigate();\n if (!virtual) {\n var _floatingFocusElement;\n (_floatingFocusElement = floatingFocusElementRef.current) == null || _floatingFocusElement.focus({\n preventScroll: true\n });\n }\n }\n })\n };\n return props;\n }, [open, floatingFocusElementRef, focusItemOnHover, listRef, onNavigate, virtual]);\n const commonOnKeyDown = useEffectEvent(event => {\n isPointerModalityRef.current = false;\n forceSyncFocusRef.current = true;\n\n // When composing a character, Chrome fires ArrowDown twice. Firefox/Safari\n // don't appear to suffer from this. `event.isComposing` is avoided due to\n // Safari not supporting it properly (although it's not needed in the first\n // place for Safari, just avoiding any possible issues).\n if (event.which === 229) {\n return;\n }\n\n // If the floating element is animating out, ignore navigation. Otherwise,\n // the `activeIndex` gets set to 0 despite not being open so the next time\n // the user ArrowDowns, the first item won't be focused.\n if (!latestOpenRef.current && event.currentTarget === floatingFocusElementRef.current) {\n return;\n }\n if (nested && isCrossOrientationCloseKey(event.key, orientation, rtl)) {\n stopEvent(event);\n onOpenChange(false, event.nativeEvent, 'list-navigation');\n if (isHTMLElement(elements.domReference)) {\n if (virtual) {\n tree == null || tree.events.emit('virtualfocus', elements.domReference);\n } else {\n elements.domReference.focus();\n }\n }\n return;\n }\n const currentIndex = indexRef.current;\n const minIndex = getMinIndex(listRef, disabledIndices);\n const maxIndex = getMaxIndex(listRef, disabledIndices);\n if (!typeableComboboxReference) {\n if (event.key === 'Home') {\n stopEvent(event);\n indexRef.current = minIndex;\n onNavigate();\n }\n if (event.key === 'End') {\n stopEvent(event);\n indexRef.current = maxIndex;\n onNavigate();\n }\n }\n\n // Grid navigation.\n if (cols > 1) {\n const sizes = itemSizes || Array.from({\n length: listRef.current.length\n }, () => ({\n width: 1,\n height: 1\n }));\n // To calculate movements on the grid, we use hypothetical cell indices\n // as if every item was 1x1, then convert back to real indices.\n const cellMap = buildCellMap(sizes, cols, dense);\n const minGridIndex = cellMap.findIndex(index => index != null && !isDisabled(listRef.current, index, disabledIndices));\n // last enabled index\n const maxGridIndex = cellMap.reduce((foundIndex, index, cellIndex) => index != null && !isDisabled(listRef.current, index, disabledIndices) ? cellIndex : foundIndex, -1);\n const index = cellMap[getGridNavigatedIndex({\n current: cellMap.map(itemIndex => itemIndex != null ? listRef.current[itemIndex] : null)\n }, {\n event,\n orientation,\n loop,\n rtl,\n cols,\n // treat undefined (empty grid spaces) as disabled indices so we\n // don't end up in them\n disabledIndices: getCellIndices([...(disabledIndices || listRef.current.map((_, index) => isDisabled(listRef.current, index) ? index : undefined)), undefined], cellMap),\n minIndex: minGridIndex,\n maxIndex: maxGridIndex,\n prevIndex: getCellIndexOfCorner(indexRef.current > maxIndex ? minIndex : indexRef.current, sizes, cellMap, cols,\n // use a corner matching the edge closest to the direction\n // we're moving in so we don't end up in the same item. Prefer\n // top/left over bottom/right.\n event.key === ARROW_DOWN ? 'bl' : event.key === (rtl ? ARROW_LEFT : ARROW_RIGHT) ? 'tr' : 'tl'),\n stopEvent: true\n })];\n if (index != null) {\n indexRef.current = index;\n onNavigate();\n }\n if (orientation === 'both') {\n return;\n }\n }\n if (isMainOrientationKey(event.key, orientation)) {\n stopEvent(event);\n\n // Reset the index if no item is focused.\n if (open && !virtual && activeElement(event.currentTarget.ownerDocument) === event.currentTarget) {\n indexRef.current = isMainOrientationToEndKey(event.key, orientation, rtl) ? minIndex : maxIndex;\n onNavigate();\n return;\n }\n if (isMainOrientationToEndKey(event.key, orientation, rtl)) {\n if (loop) {\n indexRef.current = currentIndex >= maxIndex ? allowEscape && currentIndex !== listRef.current.length ? -1 : minIndex : findNonDisabledIndex(listRef, {\n startingIndex: currentIndex,\n disabledIndices\n });\n } else {\n indexRef.current = Math.min(maxIndex, findNonDisabledIndex(listRef, {\n startingIndex: currentIndex,\n disabledIndices\n }));\n }\n } else {\n if (loop) {\n indexRef.current = currentIndex <= minIndex ? allowEscape && currentIndex !== -1 ? listRef.current.length : maxIndex : findNonDisabledIndex(listRef, {\n startingIndex: currentIndex,\n decrement: true,\n disabledIndices\n });\n } else {\n indexRef.current = Math.max(minIndex, findNonDisabledIndex(listRef, {\n startingIndex: currentIndex,\n decrement: true,\n disabledIndices\n }));\n }\n }\n if (isIndexOutOfBounds(listRef, indexRef.current)) {\n indexRef.current = -1;\n }\n onNavigate();\n }\n });\n const ariaActiveDescendantProp = React.useMemo(() => {\n return virtual && open && hasActiveIndex && {\n 'aria-activedescendant': virtualId || activeId\n };\n }, [virtual, open, hasActiveIndex, virtualId, activeId]);\n const floating = React.useMemo(() => {\n return {\n 'aria-orientation': orientation === 'both' ? undefined : orientation,\n ...(!typeableComboboxReference ? ariaActiveDescendantProp : {}),\n onKeyDown: commonOnKeyDown,\n onPointerMove() {\n isPointerModalityRef.current = true;\n }\n };\n }, [ariaActiveDescendantProp, commonOnKeyDown, orientation, typeableComboboxReference]);\n const reference = React.useMemo(() => {\n function checkVirtualMouse(event) {\n if (focusItemOnOpen === 'auto' && isVirtualClick(event.nativeEvent)) {\n focusItemOnOpenRef.current = true;\n }\n }\n function checkVirtualPointer(event) {\n // `pointerdown` fires first, reset the state then perform the checks.\n focusItemOnOpenRef.current = focusItemOnOpen;\n if (focusItemOnOpen === 'auto' && isVirtualPointerEvent(event.nativeEvent)) {\n focusItemOnOpenRef.current = true;\n }\n }\n return {\n ...ariaActiveDescendantProp,\n onKeyDown(event) {\n isPointerModalityRef.current = false;\n const isArrowKey = event.key.startsWith('Arrow');\n const isHomeOrEndKey = ['Home', 'End'].includes(event.key);\n const isMoveKey = isArrowKey || isHomeOrEndKey;\n const isCrossOpenKey = isCrossOrientationOpenKey(event.key, orientation, rtl);\n const isCrossCloseKey = isCrossOrientationCloseKey(event.key, orientation, rtl);\n const isMainKey = isMainOrientationKey(event.key, orientation);\n const isNavigationKey = (nested ? isCrossOpenKey : isMainKey) || event.key === 'Enter' || event.key.trim() === '';\n if (virtual && open) {\n const rootNode = tree == null ? void 0 : tree.nodesRef.current.find(node => node.parentId == null);\n const deepestNode = tree && rootNode ? getDeepestNode(tree.nodesRef.current, rootNode.id) : null;\n if (isMoveKey && deepestNode && virtualItemRef) {\n const eventObject = new KeyboardEvent('keydown', {\n key: event.key,\n bubbles: true\n });\n if (isCrossOpenKey || isCrossCloseKey) {\n var _deepestNode$context, _deepestNode$context2;\n const isCurrentTarget = ((_deepestNode$context = deepestNode.context) == null ? void 0 : _deepestNode$context.elements.domReference) === event.currentTarget;\n const dispatchItem = isCrossCloseKey && !isCurrentTarget ? (_deepestNode$context2 = deepestNode.context) == null ? void 0 : _deepestNode$context2.elements.domReference : isCrossOpenKey ? listRef.current.find(item => (item == null ? void 0 : item.id) === activeId) : null;\n if (dispatchItem) {\n stopEvent(event);\n dispatchItem.dispatchEvent(eventObject);\n setVirtualId(undefined);\n }\n }\n if ((isMainKey || isHomeOrEndKey) && deepestNode.context) {\n if (deepestNode.context.open && deepestNode.parentId && event.currentTarget !== deepestNode.context.elements.domReference) {\n var _deepestNode$context$;\n stopEvent(event);\n (_deepestNode$context$ = deepestNode.context.elements.domReference) == null || _deepestNode$context$.dispatchEvent(eventObject);\n return;\n }\n }\n }\n return commonOnKeyDown(event);\n }\n\n // If a floating element should not open on arrow key down, avoid\n // setting `activeIndex` while it's closed.\n if (!open && !openOnArrowKeyDown && isArrowKey) {\n return;\n }\n if (isNavigationKey) {\n keyRef.current = nested && isMainKey ? null : event.key;\n }\n if (nested) {\n if (isCrossOpenKey) {\n stopEvent(event);\n if (open) {\n indexRef.current = getMinIndex(listRef, disabledIndicesRef.current);\n onNavigate();\n } else {\n onOpenChange(true, event.nativeEvent, 'list-navigation');\n }\n }\n return;\n }\n if (isMainKey) {\n if (selectedIndex != null) {\n indexRef.current = selectedIndex;\n }\n stopEvent(event);\n if (!open && openOnArrowKeyDown) {\n onOpenChange(true, event.nativeEvent, 'list-navigation');\n } else {\n commonOnKeyDown(event);\n }\n if (open) {\n onNavigate();\n }\n }\n },\n onFocus() {\n if (open && !virtual) {\n indexRef.current = -1;\n onNavigate();\n }\n },\n onPointerDown: checkVirtualPointer,\n onPointerEnter: checkVirtualPointer,\n onMouseDown: checkVirtualMouse,\n onClick: checkVirtualMouse\n };\n }, [activeId, ariaActiveDescendantProp, commonOnKeyDown, disabledIndicesRef, focusItemOnOpen, listRef, nested, onNavigate, onOpenChange, open, openOnArrowKeyDown, orientation, rtl, selectedIndex, tree, virtual, virtualItemRef]);\n return React.useMemo(() => enabled ? {\n reference,\n floating,\n item\n } : {}, [enabled, reference, floating, item]);\n}\n\nconst componentRoleToAriaRoleMap = /*#__PURE__*/new Map([['select', 'listbox'], ['combobox', 'listbox'], ['label', false]]);\n\n/**\n * Adds base screen reader props to the reference and floating elements for a\n * given floating element `role`.\n * @see https://floating-ui.com/docs/useRole\n */\nfunction useRole(context, props) {\n var _componentRoleToAriaR;\n if (props === void 0) {\n props = {};\n }\n const {\n open,\n floatingId\n } = context;\n const {\n enabled = true,\n role = 'dialog'\n } = props;\n const ariaRole = (_componentRoleToAriaR = componentRoleToAriaRoleMap.get(role)) != null ? _componentRoleToAriaR : role;\n const referenceId = useId();\n const parentId = useFloatingParentNodeId();\n const isNested = parentId != null;\n const reference = React.useMemo(() => {\n if (ariaRole === 'tooltip' || role === 'label') {\n return {\n [\"aria-\" + (role === 'label' ? 'labelledby' : 'describedby')]: open ? floatingId : undefined\n };\n }\n return {\n 'aria-expanded': open ? 'true' : 'false',\n 'aria-haspopup': ariaRole === 'alertdialog' ? 'dialog' : ariaRole,\n 'aria-controls': open ? floatingId : undefined,\n ...(ariaRole === 'listbox' && {\n role: 'combobox'\n }),\n ...(ariaRole === 'menu' && {\n id: referenceId\n }),\n ...(ariaRole === 'menu' && isNested && {\n role: 'menuitem'\n }),\n ...(role === 'select' && {\n 'aria-autocomplete': 'none'\n }),\n ...(role === 'combobox' && {\n 'aria-autocomplete': 'list'\n })\n };\n }, [ariaRole, floatingId, isNested, open, referenceId, role]);\n const floating = React.useMemo(() => {\n const floatingProps = {\n id: floatingId,\n ...(ariaRole && {\n role: ariaRole\n })\n };\n if (ariaRole === 'tooltip' || role === 'label') {\n return floatingProps;\n }\n return {\n ...floatingProps,\n ...(ariaRole === 'menu' && {\n 'aria-labelledby': referenceId\n })\n };\n }, [ariaRole, floatingId, referenceId, role]);\n const item = React.useCallback(_ref => {\n let {\n active,\n selected\n } = _ref;\n const commonProps = {\n role: 'option',\n ...(active && {\n id: floatingId + \"-option\"\n })\n };\n\n // For `menu`, we are unable to tell if the item is a `menuitemradio`\n // or `menuitemcheckbox`. For backwards-compatibility reasons, also\n // avoid defaulting to `menuitem` as it may overwrite custom role props.\n switch (role) {\n case 'select':\n return {\n ...commonProps,\n 'aria-selected': active && selected\n };\n case 'combobox':\n {\n return {\n ...commonProps,\n ...(active && {\n 'aria-selected': true\n })\n };\n }\n }\n return {};\n }, [floatingId, role]);\n return React.useMemo(() => enabled ? {\n reference,\n floating,\n item\n } : {}, [enabled, reference, floating, item]);\n}\n\n// Converts a JS style key like `backgroundColor` to a CSS transition-property\n// like `background-color`.\nconst camelCaseToKebabCase = str => str.replace(/[A-Z]+(?![a-z])|[A-Z]/g, ($, ofs) => (ofs ? '-' : '') + $.toLowerCase());\nfunction execWithArgsOrReturn(valueOrFn, args) {\n return typeof valueOrFn === 'function' ? valueOrFn(args) : valueOrFn;\n}\nfunction useDelayUnmount(open, durationMs) {\n const [isMounted, setIsMounted] = React.useState(open);\n if (open && !isMounted) {\n setIsMounted(true);\n }\n React.useEffect(() => {\n if (!open && isMounted) {\n const timeout = setTimeout(() => setIsMounted(false), durationMs);\n return () => clearTimeout(timeout);\n }\n }, [open, isMounted, durationMs]);\n return isMounted;\n}\n/**\n * Provides a status string to apply CSS transitions to a floating element,\n * correctly handling placement-aware transitions.\n * @see https://floating-ui.com/docs/useTransition#usetransitionstatus\n */\nfunction useTransitionStatus(context, props) {\n if (props === void 0) {\n props = {};\n }\n const {\n open,\n elements: {\n floating\n }\n } = context;\n const {\n duration = 250\n } = props;\n const isNumberDuration = typeof duration === 'number';\n const closeDuration = (isNumberDuration ? duration : duration.close) || 0;\n const [status, setStatus] = React.useState('unmounted');\n const isMounted = useDelayUnmount(open, closeDuration);\n if (!isMounted && status === 'close') {\n setStatus('unmounted');\n }\n index(() => {\n if (!floating) return;\n if (open) {\n setStatus('initial');\n const frame = requestAnimationFrame(() => {\n setStatus('open');\n });\n return () => {\n cancelAnimationFrame(frame);\n };\n }\n setStatus('close');\n }, [open, floating]);\n return {\n isMounted,\n status\n };\n}\n/**\n * Provides styles to apply CSS transitions to a floating element, correctly\n * handling placement-aware transitions. Wrapper around `useTransitionStatus`.\n * @see https://floating-ui.com/docs/useTransition#usetransitionstyles\n */\nfunction useTransitionStyles(context, props) {\n if (props === void 0) {\n props = {};\n }\n const {\n initial: unstable_initial = {\n opacity: 0\n },\n open: unstable_open,\n close: unstable_close,\n common: unstable_common,\n duration = 250\n } = props;\n const placement = context.placement;\n const side = placement.split('-')[0];\n const fnArgs = React.useMemo(() => ({\n side,\n placement\n }), [side, placement]);\n const isNumberDuration = typeof duration === 'number';\n const openDuration = (isNumberDuration ? duration : duration.open) || 0;\n const closeDuration = (isNumberDuration ? duration : duration.close) || 0;\n const [styles, setStyles] = React.useState(() => ({\n ...execWithArgsOrReturn(unstable_common, fnArgs),\n ...execWithArgsOrReturn(unstable_initial, fnArgs)\n }));\n const {\n isMounted,\n status\n } = useTransitionStatus(context, {\n duration\n });\n const initialRef = useLatestRef(unstable_initial);\n const openRef = useLatestRef(unstable_open);\n const closeRef = useLatestRef(unstable_close);\n const commonRef = useLatestRef(unstable_common);\n index(() => {\n const initialStyles = execWithArgsOrReturn(initialRef.current, fnArgs);\n const closeStyles = execWithArgsOrReturn(closeRef.current, fnArgs);\n const commonStyles = execWithArgsOrReturn(commonRef.current, fnArgs);\n const openStyles = execWithArgsOrReturn(openRef.current, fnArgs) || Object.keys(initialStyles).reduce((acc, key) => {\n acc[key] = '';\n return acc;\n }, {});\n if (status === 'initial') {\n setStyles(styles => ({\n transitionProperty: styles.transitionProperty,\n ...commonStyles,\n ...initialStyles\n }));\n }\n if (status === 'open') {\n setStyles({\n transitionProperty: Object.keys(openStyles).map(camelCaseToKebabCase).join(','),\n transitionDuration: openDuration + \"ms\",\n ...commonStyles,\n ...openStyles\n });\n }\n if (status === 'close') {\n const styles = closeStyles || initialStyles;\n setStyles({\n transitionProperty: Object.keys(styles).map(camelCaseToKebabCase).join(','),\n transitionDuration: closeDuration + \"ms\",\n ...commonStyles,\n ...styles\n });\n }\n }, [closeDuration, closeRef, initialRef, openRef, commonRef, openDuration, status, fnArgs]);\n return {\n isMounted,\n styles\n };\n}\n\n/**\n * Provides a matching callback that can be used to focus an item as the user\n * types, often used in tandem with `useListNavigation()`.\n * @see https://floating-ui.com/docs/useTypeahead\n */\nfunction useTypeahead(context, props) {\n var _ref;\n const {\n open,\n dataRef\n } = context;\n const {\n listRef,\n activeIndex,\n onMatch: unstable_onMatch,\n onTypingChange: unstable_onTypingChange,\n enabled = true,\n findMatch = null,\n resetMs = 750,\n ignoreKeys = [],\n selectedIndex = null\n } = props;\n const timeoutIdRef = React.useRef();\n const stringRef = React.useRef('');\n const prevIndexRef = React.useRef((_ref = selectedIndex != null ? selectedIndex : activeIndex) != null ? _ref : -1);\n const matchIndexRef = React.useRef(null);\n const onMatch = useEffectEvent(unstable_onMatch);\n const onTypingChange = useEffectEvent(unstable_onTypingChange);\n const findMatchRef = useLatestRef(findMatch);\n const ignoreKeysRef = useLatestRef(ignoreKeys);\n index(() => {\n if (open) {\n clearTimeout(timeoutIdRef.current);\n matchIndexRef.current = null;\n stringRef.current = '';\n }\n }, [open]);\n index(() => {\n // Sync arrow key navigation but not typeahead navigation.\n if (open && stringRef.current === '') {\n var _ref2;\n prevIndexRef.current = (_ref2 = selectedIndex != null ? selectedIndex : activeIndex) != null ? _ref2 : -1;\n }\n }, [open, selectedIndex, activeIndex]);\n const setTypingChange = useEffectEvent(value => {\n if (value) {\n if (!dataRef.current.typing) {\n dataRef.current.typing = value;\n onTypingChange(value);\n }\n } else {\n if (dataRef.current.typing) {\n dataRef.current.typing = value;\n onTypingChange(value);\n }\n }\n });\n const onKeyDown = useEffectEvent(event => {\n function getMatchingIndex(list, orderedList, string) {\n const str = findMatchRef.current ? findMatchRef.current(orderedList, string) : orderedList.find(text => (text == null ? void 0 : text.toLocaleLowerCase().indexOf(string.toLocaleLowerCase())) === 0);\n return str ? list.indexOf(str) : -1;\n }\n const listContent = listRef.current;\n if (stringRef.current.length > 0 && stringRef.current[0] !== ' ') {\n if (getMatchingIndex(listContent, listContent, stringRef.current) === -1) {\n setTypingChange(false);\n } else if (event.key === ' ') {\n stopEvent(event);\n }\n }\n if (listContent == null || ignoreKeysRef.current.includes(event.key) ||\n // Character key.\n event.key.length !== 1 ||\n // Modifier key.\n event.ctrlKey || event.metaKey || event.altKey) {\n return;\n }\n if (open && event.key !== ' ') {\n stopEvent(event);\n setTypingChange(true);\n }\n\n // Bail out if the list contains a word like \"llama\" or \"aaron\". TODO:\n // allow it in this case, too.\n const allowRapidSuccessionOfFirstLetter = listContent.every(text => {\n var _text$, _text$2;\n return text ? ((_text$ = text[0]) == null ? void 0 : _text$.toLocaleLowerCase()) !== ((_text$2 = text[1]) == null ? void 0 : _text$2.toLocaleLowerCase()) : true;\n });\n\n // Allows the user to cycle through items that start with the same letter\n // in rapid succession.\n if (allowRapidSuccessionOfFirstLetter && stringRef.current === event.key) {\n stringRef.current = '';\n prevIndexRef.current = matchIndexRef.current;\n }\n stringRef.current += event.key;\n clearTimeout(timeoutIdRef.current);\n timeoutIdRef.current = setTimeout(() => {\n stringRef.current = '';\n prevIndexRef.current = matchIndexRef.current;\n setTypingChange(false);\n }, resetMs);\n const prevIndex = prevIndexRef.current;\n const index = getMatchingIndex(listContent, [...listContent.slice((prevIndex || 0) + 1), ...listContent.slice(0, (prevIndex || 0) + 1)], stringRef.current);\n if (index !== -1) {\n onMatch(index);\n matchIndexRef.current = index;\n } else if (event.key !== ' ') {\n stringRef.current = '';\n setTypingChange(false);\n }\n });\n const reference = React.useMemo(() => ({\n onKeyDown\n }), [onKeyDown]);\n const floating = React.useMemo(() => {\n return {\n onKeyDown,\n onKeyUp(event) {\n if (event.key === ' ') {\n setTypingChange(false);\n }\n }\n };\n }, [onKeyDown, setTypingChange]);\n return React.useMemo(() => enabled ? {\n reference,\n floating\n } : {}, [enabled, reference, floating]);\n}\n\nfunction getArgsWithCustomFloatingHeight(state, height) {\n return {\n ...state,\n rects: {\n ...state.rects,\n floating: {\n ...state.rects.floating,\n height\n }\n }\n };\n}\n/**\n * Positions the floating element such that an inner element inside of it is\n * anchored to the reference element.\n * @see https://floating-ui.com/docs/inner\n * @deprecated\n */\nconst inner = props => ({\n name: 'inner',\n options: props,\n async fn(state) {\n const {\n listRef,\n overflowRef,\n onFallbackChange,\n offset: innerOffset = 0,\n index = 0,\n minItemsVisible = 4,\n referenceOverflowThreshold = 0,\n scrollRef,\n ...detectOverflowOptions\n } = evaluate(props, state);\n const {\n rects,\n elements: {\n floating\n }\n } = state;\n const item = listRef.current[index];\n const scrollEl = (scrollRef == null ? void 0 : scrollRef.current) || floating;\n\n // Valid combinations:\n // 1. Floating element is the scrollRef and has a border (default)\n // 2. Floating element is not the scrollRef, floating element has a border\n // 3. Floating element is not the scrollRef, scrollRef has a border\n // Floating > {...getFloatingProps()} wrapper > scrollRef > items is not\n // allowed as VoiceOver doesn't work.\n const clientTop = floating.clientTop || scrollEl.clientTop;\n const floatingIsBordered = floating.clientTop !== 0;\n const scrollElIsBordered = scrollEl.clientTop !== 0;\n const floatingIsScrollEl = floating === scrollEl;\n if (process.env.NODE_ENV !== \"production\") {\n if (!state.placement.startsWith('bottom')) {\n warn('`placement` side must be \"bottom\" when using the `inner`', 'middleware.');\n }\n }\n if (!item) {\n return {};\n }\n const nextArgs = {\n ...state,\n ...(await offset(-item.offsetTop - floating.clientTop - rects.reference.height / 2 - item.offsetHeight / 2 - innerOffset).fn(state))\n };\n const overflow = await detectOverflow(getArgsWithCustomFloatingHeight(nextArgs, scrollEl.scrollHeight + clientTop + floating.clientTop), detectOverflowOptions);\n const refOverflow = await detectOverflow(nextArgs, {\n ...detectOverflowOptions,\n elementContext: 'reference'\n });\n const diffY = max(0, overflow.top);\n const nextY = nextArgs.y + diffY;\n const isScrollable = scrollEl.scrollHeight > scrollEl.clientHeight;\n const rounder = isScrollable ? v => v : round;\n const maxHeight = rounder(max(0, scrollEl.scrollHeight + (floatingIsBordered && floatingIsScrollEl || scrollElIsBordered ? clientTop * 2 : 0) - diffY - max(0, overflow.bottom)));\n scrollEl.style.maxHeight = maxHeight + \"px\";\n scrollEl.scrollTop = diffY;\n\n // There is not enough space, fallback to standard anchored positioning\n if (onFallbackChange) {\n const shouldFallback = scrollEl.offsetHeight < item.offsetHeight * min(minItemsVisible, listRef.current.length) - 1 || refOverflow.top >= -referenceOverflowThreshold || refOverflow.bottom >= -referenceOverflowThreshold;\n ReactDOM.flushSync(() => onFallbackChange(shouldFallback));\n }\n if (overflowRef) {\n overflowRef.current = await detectOverflow(getArgsWithCustomFloatingHeight({\n ...nextArgs,\n y: nextY\n }, scrollEl.offsetHeight + clientTop + floating.clientTop), detectOverflowOptions);\n }\n return {\n y: nextY\n };\n }\n});\n/**\n * Changes the `inner` middleware's `offset` upon a `wheel` event to\n * expand the floating element's height, revealing more list items.\n * @see https://floating-ui.com/docs/inner\n * @deprecated\n */\nfunction useInnerOffset(context, props) {\n const {\n open,\n elements\n } = context;\n const {\n enabled = true,\n overflowRef,\n scrollRef,\n onChange: unstable_onChange\n } = props;\n const onChange = useEffectEvent(unstable_onChange);\n const controlledScrollingRef = React.useRef(false);\n const prevScrollTopRef = React.useRef(null);\n const initialOverflowRef = React.useRef(null);\n React.useEffect(() => {\n if (!enabled) return;\n function onWheel(e) {\n if (e.ctrlKey || !el || overflowRef.current == null) {\n return;\n }\n const dY = e.deltaY;\n const isAtTop = overflowRef.current.top >= -0.5;\n const isAtBottom = overflowRef.current.bottom >= -0.5;\n const remainingScroll = el.scrollHeight - el.clientHeight;\n const sign = dY < 0 ? -1 : 1;\n const method = dY < 0 ? 'max' : 'min';\n if (el.scrollHeight <= el.clientHeight) {\n return;\n }\n if (!isAtTop && dY > 0 || !isAtBottom && dY < 0) {\n e.preventDefault();\n ReactDOM.flushSync(() => {\n onChange(d => d + Math[method](dY, remainingScroll * sign));\n });\n } else if (/firefox/i.test(getUserAgent())) {\n // Needed to propagate scrolling during momentum scrolling phase once\n // it gets limited by the boundary. UX improvement, not critical.\n el.scrollTop += dY;\n }\n }\n const el = (scrollRef == null ? void 0 : scrollRef.current) || elements.floating;\n if (open && el) {\n el.addEventListener('wheel', onWheel);\n\n // Wait for the position to be ready.\n requestAnimationFrame(() => {\n prevScrollTopRef.current = el.scrollTop;\n if (overflowRef.current != null) {\n initialOverflowRef.current = {\n ...overflowRef.current\n };\n }\n });\n return () => {\n prevScrollTopRef.current = null;\n initialOverflowRef.current = null;\n el.removeEventListener('wheel', onWheel);\n };\n }\n }, [enabled, open, elements.floating, overflowRef, scrollRef, onChange]);\n const floating = React.useMemo(() => ({\n onKeyDown() {\n controlledScrollingRef.current = true;\n },\n onWheel() {\n controlledScrollingRef.current = false;\n },\n onPointerMove() {\n controlledScrollingRef.current = false;\n },\n onScroll() {\n const el = (scrollRef == null ? void 0 : scrollRef.current) || elements.floating;\n if (!overflowRef.current || !el || !controlledScrollingRef.current) {\n return;\n }\n if (prevScrollTopRef.current !== null) {\n const scrollDiff = el.scrollTop - prevScrollTopRef.current;\n if (overflowRef.current.bottom < -0.5 && scrollDiff < -1 || overflowRef.current.top < -0.5 && scrollDiff > 1) {\n ReactDOM.flushSync(() => onChange(d => d + scrollDiff));\n }\n }\n\n // [Firefox] Wait for the height change to have been applied.\n requestAnimationFrame(() => {\n prevScrollTopRef.current = el.scrollTop;\n });\n }\n }), [elements.floating, onChange, overflowRef, scrollRef]);\n return React.useMemo(() => enabled ? {\n floating\n } : {}, [enabled, floating]);\n}\n\nfunction isPointInPolygon(point, polygon) {\n const [x, y] = point;\n let isInside = false;\n const length = polygon.length;\n for (let i = 0, j = length - 1; i < length; j = i++) {\n const [xi, yi] = polygon[i] || [0, 0];\n const [xj, yj] = polygon[j] || [0, 0];\n const intersect = yi >= y !== yj >= y && x <= (xj - xi) * (y - yi) / (yj - yi) + xi;\n if (intersect) {\n isInside = !isInside;\n }\n }\n return isInside;\n}\nfunction isInside(point, rect) {\n return point[0] >= rect.x && point[0] <= rect.x + rect.width && point[1] >= rect.y && point[1] <= rect.y + rect.height;\n}\n/**\n * Generates a safe polygon area that the user can traverse without closing the\n * floating element once leaving the reference element.\n * @see https://floating-ui.com/docs/useHover#safepolygon\n */\nfunction safePolygon(options) {\n if (options === void 0) {\n options = {};\n }\n const {\n buffer = 0.5,\n blockPointerEvents = false,\n requireIntent = true\n } = options;\n let timeoutId;\n let hasLanded = false;\n let lastX = null;\n let lastY = null;\n let lastCursorTime = performance.now();\n function getCursorSpeed(x, y) {\n const currentTime = performance.now();\n const elapsedTime = currentTime - lastCursorTime;\n if (lastX === null || lastY === null || elapsedTime === 0) {\n lastX = x;\n lastY = y;\n lastCursorTime = currentTime;\n return null;\n }\n const deltaX = x - lastX;\n const deltaY = y - lastY;\n const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);\n const speed = distance / elapsedTime; // px / ms\n\n lastX = x;\n lastY = y;\n lastCursorTime = currentTime;\n return speed;\n }\n const fn = _ref => {\n let {\n x,\n y,\n placement,\n elements,\n onClose,\n nodeId,\n tree\n } = _ref;\n return function onMouseMove(event) {\n function close() {\n clearTimeout(timeoutId);\n onClose();\n }\n clearTimeout(timeoutId);\n if (!elements.domReference || !elements.floating || placement == null || x == null || y == null) {\n return;\n }\n const {\n clientX,\n clientY\n } = event;\n const clientPoint = [clientX, clientY];\n const target = getTarget(event);\n const isLeave = event.type === 'mouseleave';\n const isOverFloatingEl = contains(elements.floating, target);\n const isOverReferenceEl = contains(elements.domReference, target);\n const refRect = elements.domReference.getBoundingClientRect();\n const rect = elements.floating.getBoundingClientRect();\n const side = placement.split('-')[0];\n const cursorLeaveFromRight = x > rect.right - rect.width / 2;\n const cursorLeaveFromBottom = y > rect.bottom - rect.height / 2;\n const isOverReferenceRect = isInside(clientPoint, refRect);\n const isFloatingWider = rect.width > refRect.width;\n const isFloatingTaller = rect.height > refRect.height;\n const left = (isFloatingWider ? refRect : rect).left;\n const right = (isFloatingWider ? refRect : rect).right;\n const top = (isFloatingTaller ? refRect : rect).top;\n const bottom = (isFloatingTaller ? refRect : rect).bottom;\n if (isOverFloatingEl) {\n hasLanded = true;\n if (!isLeave) {\n return;\n }\n }\n if (isOverReferenceEl) {\n hasLanded = false;\n }\n if (isOverReferenceEl && !isLeave) {\n hasLanded = true;\n return;\n }\n\n // Prevent overlapping floating element from being stuck in an open-close\n // loop: https://github.com/floating-ui/floating-ui/issues/1910\n if (isLeave && isElement(event.relatedTarget) && contains(elements.floating, event.relatedTarget)) {\n return;\n }\n\n // If any nested child is open, abort.\n if (tree && getChildren(tree.nodesRef.current, nodeId).some(_ref2 => {\n let {\n context\n } = _ref2;\n return context == null ? void 0 : context.open;\n })) {\n return;\n }\n\n // If the pointer is leaving from the opposite side, the \"buffer\" logic\n // creates a point where the floating element remains open, but should be\n // ignored.\n // A constant of 1 handles floating point rounding errors.\n if (side === 'top' && y >= refRect.bottom - 1 || side === 'bottom' && y <= refRect.top + 1 || side === 'left' && x >= refRect.right - 1 || side === 'right' && x <= refRect.left + 1) {\n return close();\n }\n\n // Ignore when the cursor is within the rectangular trough between the\n // two elements. Since the triangle is created from the cursor point,\n // which can start beyond the ref element's edge, traversing back and\n // forth from the ref to the floating element can cause it to close. This\n // ensures it always remains open in that case.\n let rectPoly = [];\n switch (side) {\n case 'top':\n rectPoly = [[left, refRect.top + 1], [left, rect.bottom - 1], [right, rect.bottom - 1], [right, refRect.top + 1]];\n break;\n case 'bottom':\n rectPoly = [[left, rect.top + 1], [left, refRect.bottom - 1], [right, refRect.bottom - 1], [right, rect.top + 1]];\n break;\n case 'left':\n rectPoly = [[rect.right - 1, bottom], [rect.right - 1, top], [refRect.left + 1, top], [refRect.left + 1, bottom]];\n break;\n case 'right':\n rectPoly = [[refRect.right - 1, bottom], [refRect.right - 1, top], [rect.left + 1, top], [rect.left + 1, bottom]];\n break;\n }\n function getPolygon(_ref3) {\n let [x, y] = _ref3;\n switch (side) {\n case 'top':\n {\n const cursorPointOne = [isFloatingWider ? x + buffer / 2 : cursorLeaveFromRight ? x + buffer * 4 : x - buffer * 4, y + buffer + 1];\n const cursorPointTwo = [isFloatingWider ? x - buffer / 2 : cursorLeaveFromRight ? x + buffer * 4 : x - buffer * 4, y + buffer + 1];\n const commonPoints = [[rect.left, cursorLeaveFromRight ? rect.bottom - buffer : isFloatingWider ? rect.bottom - buffer : rect.top], [rect.right, cursorLeaveFromRight ? isFloatingWider ? rect.bottom - buffer : rect.top : rect.bottom - buffer]];\n return [cursorPointOne, cursorPointTwo, ...commonPoints];\n }\n case 'bottom':\n {\n const cursorPointOne = [isFloatingWider ? x + buffer / 2 : cursorLeaveFromRight ? x + buffer * 4 : x - buffer * 4, y - buffer];\n const cursorPointTwo = [isFloatingWider ? x - buffer / 2 : cursorLeaveFromRight ? x + buffer * 4 : x - buffer * 4, y - buffer];\n const commonPoints = [[rect.left, cursorLeaveFromRight ? rect.top + buffer : isFloatingWider ? rect.top + buffer : rect.bottom], [rect.right, cursorLeaveFromRight ? isFloatingWider ? rect.top + buffer : rect.bottom : rect.top + buffer]];\n return [cursorPointOne, cursorPointTwo, ...commonPoints];\n }\n case 'left':\n {\n const cursorPointOne = [x + buffer + 1, isFloatingTaller ? y + buffer / 2 : cursorLeaveFromBottom ? y + buffer * 4 : y - buffer * 4];\n const cursorPointTwo = [x + buffer + 1, isFloatingTaller ? y - buffer / 2 : cursorLeaveFromBottom ? y + buffer * 4 : y - buffer * 4];\n const commonPoints = [[cursorLeaveFromBottom ? rect.right - buffer : isFloatingTaller ? rect.right - buffer : rect.left, rect.top], [cursorLeaveFromBottom ? isFloatingTaller ? rect.right - buffer : rect.left : rect.right - buffer, rect.bottom]];\n return [...commonPoints, cursorPointOne, cursorPointTwo];\n }\n case 'right':\n {\n const cursorPointOne = [x - buffer, isFloatingTaller ? y + buffer / 2 : cursorLeaveFromBottom ? y + buffer * 4 : y - buffer * 4];\n const cursorPointTwo = [x - buffer, isFloatingTaller ? y - buffer / 2 : cursorLeaveFromBottom ? y + buffer * 4 : y - buffer * 4];\n const commonPoints = [[cursorLeaveFromBottom ? rect.left + buffer : isFloatingTaller ? rect.left + buffer : rect.right, rect.top], [cursorLeaveFromBottom ? isFloatingTaller ? rect.left + buffer : rect.right : rect.left + buffer, rect.bottom]];\n return [cursorPointOne, cursorPointTwo, ...commonPoints];\n }\n }\n }\n if (isPointInPolygon([clientX, clientY], rectPoly)) {\n return;\n }\n if (hasLanded && !isOverReferenceRect) {\n return close();\n }\n if (!isLeave && requireIntent) {\n const cursorSpeed = getCursorSpeed(event.clientX, event.clientY);\n const cursorSpeedThreshold = 0.1;\n if (cursorSpeed !== null && cursorSpeed < cursorSpeedThreshold) {\n return close();\n }\n }\n if (!isPointInPolygon([clientX, clientY], getPolygon([x, y]))) {\n close();\n } else if (!hasLanded && requireIntent) {\n timeoutId = window.setTimeout(close, 40);\n }\n };\n };\n fn.__options = {\n blockPointerEvents\n };\n return fn;\n}\n\nexport { Composite, CompositeItem, FloatingArrow, FloatingDelayGroup, FloatingFocusManager, FloatingList, FloatingNode, FloatingOverlay, FloatingPortal, FloatingTree, inner, safePolygon, useClick, useClientPoint, useDelayGroup, useDelayGroupContext, useDismiss, useFloating, useFloatingNodeId, useFloatingParentNodeId, useFloatingPortalNode, useFloatingRootContext, useFloatingTree, useFocus, useHover, useId, useInnerOffset, useInteractions, useListItem, useListNavigation, useMergeRefs, useRole, useTransitionStatus, useTransitionStyles, useTypeahead };\n","/*!\n react-datepicker v8.0.0\n https://github.com/Hacker0x01/react-datepicker\n Released under the MIT License.\n*/\nimport { clsx } from 'clsx';\nimport React, { useRef, useCallback, useEffect, cloneElement, Component, createRef, createElement } from 'react';\nimport { isSameMonth as isSameMonth$1, isSameDay as isSameDay$1, isEqual as isEqual$1, isDate, parseISO, toDate, parse, isValid as isValid$1, isBefore, format, setHours, setMinutes, setSeconds, getISOWeek, startOfDay, startOfWeek, startOfMonth, startOfYear, startOfQuarter, endOfDay, endOfMonth, isSameYear as isSameYear$1, isSameQuarter as isSameQuarter$1, isWithinInterval, setMonth, setQuarter, getYear, getMonth, endOfYear, getQuarter, differenceInCalendarDays, getHours, getMinutes, getSeconds, subMonths, differenceInCalendarMonths, addMonths, subQuarters, differenceInCalendarQuarters, addQuarters, subYears, differenceInCalendarYears, addYears, min, max, addHours, addMinutes, addSeconds, isAfter, endOfWeek, getDay, getDate, addDays, addWeeks, getTime, setYear, differenceInDays, subWeeks, subDays } from 'date-fns';\nimport { useFloating, autoUpdate, flip, offset, arrow, FloatingArrow } from '@floating-ui/react';\nimport ReactDOM from 'react-dom';\n\n/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\n/* global Reflect, Promise, SuppressedError, Symbol, Iterator */\n\nvar _extendStatics = function extendStatics(d, b) {\n _extendStatics = Object.setPrototypeOf || {\n __proto__: []\n } instanceof Array && function (d, b) {\n d.__proto__ = b;\n } || function (d, b) {\n for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];\n };\n return _extendStatics(d, b);\n};\nfunction __extends(d, b) {\n if (typeof b !== \"function\" && b !== null) throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n _extendStatics(d, b);\n function __() {\n this.constructor = d;\n }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n}\nvar _assign = function __assign() {\n _assign = Object.assign || function __assign(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n }\n return t;\n };\n return _assign.apply(this, arguments);\n};\nfunction __spreadArray(to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n}\ntypeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\n var e = new Error(message);\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\n};\n\nvar CalendarContainer = function (_a) {\n var _b = _a.showTimeSelectOnly, showTimeSelectOnly = _b === undefined ? false : _b, _c = _a.showTime, showTime = _c === undefined ? false : _c, className = _a.className, children = _a.children;\n var ariaLabel = showTimeSelectOnly\n ? \"Choose Time\"\n : \"Choose Date\".concat(showTime ? \" and Time\" : \"\");\n return (React.createElement(\"div\", { className: className, role: \"dialog\", \"aria-label\": ariaLabel, \"aria-modal\": \"true\" }, children));\n};\n\nvar useDetectClickOutside = function (onClickOutside, ignoreClass) {\n var ref = useRef(null);\n var onClickOutsideRef = useRef(onClickOutside);\n onClickOutsideRef.current = onClickOutside;\n var handleClickOutside = useCallback(function (event) {\n var _a;\n var target = (event.composed &&\n event.composedPath &&\n event\n .composedPath()\n .find(function (eventTarget) { return eventTarget instanceof Node; })) ||\n event.target;\n if (ref.current && !ref.current.contains(target)) {\n if (!(ignoreClass &&\n target instanceof HTMLElement &&\n target.classList.contains(ignoreClass))) {\n (_a = onClickOutsideRef.current) === null || _a === undefined ? undefined : _a.call(onClickOutsideRef, event);\n }\n }\n }, [ignoreClass]);\n useEffect(function () {\n document.addEventListener(\"mousedown\", handleClickOutside);\n return function () {\n document.removeEventListener(\"mousedown\", handleClickOutside);\n };\n }, [handleClickOutside]);\n return ref;\n};\nvar ClickOutsideWrapper = function (_a) {\n var children = _a.children, onClickOutside = _a.onClickOutside, className = _a.className, containerRef = _a.containerRef, style = _a.style, ignoreClass = _a.ignoreClass;\n var detectRef = useDetectClickOutside(onClickOutside, ignoreClass);\n return (React.createElement(\"div\", { className: className, style: style, ref: function (node) {\n detectRef.current = node;\n if (containerRef) {\n containerRef.current = node;\n }\n } }, children));\n};\n\nvar KeyType;\n(function (KeyType) {\n KeyType[\"ArrowUp\"] = \"ArrowUp\";\n KeyType[\"ArrowDown\"] = \"ArrowDown\";\n KeyType[\"ArrowLeft\"] = \"ArrowLeft\";\n KeyType[\"ArrowRight\"] = \"ArrowRight\";\n KeyType[\"PageUp\"] = \"PageUp\";\n KeyType[\"PageDown\"] = \"PageDown\";\n KeyType[\"Home\"] = \"Home\";\n KeyType[\"End\"] = \"End\";\n KeyType[\"Enter\"] = \"Enter\";\n KeyType[\"Space\"] = \" \";\n KeyType[\"Tab\"] = \"Tab\";\n KeyType[\"Escape\"] = \"Escape\";\n KeyType[\"Backspace\"] = \"Backspace\";\n KeyType[\"X\"] = \"x\";\n})(KeyType || (KeyType = {}));\nfunction getLocaleScope() {\n // Use this cast to avoid messing with users globalThis (like window) and the rest of keys in the globalThis object we don't care about\n var scope = (typeof window !== \"undefined\"\n ? window\n : globalThis);\n return scope;\n}\nvar DEFAULT_YEAR_ITEM_NUMBER = 12;\n// ** Date Constructors **\nfunction newDate(value) {\n if (value == null) {\n return new Date();\n }\n var d = typeof value === \"string\" ? parseISO(value) : toDate(value);\n return isValid(d) ? d : new Date();\n}\n/**\n * Parses a date.\n *\n * @param value - The string representing the Date in a parsable form, e.g., ISO 1861\n * @param dateFormat - The date format.\n * @param locale - The locale.\n * @param strictParsing - The strict parsing flag.\n * @param refDate - The base date to be passed to date-fns parse() function.\n * @returns - The parsed date or null.\n */\nfunction parseDate(value, dateFormat, locale, strictParsing, refDate) {\n if (refDate === undefined) { refDate = newDate(); }\n var localeObject = getLocaleObject(locale) || getLocaleObject(getDefaultLocale());\n var formats = Array.isArray(dateFormat) ? dateFormat : [dateFormat];\n for (var _i = 0, formats_1 = formats; _i < formats_1.length; _i++) {\n var format_1 = formats_1[_i];\n var parsedDate = parse(value, format_1, refDate, {\n locale: localeObject,\n useAdditionalWeekYearTokens: true,\n useAdditionalDayOfYearTokens: true,\n });\n if (isValid(parsedDate) &&\n (!strictParsing || value === formatDate(parsedDate, format_1, locale))) {\n return parsedDate;\n }\n }\n return null;\n}\n/**\n * Checks if a given date is valid and not before the minimum date.\n * @param date - The date to be checked.\n * @param minDate - The minimum date allowed. If not provided, defaults to \"1/1/1800\".\n * @returns A boolean value indicating whether the date is valid and not before the minimum date.\n */\nfunction isValid(date, minDate) {\n /* the fallback date is essential to not break test case\n * `should auto update calendar when the updated date text is after props.minDate`\n * and backward compatibility respectfully\n */\n return isValid$1(date) && !isBefore(date, new Date(\"1/1/1800\"));\n}\n// ** Date Formatting **\n/**\n * Formats a date.\n *\n * @param date - The date.\n * @param formatStr - The format string.\n * @param locale - The locale.\n * @returns - The formatted date.\n */\nfunction formatDate(date, formatStr, locale) {\n if (locale === \"en\") {\n return format(date, formatStr, {\n useAdditionalWeekYearTokens: true,\n useAdditionalDayOfYearTokens: true,\n });\n }\n var localeObj = locale ? getLocaleObject(locale) : undefined;\n if (locale && !localeObj) {\n console.warn(\"A locale object was not found for the provided string [\\\"\".concat(locale, \"\\\"].\"));\n }\n localeObj = localeObj || getLocaleObject(getDefaultLocale());\n return format(date, formatStr, {\n locale: localeObj,\n useAdditionalWeekYearTokens: true,\n useAdditionalDayOfYearTokens: true,\n });\n}\n/**\n * Safely formats a date.\n *\n * @param date - The date.\n * @param options - An object containing the dateFormat and locale.\n * @returns - The formatted date or an empty string.\n */\nfunction safeDateFormat(date, _a) {\n var dateFormat = _a.dateFormat, locale = _a.locale;\n var formatStr = (Array.isArray(dateFormat) && dateFormat.length > 0\n ? dateFormat[0]\n : dateFormat); // Cast to string because it's impossible to get `string | string[] | undefined` here and typescript doesn't know that\n return (date && formatDate(date, formatStr, locale)) || \"\";\n}\n/**\n * Safely formats a date range.\n *\n * @param startDate - The start date.\n * @param endDate - The end date.\n * @param props - The props.\n * @returns - The formatted date range or an empty string.\n */\nfunction safeDateRangeFormat(startDate, endDate, props) {\n if (!startDate) {\n return \"\";\n }\n var formattedStartDate = safeDateFormat(startDate, props);\n var formattedEndDate = endDate ? safeDateFormat(endDate, props) : \"\";\n return \"\".concat(formattedStartDate, \" - \").concat(formattedEndDate);\n}\n/**\n * Safely formats multiple dates.\n *\n * @param dates - The dates.\n * @param props - The props.\n * @returns - The formatted dates or an empty string.\n */\nfunction safeMultipleDatesFormat(dates, props) {\n if (!(dates === null || dates === undefined ? undefined : dates.length)) {\n return \"\";\n }\n var formattedFirstDate = dates[0] ? safeDateFormat(dates[0], props) : \"\";\n if (dates.length === 1) {\n return formattedFirstDate;\n }\n if (dates.length === 2 && dates[1]) {\n var formattedSecondDate = safeDateFormat(dates[1], props);\n return \"\".concat(formattedFirstDate, \", \").concat(formattedSecondDate);\n }\n var extraDatesCount = dates.length - 1;\n return \"\".concat(formattedFirstDate, \" (+\").concat(extraDatesCount, \")\");\n}\n// ** Date Setters **\n/**\n * Sets the time for a given date.\n *\n * @param date - The date.\n * @param time - An object containing the hour, minute, and second.\n * @returns - The date with the time set.\n */\nfunction setTime(date, _a) {\n var _b = _a.hour, hour = _b === undefined ? 0 : _b, _c = _a.minute, minute = _c === undefined ? 0 : _c, _d = _a.second, second = _d === undefined ? 0 : _d;\n return setHours(setMinutes(setSeconds(date, second), minute), hour);\n}\n/**\n * Gets the week of the year for a given date.\n *\n * @param date - The date.\n * @returns - The week of the year.\n */\nfunction getWeek(date) {\n return getISOWeek(date);\n}\n/**\n * Gets the day of the week code for a given day.\n *\n * @param day - The day.\n * @param locale - The locale.\n * @returns - The day of the week code.\n */\nfunction getDayOfWeekCode(day, locale) {\n return formatDate(day, \"ddd\", locale);\n}\n// *** Start of ***\n/**\n * Gets the start of the day for a given date.\n *\n * @param date - The date.\n * @returns - The start of the day.\n */\nfunction getStartOfDay(date) {\n return startOfDay(date);\n}\n/**\n * Gets the start of the week for a given date.\n *\n * @param date - The date.\n * @param locale - The locale.\n * @param calendarStartDay - The day the calendar starts on.\n * @returns - The start of the week.\n */\nfunction getStartOfWeek(date, locale, calendarStartDay) {\n var localeObj = locale\n ? getLocaleObject(locale)\n : getLocaleObject(getDefaultLocale());\n return startOfWeek(date, {\n locale: localeObj,\n weekStartsOn: calendarStartDay,\n });\n}\n/**\n * Gets the start of the month for a given date.\n *\n * @param date - The date.\n * @returns - The start of the month.\n */\nfunction getStartOfMonth(date) {\n return startOfMonth(date);\n}\n/**\n * Gets the start of the year for a given date.\n *\n * @param date - The date.\n * @returns - The start of the year.\n */\nfunction getStartOfYear(date) {\n return startOfYear(date);\n}\n/**\n * Gets the start of the quarter for a given date.\n *\n * @param date - The date.\n * @returns - The start of the quarter.\n */\nfunction getStartOfQuarter(date) {\n return startOfQuarter(date);\n}\n/**\n * Gets the start of today.\n *\n * @returns - The start of today.\n */\nfunction getStartOfToday() {\n return startOfDay(newDate());\n}\n// *** End of ***\n/**\n * Gets the end of the day for a given date.\n *\n * @param date - The date.\n * @returns - The end of the day.\n */\nfunction getEndOfDay(date) {\n return endOfDay(date);\n}\n/**\n * Gets the end of the week for a given date.\n *\n * @param date - The date.\n * @returns - The end of the week.\n */\nfunction getEndOfWeek(date) {\n return endOfWeek(date);\n}\n/**\n * Gets the end of the month for a given date.\n *\n * @param date - The date.\n * @returns - The end of the month.\n */\nfunction getEndOfMonth(date) {\n return endOfMonth(date);\n}\n/**\n * Checks if two dates are in the same year.\n *\n * @param date1 - The first date.\n * @param date2 - The second date.\n * @returns - True if the dates are in the same year, false otherwise.\n */\nfunction isSameYear(date1, date2) {\n if (date1 && date2) {\n return isSameYear$1(date1, date2);\n }\n else {\n return !date1 && !date2;\n }\n}\n/**\n * Checks if two dates are in the same month.\n *\n * @param date1 - The first date.\n * @param date2 - The second date.\n * @returns - True if the dates are in the same month, false otherwise.\n */\nfunction isSameMonth(date1, date2) {\n if (date1 && date2) {\n return isSameMonth$1(date1, date2);\n }\n else {\n return !date1 && !date2;\n }\n}\n/**\n * Checks if two dates are in the same quarter.\n *\n * @param date1 - The first date.\n * @param date2 - The second date.\n * @returns - True if the dates are in the same quarter, false otherwise.\n */\nfunction isSameQuarter(date1, date2) {\n if (date1 && date2) {\n return isSameQuarter$1(date1, date2);\n }\n else {\n return !date1 && !date2;\n }\n}\n/**\n * Checks if two dates are on the same day.\n *\n * @param date1 - The first date.\n * @param date2 - The second date.\n * @returns - True if the dates are on the same day, false otherwise.\n */\nfunction isSameDay(date1, date2) {\n if (date1 && date2) {\n return isSameDay$1(date1, date2);\n }\n else {\n return !date1 && !date2;\n }\n}\n/**\n * Checks if two dates are equal.\n *\n * @param date1 - The first date.\n * @param date2 - The second date.\n * @returns - True if the dates are equal, false otherwise.\n */\nfunction isEqual(date1, date2) {\n if (date1 && date2) {\n return isEqual$1(date1, date2);\n }\n else {\n return !date1 && !date2;\n }\n}\n/**\n * Checks if a day is within a date range.\n *\n * @param day - The day to check.\n * @param startDate - The start date of the range.\n * @param endDate - The end date of the range.\n * @returns - True if the day is within the range, false otherwise.\n */\nfunction isDayInRange(day, startDate, endDate) {\n var valid;\n var start = startOfDay(startDate);\n var end = endOfDay(endDate);\n try {\n valid = isWithinInterval(day, { start: start, end: end });\n }\n catch (err) {\n valid = false;\n }\n return valid;\n}\n// ** Date Localization **\n/**\n * Registers a locale.\n *\n * @param localeName - The name of the locale.\n * @param localeData - The data of the locale.\n */\nfunction registerLocale(localeName, localeData) {\n var scope = getLocaleScope();\n if (!scope.__localeData__) {\n scope.__localeData__ = {};\n }\n scope.__localeData__[localeName] = localeData;\n}\n/**\n * Sets the default locale.\n *\n * @param localeName - The name of the locale.\n */\nfunction setDefaultLocale(localeName) {\n var scope = getLocaleScope();\n scope.__localeId__ = localeName;\n}\n/**\n * Gets the default locale.\n *\n * @returns - The default locale.\n */\nfunction getDefaultLocale() {\n var scope = getLocaleScope();\n return scope.__localeId__;\n}\n/**\n * Gets the locale object.\n *\n * @param localeSpec - The locale specification.\n * @returns - The locale object.\n */\nfunction getLocaleObject(localeSpec) {\n if (typeof localeSpec === \"string\") {\n // Treat it as a locale name registered by registerLocale\n var scope = getLocaleScope();\n // Null was replaced with undefined to avoid type coercion\n return scope.__localeData__ ? scope.__localeData__[localeSpec] : undefined;\n }\n else {\n // Treat it as a raw date-fns locale object\n return localeSpec;\n }\n}\n/**\n * Formats the weekday in a given locale.\n *\n * @param date - The date to format.\n * @param formatFunc - The formatting function.\n * @param locale - The locale to use for formatting.\n * @returns - The formatted weekday.\n */\nfunction getFormattedWeekdayInLocale(date, formatFunc, locale) {\n return formatFunc(formatDate(date, \"EEEE\", locale));\n}\n/**\n * Gets the minimum weekday in a given locale.\n *\n * @param date - The date to format.\n * @param locale - The locale to use for formatting.\n * @returns - The minimum weekday.\n */\nfunction getWeekdayMinInLocale(date, locale) {\n return formatDate(date, \"EEEEEE\", locale);\n}\n/**\n * Gets the short weekday in a given locale.\n *\n * @param date - The date to format.\n * @param locale - The locale to use for formatting.\n * @returns - The short weekday.\n */\nfunction getWeekdayShortInLocale(date, locale) {\n return formatDate(date, \"EEE\", locale);\n}\n/**\n * Gets the month in a given locale.\n *\n * @param month - The month to format.\n * @param locale - The locale to use for formatting.\n * @returns - The month.\n */\nfunction getMonthInLocale(month, locale) {\n return formatDate(setMonth(newDate(), month), \"LLLL\", locale);\n}\n/**\n * Gets the short month in a given locale.\n *\n * @param month - The month to format.\n * @param locale - The locale to use for formatting.\n * @returns - The short month.\n */\nfunction getMonthShortInLocale(month, locale) {\n return formatDate(setMonth(newDate(), month), \"LLL\", locale);\n}\n/**\n * Gets the short quarter in a given locale.\n *\n * @param quarter - The quarter to format.\n * @param locale - The locale to use for formatting.\n * @returns - The short quarter.\n */\nfunction getQuarterShortInLocale(quarter, locale) {\n return formatDate(setQuarter(newDate(), quarter), \"QQQ\", locale);\n}\n/**\n * Checks if a day is disabled.\n *\n * @param day - The day to check.\n * @param options - The options to consider when checking.\n * @returns - Returns true if the day is disabled, false otherwise.\n */\nfunction isDayDisabled(day, _a) {\n var _b = _a === undefined ? {} : _a, minDate = _b.minDate, maxDate = _b.maxDate, excludeDates = _b.excludeDates, excludeDateIntervals = _b.excludeDateIntervals, includeDates = _b.includeDates, includeDateIntervals = _b.includeDateIntervals, filterDate = _b.filterDate;\n return (isOutOfBounds(day, { minDate: minDate, maxDate: maxDate }) ||\n (excludeDates &&\n excludeDates.some(function (excludeDate) {\n if (excludeDate instanceof Date) {\n return isSameDay(day, excludeDate);\n }\n else {\n return isSameDay(day, excludeDate.date);\n }\n })) ||\n (excludeDateIntervals &&\n excludeDateIntervals.some(function (_a) {\n var start = _a.start, end = _a.end;\n return isWithinInterval(day, { start: start, end: end });\n })) ||\n (includeDates &&\n !includeDates.some(function (includeDate) { return isSameDay(day, includeDate); })) ||\n (includeDateIntervals &&\n !includeDateIntervals.some(function (_a) {\n var start = _a.start, end = _a.end;\n return isWithinInterval(day, { start: start, end: end });\n })) ||\n (filterDate && !filterDate(newDate(day))) ||\n false);\n}\n/**\n * Checks if a day is excluded.\n *\n * @param day - The day to check.\n * @param options - The options to consider when checking.\n * @returns - Returns true if the day is excluded, false otherwise.\n */\nfunction isDayExcluded(day, _a) {\n var _b = _a === undefined ? {} : _a, excludeDates = _b.excludeDates, excludeDateIntervals = _b.excludeDateIntervals;\n if (excludeDateIntervals && excludeDateIntervals.length > 0) {\n return excludeDateIntervals.some(function (_a) {\n var start = _a.start, end = _a.end;\n return isWithinInterval(day, { start: start, end: end });\n });\n }\n return ((excludeDates &&\n excludeDates.some(function (excludeDate) {\n var _a;\n if (excludeDate instanceof Date) {\n return isSameDay(day, excludeDate);\n }\n else {\n return isSameDay(day, (_a = excludeDate.date) !== null && _a !== undefined ? _a : new Date());\n }\n })) ||\n false);\n}\nfunction isMonthDisabled(month, _a) {\n var _b = _a === undefined ? {} : _a, minDate = _b.minDate, maxDate = _b.maxDate, excludeDates = _b.excludeDates, includeDates = _b.includeDates, filterDate = _b.filterDate;\n return (isOutOfBounds(month, {\n minDate: minDate ? startOfMonth(minDate) : undefined,\n maxDate: maxDate ? endOfMonth(maxDate) : undefined,\n }) ||\n (excludeDates === null || excludeDates === undefined ? undefined : excludeDates.some(function (excludeDate) {\n return isSameMonth(month, excludeDate instanceof Date ? excludeDate : excludeDate.date);\n })) ||\n (includeDates &&\n !includeDates.some(function (includeDate) { return isSameMonth(month, includeDate); })) ||\n (filterDate && !filterDate(newDate(month))) ||\n false);\n}\nfunction isMonthInRange(startDate, endDate, m, day) {\n var startDateYear = getYear(startDate);\n var startDateMonth = getMonth(startDate);\n var endDateYear = getYear(endDate);\n var endDateMonth = getMonth(endDate);\n var dayYear = getYear(day);\n if (startDateYear === endDateYear && startDateYear === dayYear) {\n return startDateMonth <= m && m <= endDateMonth;\n }\n else if (startDateYear < endDateYear) {\n return ((dayYear === startDateYear && startDateMonth <= m) ||\n (dayYear === endDateYear && endDateMonth >= m) ||\n (dayYear < endDateYear && dayYear > startDateYear));\n }\n return false;\n}\n/**\n * To check if a date's month and year are disabled/excluded\n * @param date Date to check\n * @returns {boolean} true if month and year are disabled/excluded, false otherwise\n */\nfunction isMonthYearDisabled(date, _a) {\n var _b = _a === undefined ? {} : _a, minDate = _b.minDate, maxDate = _b.maxDate, excludeDates = _b.excludeDates, includeDates = _b.includeDates;\n return (isOutOfBounds(date, { minDate: minDate, maxDate: maxDate }) ||\n (excludeDates &&\n excludeDates.some(function (excludedDate) {\n return isSameMonth(excludedDate instanceof Date ? excludedDate : excludedDate.date, date);\n })) ||\n (includeDates &&\n !includeDates.some(function (includedDate) { return isSameMonth(includedDate, date); })) ||\n false);\n}\nfunction isQuarterDisabled(quarter, _a) {\n var _b = _a === undefined ? {} : _a, minDate = _b.minDate, maxDate = _b.maxDate, excludeDates = _b.excludeDates, includeDates = _b.includeDates, filterDate = _b.filterDate;\n return (isOutOfBounds(quarter, { minDate: minDate, maxDate: maxDate }) ||\n (excludeDates === null || excludeDates === undefined ? undefined : excludeDates.some(function (excludeDate) {\n return isSameQuarter(quarter, excludeDate instanceof Date ? excludeDate : excludeDate.date);\n })) ||\n (includeDates &&\n !includeDates.some(function (includeDate) {\n return isSameQuarter(quarter, includeDate);\n })) ||\n (filterDate && !filterDate(newDate(quarter))) ||\n false);\n}\nfunction isYearInRange(year, start, end) {\n if (!start || !end)\n return false;\n if (!isValid$1(start) || !isValid$1(end))\n return false;\n var startYear = getYear(start);\n var endYear = getYear(end);\n return startYear <= year && endYear >= year;\n}\nfunction isYearDisabled(year, _a) {\n var _b = _a === undefined ? {} : _a, minDate = _b.minDate, maxDate = _b.maxDate, excludeDates = _b.excludeDates, includeDates = _b.includeDates, filterDate = _b.filterDate;\n var date = new Date(year, 0, 1);\n return (isOutOfBounds(date, {\n minDate: minDate ? startOfYear(minDate) : undefined,\n maxDate: maxDate ? endOfYear(maxDate) : undefined,\n }) ||\n (excludeDates === null || excludeDates === undefined ? undefined : excludeDates.some(function (excludeDate) {\n return isSameYear(date, excludeDate instanceof Date ? excludeDate : excludeDate.date);\n })) ||\n (includeDates &&\n !includeDates.some(function (includeDate) { return isSameYear(date, includeDate); })) ||\n (filterDate && !filterDate(newDate(date))) ||\n false);\n}\nfunction isQuarterInRange(startDate, endDate, q, day) {\n var startDateYear = getYear(startDate);\n var startDateQuarter = getQuarter(startDate);\n var endDateYear = getYear(endDate);\n var endDateQuarter = getQuarter(endDate);\n var dayYear = getYear(day);\n if (startDateYear === endDateYear && startDateYear === dayYear) {\n return startDateQuarter <= q && q <= endDateQuarter;\n }\n else if (startDateYear < endDateYear) {\n return ((dayYear === startDateYear && startDateQuarter <= q) ||\n (dayYear === endDateYear && endDateQuarter >= q) ||\n (dayYear < endDateYear && dayYear > startDateYear));\n }\n return false;\n}\nfunction isOutOfBounds(day, _a) {\n var _b;\n var _c = _a === undefined ? {} : _a, minDate = _c.minDate, maxDate = _c.maxDate;\n return ((_b = ((minDate && differenceInCalendarDays(day, minDate) < 0) ||\n (maxDate && differenceInCalendarDays(day, maxDate) > 0))) !== null && _b !== undefined ? _b : false);\n}\nfunction isTimeInList(time, times) {\n return times.some(function (listTime) {\n return getHours(listTime) === getHours(time) &&\n getMinutes(listTime) === getMinutes(time) &&\n getSeconds(listTime) === getSeconds(time);\n });\n}\nfunction isTimeDisabled(time, _a) {\n var _b = _a === undefined ? {} : _a, excludeTimes = _b.excludeTimes, includeTimes = _b.includeTimes, filterTime = _b.filterTime;\n return ((excludeTimes && isTimeInList(time, excludeTimes)) ||\n (includeTimes && !isTimeInList(time, includeTimes)) ||\n (filterTime && !filterTime(time)) ||\n false);\n}\nfunction isTimeInDisabledRange(time, _a) {\n var minTime = _a.minTime, maxTime = _a.maxTime;\n if (!minTime || !maxTime) {\n throw new Error(\"Both minTime and maxTime props required\");\n }\n var baseTime = newDate();\n baseTime = setHours(baseTime, getHours(time));\n baseTime = setMinutes(baseTime, getMinutes(time));\n baseTime = setSeconds(baseTime, getSeconds(time));\n var min = newDate();\n min = setHours(min, getHours(minTime));\n min = setMinutes(min, getMinutes(minTime));\n min = setSeconds(min, getSeconds(minTime));\n var max = newDate();\n max = setHours(max, getHours(maxTime));\n max = setMinutes(max, getMinutes(maxTime));\n max = setSeconds(max, getSeconds(maxTime));\n var valid;\n try {\n valid = !isWithinInterval(baseTime, { start: min, end: max });\n }\n catch (err) {\n valid = false;\n }\n return valid;\n}\nfunction monthDisabledBefore(day, _a) {\n var _b = _a === undefined ? {} : _a, minDate = _b.minDate, includeDates = _b.includeDates;\n var previousMonth = subMonths(day, 1);\n return ((minDate && differenceInCalendarMonths(minDate, previousMonth) > 0) ||\n (includeDates &&\n includeDates.every(function (includeDate) {\n return differenceInCalendarMonths(includeDate, previousMonth) > 0;\n })) ||\n false);\n}\nfunction monthDisabledAfter(day, _a) {\n var _b = _a === undefined ? {} : _a, maxDate = _b.maxDate, includeDates = _b.includeDates;\n var nextMonth = addMonths(day, 1);\n return ((maxDate && differenceInCalendarMonths(nextMonth, maxDate) > 0) ||\n (includeDates &&\n includeDates.every(function (includeDate) { return differenceInCalendarMonths(nextMonth, includeDate) > 0; })) ||\n false);\n}\nfunction quarterDisabledBefore(date, _a) {\n var _b = _a === undefined ? {} : _a, minDate = _b.minDate, includeDates = _b.includeDates;\n var firstDateOfYear = startOfYear(date);\n var previousQuarter = subQuarters(firstDateOfYear, 1);\n return ((minDate && differenceInCalendarQuarters(minDate, previousQuarter) > 0) ||\n (includeDates &&\n includeDates.every(function (includeDate) {\n return differenceInCalendarQuarters(includeDate, previousQuarter) > 0;\n })) ||\n false);\n}\nfunction quarterDisabledAfter(date, _a) {\n var _b = _a === undefined ? {} : _a, maxDate = _b.maxDate, includeDates = _b.includeDates;\n var lastDateOfYear = endOfYear(date);\n var nextQuarter = addQuarters(lastDateOfYear, 1);\n return ((maxDate && differenceInCalendarQuarters(nextQuarter, maxDate) > 0) ||\n (includeDates &&\n includeDates.every(function (includeDate) {\n return differenceInCalendarQuarters(nextQuarter, includeDate) > 0;\n })) ||\n false);\n}\nfunction yearDisabledBefore(day, _a) {\n var _b = _a === undefined ? {} : _a, minDate = _b.minDate, includeDates = _b.includeDates;\n var previousYear = subYears(day, 1);\n return ((minDate && differenceInCalendarYears(minDate, previousYear) > 0) ||\n (includeDates &&\n includeDates.every(function (includeDate) {\n return differenceInCalendarYears(includeDate, previousYear) > 0;\n })) ||\n false);\n}\nfunction yearsDisabledBefore(day, _a) {\n var _b = _a === undefined ? {} : _a, minDate = _b.minDate, _c = _b.yearItemNumber, yearItemNumber = _c === undefined ? DEFAULT_YEAR_ITEM_NUMBER : _c;\n var previousYear = getStartOfYear(subYears(day, yearItemNumber));\n var endPeriod = getYearsPeriod(previousYear, yearItemNumber).endPeriod;\n var minDateYear = minDate && getYear(minDate);\n return (minDateYear && minDateYear > endPeriod) || false;\n}\nfunction yearDisabledAfter(day, _a) {\n var _b = _a === undefined ? {} : _a, maxDate = _b.maxDate, includeDates = _b.includeDates;\n var nextYear = addYears(day, 1);\n return ((maxDate && differenceInCalendarYears(nextYear, maxDate) > 0) ||\n (includeDates &&\n includeDates.every(function (includeDate) { return differenceInCalendarYears(nextYear, includeDate) > 0; })) ||\n false);\n}\nfunction yearsDisabledAfter(day, _a) {\n var _b = _a === undefined ? {} : _a, maxDate = _b.maxDate, _c = _b.yearItemNumber, yearItemNumber = _c === undefined ? DEFAULT_YEAR_ITEM_NUMBER : _c;\n var nextYear = addYears(day, yearItemNumber);\n var startPeriod = getYearsPeriod(nextYear, yearItemNumber).startPeriod;\n var maxDateYear = maxDate && getYear(maxDate);\n return (maxDateYear && maxDateYear < startPeriod) || false;\n}\nfunction getEffectiveMinDate(_a) {\n var minDate = _a.minDate, includeDates = _a.includeDates;\n if (includeDates && minDate) {\n var minDates = includeDates.filter(function (includeDate) { return differenceInCalendarDays(includeDate, minDate) >= 0; });\n return min(minDates);\n }\n else if (includeDates) {\n return min(includeDates);\n }\n else {\n return minDate;\n }\n}\nfunction getEffectiveMaxDate(_a) {\n var maxDate = _a.maxDate, includeDates = _a.includeDates;\n if (includeDates && maxDate) {\n var maxDates = includeDates.filter(function (includeDate) { return differenceInCalendarDays(includeDate, maxDate) <= 0; });\n return max(maxDates);\n }\n else if (includeDates) {\n return max(includeDates);\n }\n else {\n return maxDate;\n }\n}\n/**\n * Get a map of highlighted dates with their corresponding classes.\n * @param highlightDates The dates to highlight.\n * @param defaultClassName The default class to use for highlighting.\n * @returns A map with dates as keys and arrays of class names as values.\n */\nfunction getHighLightDaysMap(highlightDates, defaultClassName) {\n var _a;\n if (highlightDates === undefined) { highlightDates = []; }\n if (defaultClassName === undefined) { defaultClassName = \"react-datepicker__day--highlighted\"; }\n var dateClasses = new Map();\n for (var i = 0, len = highlightDates.length; i < len; i++) {\n var obj = highlightDates[i];\n if (isDate(obj)) {\n var key = formatDate(obj, \"MM.dd.yyyy\");\n var classNamesArr = dateClasses.get(key) || [];\n if (!classNamesArr.includes(defaultClassName)) {\n classNamesArr.push(defaultClassName);\n dateClasses.set(key, classNamesArr);\n }\n }\n else if (typeof obj === \"object\") {\n var keys = Object.keys(obj);\n var className = (_a = keys[0]) !== null && _a !== undefined ? _a : \"\";\n var arrOfDates = obj[className];\n if (typeof className === \"string\" && Array.isArray(arrOfDates)) {\n for (var k = 0, len_1 = arrOfDates.length; k < len_1; k++) {\n var dateK = arrOfDates[k];\n if (dateK) {\n var key = formatDate(dateK, \"MM.dd.yyyy\");\n var classNamesArr = dateClasses.get(key) || [];\n if (!classNamesArr.includes(className)) {\n classNamesArr.push(className);\n dateClasses.set(key, classNamesArr);\n }\n }\n }\n }\n }\n }\n return dateClasses;\n}\n/**\n * Compare the two arrays\n * @param array1 The first array to compare.\n * @param array2 The second array to compare.\n * @returns true, if the passed arrays are equal, false otherwise.\n */\nfunction arraysAreEqual(array1, array2) {\n if (array1.length !== array2.length) {\n return false;\n }\n return array1.every(function (value, index) { return value === array2[index]; });\n}\n/**\n * Assign the custom class to each date\n * @param holidayDates array of object containing date and name of the holiday\n * @param defaultClassName className to be added.\n * @returns Map containing date as key and array of className and holiday name as value\n */\nfunction getHolidaysMap(holidayDates, defaultClassName) {\n if (holidayDates === undefined) { holidayDates = []; }\n if (defaultClassName === undefined) { defaultClassName = \"react-datepicker__day--holidays\"; }\n var dateClasses = new Map();\n holidayDates.forEach(function (holiday) {\n var dateObj = holiday.date, holidayName = holiday.holidayName;\n if (!isDate(dateObj)) {\n return;\n }\n var key = formatDate(dateObj, \"MM.dd.yyyy\");\n var classNamesObj = dateClasses.get(key) || {\n className: \"\",\n holidayNames: [],\n };\n if (\"className\" in classNamesObj &&\n classNamesObj[\"className\"] === defaultClassName &&\n arraysAreEqual(classNamesObj[\"holidayNames\"], [holidayName])) {\n return;\n }\n classNamesObj[\"className\"] = defaultClassName;\n var holidayNameArr = classNamesObj[\"holidayNames\"];\n classNamesObj[\"holidayNames\"] = holidayNameArr\n ? __spreadArray(__spreadArray([], holidayNameArr, true), [holidayName], false) : [holidayName];\n dateClasses.set(key, classNamesObj);\n });\n return dateClasses;\n}\n/**\n * Determines the times to inject after a given start of day, current time, and multiplier.\n * @param startOfDay The start of the day.\n * @param currentTime The current time.\n * @param currentMultiplier The current multiplier.\n * @param intervals The intervals.\n * @param injectedTimes The times to potentially inject.\n * @returns An array of times to inject.\n */\nfunction timesToInjectAfter(startOfDay, currentTime, currentMultiplier, intervals, injectedTimes) {\n var l = injectedTimes.length;\n var times = [];\n for (var i = 0; i < l; i++) {\n var injectedTime = startOfDay;\n var injectedTimeValue = injectedTimes[i];\n if (injectedTimeValue) {\n injectedTime = addHours(injectedTime, getHours(injectedTimeValue));\n injectedTime = addMinutes(injectedTime, getMinutes(injectedTimeValue));\n injectedTime = addSeconds(injectedTime, getSeconds(injectedTimeValue));\n }\n var nextTime = addMinutes(startOfDay, (currentMultiplier + 1) * intervals);\n if (isAfter(injectedTime, currentTime) &&\n isBefore(injectedTime, nextTime) &&\n injectedTimeValue != undefined) {\n times.push(injectedTimeValue);\n }\n }\n return times;\n}\n/**\n * Adds a leading zero to a number if it's less than 10.\n * @param i The number to add a leading zero to.\n * @returns The number as a string, with a leading zero if it was less than 10.\n */\nfunction addZero(i) {\n return i < 10 ? \"0\".concat(i) : \"\".concat(i);\n}\n/**\n * Gets the start and end years for a period.\n * @param date The date to get the period for.\n * @param yearItemNumber The number of years in the period. Defaults to DEFAULT_YEAR_ITEM_NUMBER.\n * @returns An object with the start and end years for the period.\n */\nfunction getYearsPeriod(date, yearItemNumber) {\n if (yearItemNumber === undefined) { yearItemNumber = DEFAULT_YEAR_ITEM_NUMBER; }\n var endPeriod = Math.ceil(getYear(date) / yearItemNumber) * yearItemNumber;\n var startPeriod = endPeriod - (yearItemNumber - 1);\n return { startPeriod: startPeriod, endPeriod: endPeriod };\n}\n/**\n * Gets the number of hours in a day.\n * @param d The date to get the number of hours for.\n * @returns The number of hours in the day.\n */\nfunction getHoursInDay(d) {\n var startOfDay = new Date(d.getFullYear(), d.getMonth(), d.getDate());\n var startOfTheNextDay = new Date(d.getFullYear(), d.getMonth(), d.getDate(), 24);\n return Math.round((+startOfTheNextDay - +startOfDay) / 3600000);\n}\n/**\n * Returns the start of the minute for the given date\n *\n * NOTE: this function is a DST and timezone-safe analog of `date-fns/startOfMinute`\n * do not make changes unless you know what you're doing\n *\n * See comments on https://github.com/Hacker0x01/react-datepicker/pull/4244\n * for more details\n *\n * @param d date\n * @returns start of the minute\n */\nfunction startOfMinute(d) {\n var seconds = d.getSeconds();\n var milliseconds = d.getMilliseconds();\n return toDate(d.getTime() - seconds * 1000 - milliseconds);\n}\n/**\n * Returns whether the given dates are in the same minute\n *\n * This function is a DST and timezone-safe analog of `date-fns/isSameMinute`\n *\n * @param d1\n * @param d2\n * @returns\n */\nfunction isSameMinute(d1, d2) {\n return startOfMinute(d1).getTime() === startOfMinute(d2).getTime();\n}\n/**\n * Returns a new datetime object representing the input date with midnight time\n * @param date The date to get the midnight time for\n * @returns A new datetime object representing the input date with midnight time\n */\nfunction getMidnightDate(date) {\n if (!isDate(date)) {\n throw new Error(\"Invalid date\");\n }\n var dateWithoutTime = new Date(date);\n dateWithoutTime.setHours(0, 0, 0, 0);\n return dateWithoutTime;\n}\n/**\n * Is the first date before the second one?\n * @param date The date that should be before the other one to return true\n * @param dateToCompare The date to compare with\n * @returns The first date is before the second date\n *\n * Note:\n * This function considers the mid-night of the given dates for comparison.\n * It evaluates whether date is before dateToCompare based on their mid-night timestamps.\n */\nfunction isDateBefore(date, dateToCompare) {\n if (!isDate(date) || !isDate(dateToCompare)) {\n throw new Error(\"Invalid date received\");\n }\n var midnightDate = getMidnightDate(date);\n var midnightDateToCompare = getMidnightDate(dateToCompare);\n return isBefore(midnightDate, midnightDateToCompare);\n}\n/**\n * Checks if the space key was pressed down.\n *\n * @param event - The keyboard event.\n * @returns - Returns true if the space key was pressed down, false otherwise.\n */\nfunction isSpaceKeyDown(event) {\n return event.key === KeyType.Space;\n}\n\n/**\n * `InputTime` is a React component that manages time input.\n *\n * @component\n * @example\n *
\n *\n * @param props - The properties that define the `InputTime` component.\n * @param props.onChange - Function that is called when the date changes.\n * @param props.date - The initial date value.\n * @param props.timeString - The initial time string value.\n * @param props.timeInputLabel - The label for the time input.\n * @param props.customTimeInput - An optional custom time input element.\n *\n * @returns The `InputTime` component.\n */\nvar InputTime = /** @class */ (function (_super) {\n __extends(InputTime, _super);\n function InputTime(props) {\n var _this = _super.call(this, props) || this;\n _this.inputRef = React.createRef();\n _this.onTimeChange = function (time) {\n var _a, _b;\n _this.setState({ time: time });\n var propDate = _this.props.date;\n var isPropDateValid = propDate instanceof Date && !isNaN(+propDate);\n var date = isPropDateValid ? propDate : new Date();\n if (time === null || time === undefined ? undefined : time.includes(\":\")) {\n var _c = time.split(\":\"), hours = _c[0], minutes = _c[1];\n date.setHours(Number(hours));\n date.setMinutes(Number(minutes));\n }\n (_b = (_a = _this.props).onChange) === null || _b === undefined ? undefined : _b.call(_a, date);\n };\n _this.renderTimeInput = function () {\n var time = _this.state.time;\n var _a = _this.props, date = _a.date, timeString = _a.timeString, customTimeInput = _a.customTimeInput;\n if (customTimeInput) {\n return cloneElement(customTimeInput, {\n date: date,\n value: time,\n onChange: _this.onTimeChange,\n });\n }\n return (React.createElement(\"input\", { type: \"time\", className: \"react-datepicker-time__input\", placeholder: \"Time\", name: \"time-input\", ref: _this.inputRef, onClick: function () {\n var _a;\n (_a = _this.inputRef.current) === null || _a === undefined ? undefined : _a.focus();\n }, required: true, value: time, onChange: function (event) {\n _this.onTimeChange(event.target.value || timeString);\n } }));\n };\n _this.state = {\n time: _this.props.timeString,\n };\n return _this;\n }\n InputTime.getDerivedStateFromProps = function (props, state) {\n if (props.timeString !== state.time) {\n return {\n time: props.timeString,\n };\n }\n // Return null to indicate no change to state.\n return null;\n };\n InputTime.prototype.render = function () {\n return (React.createElement(\"div\", { className: \"react-datepicker__input-time-container\" },\n React.createElement(\"div\", { className: \"react-datepicker-time__caption\" }, this.props.timeInputLabel),\n React.createElement(\"div\", { className: \"react-datepicker-time__input-container\" },\n React.createElement(\"div\", { className: \"react-datepicker-time__input\" }, this.renderTimeInput()))));\n };\n return InputTime;\n}(Component));\n\n/**\n * `Day` is a React component that represents a single day in a date picker.\n * It handles the rendering and interaction of a day.\n *\n * @prop ariaLabelPrefixWhenEnabled - Aria label prefix when the day is enabled.\n * @prop ariaLabelPrefixWhenDisabled - Aria label prefix when the day is disabled.\n * @prop disabledKeyboardNavigation - Whether keyboard navigation is disabled.\n * @prop day - The day to be displayed.\n * @prop dayClassName - Function to customize the CSS class of the day.\n * @prop endDate - The end date in a range.\n * @prop highlightDates - Map of dates to be highlighted.\n * @prop holidays - Map of holiday dates.\n * @prop inline - Whether the date picker is inline.\n * @prop shouldFocusDayInline - Whether the day should be focused when date picker is inline.\n * @prop month - The month the day belongs to.\n * @prop onClick - Click event handler.\n * @prop onMouseEnter - Mouse enter event handler.\n * @prop handleOnKeyDown - Key down event handler.\n * @prop usePointerEvent - Whether to use pointer events.\n * @prop preSelection - The date that is currently selected.\n * @prop selected - The selected date.\n * @prop selectingDate - The date currently being selected.\n * @prop selectsEnd - Whether the day can be the end date in a range.\n * @prop selectsStart - Whether the day can be the start date in a range.\n * @prop selectsRange - Whether the day can be in a range.\n * @prop showWeekPicker - Whether to show week picker.\n * @prop showWeekNumber - Whether to show week numbers.\n * @prop selectsDisabledDaysInRange - Whether to select disabled days in a range.\n * @prop selectsMultiple - Whether to allow multiple date selection.\n * @prop selectedDates - Array of selected dates.\n * @prop startDate - The start date in a range.\n * @prop renderDayContents - Function to customize the rendering of the day's contents.\n * @prop containerRef - Ref for the container.\n * @prop excludeDates - Array of dates to be excluded.\n * @prop calendarStartDay - The start day of the week.\n * @prop locale - The locale object.\n * @prop monthShowsDuplicateDaysEnd - Whether to show duplicate days at the end of the month.\n * @prop monthShowsDuplicateDaysStart - Whether to show duplicate days at the start of the month.\n * @prop includeDates - Array of dates to be included.\n * @prop includeDateIntervals - Array of date intervals to be included.\n * @prop minDate - The minimum date that can be selected.\n * @prop maxDate - The maximum date that can be selected.\n *\n * @example\n * ```tsx\n * import React from 'react';\n * import Day from './day';\n *\n * function MyComponent() {\n * const handleDayClick = (event) => {\n * console.log('Day clicked', event);\n * };\n *\n * const handleDayMouseEnter = (event) => {\n * console.log('Mouse entered day', event);\n * };\n *\n * const renderDayContents = (date) => {\n * return
{date.getDate()}
;\n * };\n *\n * return (\n *
\n * );\n * }\n *\n * export default MyComponent;\n * ```\n */\nvar Day = /** @class */ (function (_super) {\n __extends(Day, _super);\n function Day() {\n var _this = _super !== null && _super.apply(this, arguments) || this;\n _this.dayEl = createRef();\n _this.handleClick = function (event) {\n if (!_this.isDisabled() && _this.props.onClick) {\n _this.props.onClick(event);\n }\n };\n _this.handleMouseEnter = function (event) {\n if (!_this.isDisabled() && _this.props.onMouseEnter) {\n _this.props.onMouseEnter(event);\n }\n };\n _this.handleOnKeyDown = function (event) {\n var _a, _b;\n var eventKey = event.key;\n if (eventKey === KeyType.Space) {\n event.preventDefault();\n event.key = KeyType.Enter;\n }\n (_b = (_a = _this.props).handleOnKeyDown) === null || _b === undefined ? undefined : _b.call(_a, event);\n };\n _this.isSameDay = function (other) {\n return isSameDay(_this.props.day, other);\n };\n _this.isKeyboardSelected = function () {\n var _a;\n if (_this.props.disabledKeyboardNavigation) {\n return false;\n }\n var isSelectedDate = _this.props.selectsMultiple\n ? (_a = _this.props.selectedDates) === null || _a === undefined ? undefined : _a.some(function (date) { return _this.isSameDayOrWeek(date); })\n : _this.isSameDayOrWeek(_this.props.selected);\n var isDisabled = _this.props.preSelection && _this.isDisabled(_this.props.preSelection);\n return (!isSelectedDate &&\n _this.isSameDayOrWeek(_this.props.preSelection) &&\n !isDisabled);\n };\n _this.isDisabled = function (day) {\n if (day === undefined) { day = _this.props.day; }\n // Almost all props previously were passed as this.props w/o proper typing with prop-types\n // after the migration to TS i made it explicit\n return isDayDisabled(day, {\n minDate: _this.props.minDate,\n maxDate: _this.props.maxDate,\n excludeDates: _this.props.excludeDates,\n excludeDateIntervals: _this.props.excludeDateIntervals,\n includeDateIntervals: _this.props.includeDateIntervals,\n includeDates: _this.props.includeDates,\n filterDate: _this.props.filterDate,\n });\n };\n _this.isExcluded = function () {\n // Almost all props previously were passed as this.props w/o proper typing with prop-types\n // after the migration to TS i made it explicit\n return isDayExcluded(_this.props.day, {\n excludeDates: _this.props.excludeDates,\n excludeDateIntervals: _this.props.excludeDateIntervals,\n });\n };\n _this.isStartOfWeek = function () {\n return isSameDay(_this.props.day, getStartOfWeek(_this.props.day, _this.props.locale, _this.props.calendarStartDay));\n };\n _this.isSameWeek = function (other) {\n return _this.props.showWeekPicker &&\n isSameDay(other, getStartOfWeek(_this.props.day, _this.props.locale, _this.props.calendarStartDay));\n };\n _this.isSameDayOrWeek = function (other) {\n return _this.isSameDay(other) || _this.isSameWeek(other);\n };\n _this.getHighLightedClass = function () {\n var _a = _this.props, day = _a.day, highlightDates = _a.highlightDates;\n if (!highlightDates) {\n return false;\n }\n // Looking for className in the Map of {'day string, 'className'}\n var dayStr = formatDate(day, \"MM.dd.yyyy\");\n return highlightDates.get(dayStr);\n };\n // Function to return the array containing className associated to the date\n _this.getHolidaysClass = function () {\n var _a;\n var _b = _this.props, day = _b.day, holidays = _b.holidays;\n if (!holidays) {\n // For type consistency no other reasons\n return [undefined];\n }\n var dayStr = formatDate(day, \"MM.dd.yyyy\");\n // Looking for className in the Map of {day string: {className, holidayName}}\n if (holidays.has(dayStr)) {\n return [(_a = holidays.get(dayStr)) === null || _a === undefined ? undefined : _a.className];\n }\n // For type consistency no other reasons\n return [undefined];\n };\n _this.isInRange = function () {\n var _a = _this.props, day = _a.day, startDate = _a.startDate, endDate = _a.endDate;\n if (!startDate || !endDate) {\n return false;\n }\n return isDayInRange(day, startDate, endDate);\n };\n _this.isInSelectingRange = function () {\n var _a;\n var _b = _this.props, day = _b.day, selectsStart = _b.selectsStart, selectsEnd = _b.selectsEnd, selectsRange = _b.selectsRange, selectsDisabledDaysInRange = _b.selectsDisabledDaysInRange, startDate = _b.startDate, endDate = _b.endDate;\n var selectingDate = (_a = _this.props.selectingDate) !== null && _a !== undefined ? _a : _this.props.preSelection;\n if (!(selectsStart || selectsEnd || selectsRange) ||\n !selectingDate ||\n (!selectsDisabledDaysInRange && _this.isDisabled())) {\n return false;\n }\n if (selectsStart &&\n endDate &&\n (isBefore(selectingDate, endDate) || isEqual(selectingDate, endDate))) {\n return isDayInRange(day, selectingDate, endDate);\n }\n if (selectsEnd &&\n startDate &&\n (isAfter(selectingDate, startDate) || isEqual(selectingDate, startDate))) {\n return isDayInRange(day, startDate, selectingDate);\n }\n if (selectsRange &&\n startDate &&\n !endDate &&\n (isAfter(selectingDate, startDate) || isEqual(selectingDate, startDate))) {\n return isDayInRange(day, startDate, selectingDate);\n }\n return false;\n };\n _this.isSelectingRangeStart = function () {\n var _a;\n if (!_this.isInSelectingRange()) {\n return false;\n }\n var _b = _this.props, day = _b.day, startDate = _b.startDate, selectsStart = _b.selectsStart;\n var selectingDate = (_a = _this.props.selectingDate) !== null && _a !== undefined ? _a : _this.props.preSelection;\n if (selectsStart) {\n return isSameDay(day, selectingDate);\n }\n else {\n return isSameDay(day, startDate);\n }\n };\n _this.isSelectingRangeEnd = function () {\n var _a;\n if (!_this.isInSelectingRange()) {\n return false;\n }\n var _b = _this.props, day = _b.day, endDate = _b.endDate, selectsEnd = _b.selectsEnd, selectsRange = _b.selectsRange;\n var selectingDate = (_a = _this.props.selectingDate) !== null && _a !== undefined ? _a : _this.props.preSelection;\n if (selectsEnd || selectsRange) {\n return isSameDay(day, selectingDate);\n }\n else {\n return isSameDay(day, endDate);\n }\n };\n _this.isRangeStart = function () {\n var _a = _this.props, day = _a.day, startDate = _a.startDate, endDate = _a.endDate;\n if (!startDate || !endDate) {\n return false;\n }\n return isSameDay(startDate, day);\n };\n _this.isRangeEnd = function () {\n var _a = _this.props, day = _a.day, startDate = _a.startDate, endDate = _a.endDate;\n if (!startDate || !endDate) {\n return false;\n }\n return isSameDay(endDate, day);\n };\n _this.isWeekend = function () {\n var weekday = getDay(_this.props.day);\n return weekday === 0 || weekday === 6;\n };\n _this.isAfterMonth = function () {\n return (_this.props.month !== undefined &&\n (_this.props.month + 1) % 12 === getMonth(_this.props.day));\n };\n _this.isBeforeMonth = function () {\n return (_this.props.month !== undefined &&\n (getMonth(_this.props.day) + 1) % 12 === _this.props.month);\n };\n _this.isCurrentDay = function () { return _this.isSameDay(newDate()); };\n _this.isSelected = function () {\n var _a;\n if (_this.props.selectsMultiple) {\n return (_a = _this.props.selectedDates) === null || _a === undefined ? undefined : _a.some(function (date) {\n return _this.isSameDayOrWeek(date);\n });\n }\n return _this.isSameDayOrWeek(_this.props.selected);\n };\n _this.getClassNames = function (date) {\n var dayClassName = _this.props.dayClassName\n ? _this.props.dayClassName(date)\n : undefined;\n return clsx(\"react-datepicker__day\", dayClassName, \"react-datepicker__day--\" + getDayOfWeekCode(_this.props.day), {\n \"react-datepicker__day--disabled\": _this.isDisabled(),\n \"react-datepicker__day--excluded\": _this.isExcluded(),\n \"react-datepicker__day--selected\": _this.isSelected(),\n \"react-datepicker__day--keyboard-selected\": _this.isKeyboardSelected(),\n \"react-datepicker__day--range-start\": _this.isRangeStart(),\n \"react-datepicker__day--range-end\": _this.isRangeEnd(),\n \"react-datepicker__day--in-range\": _this.isInRange(),\n \"react-datepicker__day--in-selecting-range\": _this.isInSelectingRange(),\n \"react-datepicker__day--selecting-range-start\": _this.isSelectingRangeStart(),\n \"react-datepicker__day--selecting-range-end\": _this.isSelectingRangeEnd(),\n \"react-datepicker__day--today\": _this.isCurrentDay(),\n \"react-datepicker__day--weekend\": _this.isWeekend(),\n \"react-datepicker__day--outside-month\": _this.isAfterMonth() || _this.isBeforeMonth(),\n }, _this.getHighLightedClass(), _this.getHolidaysClass());\n };\n _this.getAriaLabel = function () {\n var _a = _this.props, day = _a.day, _b = _a.ariaLabelPrefixWhenEnabled, ariaLabelPrefixWhenEnabled = _b === undefined ? \"Choose\" : _b, _c = _a.ariaLabelPrefixWhenDisabled, ariaLabelPrefixWhenDisabled = _c === undefined ? \"Not available\" : _c;\n var prefix = _this.isDisabled() || _this.isExcluded()\n ? ariaLabelPrefixWhenDisabled\n : ariaLabelPrefixWhenEnabled;\n return \"\".concat(prefix, \" \").concat(formatDate(day, \"PPPP\", _this.props.locale));\n };\n // A function to return the holiday's name as title's content\n _this.getTitle = function () {\n var _a = _this.props, day = _a.day, _b = _a.holidays, holidays = _b === undefined ? new Map() : _b, excludeDates = _a.excludeDates;\n var compareDt = formatDate(day, \"MM.dd.yyyy\");\n var titles = [];\n if (holidays.has(compareDt)) {\n titles.push.apply(titles, holidays.get(compareDt).holidayNames);\n }\n if (_this.isExcluded()) {\n titles.push(excludeDates === null || excludeDates === undefined ? undefined : excludeDates.filter(function (excludeDate) {\n if (excludeDate instanceof Date) {\n return isSameDay(excludeDate, day);\n }\n return isSameDay(excludeDate === null || excludeDate === undefined ? undefined : excludeDate.date, day);\n }).map(function (excludeDate) {\n if (excludeDate instanceof Date) {\n return undefined;\n }\n return excludeDate === null || excludeDate === undefined ? undefined : excludeDate.message;\n }));\n }\n // I'm not sure that this is a right output, but all tests are green\n return titles.join(\", \");\n };\n _this.getTabIndex = function () {\n var selectedDay = _this.props.selected;\n var preSelectionDay = _this.props.preSelection;\n var tabIndex = !(_this.props.showWeekPicker &&\n (_this.props.showWeekNumber || !_this.isStartOfWeek())) &&\n (_this.isKeyboardSelected() ||\n (_this.isSameDay(selectedDay) &&\n isSameDay(preSelectionDay, selectedDay)))\n ? 0\n : -1;\n return tabIndex;\n };\n // various cases when we need to apply focus to the preselected day\n // focus the day on mount/update so that keyboard navigation works while cycling through months with up or down keys (not for prev and next month buttons)\n // prevent focus for these activeElement cases so we don't pull focus from the input as the calendar opens\n _this.handleFocusDay = function () {\n var _a;\n // only do this while the input isn't focused\n // otherwise, typing/backspacing the date manually may steal focus away from the input\n _this.shouldFocusDay() && ((_a = _this.dayEl.current) === null || _a === undefined ? undefined : _a.focus({ preventScroll: true }));\n };\n _this.renderDayContents = function () {\n if (_this.props.monthShowsDuplicateDaysEnd && _this.isAfterMonth())\n return null;\n if (_this.props.monthShowsDuplicateDaysStart && _this.isBeforeMonth())\n return null;\n return _this.props.renderDayContents\n ? _this.props.renderDayContents(getDate(_this.props.day), _this.props.day)\n : getDate(_this.props.day);\n };\n _this.render = function () { return (\n // TODO: Use