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IAClD,OAAO,SAAS,EAAE;IAClB,OAAO,SAAS,OAAO;IAEvB,qBACE,0DAAC,CAAA,GAAA,6BAAE,EAAE,KAAK;QACP,GAAG,CAAA,GAAA,qCAAS,EAAE,UAAU,YAAY,YAAY,YAAY;QAC7D,KAAK;QACL,MAAM,MAAM,IAAI,IAAI;QACpB,iBAAe,cAAc;QAC7B,gBAAc,aAAa;QAC3B,gBAAc,aAAa;QAC3B,gBAAc,aAAa;QAC3B,sBAAoB,kBAAkB;QACtC,iBAAe,cAAc;QAC7B,iBAAe,cAAc;qBAC7B,0DAAC,CAAA,GAAA,6CAAa;QAAE,aAAY;qBAC1B,0DAAC;QAAO,GAAG,CAAA,GAAA,qCAAS,EAAE,YAAY,WAAW;QAAE,KAAK;SAErD,YAAY,QAAQ;AAG3B","sources":["packages/react-aria-components/src/Switch.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 {AriaSwitchProps, useSwitch} from 'react-aria/useSwitch';\n\nimport {\n  ClassNameOrFunction,\n  ContextValue,\n  dom,\n  removeDataAttributes,\n  RenderProps,\n  SlotProps,\n  useContextProps,\n  useRenderProps\n} from './utils';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {forwardRefType, GlobalDOMAttributes, RefObject} from '@react-types/shared';\nimport {HoverEvents} from '@react-types/shared';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {mergeRefs} from 'react-aria/mergeRefs';\nimport React, {createContext, ForwardedRef, forwardRef} from 'react';\nimport {ToggleState, useToggleState} from 'react-stately/useToggleState';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useHover} from 'react-aria/useHover';\nimport {useObjectRef} from 'react-aria/useObjectRef';\nimport {VisuallyHidden} from 'react-aria/VisuallyHidden';\n\nexport interface SwitchProps extends Omit<AriaSwitchProps, 'children'>, HoverEvents, RenderProps<SwitchRenderProps, 'label'>, SlotProps, Omit<GlobalDOMAttributes<HTMLLabelElement>, '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-Switch'\n  */\n className?: ClassNameOrFunction<SwitchRenderProps>,\n /**\n  * A ref for the HTML input element.\n  */\n inputRef?: RefObject<HTMLInputElement | null>\n}\n\nexport interface SwitchRenderProps {\n  /**\n   * Whether the switch is selected.\n   * @selector [data-selected]\n   */\n  isSelected: boolean,\n  /**\n   * Whether the switch is currently hovered with a mouse.\n   * @selector [data-hovered]\n   */\n  isHovered: boolean,\n  /**\n   * Whether the switch is currently in a pressed state.\n   * @selector [data-pressed]\n   */\n  isPressed: boolean,\n  /**\n   * Whether the switch is focused, either via a mouse or keyboard.\n   * @selector [data-focused]\n   */\n  isFocused: boolean,\n  /**\n   * Whether the switch is keyboard focused.\n   * @selector [data-focus-visible]\n   */\n  isFocusVisible: boolean,\n  /**\n   * Whether the switch is disabled.\n   * @selector [data-disabled]\n   */\n  isDisabled: boolean,\n  /**\n   * Whether the switch is read only.\n   * @selector [data-readonly]\n   */\n  isReadOnly: boolean,\n  /**\n   * State of the switch.\n   */\n  state: ToggleState\n}\n\nexport const SwitchContext = createContext<ContextValue<SwitchProps, HTMLLabelElement>>(null);\n\n/**\n * A switch allows a user to turn a setting on or off.\n */\nexport const Switch = /*#__PURE__*/ (forwardRef as forwardRefType)(function Switch(props: SwitchProps, ref: ForwardedRef<HTMLLabelElement>) {\n  let {\n    inputRef: userProvidedInputRef = null,\n    ...otherProps\n  } = props;\n  [props, ref] = useContextProps(otherProps, ref, SwitchContext);\n  let inputRef = useObjectRef(mergeRefs(userProvidedInputRef, props.inputRef !== undefined ? props.inputRef : null));\n  let state = useToggleState(props);\n  let {labelProps, inputProps, isSelected, isDisabled, isReadOnly, isPressed} = useSwitch({\n    ...removeDataAttributes(props),\n    // ReactNode type doesn't allow function children.\n    children: typeof props.children === 'function' ? true : props.children\n  }, state, inputRef);\n  let {isFocused, isFocusVisible, focusProps} = useFocusRing();\n  let isInteractionDisabled = props.isDisabled || props.isReadOnly;\n\n  let {hoverProps, isHovered} = useHover({\n    ...props,\n    isDisabled: isInteractionDisabled\n  });\n\n  let renderProps = useRenderProps({\n    ...props,\n    defaultClassName: 'react-aria-Switch',\n    values: {\n      isSelected,\n      isPressed,\n      isHovered,\n      isFocused,\n      isFocusVisible,\n      isDisabled,\n      isReadOnly,\n      state\n    }\n  });\n\n  let DOMProps = filterDOMProps(props, {global: true});\n  delete DOMProps.id;\n  delete DOMProps.onClick;\n\n  return (\n    <dom.label\n      {...mergeProps(DOMProps, labelProps, hoverProps, renderProps)}\n      ref={ref}\n      slot={props.slot || undefined}\n      data-selected={isSelected || undefined}\n      data-pressed={isPressed || undefined}\n      data-hovered={isHovered || undefined}\n      data-focused={isFocused || undefined}\n      data-focus-visible={isFocusVisible || undefined}\n      data-disabled={isDisabled || undefined}\n      data-readonly={isReadOnly || undefined}>\n      <VisuallyHidden elementType=\"span\">\n        <input {...mergeProps(inputProps, focusProps)} ref={inputRef} />\n      </VisuallyHidden>\n      {renderProps.children}\n    </dom.label>\n  );\n});\n"],"names":[],"version":3,"file":"Switch.cjs.map"}