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;QAAK;QACzG,kBAAkB;IACpB;IAEA,IAAI,WAAW,CAAA,GAAA,6CAAa,EAAE,OAAc;QAAC,QAAQ;IAAI;IACzD,OAAO,SAAS,EAAE;IAClB,OAAO,SAAS,OAAO;IAEvB,qBACE,0DAAC,CAAA,GAAA,6BAAE,EAAE,MAAM;QACR,GAAG,CAAA,GAAA,qCAAS,EAAE,UAAU,aAAa,aAAa,YAAY,WAAW;QAC1E,KAAK;QACL,MAAM,MAAM,IAAI,IAAI;QACpB,gBAAc,aAAa;QAC3B,iBAAe,cAAc;QAC7B,gBAAc,aAAa;QAC3B,iBAAe,cAAc;QAC7B,gBAAc,aAAa;QAC3B,sBAAoB,kBAAkB;qBACtC,0DAAC,CAAA,GAAA,mDAAwB,EAAE,QAAQ;QAAC,OAAO;wBAAC;QAAU;OACnD,YAAY,QAAQ;AAI7B","sources":["packages/react-aria-components/src/ToggleButton.tsx"],"sourcesContent":["/*\n * Copyright 2022 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 {AriaToggleButtonProps, useToggleButton} from 'react-aria/useToggleButton';\n\nimport {ButtonRenderProps} from './Button';\nimport {\n  ClassNameOrFunction,\n  ContextValue,\n  dom,\n  RenderProps,\n  SlotProps,\n  useContextProps,\n  useRenderProps\n} from './utils';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {forwardRefType, GlobalDOMAttributes, Key} from '@react-types/shared';\nimport {HoverEvents} from '@react-types/shared';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport React, {createContext, ForwardedRef, forwardRef, useContext} from 'react';\nimport {SelectionIndicatorContext} from './SelectionIndicator';\nimport {ToggleGroupStateContext} from './ToggleButtonGroup';\nimport {ToggleState, useToggleState} from 'react-stately/useToggleState';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useHover} from 'react-aria/useHover';\nimport {useToggleButtonGroupItem} from 'react-aria/useToggleButtonGroup';\n\nexport interface ToggleButtonRenderProps extends Omit<ButtonRenderProps, 'isPending'> {\n  /**\n   * Whether the button is currently selected.\n   * @selector [data-selected]\n   */\n  isSelected: boolean,\n  /**\n   * State of the toggle button.\n   */\n  state: ToggleState\n}\n\nexport interface ToggleButtonProps extends Omit<AriaToggleButtonProps, 'children' | 'elementType' | 'id'>, HoverEvents, SlotProps, RenderProps<ToggleButtonRenderProps, 'button'>, Omit<GlobalDOMAttributes<HTMLDivElement>, 'onClick'> {\n  /**\n   * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state.\n   * @default 'react-aria-ToggleButton'\n   */\n  className?: ClassNameOrFunction<ToggleButtonRenderProps>,\n  /** When used in a ToggleButtonGroup, an identifier for the item in `selectedKeys`. When used standalone, a DOM id. */\n  id?: Key\n}\n\nexport const ToggleButtonContext = createContext<ContextValue<ToggleButtonProps, HTMLButtonElement>>({});\n\n/**\n * A toggle button allows a user to toggle a selection on or off, for example switching between two states or modes.\n */\nexport const ToggleButton = /*#__PURE__*/ (forwardRef as forwardRefType)(function ToggleButton(props: ToggleButtonProps, ref: ForwardedRef<HTMLButtonElement>) {\n  [props, ref] = useContextProps(props, ref, ToggleButtonContext);\n  let groupState = useContext(ToggleGroupStateContext);\n  let state = useToggleState(groupState && props.id != null ? {\n    isSelected: groupState.selectedKeys.has(props.id),\n    onChange(isSelected) {\n      groupState.setSelected(props.id!, isSelected);\n    }\n  } : props);\n\n  let {buttonProps, isPressed, isSelected, isDisabled} = groupState && props.id != null\n    // eslint-disable-next-line react-hooks/rules-of-hooks\n    ? useToggleButtonGroupItem({...props, id: props.id}, groupState, ref)\n    // eslint-disable-next-line react-hooks/rules-of-hooks\n    : useToggleButton({...props, id: props.id != null ? String(props.id) : undefined}, state, ref);\n\n  let {focusProps, isFocused, isFocusVisible} = useFocusRing(props);\n  let {hoverProps, isHovered} = useHover({...props, isDisabled});\n  let renderProps = useRenderProps({\n    ...props,\n    id: undefined,\n    values: {isHovered, isPressed, isFocused, isSelected: state.isSelected, isFocusVisible, isDisabled, state},\n    defaultClassName: 'react-aria-ToggleButton'\n  });\n\n  let DOMProps = filterDOMProps(props as any, {global: true});\n  delete DOMProps.id;\n  delete DOMProps.onClick;\n\n  return (\n    <dom.button\n      {...mergeProps(DOMProps, renderProps, buttonProps, focusProps, hoverProps)}\n      ref={ref}\n      slot={props.slot || undefined}\n      data-focused={isFocused || undefined}\n      data-disabled={isDisabled || undefined}\n      data-pressed={isPressed || undefined}\n      data-selected={isSelected || undefined}\n      data-hovered={isHovered || undefined}\n      data-focus-visible={isFocusVisible || undefined}>\n      <SelectionIndicatorContext.Provider value={{isSelected}}>\n        {renderProps.children}\n      </SelectionIndicatorContext.Provider>\n    </dom.button>\n  );\n});\n"],"names":[],"version":3,"file":"ToggleButton.cjs.map"}