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AU,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;QAC7B,gBAAc,aAAa;QAC3B,iBAAe,cAAc;qBAC7B,gCAAC,CAAA,GAAA,qBAAa;QAAE,aAAY;qBAC1B,gCAAC;QAAO,GAAG,CAAA,GAAA,iBAAS,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, SwitchAria, useSwitch} from 'react-aria/useSwitch';\n\nimport {\n  ClassNameOrFunction,\n  ContextValue,\n  dom,\n  Provider,\n  RACValidation,\n  removeDataAttributes,\n  RenderProps,\n  SlotProps,\n  useContextProps,\n  useRenderProps,\n  useSlottedContext\n} from './utils';\nimport {FieldErrorContext} from './FieldError';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\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, useContext} from 'react';\nimport {TextContext} from './Text';\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\n  extends\n    Omit<\n      AriaSwitchProps,\n      | 'children'\n      | 'validationState'\n      | 'validationBehavior'\n      | 'isRequired'\n      | 'isInvalid'\n      | 'validate'\n    >,\n    HoverEvents,\n    RenderProps<SwitchRenderProps, 'label'>,\n    SlotProps,\n    Omit<GlobalDOMAttributes<HTMLLabelElement>, 'onClick'> {\n  /**\n   * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n   * element. A function may be provided to compute the class based on component state.\n   *\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 SwitchFieldProps\n  extends\n    Omit<AriaSwitchProps, 'children' | 'validationState' | 'validationBehavior'>,\n    RACValidation,\n    RenderProps<SwitchFieldRenderProps>,\n    SlotProps,\n    Omit<GlobalDOMAttributes<HTMLDivElement>, 'onClick'> {\n  /**\n   * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n   * element. A function may be provided to compute the class based on component state.\n   *\n   * @default 'react-aria-SwitchField'\n   */\n  className?: ClassNameOrFunction<SwitchFieldRenderProps>;\n  /**\n   * A ref for the HTML input element.\n   */\n  inputRef?: RefObject<HTMLInputElement | null>;\n}\n\nexport interface SwitchButtonProps\n  extends\n    HoverEvents,\n    RenderProps<SwitchButtonRenderProps, 'label'>,\n    SlotProps,\n    GlobalDOMAttributes<HTMLLabelElement> {\n  /**\n   * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n   * element. A function may be provided to compute the class based on component state.\n   *\n   * @default 'react-aria-SwitchButton'\n   */\n  className?: ClassNameOrFunction<SwitchButtonRenderProps>;\n}\n\nexport interface SwitchRenderProps {\n  /**\n   * Whether the switch is selected.\n   *\n   * @selector [data-selected]\n   */\n  isSelected: boolean;\n  /**\n   * Whether the switch is currently hovered with a mouse.\n   *\n   * @selector [data-hovered]\n   */\n  isHovered: boolean;\n  /**\n   * Whether the switch is currently in a pressed state.\n   *\n   * @selector [data-pressed]\n   */\n  isPressed: boolean;\n  /**\n   * Whether the switch is focused, either via a mouse or keyboard.\n   *\n   * @selector [data-focused]\n   */\n  isFocused: boolean;\n  /**\n   * Whether the switch is keyboard focused.\n   *\n   * @selector [data-focus-visible]\n   */\n  isFocusVisible: boolean;\n  /**\n   * Whether the switch is disabled.\n   *\n   * @selector [data-disabled]\n   */\n  isDisabled: boolean;\n  /**\n   * Whether the switch is read only.\n   *\n   * @selector [data-readonly]\n   */\n  isReadOnly: boolean;\n  /**\n   * State of the switch.\n   */\n  state: ToggleState;\n}\n\nexport interface SwitchFieldRenderProps {\n  /**\n   * Whether the switch is selected.\n   *\n   * @selector [data-selected]\n   */\n  isSelected: boolean;\n  /**\n   * Whether the switch is disabled.\n   *\n   * @selector [data-disabled]\n   */\n  isDisabled: boolean;\n  /**\n   * Whether the switch is read only.\n   *\n   * @selector [data-readonly]\n   */\n  isReadOnly: boolean;\n  /**\n   * Whether the switch invalid.\n   *\n   * @selector [data-invalid]\n   */\n  isInvalid: boolean;\n  /**\n   * Whether the switch is required.\n   *\n   * @selector [data-required]\n   */\n  isRequired: boolean;\n  /**\n   * State of the switch.\n   */\n  state: ToggleState;\n}\n\nexport interface SwitchButtonRenderProps extends SwitchRenderProps {\n  /**\n   * Whether the switch invalid.\n   *\n   * @selector [data-invalid]\n   */\n  isInvalid: boolean;\n  /**\n   * Whether the switch is required.\n   *\n   * @selector [data-required]\n   */\n  isRequired: boolean;\n  /**\n   * State of the switch.\n   */\n  state: ToggleState;\n}\n\nexport const SwitchContext = createContext<ContextValue<SwitchProps, HTMLLabelElement>>(null);\nexport const SwitchFieldContext =\n  createContext<ContextValue<SwitchFieldProps, HTMLDivElement>>(null);\nexport const ToggleStateContext = createContext<ToggleState | null>(null);\n\n/**\n * A switch allows a user to turn a setting on or off.\n *\n * @deprecated Use SwitchField + SwitchButton instead.\n */\nexport const Switch = /*#__PURE__*/ (forwardRef as forwardRefType)(function Switch(\n  props: SwitchProps,\n  ref: ForwardedRef<HTMLLabelElement>\n) {\n  let {inputRef: userProvidedInputRef = null, ...otherProps} = props;\n  [props, ref] = useContextProps(otherProps, ref, SwitchContext);\n  let inputRef = useObjectRef(\n    mergeRefs(userProvidedInputRef, props.inputRef !== undefined ? props.inputRef : null)\n  );\n  let state = useToggleState(props);\n  let aria = useSwitch(\n    {\n      ...removeDataAttributes(props),\n      // ReactNode type doesn't allow function children.\n      children: typeof props.children === 'function' ? true : props.children\n    },\n    state,\n    inputRef\n  );\n\n  return (\n    <Provider\n      values={[\n        [ToggleStateContext, state],\n        [\n          InternalSwitchContext,\n          {\n            ...aria,\n            inputRef,\n            defaultClassName: 'react-aria-Switch'\n          }\n        ]\n      ]}>\n      <SwitchButton {...props} ref={ref} />\n    </Provider>\n  );\n});\n\ninterface InternalSwitchContextValue extends SwitchAria {\n  inputRef: RefObject<HTMLInputElement | null>;\n  defaultClassName: string;\n  isRequired?: boolean;\n}\n\nconst InternalSwitchContext = createContext<InternalSwitchContextValue | null>(null);\n\n/**\n * A switch allows a user to turn a setting on or off, with support for validation and help text.\n */\nexport const SwitchField = /*#__PURE__*/ (forwardRef as forwardRefType)(function Switch(\n  props: SwitchFieldProps,\n  ref: ForwardedRef<HTMLDivElement>\n) {\n  let {inputRef: userProvidedInputRef = null, ...otherProps} = props;\n  [props, ref] = useContextProps(otherProps, ref, SwitchFieldContext);\n  let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n  let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n  let inputRef = useObjectRef(\n    mergeRefs(userProvidedInputRef, props.inputRef !== undefined ? props.inputRef : null)\n  );\n  let state = useToggleState(props);\n  let aria = useSwitch(\n    {\n      ...removeDataAttributes(props),\n      // ReactNode type doesn't allow function children.\n      children: typeof props.children === 'function' ? true : props.children,\n      validationBehavior\n    },\n    state,\n    inputRef\n  );\n  let {\n    descriptionProps,\n    errorMessageProps,\n    isSelected,\n    isDisabled,\n    isReadOnly,\n    isInvalid,\n    validationDetails,\n    validationErrors\n  } = aria;\n\n  let renderProps = useRenderProps({\n    ...props,\n    defaultClassName: 'react-aria-SwitchField',\n    values: {\n      isSelected,\n      isDisabled,\n      isReadOnly,\n      isInvalid,\n      isRequired: props.isRequired || false,\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.div\n      {...mergeProps(DOMProps, renderProps)}\n      ref={ref}\n      slot={props.slot || undefined}\n      data-selected={isSelected || undefined}\n      data-disabled={isDisabled || undefined}\n      data-readonly={isReadOnly || undefined}\n      data-invalid={isInvalid || undefined}\n      data-required={props.isRequired || undefined}>\n      <Provider\n        values={[\n          [ToggleStateContext, state],\n          [\n            InternalSwitchContext,\n            {\n              ...aria,\n              inputRef,\n              defaultClassName: 'react-aria-SwitchButton',\n              isRequired: props.isRequired\n            }\n          ],\n          [\n            TextContext,\n            {\n              slots: {\n                description: descriptionProps,\n                errorMessage: errorMessageProps\n              }\n            }\n          ],\n          [FieldErrorContext, {isInvalid, validationDetails, validationErrors}]\n        ]}>\n        {renderProps.children}\n      </Provider>\n    </dom.div>\n  );\n});\n\n/**\n * A switch button is the clickable area of a switch, including the indicator and label.\n */\nexport const SwitchButton = /*#__PURE__*/ (forwardRef as forwardRefType)(function SwitchButton(\n  props: SwitchButtonProps,\n  ref: ForwardedRef<HTMLLabelElement>\n) {\n  let {\n    labelProps,\n    inputProps,\n    isSelected,\n    isDisabled,\n    isReadOnly,\n    isPressed,\n    isInvalid,\n    inputRef,\n    defaultClassName,\n    isRequired\n  } = useContext(InternalSwitchContext)!;\n  let {isFocused, isFocusVisible, focusProps} = useFocusRing();\n  let isInteractionDisabled = isDisabled || isReadOnly;\n  let state = useContext(ToggleStateContext)!;\n\n  let {hoverProps, isHovered} = useHover({\n    ...props,\n    isDisabled: isInteractionDisabled\n  });\n\n  let renderProps = useRenderProps({\n    ...props,\n    defaultClassName,\n    values: {\n      isSelected,\n      isPressed,\n      isHovered,\n      isFocused,\n      isFocusVisible,\n      isDisabled,\n      isReadOnly,\n      isInvalid,\n      isRequired: isRequired || false,\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      data-invalid={isInvalid || undefined}\n      data-required={isRequired || 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.mjs.map"}