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,aAAa;QAC/B,eAAe;QACf,MAAM,UAAU,CAAC;IACnB;IAEA,IAAI,CAAC,iBAAiB,mBAAmB,GAAG,CAAA,GAAA,qBAAO,EAAE;IACrD,IAAI,mBAAmB,MAAM,UAAU,IAAI,MAAM,6BAA6B;IAC9E,IAAI,oBAAoB,iBAAiB;QACvC,mBAAmB;QACnB,MAAM,UAAU,CAAC;IACnB;IAEA,IAAI,aAAa,CAAA,GAAA,mCAAQ,EAAE;QACzB,IAAI,KAAK,CAAC,KAAK;QACf,cAAc;YAAC,KAAK,CAAC,aAAa;YAAE;SAAwB,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC;QAClF,mBAAmB,KAAK,CAAC,kBAAkB;IAC7C;IAEA,OAAO;QACL,eAAe,CAAA,GAAA,oCAAS,EAAE,UAAU,YAAY;YAC9C,MAAM;YACN,gBAAgB,KAAK,CAAC,eAAe,IAAI;YACzC,oBAAoB,KAAK,CAAC,mBAAmB,IAAI;QACnD;QACA,iBAAiB;YACf,SAAS,IAAM,MAAM,aAAa;YAClC,cAAc,gBAAgB,MAAM,CAAC;YACrC,YAAY;YACZ,eAAe;QACjB;QACA,iBAAiB;YACf,SAAS,IAAM,MAAM,iBAAiB;YACtC,cAAc,gBAAgB,MAAM,CAAC;YACrC,YAAY;YACZ,eAAe;QACjB;QACA,mBAAmB;YACjB,IAAI;QACN;eACA;IACF;AACF","sources":["packages/react-aria/src/calendar/useCalendarBase.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {announce} from '../live-announcer/LiveAnnouncer';\n\nimport {AriaButtonProps} from '../button/useButton';\nimport {AriaLabelingProps, DOMAttributes, DOMProps} from '@react-types/shared';\nimport {CalendarPropsBase, CalendarState} from 'react-stately/useCalendarState';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport {hookData, useSelectedDateDescription, useVisibleRangeDescription} from './utils';\nimport intlMessages from '../../intl/calendar/*.json';\nimport {mergeProps} from '../utils/mergeProps';\nimport {RangeCalendarState} from 'react-stately/useRangeCalendarState';\nimport {useLabels} from '../utils/useLabels';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n// @ts-ignore\nimport {useSlotId} from '../utils/useId';\nimport {useState} from 'react';\nimport {useUpdateEffect} from '../utils/useUpdateEffect';\n\nexport interface CalendarAria {\n  /** Props for the calendar grouping element. */\n  calendarProps: DOMAttributes,\n  /** Props for the next button. */\n  nextButtonProps: AriaButtonProps,\n  /** Props for the previous button. */\n  prevButtonProps: AriaButtonProps,\n  /** Props for the error message element, if any. */\n  errorMessageProps: DOMAttributes,\n  /** A description of the visible date range, for use in the calendar title. */\n  title: string\n}\n\nexport function useCalendarBase(props: CalendarPropsBase & DOMProps & AriaLabelingProps, state: CalendarState | RangeCalendarState): CalendarAria {\n  let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/calendar');\n  let domProps = filterDOMProps(props);\n\n  let title = useVisibleRangeDescription(state.visibleRange.start, state.visibleRange.end, state.timeZone, false);\n  let visibleRangeDescription = useVisibleRangeDescription(state.visibleRange.start, state.visibleRange.end, state.timeZone, true);\n\n  // Announce when the visible date range changes\n  useUpdateEffect(() => {\n    // only when pressing the Previous or Next button\n    if (!state.isFocused) {\n      announce(visibleRangeDescription);\n    }\n  }, [visibleRangeDescription]);\n\n  // Announce when the selected value changes\n  let selectedDateDescription = useSelectedDateDescription(state);\n  useUpdateEffect(() => {\n    if (selectedDateDescription) {\n      announce(selectedDateDescription, 'polite', 4000);\n    }\n    // handle an update to the caption that describes the currently selected range, to announce the new value\n  }, [selectedDateDescription]);\n\n  let errorMessageId = useSlotId([Boolean(props.errorMessage), props.isInvalid, props.validationState]);\n\n  // Pass the label to the child grid elements.\n  hookData.set(state, {\n    ariaLabel: props['aria-label'],\n    ariaLabelledBy: props['aria-labelledby'],\n    errorMessageId,\n    selectedDateDescription\n  });\n\n  // If the next or previous buttons become disabled while they are focused, move focus to the calendar body.\n  let [nextFocused, setNextFocused] = useState(false);\n  let nextDisabled = props.isDisabled || state.isNextVisibleRangeInvalid();\n  if (nextDisabled && nextFocused) {\n    setNextFocused(false);\n    state.setFocused(true);\n  }\n\n  let [previousFocused, setPreviousFocused] = useState(false);\n  let previousDisabled = props.isDisabled || state.isPreviousVisibleRangeInvalid();\n  if (previousDisabled && previousFocused) {\n    setPreviousFocused(false);\n    state.setFocused(true);\n  }\n\n  let labelProps = useLabels({\n    id: props['id'],\n    'aria-label': [props['aria-label'], visibleRangeDescription].filter(Boolean).join(', '),\n    'aria-labelledby': props['aria-labelledby']\n  });\n\n  return {\n    calendarProps: mergeProps(domProps, labelProps, {\n      role: 'application',\n      'aria-details': props['aria-details'] || undefined,\n      'aria-describedby': props['aria-describedby'] || undefined\n    }),\n    nextButtonProps: {\n      onPress: () => state.focusNextPage(),\n      'aria-label': stringFormatter.format('next'),\n      isDisabled: nextDisabled,\n      onFocusChange: setNextFocused\n    },\n    prevButtonProps: {\n      onPress: () => state.focusPreviousPage(),\n      'aria-label': stringFormatter.format('previous'),\n      isDisabled: previousDisabled,\n      onFocusChange: setPreviousFocused\n    },\n    errorMessageProps: {\n      id: errorMessageId\n    },\n    title\n  };\n}\n"],"names":[],"version":3,"file":"useCalendarBase.cjs.map"}