{"ast":null,"code":"import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\n\nimport { filterDOMProps as $7Yq4N$filterDOMProps, useId as $7Yq4N$useId, mergeProps as $7Yq4N$mergeProps, useSlotId as $7Yq4N$useSlotId, isMac as $7Yq4N$isMac, isWebKit as $7Yq4N$isWebKit } from \"@react-aria/utils\";\nimport { useFocusWithin as $7Yq4N$useFocusWithin, useHover as $7Yq4N$useHover, isFocusVisible as $7Yq4N$isFocusVisible } from \"@react-aria/interactions\";\nimport { useLabel as $7Yq4N$useLabel } from \"@react-aria/label\";\nimport { useSelectableList as $7Yq4N$useSelectableList, useSelectableItem as $7Yq4N$useSelectableItem } from \"@react-aria/selection\";\nimport { getItemCount as $7Yq4N$getItemCount } from \"@react-stately/collections\";\n\nfunction $parcel$export(e, n, v, s) {\n  Object.defineProperty(e, n, {\n    get: v,\n    set: s,\n    enumerable: true,\n    configurable: true\n  });\n}\n\nvar $b6a6a3879de3c160$exports = {};\n$parcel$export($b6a6a3879de3c160$exports, \"useListBox\", function () {\n  return $b6a6a3879de3c160$export$50eacbbf140a3141;\n});\nvar $d786742a15de2e64$exports = {};\n$parcel$export($d786742a15de2e64$exports, \"listData\", function () {\n  return $d786742a15de2e64$export$3585ede4d035bf14;\n});\n$parcel$export($d786742a15de2e64$exports, \"getItemId\", function () {\n  return $d786742a15de2e64$export$9145995848b05025;\n});\nvar $d786742a15de2e64$export$3585ede4d035bf14 = new WeakMap();\n\nfunction $d786742a15de2e64$var$normalizeKey(key) {\n  if (typeof key === 'string') return key.replace(/\\s*/g, '');\n  return '' + key;\n}\n\nfunction $d786742a15de2e64$export$9145995848b05025(state, itemKey) {\n  var data = $d786742a15de2e64$export$3585ede4d035bf14.get(state);\n  if (!data) throw new Error('Unknown list');\n  return data.id + \"-option-\" + $d786742a15de2e64$var$normalizeKey(itemKey);\n}\n\nfunction $b6a6a3879de3c160$export$50eacbbf140a3141(props, state, ref) {\n  var domProps = $7Yq4N$filterDOMProps(props, {\n    labelable: true\n  });\n\n  var _$7Yq4N$useSelectable = $7Yq4N$useSelectableList(_objectSpread(_objectSpread({}, props), {}, {\n    ref: ref,\n    selectionManager: state.selectionManager,\n    collection: state.collection,\n    disabledKeys: state.disabledKeys\n  })),\n      listProps = _$7Yq4N$useSelectable.listProps;\n\n  var _$7Yq4N$useFocusWithi = $7Yq4N$useFocusWithin({\n    onFocusWithin: props.onFocus,\n    onBlurWithin: props.onBlur,\n    onFocusWithinChange: props.onFocusChange\n  }),\n      focusWithinProps = _$7Yq4N$useFocusWithi.focusWithinProps;\n\n  var id = $7Yq4N$useId(props.id);\n  $d786742a15de2e64$export$3585ede4d035bf14.set(state, {\n    id: id,\n    shouldUseVirtualFocus: props.shouldUseVirtualFocus,\n    shouldSelectOnPressUp: props.shouldSelectOnPressUp,\n    shouldFocusOnHover: props.shouldFocusOnHover,\n    isVirtualized: props.isVirtualized\n  });\n\n  var _$7Yq4N$useLabel = $7Yq4N$useLabel(_objectSpread(_objectSpread({}, props), {}, {\n    id: id,\n    labelElementType: 'span'\n  })),\n      labelProps = _$7Yq4N$useLabel.labelProps,\n      fieldProps = _$7Yq4N$useLabel.fieldProps;\n\n  return {\n    labelProps: labelProps,\n    listBoxProps: $7Yq4N$mergeProps(domProps, focusWithinProps, state.selectionManager.selectionMode === 'multiple' ? {\n      'aria-multiselectable': 'true'\n    } : {}, _objectSpread({\n      role: 'listbox'\n    }, $7Yq4N$mergeProps(fieldProps, listProps)))\n  };\n}\n\nvar $ffbe2720d8d792ce$exports = {};\n$parcel$export($ffbe2720d8d792ce$exports, \"useOption\", function () {\n  return $ffbe2720d8d792ce$export$497855f14858aa34;\n});\n\nfunction $ffbe2720d8d792ce$export$497855f14858aa34(props, state, ref) {\n  var _props$isDisabled, _props$isSelected, _props$shouldSelectOn, _props$shouldFocusOnH, _props$shouldUseVirtu, _props$isVirtualized;\n\n  var key = props.key;\n  var data = $d786742a15de2e64$export$3585ede4d035bf14.get(state);\n  var isDisabled = (_props$isDisabled = props.isDisabled) != null ? _props$isDisabled : state.disabledKeys.has(key);\n  var isSelected = (_props$isSelected = props.isSelected) != null ? _props$isSelected : state.selectionManager.isSelected(key);\n  var isFocused = state.selectionManager.focusedKey === key;\n  var shouldSelectOnPressUp = (_props$shouldSelectOn = props.shouldSelectOnPressUp) != null ? _props$shouldSelectOn : data.shouldSelectOnPressUp;\n  var shouldFocusOnHover = (_props$shouldFocusOnH = props.shouldFocusOnHover) != null ? _props$shouldFocusOnH : data.shouldFocusOnHover;\n  var shouldUseVirtualFocus = (_props$shouldUseVirtu = props.shouldUseVirtualFocus) != null ? _props$shouldUseVirtu : data.shouldUseVirtualFocus;\n  var isVirtualized = (_props$isVirtualized = props.isVirtualized) != null ? _props$isVirtualized : data.isVirtualized;\n  var labelId = $7Yq4N$useSlotId();\n  var descriptionId = $7Yq4N$useSlotId();\n  var optionProps = {\n    role: 'option',\n    'aria-disabled': isDisabled,\n    'aria-selected': state.selectionManager.selectionMode !== 'none' ? isSelected : undefined\n  };\n\n  if (!($7Yq4N$isMac() && $7Yq4N$isWebKit())) {\n    optionProps['aria-label'] = props['aria-label'];\n    optionProps['aria-labelledby'] = labelId;\n    optionProps['aria-describedby'] = descriptionId;\n  }\n\n  if (isVirtualized) {\n    optionProps['aria-posinset'] = state.collection.getItem(key).index + 1;\n    optionProps['aria-setsize'] = $7Yq4N$getItemCount(state.collection);\n  }\n\n  var _$7Yq4N$useSelectable2 = $7Yq4N$useSelectableItem({\n    selectionManager: state.selectionManager,\n    key: key,\n    ref: ref,\n    shouldSelectOnPressUp: shouldSelectOnPressUp,\n    isVirtualized: isVirtualized,\n    shouldUseVirtualFocus: shouldUseVirtualFocus,\n    isDisabled: isDisabled\n  }),\n      itemProps = _$7Yq4N$useSelectable2.itemProps,\n      isPressed = _$7Yq4N$useSelectable2.isPressed;\n\n  var _$7Yq4N$useHover = $7Yq4N$useHover({\n    isDisabled: isDisabled || !shouldFocusOnHover,\n    onHoverStart: function onHoverStart() {\n      if (!$7Yq4N$isFocusVisible()) {\n        state.selectionManager.setFocused(true);\n        state.selectionManager.setFocusedKey(key);\n      }\n    }\n  }),\n      hoverProps = _$7Yq4N$useHover.hoverProps;\n\n  return {\n    optionProps: _objectSpread(_objectSpread(_objectSpread({}, optionProps), $7Yq4N$mergeProps(itemProps, hoverProps)), {}, {\n      id: $d786742a15de2e64$export$9145995848b05025(state, key)\n    }),\n    labelProps: {\n      id: labelId\n    },\n    descriptionProps: {\n      id: descriptionId\n    },\n    isFocused: isFocused,\n    isSelected: isSelected,\n    isDisabled: isDisabled,\n    isPressed: isPressed\n  };\n}\n\nvar $60eb9482f3936d5e$exports = {};\n$parcel$export($60eb9482f3936d5e$exports, \"useListBoxSection\", function () {\n  return $60eb9482f3936d5e$export$c3f9f39876e4bc7;\n});\n\nfunction $60eb9482f3936d5e$export$c3f9f39876e4bc7(props) {\n  var heading = props.heading,\n      ariaLabel = props['aria-label'];\n  var headingId = $7Yq4N$useId();\n  return {\n    itemProps: {\n      role: 'presentation'\n    },\n    headingProps: heading ? {\n      id: headingId,\n      'aria-hidden': true\n    } : {},\n    groupProps: {\n      role: 'group',\n      'aria-label': ariaLabel,\n      'aria-labelledby': heading ? headingId : undefined\n    }\n  };\n}\n\nexport { $b6a6a3879de3c160$export$50eacbbf140a3141 as useListBox, $ffbe2720d8d792ce$export$497855f14858aa34 as useOption, $60eb9482f3936d5e$export$c3f9f39876e4bc7 as useListBoxSection, $d786742a15de2e64$export$3585ede4d035bf14 as listData, $d786742a15de2e64$export$9145995848b05025 as getItemId };","map":{"version":3,"sources":["packages/@react-aria/listbox/src/useListBox.ts","packages/@react-aria/listbox/src/utils.ts","packages/@react-aria/listbox/src/useOption.ts","packages/@react-aria/listbox/src/useListBoxSection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACuBO,IAAM,yCAAQ,GAAG,IAAI,OAAJ,EAAjB;;SAEE,kC,CAAa,G,EAAkB;AACtC,MAAI,OAAO,GAAP,KAAe,QAAnB,EACE,OAAO,GAAG,CAAC,OAAJ,CAAW,MAAX,EAAoB,EAApB,CAAP;AAGF,SAAO,KAAK,GAAZ;AACD;;SAEe,yC,CAAa,K,EAAqB,O,EAAsB;AACtE,MAAI,IAAI,GAAG,yCAAQ,CAAC,GAAT,CAAa,KAAb,CAAX;AAEA,MAAE,CAAG,IAAL,EACE,MAAM,IAAI,KAAJ,CAAU,cAAV,CAAN;AAGF,SAAU,IAAI,CAAC,EAAf,gBAA4B,kCAAY,CAAC,OAAD,CAAxC;AACD;;SDsBe,yC,CAAc,K,EAA8B,K,EAAqB,G,EAA0C;AACzH,MAAI,QAAQ,GAAG,qBAAc,CAAC,KAAD,EAAQ;AAAC,IAAA,SAAS,EAAE;AAAZ,GAAR,CAA7B;;AACA,8BAAkB,wBAAiB,iCAC9B,KAD8B;SAEjC,GAFiC;AAGjC,IAAA,gBAAgB,EAAE,KAAK,CAAC,gBAHS;AAIjC,IAAA,UAAU,EAAE,KAAK,CAAC,UAJe;AAKjC,IAAA,YAAY,EAAE,KAAK,CAAC;AALa,KAAnC;AAAA,MAAK,SAAL,yBAAK,SAAL;;AAQA,8BAAyB,qBAAc,CAAC;AACtC,IAAA,aAAa,EAAE,KAAK,CAAC,OADiB;AAEtC,I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AiBD","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 {AriaListBoxProps} from '@react-types/listbox';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {HTMLAttributes, ReactNode, RefObject} from 'react';\nimport {KeyboardDelegate} from '@react-types/shared';\nimport {listData} from './utils';\nimport {ListState} from '@react-stately/list';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useId} from '@react-aria/utils';\nimport {useLabel} from '@react-aria/label';\nimport {useSelectableList} from '@react-aria/selection';\n\ninterface ListBoxAria {\n  /** Props for the listbox element. */\n  listBoxProps: HTMLAttributes<HTMLElement>,\n  /** Props for the listbox's visual label element (if any). */\n  labelProps: HTMLAttributes<HTMLElement>\n}\n\nexport interface AriaListBoxOptions<T> extends Omit<AriaListBoxProps<T>, 'children'> {\n  /** Whether the listbox uses virtual scrolling. */\n  isVirtualized?: boolean,\n\n  /**\n   * An optional keyboard delegate implementation for type to select,\n   * to override the default.\n   */\n  keyboardDelegate?: KeyboardDelegate,\n\n  /**\n   * Whether the listbox items should use virtual focus instead of being focused directly.\n   */\n  shouldUseVirtualFocus?: boolean,\n\n  /** Whether selection should occur on press up instead of press down. */\n  shouldSelectOnPressUp?: boolean,\n\n  /** Whether options should be focused when the user hovers over them. */\n  shouldFocusOnHover?: boolean,\n\n  /**\n   * An optional visual label for the listbox.\n   */\n  label?: ReactNode\n}\n\n/**\n * Provides the behavior and accessibility implementation for a listbox component.\n * A listbox displays a list of options and allows a user to select one or more of them.\n * @param props - Props for the listbox.\n * @param state - State for the listbox, as returned by `useListState`.\n */\nexport function useListBox<T>(props: AriaListBoxOptions<T>, state: ListState<T>, ref: RefObject<HTMLElement>): ListBoxAria {\n  let domProps = filterDOMProps(props, {labelable: true});\n  let {listProps} = useSelectableList({\n    ...props,\n    ref,\n    selectionManager: state.selectionManager,\n    collection: state.collection,\n    disabledKeys: state.disabledKeys\n  });\n\n  let {focusWithinProps} = useFocusWithin({\n    onFocusWithin: props.onFocus,\n    onBlurWithin: props.onBlur,\n    onFocusWithinChange: props.onFocusChange\n  });\n\n  // Share list id and some props with child options.\n  let id = useId(props.id);\n  listData.set(state, {\n    id,\n    shouldUseVirtualFocus: props.shouldUseVirtualFocus,\n    shouldSelectOnPressUp: props.shouldSelectOnPressUp,\n    shouldFocusOnHover: props.shouldFocusOnHover,\n    isVirtualized: props.isVirtualized\n  });\n\n  let {labelProps, fieldProps} = useLabel({\n    ...props,\n    id,\n    // listbox is not an HTML input element so it\n    // shouldn't be labeled by a <label> element.\n    labelElementType: 'span'\n  });\n\n  return {\n    labelProps,\n    listBoxProps: mergeProps(domProps, focusWithinProps, state.selectionManager.selectionMode === 'multiple' ? {\n      'aria-multiselectable': 'true'\n    } : {}, {\n      role: 'listbox',\n      ...mergeProps(fieldProps, listProps)\n    })\n  };\n}\n","/*\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 {Key} from 'react';\nimport {ListState} from '@react-stately/list';\n\ninterface ListData {\n  id: string,\n  shouldSelectOnPressUp?: boolean,\n  shouldFocusOnHover?: boolean,\n  shouldUseVirtualFocus?: boolean,\n  isVirtualized?: boolean\n}\n\nexport const listData = new WeakMap<ListState<unknown>, ListData>();\n\nfunction normalizeKey(key: Key): string {\n  if (typeof key === 'string') {\n    return key.replace(/\\s*/g, '');\n  }\n\n  return '' + key;\n}\n\nexport function getItemId<T>(state: ListState<T>, itemKey: Key): string {\n  let data = listData.get(state);\n\n  if (!data) {\n    throw new Error('Unknown list');\n  }\n\n  return `${data.id}-option-${normalizeKey(itemKey)}`;\n}\n","/*\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 {getItemCount} from '@react-stately/collections';\nimport {getItemId, listData} from './utils';\nimport {HTMLAttributes, Key, RefObject} from 'react';\nimport {isFocusVisible, useHover} from '@react-aria/interactions';\nimport {isMac, isWebKit, mergeProps, useSlotId} from '@react-aria/utils';\nimport {ListState} from '@react-stately/list';\nimport {useSelectableItem} from '@react-aria/selection';\n\ninterface OptionAria {\n  /** Props for the option element. */\n  optionProps: HTMLAttributes<HTMLElement>,\n\n  /** Props for the main text element inside the option. */\n  labelProps: HTMLAttributes<HTMLElement>,\n\n  /** Props for the description text element inside the option, if any. */\n  descriptionProps: HTMLAttributes<HTMLElement>,\n\n  /** Whether the option is currently focused. */\n  isFocused: boolean,\n  /** Whether the option is currently selected. */\n  isSelected: boolean,\n  /** Whether the option is currently in a pressed state. */\n  isPressed: boolean,\n  /** Whether the option is disabled. */\n  isDisabled: boolean\n}\n\ninterface AriaOptionProps {\n  /**\n   * Whether the option is disabled.\n   * @deprecated\n   */\n  isDisabled?: boolean,\n\n  /**\n   * Whether the option is selected.\n   * @deprecated\n   */\n  isSelected?: boolean,\n\n  /** A screen reader only label for the option. */\n  'aria-label'?: string,\n\n  /** The unique key for the option. */\n  key: Key,\n\n  /**\n   * Whether selection should occur on press up instead of press down.\n   * @deprecated\n   */\n  shouldSelectOnPressUp?: boolean,\n\n  /**\n   * Whether the option should be focused when the user hovers over it.\n   * @deprecated\n   */\n  shouldFocusOnHover?: boolean,\n\n  /**\n   * Whether the option is contained in a virtual scrolling listbox.\n   * @deprecated\n   */\n  isVirtualized?: boolean,\n\n  /**\n   * Whether the option should use virtual focus instead of being focused directly.\n   * @deprecated\n   */\n  shouldUseVirtualFocus?: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for an option in a listbox.\n * See `useListBox` for more details about listboxes.\n * @param props - Props for the option.\n * @param state - State for the listbox, as returned by `useListState`.\n */\nexport function useOption<T>(props: AriaOptionProps, state: ListState<T>, ref: RefObject<HTMLElement>): OptionAria {\n  let {\n    key\n  } = props;\n\n  let data = listData.get(state);\n\n  let isDisabled = props.isDisabled ?? state.disabledKeys.has(key);\n  let isSelected = props.isSelected ?? state.selectionManager.isSelected(key);\n  let isFocused = state.selectionManager.focusedKey === key;\n  let shouldSelectOnPressUp = props.shouldSelectOnPressUp ?? data.shouldSelectOnPressUp;\n  let shouldFocusOnHover = props.shouldFocusOnHover ?? data.shouldFocusOnHover;\n  let shouldUseVirtualFocus = props.shouldUseVirtualFocus ?? data.shouldUseVirtualFocus;\n  let isVirtualized = props.isVirtualized ?? data.isVirtualized;\n\n  let labelId = useSlotId();\n  let descriptionId = useSlotId();\n\n  let optionProps = {\n    role: 'option',\n    'aria-disabled': isDisabled,\n    'aria-selected': state.selectionManager.selectionMode !== 'none' ? isSelected : undefined\n  };\n\n  // Safari with VoiceOver on macOS misreads options with aria-labelledby or aria-label as simply \"text\".\n  // We should not map slots to the label and description on Safari and instead just have VoiceOver read the textContent.\n  // https://bugs.webkit.org/show_bug.cgi?id=209279\n  if (!(isMac() && isWebKit())) {\n    optionProps['aria-label'] = props['aria-label'];\n    optionProps['aria-labelledby'] = labelId;\n    optionProps['aria-describedby'] = descriptionId;\n  }\n\n  if (isVirtualized) {\n    optionProps['aria-posinset'] = state.collection.getItem(key).index + 1;\n    optionProps['aria-setsize'] = getItemCount(state.collection);\n  }\n\n  let {itemProps, isPressed} = useSelectableItem({\n    selectionManager: state.selectionManager,\n    key,\n    ref,\n    shouldSelectOnPressUp,\n    isVirtualized,\n    shouldUseVirtualFocus,\n    isDisabled\n  });\n\n  let {hoverProps} = useHover({\n    isDisabled: isDisabled || !shouldFocusOnHover,\n    onHoverStart() {\n      if (!isFocusVisible()) {\n        state.selectionManager.setFocused(true);\n        state.selectionManager.setFocusedKey(key);\n      }\n    }\n  });\n\n  return {\n    optionProps: {\n      ...optionProps,\n      ...mergeProps(itemProps, hoverProps),\n      id: getItemId(state, key)\n    },\n    labelProps: {\n      id: labelId\n    },\n    descriptionProps: {\n      id: descriptionId\n    },\n    isFocused,\n    isSelected,\n    isDisabled,\n    isPressed\n  };\n}\n","/*\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 {HTMLAttributes, ReactNode} from 'react';\nimport {useId} from '@react-aria/utils';\n\ninterface AriaListBoxSectionProps {\n  /** The heading for the section. */\n  heading?: ReactNode,\n  /** An accessibility label for the section. Required if `heading` is not present. */\n  'aria-label'?: string\n}\n\ninterface ListBoxSectionAria {\n  /** Props for the wrapper list item. */\n  itemProps: HTMLAttributes<HTMLElement>,\n\n  /** Props for the heading element, if any. */\n  headingProps: HTMLAttributes<HTMLElement>,\n\n  /** Props for the group element. */\n  groupProps: HTMLAttributes<HTMLElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a section in a listbox.\n * See `useListBox` for more details about listboxes.\n * @param props - Props for the section.\n */\nexport function useListBoxSection(props: AriaListBoxSectionProps): ListBoxSectionAria {\n  let {heading, 'aria-label': ariaLabel} = props;\n  let headingId = useId();\n\n  return {\n    itemProps: {\n      role: 'presentation'\n    },\n    headingProps: heading ? {\n      // Techincally, listbox cannot contain headings according to ARIA.\n      // We hide the heading from assistive technology, and only use it\n      // as a label for the nested group.\n      id: headingId,\n      'aria-hidden': true\n    } : {},\n    groupProps: {\n      role: 'group',\n      'aria-label': ariaLabel,\n      'aria-labelledby': heading ? headingId : undefined\n    }\n  };\n}\n"]},"metadata":{},"sourceType":"module"}