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AA,GAAA,6CAAa,EAAE,WAAW;QAC9B,4BAA4B;QAC5B,yBAAyB;QACzB,oIAAoI;QACpI,eAAY;QACZ,WAAW,CAAA,GAAA,6CAAU,EACnB,4BAAM;kBACJ;QACF,IACA,MAAM,MAAM;QAEd,KAAK;kBACJ;;AAGP","sources":["packages/@react-spectrum/ai/src/MessageSource.tsx"],"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 {\n  AriaLabelingProps,\n  DOMProps,\n  DOMRef,\n  forwardRefType,\n  GlobalDOMAttributes\n} from '@react-types/shared';\nimport {baseColor, focusRing, style} from '@react-spectrum/s2/style' with {type: 'macro'};\nimport {\n  Disclosure,\n  DisclosurePanel,\n  DisclosurePanelProps,\n  DisclosureProps,\n  DisclosureTitle\n} from '@react-spectrum/s2/Disclosure';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {Link, LinkProps} from 'react-aria-components/Link';\nimport {mergeStyles} from '@react-spectrum/s2/mergeStyles';\nimport {NumberFormatter} from '@internationalized/number';\nimport React, {createContext, forwardRef, useContext} from 'react';\nimport {SlotProps} from 'react-aria-components/slots';\nimport {StyleString} from '@react-spectrum/s2/style' with {type: 'macro'};\nimport {useDOMRef} from './useDOMRef';\nimport {useLocale} from 'react-aria/I18nProvider';\n\nexport interface MessageSourceProps extends Omit<\n  DisclosureProps,\n  'isQuiet' | 'UNSAFE_className' | 'UNSAFE_style'\n> {\n  label: string;\n}\n\nconst MessageSourceInternalContext = createContext<{size: 'S' | 'M' | 'L' | 'XL'}>({size: 'M'});\n\n/**\n * Message sources display references associated with a system message. Associating the source to\n * the output builds trust and transparency in the conversation.\n */\nexport const MessageSource = (forwardRef as forwardRefType)(function MessageSource(\n  props: MessageSourceProps,\n  ref: DOMRef<HTMLDivElement>\n) {\n  // [props, ref] = useSpectrumContextProps(props, ref, MessageSourceContext);\n  let {label, children, size = 'M', styles, ...otherProps} = props;\n\n  return (\n    <MessageSourceInternalContext.Provider value={{size}}>\n      <NumberBadgeContext.Provider value={{size}}>\n        <Disclosure {...otherProps} styles={styles} size={size} ref={ref} isQuiet>\n          <DisclosureTitle>{label}</DisclosureTitle>\n          {children}\n        </Disclosure>\n      </NumberBadgeContext.Provider>\n    </MessageSourceInternalContext.Provider>\n  );\n});\n\n// SourceList injects a 1-based index so SourceListItem\n// can render it without needing an explicit prop.\nconst SourceListIndexContext = createContext<number>(1);\n\nconst listStyles = style({\n  listStyleType: 'none',\n  padding: 0,\n  margin: 0,\n  display: 'flex',\n  flexDirection: 'column',\n  gap: 4\n});\n\nconst itemStyles = style({\n  display: 'flex',\n  alignItems: 'center',\n  gap: 8\n});\n\nexport interface SourceListProps extends DisclosurePanelProps {}\n\n/**\n * A SourceList displays an ordered list of sources inside a MessageSource.\n * Wrap SourceListItem children inside to have them numbered automatically.\n */\nexport const SourceList = (forwardRef as forwardRefType)(function SourceList(\n  props: SourceListProps,\n  ref: DOMRef<HTMLDivElement>\n) {\n  let {children, ...otherProps} = props;\n\n  let numberedChildren = React.Children.map(children, (child, i) => (\n    <SourceListIndexContext.Provider value={i + 1}>{child}</SourceListIndexContext.Provider>\n  ));\n\n  return (\n    <DisclosurePanel {...otherProps} ref={ref}>\n      <ol className={listStyles}>{numberedChildren}</ol>\n    </DisclosurePanel>\n  );\n});\n\nconst linkStyles = style({\n  ...focusRing(),\n  font: {\n    size: {\n      S: 'body-sm',\n      M: 'body',\n      L: 'body-lg',\n      XL: 'body-xl'\n    }\n  },\n  borderRadius: 'sm',\n  color: baseColor('neutral'),\n  disableTapHighlight: true\n});\n\nexport interface SourceListItemProps\n  extends Omit<LinkProps, 'className' | 'style' | 'render' | keyof GlobalDOMAttributes>, DOMProps {\n  /** The content of the source list item. */\n  children: React.ReactNode;\n  /**\n   * Spectrum-defined styles, returned by the `style()` macro.\n   */\n  styles?: StyleString;\n}\n\n/**\n * A SourceListItem represents a single source within a SourceList.\n * The item number is provided automatically by the parent SourceList.\n */\nexport const SourceListItem = (forwardRef as forwardRefType)(function SourceListItem(\n  props: SourceListItemProps,\n  ref: DOMRef<HTMLLIElement>\n) {\n  let index = useContext(SourceListIndexContext);\n  let {size} = useContext(MessageSourceInternalContext);\n  let {children, ...otherProps} = props;\n  let itemRef = useDOMRef(ref);\n\n  return (\n    <li ref={itemRef} className={mergeStyles(itemStyles, props.styles)}>\n      <NumberBadge value={index} size={size} />\n      <Link {...otherProps} className={renderProps => linkStyles({size, ...renderProps})}>\n        {children}\n      </Link>\n    </li>\n  );\n});\n\ninterface NumberBadgeStyleProps {\n  /**\n   * The size of the number badge.\n   *\n   * @default 'S'\n   */\n  size?: 'S' | 'M' | 'L' | 'XL';\n}\n\nexport interface NumberBadgeProps\n  extends DOMProps, AriaLabelingProps, NumberBadgeStyleProps, SlotProps {\n  /**\n   * The value to be displayed in the notification badge.\n   */\n  value: number;\n  /**\n   * Spectrum-defined styles, returned by the `style()` macro.\n   */\n  styles?: StyleString;\n}\n\nconst NumberBadgeContext = createContext<{size?: 'S' | 'M' | 'L' | 'XL'}>({});\n\nconst badge = style({\n  display: 'flex',\n  color: 'gray-900',\n  font: {\n    size: {\n      S: 'ui-xs',\n      M: 'ui-sm',\n      L: 'ui',\n      XL: 'ui-lg'\n    }\n  },\n  borderStyle: {\n    forcedColors: 'solid'\n  },\n  borderWidth: {\n    forcedColors: '[1px]'\n  },\n  borderColor: {\n    forcedColors: 'ButtonBorder'\n  },\n  justifyContent: 'center',\n  alignItems: 'center',\n  backgroundColor: 'gray-200',\n  // These are arbitrary sizes since there are no designs for them\n  width: {\n    size: {\n      S: 14,\n      M: 16,\n      L: 18,\n      XL: 20\n    }\n  },\n  height: {\n    size: {\n      S: 18,\n      M: 20,\n      L: 22,\n      XL: 24\n    }\n  },\n  borderRadius: 'sm'\n});\n\n/**\n * A small visual indicator showing a count or position.\n */\nexport const NumberBadge = forwardRef(function NumberBadge(\n  props: NumberBadgeProps,\n  ref: DOMRef<HTMLSpanElement>\n) {\n  let {size = 'M', value, ...otherProps} = props;\n  let domRef = useDOMRef(ref);\n  let {locale} = useLocale();\n  let formattedValue = '';\n\n  if (value <= 0 && process.env.NODE_ENV !== 'production') {\n    console.warn('Value must be a positive integer');\n  } else {\n    formattedValue = new NumberFormatter(locale).format(value);\n  }\n\n  // let ariaLabel = props['aria-label'] || undefined;\n  return (\n    <span\n      {...filterDOMProps(otherProps)}\n      // role={ariaLabel && 'img'}\n      // aria-label={ariaLabel}\n      // We set aria-hidden to true to prevent screenreader from announcing the value of the badge by itself which is not very meaningful.\n      aria-hidden=\"true\"\n      className={mergeStyles(\n        badge({\n          size\n        }),\n        props.styles\n      )}\n      ref={domRef}>\n      {formattedValue}\n    </span>\n  );\n});\n"],"names":[],"version":3,"file":"MessageSource.cjs.map"}