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"sourcesContent":["/*\n * Copyright 2026 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 {AriaLabelingProps, DOMProps, DOMRef, Selection} from '@react-types/shared';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {forwardRef} from 'react';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {SlotProps} from 'react-aria-components/slots';\nimport {StylesPropWithHeight} from '@react-spectrum/s2';\nimport ThumbDown from '@react-spectrum/s2/icons/ThumbDown';\nimport ThumbUp from '@react-spectrum/s2/icons/ThumbUp';\nimport {ToggleButton} from '@react-spectrum/s2/ToggleButton';\nimport {ToggleButtonGroup, ToggleButtonGroupProps} from '@react-spectrum/s2/ToggleButtonGroup';\nimport {useDOMRef} from './useDOMRef';\nimport {useLocalizedStringFormatter} from 'react-aria/useLocalizedStringFormatter';\n\nexport type MessageFeedbackValue = 'up' | 'down' | null;\n\nexport interface MessageFeedbackProps\n  extends DOMProps, AriaLabelingProps, SlotProps, Pick<ToggleButtonGroupProps, 'size'> {\n  /** The selected feedback value (controlled). */\n  value?: MessageFeedbackValue;\n  /** The default feedback value (uncontrolled). */\n  defaultValue?: MessageFeedbackValue;\n  /** Called when the selection changes, including when toggled off (value=null). */\n  onChange?: (value: MessageFeedbackValue) => void;\n  /** Whether the feedback controls are disabled. */\n  isDisabled?: boolean;\n  /** Accessible label for the thumbs up button. */\n  thumbUpLabel?: string;\n  /** Accessible label for the thumbs down button. */\n  thumbDownLabel?: string;\n  /** Spectrum-defined styles, returned by the `style()` macro. */\n  styles?: StylesPropWithHeight;\n}\n\nfunction selectionToValue(selection: Selection): MessageFeedbackValue {\n  let [first] = selection as Iterable<string>;\n  return first === 'up' || first === 'down' ? first : null;\n}\n\n/**\n * MessageFeedback collects thumbs up / thumbs down feedback on an AI response.\n */\nexport const MessageFeedback = forwardRef(function MessageFeedback(\n  props: MessageFeedbackProps,\n  ref: DOMRef<HTMLDivElement>\n) {\n  let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/ai');\n  let domRef = useDOMRef(ref);\n  let {\n    value,\n    defaultValue,\n    onChange,\n    isDisabled,\n    thumbUpLabel,\n    thumbDownLabel,\n    styles,\n    size = 'M'\n  } = props;\n\n  let handleSelectionChange = (selection: Selection): void => {\n    onChange?.(selectionToValue(selection));\n  };\n\n  let toKeys = (v: MessageFeedbackValue | undefined): Iterable<string> | undefined => {\n    if (v === undefined) {\n      return undefined;\n    }\n    return v === null ? [] : [v];\n  };\n  let selectedKeys = toKeys(value);\n  let defaultSelectedKeys = toKeys(defaultValue);\n\n  return (\n    <ToggleButtonGroup\n      {...filterDOMProps(props, {labelable: true})}\n      ref={domRef}\n      size={size}\n      selectionMode=\"single\"\n      selectedKeys={selectedKeys}\n      defaultSelectedKeys={defaultSelectedKeys}\n      onSelectionChange={handleSelectionChange}\n      isDisabled={isDisabled}\n      styles={styles}>\n      <ToggleButton\n        id=\"up\"\n        isQuiet\n        aria-label={thumbUpLabel ?? stringFormatter.format('messagefeedback.thumbUp')}>\n        <ThumbUp />\n      </ToggleButton>\n      <ToggleButton\n        id=\"down\"\n        isQuiet\n        aria-label={thumbDownLabel ?? stringFormatter.format('messagefeedback.thumbDown')}>\n        <ThumbDown />\n      </ToggleButton>\n    </ToggleButtonGroup>\n  );\n});\n"],"names":[],"version":3,"file":"MessageFeedback.mjs.map"}