'use strict';

var chunkCUFFPIPP_cjs = require('./chunk-CUFFPIPP.cjs');
var input = require('@base-ui/react/input');
var popover = require('@base-ui/react/popover');
var classnames3 = require('classnames');
var React6 = require('react');
var combobox = require('@base-ui/react/combobox');
var icons = require('@blueprintjs/icons');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var classnames3__default = /*#__PURE__*/_interopDefault(classnames3);
var React6__default = /*#__PURE__*/_interopDefault(React6);

// src/shared/PortalDismissLayer.module.css
var PortalDismissLayer_default = {};

// src/shared/PortalDismissLayer.tsx
var PortalDismissLayer = /* @__PURE__ */ React6__default.default.memo(function PortalDismissLayer2({
  className,
  onDismiss
}) {
  const handlePointerDown = React6.useCallback((event) => {
    event.preventDefault();
    onDismiss();
  }, [onDismiss]);
  return /* @__PURE__ */ React6__default.default.createElement("div", {
    "aria-hidden": "true",
    className: classnames3__default.default(PortalDismissLayer_default.osdkPortalDismissLayer, className),
    "data-osdk-portal-dismiss-layer": "",
    onPointerDown: handlePointerDown
  });
});

// src/shared/calendar/DatePickerCommon.module.css
var DatePickerCommon_default = {};

// src/shared/calendar/LazyDateCalendar.tsx
var DateCalendarLazy = /* @__PURE__ */ React6__default.default.lazy(() => import('./DateCalendar-BX6YESN7.cjs'));
function LazyDateCalendar(props) {
  return /* @__PURE__ */ React6__default.default.createElement(React6.Suspense, {
    fallback: /* @__PURE__ */ React6__default.default.createElement("div", {
      className: DatePickerCommon_default.osdkDatePickerFallback
    })
  }, /* @__PURE__ */ React6__default.default.createElement(DateCalendarLazy, props));
}
function useDateEditState({
  value,
  displayFormatFn,
  editFormatFn,
  parseFn,
  min,
  max,
  onChange
}) {
  const [isEditing, setIsEditing] = React6.useState(false);
  const [inputValue, setInputValue] = React6.useState("");
  const prevValueTimeRef = React6.useRef(value?.getTime() ?? null);
  const currentValueTime = value?.getTime() ?? null;
  if (prevValueTimeRef.current !== currentValueTime) {
    prevValueTimeRef.current = currentValueTime;
    if (!isEditing) {
      setInputValue(value != null ? editFormatFn(value) : "");
    }
  }
  const displayedValue = isEditing ? inputValue : value != null ? displayFormatFn(value) : "";
  const dateValue = inputValue !== "" ? parseFn(inputValue) : void 0;
  const inputError = (() => {
    if (!isEditing || inputValue === "") return null;
    if (dateValue == null) return "invalid";
    if (!chunkCUFFPIPP_cjs.isDateInRange(dateValue, min, max)) return "out-of-range";
    return null;
  })();
  const validatedDate = inputError == null && dateValue != null ? dateValue : null;
  const setDateValue = React6.useCallback((date) => {
    setInputValue(date != null ? editFormatFn(date) : "");
  }, [editFormatFn]);
  const startEditing = React6.useCallback(() => {
    setIsEditing(true);
    setDateValue(value);
  }, [value, setDateValue]);
  const stopEditing = React6.useCallback(() => {
    setIsEditing(false);
    setDateValue(value);
  }, [value, setDateValue]);
  const inputValueRef = React6.useRef(inputValue);
  inputValueRef.current = inputValue;
  const validatedDateRef = React6.useRef(validatedDate);
  validatedDateRef.current = validatedDate;
  const commitAndStopEditing = React6.useCallback(() => {
    if (inputValueRef.current === "") {
      onChange?.(null);
    } else if (validatedDateRef.current != null) {
      onChange?.(validatedDateRef.current);
    }
    setIsEditing(false);
    setDateValue(value);
  }, [onChange, setDateValue, value]);
  return {
    isEditing,
    displayedValue,
    inputError,
    dateValue,
    startEditing,
    stopEditing,
    commitAndStopEditing,
    setInputValue,
    setDateValue
  };
}

// src/shared/calendar/DatePicker.module.css
var DatePicker_default = {};

// src/shared/calendar/DatePicker.tsx
var DatePicker = /* @__PURE__ */ React6__default.default.memo(function DatePicker2({
  id,
  value,
  onChange,
  error,
  min,
  max,
  placeholder,
  formatDate,
  parseDate,
  showTime = false,
  closeOnSelection,
  portalRef,
  portalContainer,
  ariaLabel,
  modal = "trap-focus",
  disabled = false
}) {
  const isModal = modal !== false;
  const shouldCloseOnSelection = closeOnSelection ?? !showTime;
  const popoverId = React6.useId();
  const wrapperRef = React6.useRef(null);
  const inputRef = React6.useRef(null);
  const popoverRef = React6.useRef(null);
  const [isOpen, setIsOpen] = React6.useState(false);
  const [visibleCalendarMonth, setVisibleCalendarMonth] = React6.useState(value ?? /* @__PURE__ */ new Date());
  const skipReopenRef = React6.useRef(false);
  const editFormatFn = showTime ? chunkCUFFPIPP_cjs.formatDatetimeForInput : chunkCUFFPIPP_cjs.formatDateForInput;
  const displayFormatFn = formatDate ?? (showTime ? chunkCUFFPIPP_cjs.formatDatetimeForInput : chunkCUFFPIPP_cjs.formatDateForInput);
  const parseFn = parseDate ?? (showTime ? chunkCUFFPIPP_cjs.parseDatetimeFromInput : chunkCUFFPIPP_cjs.parseDateFromInput);
  const handleChange = React6.useCallback((date) => {
    if (onChange == null) {
      return;
    }
    if (date != null && !showTime) {
      const dateOnly = new Date(date.getFullYear(), date.getMonth(), date.getDate());
      onChange(dateOnly);
    } else {
      onChange(date);
    }
  }, [onChange, showTime]);
  const {
    isEditing,
    displayedValue,
    inputError,
    dateValue,
    startEditing,
    stopEditing,
    commitAndStopEditing,
    setInputValue,
    setDateValue
  } = useDateEditState({
    value,
    displayFormatFn,
    editFormatFn,
    parseFn,
    min,
    max,
    onChange: handleChange
  });
  const activeDateValue = isEditing && inputError == null ? dateValue : value ?? void 0;
  const handleFocus = React6.useCallback(() => {
    if (skipReopenRef.current) {
      skipReopenRef.current = false;
      startEditing();
      return;
    }
    startEditing();
    setVisibleCalendarMonth(value ?? void 0);
    setIsOpen(true);
  }, [startEditing, value]);
  const handlePointerDown = React6.useCallback(() => {
    inputRef.current?.focus();
    handleFocus();
  }, [handleFocus]);
  const handleInputValueChange = React6.useCallback((nextValue) => {
    setInputValue(nextValue);
    const parsedDate = nextValue !== "" ? parseFn(nextValue) : void 0;
    if (parsedDate != null && chunkCUFFPIPP_cjs.isDateInRange(parsedDate, min, max)) {
      setVisibleCalendarMonth(parsedDate);
    }
  }, [max, min, parseFn, setInputValue]);
  const handleBlur = React6.useCallback((e) => {
    const relatedTarget = e.relatedTarget ?? document.activeElement;
    if (popoverRef.current?.contains(relatedTarget)) {
      e.stopPropagation();
      return;
    }
    commitAndStopEditing();
  }, [commitAndStopEditing]);
  const closePopover = React6.useCallback(() => {
    setIsOpen(false);
    stopEditing();
    inputRef.current?.blur();
  }, [stopEditing]);
  const handleKeyDown = React6.useCallback((e) => {
    if (e.key === "Enter") {
      e.preventDefault();
      commitAndStopEditing();
      setIsOpen(false);
      inputRef.current?.blur();
    } else if (e.key === "Escape") {
      e.preventDefault();
      closePopover();
    } else if (e.key === "Tab" && !e.shiftKey && isOpen && isModal) {
      const firstFocusable = popoverRef.current?.querySelector("button, select");
      if (firstFocusable != null) {
        e.preventDefault();
        firstFocusable.focus();
      }
    } else if (e.key === "Tab" && e.shiftKey) {
      setIsOpen(false);
    }
  }, [commitAndStopEditing, closePopover, isOpen, isModal]);
  const handleOpenChange = React6.useCallback((nextOpen) => {
    if (nextOpen) {
      setIsOpen(true);
    } else {
      closePopover();
    }
  }, [closePopover]);
  const handleCalendarSelect = React6.useCallback((selected) => {
    if (selected == null) {
      handleChange(null);
      setInputValue("");
      return;
    }
    const date = new Date(selected.getTime());
    handleChange(date);
    setDateValue(date);
    setVisibleCalendarMonth(date);
    if (shouldCloseOnSelection) {
      closePopover();
    }
  }, [handleChange, shouldCloseOnSelection, setDateValue, setInputValue, closePopover]);
  const handleTimeChange = React6.useCallback((time) => {
    handleChange(time);
    setDateValue(time);
  }, [handleChange, setDateValue]);
  const handleCalendarClear = React6.useCallback(() => {
    handleChange(null);
    setDateValue(null);
  }, [handleChange, setDateValue]);
  const handleStartFocusBoundary = React6.useCallback(() => {
    inputRef.current?.focus();
  }, []);
  const handleEndFocusBoundary = React6.useCallback((e) => {
    const relatedTarget = e.relatedTarget ?? document.activeElement;
    if (popoverRef.current?.contains(relatedTarget)) {
      skipReopenRef.current = true;
      setIsOpen(false);
      stopEditing();
      inputRef.current?.focus();
    } else {
      const buttons = popoverRef.current?.querySelectorAll("button, select");
      const lastButton = buttons?.[buttons.length - 1];
      lastButton?.focus();
    }
  }, [stopEditing]);
  const wrapperClassName = classnames3__default.default(DatePickerCommon_default.osdkDatePickerInputWrapper, DatePicker_default.osdkDatetimeInputWrapper, inputError != null && DatePickerCommon_default.osdkDatePickerInputWrapperError);
  const isPopoverOpen = !disabled && isOpen;
  return /* @__PURE__ */ React6__default.default.createElement(popover.Popover.Root, {
    open: isPopoverOpen,
    onOpenChange: handleOpenChange,
    modal
  }, /* @__PURE__ */ React6__default.default.createElement("div", {
    ref: wrapperRef,
    className: wrapperClassName,
    "data-disabled": disabled || void 0
  }, /* @__PURE__ */ React6__default.default.createElement(popover.Popover.Trigger, {
    nativeButton: false,
    render: /* @__PURE__ */ React6__default.default.createElement(input.Input, {
      ref: inputRef,
      id,
      className: DatePickerCommon_default.osdkDatePickerInput,
      type: "text",
      value: displayedValue,
      onValueChange: handleInputValueChange,
      disabled,
      onFocus: handleFocus,
      onPointerDown: handlePointerDown,
      onBlur: handleBlur,
      onClick: chunkCUFFPIPP_cjs.stopPropagation,
      onKeyDown: handleKeyDown,
      placeholder,
      autoComplete: "off",
      role: "combobox",
      "aria-expanded": isPopoverOpen,
      "aria-controls": popoverId,
      "aria-haspopup": "dialog",
      "aria-label": ariaLabel
    })
  })), /* @__PURE__ */ React6__default.default.createElement(popover.Popover.Portal, {
    ref: portalRef,
    container: portalContainer
  }, isModal && /* @__PURE__ */ React6__default.default.createElement(PortalDismissLayer, {
    className: DatePickerCommon_default.osdkDatePickerDismissLayer,
    onDismiss: closePopover
  }), /* @__PURE__ */ React6__default.default.createElement(popover.Popover.Positioner, {
    anchor: wrapperRef,
    className: DatePickerCommon_default.osdkDatePickerPositioner,
    sideOffset: 4,
    side: "bottom",
    align: "start"
  }, /* @__PURE__ */ React6__default.default.createElement(popover.Popover.Popup, {
    ref: popoverRef,
    className: DatePickerCommon_default.osdkDatePickerPopover,
    id: popoverId,
    role: "dialog",
    "aria-label": "Date picker",
    finalFocus: false
  }, isModal && /* @__PURE__ */ React6__default.default.createElement("div", {
    onFocus: handleStartFocusBoundary,
    tabIndex: 0,
    "aria-label": "Start of date picker dialog",
    className: DatePickerCommon_default.osdkDatePickerFocusBoundary
  }), /* @__PURE__ */ React6__default.default.createElement(LazyDateCalendar, {
    dateSelected: activeDateValue,
    onSelect: handleCalendarSelect,
    onTimeChange: showTime ? handleTimeChange : void 0,
    onClear: handleCalendarClear,
    month: visibleCalendarMonth,
    onMonthChange: setVisibleCalendarMonth,
    min,
    max
  }), isModal && /* @__PURE__ */ React6__default.default.createElement("div", {
    onFocus: handleEndFocusBoundary,
    tabIndex: 0,
    "aria-label": "End of date picker dialog",
    className: DatePickerCommon_default.osdkDatePickerFocusBoundary
  })))));
});
var DateRangeCalendarLazy = /* @__PURE__ */ React6__default.default.lazy(() => import('./DateRangeCalendar-UTK6OTEQ.cjs'));
function LazyDateRangeCalendar(props) {
  return /* @__PURE__ */ React6__default.default.createElement(React6.Suspense, {
    fallback: /* @__PURE__ */ React6__default.default.createElement("div", {
      className: DatePickerCommon_default.osdkDatePickerFallback
    })
  }, /* @__PURE__ */ React6__default.default.createElement(DateRangeCalendarLazy, props));
}

// src/shared/calendar/DateRangePicker.module.css
var DateRangePicker_default = {};

// src/shared/calendar/DateRangePicker.tsx
function _extends() {
  return _extends = Object.assign ? Object.assign.bind() : function(n) {
    for (var e = 1; e < arguments.length; e++) {
      var t = arguments[e];
      for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
    }
    return n;
  }, _extends.apply(null, arguments);
}
var EMPTY_RANGE = [null, null];
var SHARED_INPUT_PROPS = {
  className: DatePickerCommon_default.osdkDatePickerInput,
  type: "text",
  onClick: chunkCUFFPIPP_cjs.stopPropagation,
  autoComplete: "off",
  role: "combobox",
  "aria-haspopup": "dialog"
};
var DateRangePicker = /* @__PURE__ */ React6__default.default.memo(function DateRangePicker2({
  id,
  value,
  onChange,
  min,
  max,
  placeholderStart,
  placeholderEnd,
  allowSingleDayRange = true,
  showTime = false,
  formatDate,
  parseDate,
  portalContainer,
  modal = "trap-focus",
  disabled = false
}) {
  const shouldCloseOnSelection = !showTime;
  const popoverId = React6.useId();
  const triggerRef = React6.useRef(null);
  const startInputRef = React6.useRef(null);
  const endInputRef = React6.useRef(null);
  const popoverRef = React6.useRef(null);
  const [isOpen, setIsOpen] = React6.useState(false);
  const skipReopenRef = React6.useRef(false);
  const [activeBoundary, setActiveBoundary] = React6.useState("start");
  const [startDate, endDate] = value ?? EMPTY_RANGE;
  const editFormatFn = showTime ? chunkCUFFPIPP_cjs.formatDatetimeForInput : chunkCUFFPIPP_cjs.formatDateForInput;
  const displayFormatFn = formatDate ?? (showTime ? chunkCUFFPIPP_cjs.formatDatetimeForInput : chunkCUFFPIPP_cjs.formatDateForInput);
  const parseFn = parseDate ?? (showTime ? chunkCUFFPIPP_cjs.parseDatetimeFromInput : chunkCUFFPIPP_cjs.parseDateFromInput);
  const startOnChange = React6.useCallback((date) => {
    if (date != null && isOverlapping(date, endDate, allowSingleDayRange)) {
      return;
    }
    onChange?.([date, endDate ?? null]);
  }, [endDate, onChange, allowSingleDayRange]);
  const endOnChange = React6.useCallback((date) => {
    if (date != null && isOverlapping(startDate, date, allowSingleDayRange)) {
      return;
    }
    onChange?.([startDate ?? null, date]);
  }, [startDate, onChange, allowSingleDayRange]);
  const {
    isEditing: isEditingStart,
    dateValue: startParsedValue,
    inputError: startInputError,
    displayedValue: displayedStart,
    startEditing: beginStartEditing,
    stopEditing: stopStartEditing,
    commitAndStopEditing: commitStartAndStopEditing,
    setInputValue: setStartInputValue,
    setDateValue: setStartDateValue
  } = useDateEditState({
    value: startDate,
    displayFormatFn,
    editFormatFn,
    parseFn,
    min,
    max,
    onChange: startOnChange
  });
  const {
    isEditing: isEditingEnd,
    dateValue: endParsedValue,
    inputError: endInputError,
    displayedValue: displayedEnd,
    startEditing: beginEndEditing,
    stopEditing: stopEndEditing,
    commitAndStopEditing: commitEndAndStopEditing,
    setInputValue: setEndInputValue,
    setDateValue: setEndDateValue
  } = useDateEditState({
    value: endDate,
    displayFormatFn,
    editFormatFn,
    parseFn,
    min,
    max,
    onChange: endOnChange
  });
  const hasOverlapError = (() => {
    if (!isEditingStart && !isEditingEnd) return false;
    const effectiveStart = isEditingStart ? startParsedValue : startDate ?? void 0;
    const effectiveEnd = isEditingEnd ? endParsedValue : endDate ?? void 0;
    return isOverlapping(effectiveStart, effectiveEnd, allowSingleDayRange);
  })();
  const startInvalid = startInputError != null || hasOverlapError;
  const endInvalid = endInputError != null || hasOverlapError;
  const activeStartDateValue = startInputError == null && startParsedValue != null ? startParsedValue : startDate ?? void 0;
  const activeEndDateValue = endInputError == null && endParsedValue != null ? endParsedValue : endDate ?? void 0;
  const getActiveInputRef = React6.useCallback(() => activeBoundary === "start" ? startInputRef : endInputRef, [activeBoundary]);
  const beginEditing = React6.useCallback((boundary) => {
    if (boundary === "start") {
      beginStartEditing();
    } else {
      beginEndEditing();
    }
    setActiveBoundary(boundary);
  }, [beginStartEditing, beginEndEditing]);
  const handleInputFocus = React6.useCallback((boundary) => {
    beginEditing(boundary);
    if (skipReopenRef.current) {
      skipReopenRef.current = false;
      return;
    }
    setIsOpen(true);
  }, [beginEditing]);
  const handleStartFocus = React6.useCallback(() => {
    handleInputFocus("start");
  }, [handleInputFocus]);
  const handleEndFocus = React6.useCallback(() => {
    handleInputFocus("end");
  }, [handleInputFocus]);
  const closePopoverForBoundaryExit = React6.useCallback(() => {
    skipReopenRef.current = true;
    setIsOpen(false);
    stopStartEditing();
    stopEndEditing();
    getActiveInputRef().current?.focus();
  }, [getActiveInputRef, stopStartEditing, stopEndEditing]);
  const handleStartPointerDown = React6.useCallback(() => {
    startInputRef.current?.focus();
    handleStartFocus();
  }, [handleStartFocus]);
  const handleEndPointerDown = React6.useCallback(() => {
    endInputRef.current?.focus();
    handleEndFocus();
  }, [handleEndFocus]);
  const handleStartBlur = React6.useCallback((e) => {
    const related = e.relatedTarget ?? document.activeElement;
    if (popoverRef.current?.contains(related)) {
      e.stopPropagation();
      return;
    }
    if (endInputRef.current === related) {
      return;
    }
    commitStartAndStopEditing();
  }, [commitStartAndStopEditing]);
  const handleEndBlur = React6.useCallback((e) => {
    const related = e.relatedTarget ?? document.activeElement;
    if (popoverRef.current?.contains(related)) {
      e.stopPropagation();
      return;
    }
    if (startInputRef.current === related) {
      return;
    }
    commitEndAndStopEditing();
  }, [commitEndAndStopEditing]);
  const closePopover = React6.useCallback(() => {
    setIsOpen(false);
    stopStartEditing();
    stopEndEditing();
    startInputRef.current?.blur();
    endInputRef.current?.blur();
  }, [stopStartEditing, stopEndEditing]);
  const handleStartKeyDown = React6.useCallback((e) => {
    if (e.key === "Enter") {
      e.preventDefault();
      commitStartAndStopEditing();
      endInputRef.current?.focus();
    } else if (e.key === "Escape") {
      e.preventDefault();
      closePopover();
    } else if (e.key === "Tab" && e.shiftKey) {
      setIsOpen(false);
    }
  }, [commitStartAndStopEditing, closePopover]);
  const handleEndKeyDown = React6.useCallback((e) => {
    if (e.key === "Enter") {
      e.preventDefault();
      commitEndAndStopEditing();
      closePopover();
    } else if (e.key === "Escape") {
      e.preventDefault();
      closePopover();
    } else if (e.key === "Tab" && !e.shiftKey && isOpen) {
      const firstButton = popoverRef.current?.querySelector("button, select");
      if (firstButton != null) {
        e.preventDefault();
        firstButton.focus();
      }
    }
  }, [commitEndAndStopEditing, closePopover, isOpen]);
  const handleOpenChange = React6.useCallback((nextOpen) => {
    if (nextOpen) {
      setIsOpen(true);
    } else {
      closePopover();
    }
  }, [closePopover]);
  const handleRangeSelect = React6.useCallback((range) => {
    const newStart = range?.from ?? null;
    const newEnd = range?.to ?? null;
    onChange?.([newStart, newEnd]);
    if (newStart != null && newEnd == null) {
      stopStartEditing();
      setActiveBoundary("end");
      endInputRef.current?.focus();
    } else if (newStart != null && newEnd != null && shouldCloseOnSelection) {
      closePopover();
    } else if (newStart != null && newEnd != null) {
      setStartDateValue(newStart);
      setEndDateValue(newEnd);
    }
  }, [onChange, shouldCloseOnSelection, closePopover, stopStartEditing, setStartDateValue, setEndDateValue]);
  const handleStartTimeChange = React6.useCallback((time) => {
    onChange?.([time, endDate ?? null]);
    setStartDateValue(time);
  }, [endDate, onChange, setStartDateValue]);
  const handleEndTimeChange = React6.useCallback((time) => {
    onChange?.([startDate ?? null, time]);
    setEndDateValue(time);
  }, [startDate, onChange, setEndDateValue]);
  const handleStartFocusBoundary = React6.useCallback(() => {
    getActiveInputRef().current?.focus();
  }, [getActiveInputRef]);
  const handleEndFocusBoundary = React6.useCallback((e) => {
    const related = e.relatedTarget ?? document.activeElement;
    if (popoverRef.current?.contains(related)) {
      closePopoverForBoundaryExit();
    } else {
      const buttons = popoverRef.current?.querySelectorAll("button, select");
      const lastButton = buttons?.[buttons.length - 1];
      lastButton?.focus();
    }
  }, [closePopoverForBoundaryExit]);
  const calendarSelected = startDate != null || endDate != null ? {
    from: startDate ?? void 0,
    to: endDate ?? void 0
  } : void 0;
  const timeFooter = showTime ? /* @__PURE__ */ React6__default.default.createElement(React6__default.default.Fragment, null, /* @__PURE__ */ React6__default.default.createElement(chunkCUFFPIPP_cjs.TimePicker, {
    value: activeStartDateValue ?? null,
    onChange: handleStartTimeChange,
    label: "Start time"
  }), /* @__PURE__ */ React6__default.default.createElement(chunkCUFFPIPP_cjs.TimePicker, {
    value: activeEndDateValue ?? null,
    onChange: handleEndTimeChange,
    label: "End time"
  })) : void 0;
  const sharedInputProps = {
    ...SHARED_INPUT_PROPS,
    "aria-controls": popoverId
  };
  const isPopoverOpen = !disabled && isOpen;
  return /* @__PURE__ */ React6__default.default.createElement(popover.Popover.Root, {
    open: isPopoverOpen,
    onOpenChange: handleOpenChange,
    modal
  }, /* @__PURE__ */ React6__default.default.createElement("div", {
    ref: triggerRef,
    className: DateRangePicker_default.osdkDateRangeContainer,
    "data-disabled": disabled || void 0
  }, /* @__PURE__ */ React6__default.default.createElement("div", {
    className: classnames3__default.default(DatePickerCommon_default.osdkDatePickerInputWrapper, DateRangePicker_default.osdkDateRangeInputWrapper, startInvalid && DatePickerCommon_default.osdkDatePickerInputWrapperError),
    "data-disabled": disabled || void 0
  }, /* @__PURE__ */ React6__default.default.createElement(popover.Popover.Trigger, {
    nativeButton: false,
    render: /* @__PURE__ */ React6__default.default.createElement(input.Input, _extends({
      ref: startInputRef,
      id: id != null ? `${id}-start` : void 0,
      value: displayedStart,
      onValueChange: setStartInputValue,
      disabled,
      onFocus: handleStartFocus,
      onPointerDown: handleStartPointerDown,
      onBlur: handleStartBlur,
      onKeyDown: handleStartKeyDown,
      placeholder: placeholderStart,
      "aria-expanded": isPopoverOpen && activeBoundary === "start",
      "aria-label": "Start date",
      "aria-invalid": startInvalid || void 0
    }, sharedInputProps))
  })), /* @__PURE__ */ React6__default.default.createElement("div", {
    className: classnames3__default.default(DatePickerCommon_default.osdkDatePickerInputWrapper, DateRangePicker_default.osdkDateRangeInputWrapper, endInvalid && DatePickerCommon_default.osdkDatePickerInputWrapperError),
    "data-disabled": disabled || void 0
  }, /* @__PURE__ */ React6__default.default.createElement(popover.Popover.Trigger, {
    nativeButton: false,
    render: /* @__PURE__ */ React6__default.default.createElement(input.Input, _extends({
      ref: endInputRef,
      id: id != null ? `${id}-end` : void 0,
      value: displayedEnd,
      onValueChange: setEndInputValue,
      disabled,
      onBlur: handleEndBlur,
      onKeyDown: handleEndKeyDown,
      onFocus: handleEndFocus,
      onPointerDown: handleEndPointerDown,
      placeholder: placeholderEnd,
      "aria-expanded": isPopoverOpen && activeBoundary === "end",
      "aria-label": "End date",
      "aria-invalid": endInvalid || void 0
    }, sharedInputProps))
  }))), /* @__PURE__ */ React6__default.default.createElement(popover.Popover.Portal, {
    container: portalContainer
  }, /* @__PURE__ */ React6__default.default.createElement(PortalDismissLayer, {
    className: DatePickerCommon_default.osdkDatePickerDismissLayer,
    onDismiss: closePopover
  }), /* @__PURE__ */ React6__default.default.createElement(popover.Popover.Positioner, {
    anchor: triggerRef,
    className: DatePickerCommon_default.osdkDatePickerPositioner,
    sideOffset: 4,
    side: "bottom",
    align: "start"
  }, /* @__PURE__ */ React6__default.default.createElement(popover.Popover.Popup, {
    ref: popoverRef,
    className: DatePickerCommon_default.osdkDatePickerPopover,
    id: popoverId,
    role: "dialog",
    "aria-label": "date range picker",
    finalFocus: false
  }, /* @__PURE__ */ React6__default.default.createElement("div", {
    onFocus: handleStartFocusBoundary,
    tabIndex: 0,
    "aria-label": "Start of date range picker dialog",
    className: DatePickerCommon_default.osdkDatePickerFocusBoundary
  }), /* @__PURE__ */ React6__default.default.createElement(LazyDateRangeCalendar, {
    selected: calendarSelected,
    onSelect: handleRangeSelect,
    min,
    max,
    footer: timeFooter
  }), /* @__PURE__ */ React6__default.default.createElement("div", {
    onFocus: handleEndFocusBoundary,
    tabIndex: 0,
    "aria-label": "End of date range picker dialog",
    className: DatePickerCommon_default.osdkDatePickerFocusBoundary
  })))));
});
function isOverlapping(start, end, allowSingleDayRange) {
  if (start == null || end == null) return false;
  if (!allowSingleDayRange && end.getTime() === start.getTime()) return true;
  return end.getTime() < start.getTime();
}

// src/base-components/combobox/Combobox.module.css
var Combobox_default = {};

// src/base-components/combobox/Combobox.tsx
function _extends2() {
  return _extends2 = Object.assign ? Object.assign.bind() : function(n) {
    for (var e = 1; e < arguments.length; e++) {
      var t = arguments[e];
      for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
    }
    return n;
  }, _extends2.apply(null, arguments);
}
function ComboboxTrigger({
  className,
  children,
  ...rest
}) {
  return /* @__PURE__ */ React6__default.default.createElement(combobox.Combobox.Trigger, _extends2({
    className: classnames3__default.default(Combobox_default.osdkComboboxTrigger, className)
  }, rest), children ?? /* @__PURE__ */ React6__default.default.createElement(React6__default.default.Fragment, null, /* @__PURE__ */ React6__default.default.createElement("div", {
    className: Combobox_default.osdkComboboxValueContainer
  }, /* @__PURE__ */ React6__default.default.createElement(combobox.Combobox.Value, null)), /* @__PURE__ */ React6__default.default.createElement(ComboboxIcon, null)));
}
function ComboboxIcon({
  className,
  children,
  ...rest
}) {
  return /* @__PURE__ */ React6__default.default.createElement(combobox.Combobox.Icon, _extends2({
    className: classnames3__default.default(Combobox_default.osdkComboboxIcon, className)
  }, rest), children ?? /* @__PURE__ */ React6__default.default.createElement(icons.CaretDown, null));
}
function ComboboxSearchInput({
  className,
  ...rest
}) {
  return /* @__PURE__ */ React6__default.default.createElement("div", {
    className: classnames3__default.default(Combobox_default.osdkComboboxInputWrapper, className)
  }, /* @__PURE__ */ React6__default.default.createElement(icons.Search, {
    className: Combobox_default.osdkComboboxSearchIcon
  }), /* @__PURE__ */ React6__default.default.createElement(combobox.Combobox.Input, _extends2({
    className: Combobox_default.osdkComboboxInput
  }, rest)));
}
function ComboboxInput({
  className,
  ...rest
}) {
  return /* @__PURE__ */ React6__default.default.createElement(combobox.Combobox.Input, _extends2({
    className: classnames3__default.default(Combobox_default.osdkComboboxInput, className)
  }, rest));
}
function ComboboxPositioner({
  className,
  children,
  ...rest
}) {
  return /* @__PURE__ */ React6__default.default.createElement(combobox.Combobox.Positioner, _extends2({
    className: classnames3__default.default(Combobox_default.osdkComboboxPositioner, className),
    sideOffset: 4
  }, rest), children);
}
function ComboboxPopup({
  className,
  children,
  ...rest
}) {
  return /* @__PURE__ */ React6__default.default.createElement(combobox.Combobox.Popup, _extends2({
    className: classnames3__default.default(Combobox_default.osdkComboboxPopup, className)
  }, rest), children);
}
function ComboboxItem({
  className,
  children,
  ...rest
}) {
  return /* @__PURE__ */ React6__default.default.createElement(combobox.Combobox.Item, _extends2({
    className: classnames3__default.default(Combobox_default.osdkComboboxItem, className)
  }, rest), children);
}
function ComboboxChips({
  children,
  className
}) {
  return /* @__PURE__ */ React6__default.default.createElement(combobox.Combobox.Chips, {
    render: (props) => /* @__PURE__ */ React6__default.default.createElement("div", _extends2({}, props, {
      className: classnames3__default.default(Combobox_default.osdkComboboxInputWrapper, className)
    }), props.children)
  }, children);
}
function ComboboxChip({
  className,
  children,
  ...rest
}) {
  return /* @__PURE__ */ React6__default.default.createElement(combobox.Combobox.Chip, _extends2({
    className: classnames3__default.default(Combobox_default.osdkComboboxChip, className)
  }, rest), children);
}
function ComboboxChipRemove({
  className,
  ...rest
}) {
  return /* @__PURE__ */ React6__default.default.createElement(combobox.Combobox.ChipRemove, _extends2({
    className: classnames3__default.default(Combobox_default.osdkComboboxChipRemove, className),
    "aria-label": "Remove"
  }, rest), /* @__PURE__ */ React6__default.default.createElement(icons.Cross, null));
}
function ComboboxClear({
  className,
  ...rest
}) {
  return /* @__PURE__ */ React6__default.default.createElement(combobox.Combobox.Clear, _extends2({
    className: classnames3__default.default(Combobox_default.osdkComboboxClear, className),
    "aria-label": "Clear all"
  }, rest), /* @__PURE__ */ React6__default.default.createElement(icons.Cross, null));
}
function ComboboxEmpty({
  children,
  className
}) {
  return /* @__PURE__ */ React6__default.default.createElement(combobox.Combobox.Empty, {
    className: classnames3__default.default(Combobox_default.osdkComboboxEmpty, className)
  }, children);
}
function ComboboxList({
  className,
  children,
  ...rest
}) {
  return /* @__PURE__ */ React6__default.default.createElement(combobox.Combobox.List, _extends2({
    className: classnames3__default.default(Combobox_default.osdkComboboxList, className)
  }, rest), children);
}
function ComboboxItemIndicator({
  className,
  children,
  ...rest
}) {
  return /* @__PURE__ */ React6__default.default.createElement(combobox.Combobox.ItemIndicator, _extends2({
    className: classnames3__default.default(Combobox_default.osdkComboboxItemIndicator, className),
    keepMounted: true
  }, rest), children ?? /* @__PURE__ */ React6__default.default.createElement(icons.Tick, {
    size: 16
  }));
}
var Combobox = {
  Root: combobox.Combobox.Root,
  Trigger: ComboboxTrigger,
  Icon: ComboboxIcon,
  SearchInput: ComboboxSearchInput,
  Input: ComboboxInput,
  Portal: combobox.Combobox.Portal,
  Positioner: ComboboxPositioner,
  Popup: ComboboxPopup,
  List: ComboboxList,
  Item: ComboboxItem,
  ItemIndicator: ComboboxItemIndicator,
  Collection: combobox.Combobox.Collection,
  Chips: ComboboxChips,
  Chip: ComboboxChip,
  ChipRemove: ComboboxChipRemove,
  Clear: ComboboxClear,
  Empty: ComboboxEmpty,
  Value: combobox.Combobox.Value
};

exports.Combobox = Combobox;
exports.Combobox_default = Combobox_default;
exports.DatePicker = DatePicker;
exports.DateRangePicker = DateRangePicker;
exports.EMPTY_RANGE = EMPTY_RANGE;
exports.PortalDismissLayer = PortalDismissLayer;
//# sourceMappingURL=chunk-FDRFBFI7.cjs.map
//# sourceMappingURL=chunk-FDRFBFI7.cjs.map