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ACN;YACA,MAAM;YACN,OAAO;YACP,UAAU,CAAC;gBACT,IAAI,eAAe,CAAA,GAAA,qBAAa,EAAE,GAAG,KAAK,CAAC,QAAQ;gBACnD,IAAI,cACF,IAAI;oBACF,IAAI,cAA+C,CAAA,GAAA,oBAAY,EAAE;oBACjE,IAAI,MAAM,WAAW,KAAK,OACxB,cAAc,CAAA,GAAA,gBAAQ,EAAE;oBAE1B,uHAAuH;oBACvH,iHAAiH;oBACjH,oHAAoH;oBACpH,2GAA2G;oBAC3G,wHAAwH;oBACxH,kDAAkD;oBAClD,IAAI,gBAAgB,OAClB,IAAK,IAAI,QAAQ,YAAa;wBAC5B,qCAAqC;wBACrC,IAAI,mCAAa,QAAQ,CAAC,OACxB,MAAM,UAAU,CAAC,MAAyB,WAAW,CAAC,KAAK;wBAE7D,qCAAqC;wBACrC,IAAI,aAAa,QAAQ,CAAC,OACxB,MAAM,UAAU,CAAC,MAAyB,WAAW,CAAC,KAAK;oBAE/D;oBAEF,MAAM,QAAQ,CAAC;gBACjB,EAAE,OAAM;gBACN,SAAS;gBACX;YAEJ;QACF;IACF;AACF;AAEO,SAAS,0CAAgB,KAA2B;IACzD,IAAI,SAAC,KAAK,EAAC,GAAG;IACd,IAAI,kBAAC,cAAc,cAAE,UAAU,EAAC,GAAG,0CAAmB;QAAC,GAAG,KAAK;IAAA,GAAG;IAClE,qBACE,gCAAC;QAAK,GAAG,cAAc;QAAE,eAAY;qBACnC,gCAAC,SAAU;AAGjB","sources":["packages/react-aria-components/src/HiddenDateInput.tsx"],"sourcesContent":["/*\n * Copyright 2025 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\n\nimport {CalendarDate, CalendarDateTime, parseDate, parseDateTime, toCalendarDate, toCalendarDateTime, toLocalTimeZone} from '@internationalized/date';\nimport {DateFieldState, DateSegmentType} from 'react-stately/useDateFieldState';\nimport {DatePickerState} from 'react-stately/useDatePickerState';\nimport {getEventTarget} from 'react-aria/private/utils/shadowdom/DOMFunctions';\nimport React, {ReactNode} from 'react';\nimport {useVisuallyHidden} from 'react-aria/VisuallyHidden';\n\ninterface AriaHiddenDateInputProps {\n  /**\n   * Describes the type of autocomplete functionality the input should provide if any. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefautocomplete).\n   */\n  autoComplete?: string,\n  /** HTML form input name. */\n  name?: string,\n  /** Sets the disabled state of the input. */\n  isDisabled?: boolean\n}\n\ninterface HiddenDateInputProps extends AriaHiddenDateInputProps {\n  /**\n   * State for the input.\n   */\n  state: DateFieldState | DatePickerState\n}\n\nexport interface HiddenDateAria {\n  /** Props for the container element. */\n  containerProps: React.HTMLAttributes<HTMLDivElement>,\n  /** Props for the hidden input element. */\n  inputProps: React.InputHTMLAttributes<HTMLInputElement>\n}\n\nconst dateSegments = ['day', 'month', 'year'];\nconst granularityMap = {'hour': 1, 'minute': 2, 'second': 3};\n\nexport function useHiddenDateInput(props: HiddenDateInputProps, state: DateFieldState | DatePickerState) : HiddenDateAria {\n  let {\n    autoComplete,\n    isDisabled,\n    name\n  } = props;\n  let {visuallyHiddenProps} = useVisuallyHidden({\n    style: {\n      // Prevent page scrolling.\n      position: 'fixed',\n      top: 0,\n      left: 0\n    }\n  });\n\n  let inputStep = 60;\n  if (state.granularity === 'second') {\n    inputStep = 1;\n  } else if (state.granularity === 'hour') {\n    inputStep = 3600;\n  }\n  \n  let dateValue = '';\n  if (state.value) {\n    if (state.granularity === 'day') {\n      dateValue = toCalendarDate(state.value).toString();\n    } else {\n      dateValue = toCalendarDateTime('timeZone' in state.value ? toLocalTimeZone(state.value) : state.value).toString();\n    }\n  }\n\n  let inputType = state.granularity === 'day' ? 'date' : 'datetime-local';\n\n  let timeSegments = ['hour', 'minute', 'second'];\n  // Depending on the granularity, we only want to validate certain time segments\n  let end = 0;\n  if (timeSegments.includes(state.granularity)) {\n    end = granularityMap[state.granularity];\n    timeSegments = timeSegments.slice(0, end);\n  }\n\n  return {\n    containerProps: {\n      ...visuallyHiddenProps,\n      'aria-hidden': true,\n      // @ts-ignore\n      ['data-react-aria-prevent-focus']: true,\n      // @ts-ignore\n      ['data-a11y-ignore']: 'aria-hidden-focus'\n    },\n    inputProps: {\n      tabIndex: -1,\n      autoComplete,\n      disabled: isDisabled,\n      type: inputType,\n      // We set the form prop to an empty string to prevent the hidden date input's value from being submitted\n      form: '',\n      name,\n      step: inputStep,\n      value: dateValue,\n      onChange: (e) => {\n        let targetString = getEventTarget(e).value.toString();\n        if (targetString) {\n          try {\n            let targetValue: CalendarDateTime | CalendarDate = parseDateTime(targetString);\n            if (state.granularity === 'day') {\n              targetValue = parseDate(targetString);\n            }\n            // We check to to see if setSegment exists in the state since it only exists in DateFieldState and not DatePickerState.\n            // The setValue method has different behavior depending on if it's coming from DateFieldState or DatePickerState.\n            // In DateFieldState, setValue firsts checks to make sure that each segment is filled before committing the newValue\n            // which is why in the code below we first set each segment to validate it before committing the new value.\n            // However, in DatePickerState, since we have to be able to commit values from the Calendar popover, we are also able to\n            // set a new value when the field itself is empty.\n            if ('setSegment' in state) {\n              for (let type in targetValue) {\n                // eslint-disable-next-line max-depth\n                if (dateSegments.includes(type)) {\n                  state.setSegment(type as DateSegmentType, targetValue[type]);\n                }\n                // eslint-disable-next-line max-depth\n                if (timeSegments.includes(type)) {\n                  state.setSegment(type as DateSegmentType, targetValue[type]);\n                }\n              }\n            }\n            state.setValue(targetValue);\n          } catch {\n            // ignore\n          }\n        }\n      }\n    }\n  };\n}\n\nexport function HiddenDateInput(props: HiddenDateInputProps): ReactNode | null {\n  let {state} = props;\n  let {containerProps, inputProps} = useHiddenDateInput({...props}, state);\n  return (\n    <div {...containerProps} data-testid=\"hidden-dateinput-container\">\n      <input {...inputProps} />\n    </div>\n  );\n}\n"],"names":[],"version":3,"file":"HiddenDateInput.mjs.map"}