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a,SAAS;0CAAC;gCAAI,KAAK;;;oBAI1D,2BACC,gBAAC;wBAAI,eAAY;wBAAO,WAAW;kCACjC,cAAA,gBAAC;4BAAkB,MAAM;;;;;0BAK/B,gBAAC;gBACC,SAAS;0BAMT,cAAA,gBAAC;oBAAY,MAAK;;;;;AAI1B;AAEA,SAAS,wCAAkB,QAAC,IAAI,EAAC;IAC/B,OAAQ;QACN,KAAK;YACH,qBAAO,gBAAC,CAAA,GAAA,wCAAY;gBAAE,MAAM;;QAC9B,KAAK;YACH,qBAAO,gBAAC,CAAA,GAAA,wCAAY;gBAAE,MAAM;;QAC9B,KAAK;YACH,qBAAO,gBAAC,CAAA,GAAA,wCAAY;gBAAE,MAAM;;QAC9B,KAAK;YACH,qBAAO,gBAAC,CAAA,GAAA,wCAAY;gBAAE,MAAM;;QAC9B,KAAK;YACH,qBAAO,gBAAC,CAAA,GAAA,wCAAY;gBAAE,MAAM;;IAChC;AACF","sources":["packages/@react-spectrum/ai/src/AttachmentList.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 AlertTriangle from '@react-spectrum/s2/icons/AlertTriangle';\nimport {\n  AriaLabelingProps,\n  DOMProps,\n  DOMRef,\n  forwardRefType,\n  GlobalDOMAttributes\n} from '@react-types/shared';\nimport {\n  baseColor,\n  focusRing,\n  iconStyle,\n  style\n} from '@react-spectrum/s2/style' with {type: 'macro'};\nimport {BasicHorizontalCard} from './HorizontalCard';\nimport {Button} from 'react-aria-components/Button';\nimport {CardProps} from '@react-spectrum/s2/Card';\nimport Cross from '../ui-icons/Cross';\nimport {forwardRef, ReactNode, useRef} from 'react';\nimport {ImageContext} from '@react-spectrum/s2/Image';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {mergeStyles} from '@react-spectrum/s2/mergeStyles';\nimport {pressScale} from '@react-spectrum/s2/pressScale';\nimport {ProgressCircle} from '@react-spectrum/s2/ProgressCircle';\nimport {StyleString} from '@react-spectrum/s2/style' with {type: 'macro'};\nimport {\n  Tag,\n  TagGroup,\n  TagGroupProps,\n  TagList,\n  TagListProps,\n  TagProps\n} from 'react-aria-components/TagGroup';\nimport {useDOMRef} from './useDOMRef';\nimport {useLocalizedStringFormatter} from 'react-aria/useLocalizedStringFormatter';\n\ninterface AttachmentRenderProps {\n  /** The size of the Card. */\n  size: 'XS' | 'S' | 'M' | 'L' | 'XL';\n}\n\nconst controlSizeM = {\n  default: 32,\n  size: {\n    XS: 20,\n    S: 24,\n    L: 40,\n    XL: 48\n  }\n} as const;\n\nconst hoverBackground = {\n  default: 'gray-200',\n  isStaticColor: 'transparent-overlay-200'\n} as const;\n\nconst styles = style<{\n  isDisabled: boolean;\n  isHovered: boolean;\n  isFocusVisible: boolean;\n  isPressed: boolean;\n  size: 'S' | 'M' | 'L' | 'XL';\n}>({\n  ...focusRing(),\n  display: 'flex',\n  alignItems: 'center',\n  justifyContent: 'center',\n  size: controlSizeM,\n  flexShrink: 0,\n  borderRadius: 'full',\n  padding: 0,\n  borderStyle: 'none',\n  transition: 'default',\n  backgroundColor: {\n    default: 'gray-200',\n    isHovered: hoverBackground,\n    isFocusVisible: hoverBackground,\n    isPressed: hoverBackground\n  },\n  color: {\n    default: baseColor('neutral'),\n    isDisabled: 'disabled',\n    forcedColors: {\n      default: 'ButtonText',\n      isDisabled: 'GrayText'\n    }\n  },\n  '--iconPrimary': {\n    type: 'fill',\n    value: 'currentColor'\n  },\n  outlineColor: {\n    default: 'focus-ring',\n    forcedColors: 'Highlight'\n  },\n  disableTapHighlight: true\n});\n\nconst CloseButton = function CloseButton(props) {\n  let ref = useRef(null);\n  // oxlint-disable react/react-compiler\n  return (\n    <Button\n      {...props}\n      ref={ref}\n      slot=\"remove\"\n      style={pressScale(ref, {})}\n      className={renderProps =>\n        mergeStyles(styles({...renderProps, size: props.size || 'M'}), props.styles)\n      }>\n      <Cross size=\"M\" />\n    </Button>\n  );\n  // oxlint-enable react/react-compiler\n};\n\nexport interface AttachmentListProps<T>\n  extends\n    DOMProps,\n    Omit<\n      TagGroupProps,\n      | 'children'\n      | 'selectionMode'\n      | 'defaultSelectedKeys'\n      | 'selectionBehavior'\n      | 'selectedKeys'\n      | 'disallowEmptySelection'\n      | 'escapeKeyBehavior'\n      | 'onSelectionChange'\n      | 'shouldSelectOnPressUp'\n      | 'onAction'\n      | 'render'\n      | 'style'\n      | 'className'\n      | keyof GlobalDOMAttributes\n    >,\n    Pick<TagListProps<T>, 'items' | 'children' | 'dependencies'> {\n  /**\n   * Spectrum-defined styles, returned by the `style()` macro.\n   */\n  styles?: StyleString;\n}\n\nexport const AttachmentList = (forwardRef as forwardRefType)(function AttachmentList<T>(\n  props: AttachmentListProps<T>,\n  ref: DOMRef<HTMLDivElement>\n) {\n  let {styles, items, children, dependencies, ...otherProps} = props;\n  let domRef = useDOMRef(ref);\n  return (\n    <TagGroup {...otherProps} className={styles} ref={domRef}>\n      <TagList\n        items={items}\n        dependencies={dependencies}\n        className={style({\n          display: 'flex',\n          flexDirection: 'row',\n          gap: 16,\n          flexWrap: 'wrap',\n          alignItems: 'center',\n          width: 'full'\n        })}>\n        {children}\n      </TagList>\n    </TagGroup>\n  );\n});\n\nexport interface AttachmentProps\n  extends\n    Omit<\n      CardProps,\n      'styles' | 'UNSAFE_className' | 'UNSAFE_style' | 'allowsArrowNavigation' | 'focusMode'\n    >,\n    AriaLabelingProps,\n    Pick<TagProps, 'id' | 'textValue' | 'render'> {\n  /** The children of the Attachment. */\n  children: ReactNode | ((renderProps: AttachmentRenderProps) => ReactNode);\n  uploadProgress?: number;\n  /** Whether the attachment has an error. */\n  isInvalid?: boolean;\n  /**\n   * Spectrum-defined styles, returned by the `style()` macro.\n   */\n  styles?: StyleString;\n}\n\nconst tagStyles = style({\n  flexShrink: 0,\n  flexGrow: 0,\n  position: 'relative',\n  ...focusRing(),\n  borderRadius: 'default'\n});\n\nconst attachmentErrorStyles = style({\n  display: 'flex',\n  flexShrink: 0,\n  alignItems: 'center',\n  paddingStart: 8,\n  '--iconPrimary': {\n    type: 'color',\n    value: 'negative'\n  }\n});\n\nexport const Attachment = forwardRef(function Attachment(\n  props: AttachmentProps,\n  ref: DOMRef<HTMLDivElement>\n) {\n  let {\n    id,\n    textValue,\n    'aria-label': ariaLabel,\n    'aria-labelledby': ariaLabelledby,\n    'aria-describedby': ariaDescribedby,\n    styles,\n    isInvalid,\n    children,\n    size = 'M',\n    ...otherProps\n  } = props;\n  let domRef = useDOMRef(ref);\n  let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/ai');\n  return (\n    <Tag\n      id={id}\n      textValue={textValue}\n      aria-label={ariaLabel}\n      aria-labelledby={ariaLabelledby}\n      aria-describedby={ariaDescribedby}\n      ref={domRef}\n      className={renderProps => mergeStyles(tagStyles({...renderProps}), styles)}>\n      <BasicHorizontalCard {...otherProps} isInvalid={isInvalid} size={size}>\n        {props.uploadProgress != null && props.uploadProgress < 100 && (\n          <div\n            className={style({\n              position: 'absolute',\n              top: '50%',\n              insetStart: {\n                default: '50%',\n                ':has(~ [data-slot=content])':\n                  '[calc(var(--card-padding-x) + var(--basic-thumb-size) / 2)]'\n              },\n              transform: 'translate(-50%, -50%)'\n            })}>\n            <ProgressCircle\n              aria-label={stringFormatter.format('promptfield.uploading')}\n              value={props.uploadProgress}\n              // TODO: should probably be M for most thumbnail only attachments at varying sizes, but needs to be S if there is text content\n              // aka like a actualy horizontal card, but to do this I need to know if text sibling is there...\n              size=\"S\"\n            />\n          </div>\n        )}\n        {/* Reduce opacity of the thumbnail if upload is in progress */}\n        <ImageContext.Consumer>\n          {ctx => (\n            <ImageContext.Provider\n              value={{\n                ...ctx,\n                slots: {\n                  thumbnail: {\n                    ...(ctx && 'slots' in ctx ? ctx.slots?.thumbnail : {}),\n                    styles: mergeStyles(\n                      ctx && 'slots' in ctx ? ctx.slots?.thumbnail?.styles : undefined,\n                      style({\n                        opacity: {default: 1, isUploading: 0.15},\n                        transition: 'default'\n                      })({isUploading: props.uploadProgress != null && props.uploadProgress < 100})\n                    )\n                  }\n                }\n              }}>\n              {typeof children === 'function' ? children({size}) : children}\n            </ImageContext.Provider>\n          )}\n        </ImageContext.Consumer>\n        {isInvalid && (\n          <div aria-hidden=\"true\" className={attachmentErrorStyles}>\n            <AlertTriangleIcon size={size} />\n          </div>\n        )}\n      </BasicHorizontalCard>\n      {/** Definitely not a close button, though looks like one. */}\n      <div\n        className={style({\n          position: 'absolute',\n          top: 0,\n          insetEnd: 0,\n          transform: 'translate(50%, -50%)'\n        })}>\n        <CloseButton size=\"XS\" />\n      </div>\n    </Tag>\n  );\n});\n\nfunction AlertTriangleIcon({size}) {\n  switch (size) {\n    case 'XS':\n      return <AlertTriangle styles={iconStyle({size: 'XS'})} />;\n    case 'S':\n      return <AlertTriangle styles={iconStyle({size: 'S'})} />;\n    case 'M':\n      return <AlertTriangle styles={iconStyle({size: 'M'})} />;\n    case 'L':\n      return <AlertTriangle styles={iconStyle({size: 'L'})} />;\n    case 'XL':\n      return <AlertTriangle styles={iconStyle({size: 'XL'})} />;\n  }\n}\n"],"names":[],"version":3,"file":"AttachmentList.mjs.map"}