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,MAAM,MAAM,GAAG;gBACjC,MAAM;uBACN;gBACA,GAAG;gBACH,GAAG;gBACH,eAAe;YACjB;IACF;IAEA,IAAI,cAAc,CAAA,GAAA,uCAAa,EAAE;QAC/B,GAAG,KAAK;QACR,QAAQ;uBAAC;uBAAW;4BAAW;0BAAgB;wBAAc;QAAU;QACvE,kBAAkB;IACpB;IACA,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,OAAO;QAAC,QAAQ;IAAI;IAClD,OAAO,SAAS,EAAE;IAElB,qBACE,gCAAC,CAAA,GAAA,yCAAO;QACN,QAAQ;YACN;gBAAC,CAAA,GAAA,yCAAU;gBAAG;oBAAC,IAAI;oBAAQ,MAAM;gBAAO;aAAE;SAC3C;qBACD,gCAAC,CAAA,GAAA,yCAAE,EAAE,GAAG;QACL,GAAG,CAAA,GAAA,iBAAS,EAAE,UAAU,aAAa,WAAW,WAAW;QAC5D,MAAM,MAAM,IAAI,IAAI;QACpB,KAAK;QACL,SAAS,CAAC;YACR,IAAI,SAAS,CAAA,GAAA,qBAAa,EAAE;YAC5B,MAAO,UAAU,CAAA,GAAA,mBAAW,EAAE,YAAY,OAAO,EAAE,QAAS;gBAC1D,IAAI,CAAA,GAAA,kBAAU,EAAE,SACd;qBACK,IAAI,WAAW,YAAY,OAAO,EAAE;oBACzC,UAAU,OAAO,EAAE;oBACnB;gBACF;gBAEA,SAAS,OAAO,aAAa;YAC/B;QACF;QACA,gBAAc,aAAa;QAC3B,gBAAc,aAAa;QAC3B,sBAAoB,kBAAkB;QACtC,oBAAkB,gBAAgB;QAClC,iBAAe,cAAc;qBAC7B,gCAAC,CAAA,GAAA,qBAAa,uBACZ,gCAAC;QACE,GAAG,CAAA,GAAA,iBAAS,EAAE,aAAa,YAAY,gBAAgB,WAAW;QACnE,KAAK;SAER,YAAY,QAAQ;AAI7B","sources":["packages/react-aria-components/src/DropZone.tsx"],"sourcesContent":["/*\n * Copyright 2023 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, GlobalDOMAttributes, HoverEvents} from '@react-types/shared';\nimport {\n  ClassNameOrFunction,\n  ContextValue,\n  dom,\n  Provider,\n  RenderProps,\n  SlotProps,\n  useContextProps,\n  useRenderProps\n} from './utils';\nimport {DropOptions, useDrop} from 'react-aria/useDrop';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {getEventTarget, nodeContains} from 'react-aria/private/utils/shadowdom/DOMFunctions';\nimport intlMessages from '../intl/*.json';\nimport {isFocusable} from 'react-aria/private/utils/isFocusable';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport React, {createContext, ForwardedRef, forwardRef, useRef} from 'react';\nimport {TextContext} from './Text';\nimport {useButton} from 'react-aria/useButton';\nimport {useClipboard} from 'react-aria/useClipboard';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useHover} from 'react-aria/useHover';\nimport {useLabels} from 'react-aria/private/utils/useLabels';\nimport {useLocalizedStringFormatter} from 'react-aria/useLocalizedStringFormatter';\n// @ts-ignore\nimport {useObjectRef} from 'react-aria/useObjectRef';\nimport {useSlotId} from 'react-aria/private/utils/useId';\nimport {VisuallyHidden} from 'react-aria/VisuallyHidden';\n\nexport interface DropZoneRenderProps {\n  /**\n   * Whether the dropzone is currently hovered with a mouse.\n   * @selector [data-hovered]\n   */\n  isHovered: boolean,\n  /**\n   * Whether the dropzone is focused, either via a mouse or keyboard.\n   * @selector [data-focused]\n   */\n  isFocused: boolean,\n  /**\n   * Whether the dropzone is keyboard focused.\n   * @selector [data-focus-visible]\n   */\n  isFocusVisible: boolean,\n  /**\n   * Whether the dropzone is the drop target.\n   * @selector [data-drop-target]\n   */\n  isDropTarget: boolean,\n  /**\n   * Whether the dropzone is disabled.\n   * @selector [data-disabled]\n   */\n  isDisabled: boolean\n}\n\nexport interface DropZoneProps extends Omit<DropOptions, 'getDropOperationForPoint' | 'ref' | 'hasDropButton'>, HoverEvents, RenderProps<DropZoneRenderProps>, SlotProps, AriaLabelingProps, GlobalDOMAttributes<HTMLDivElement> {\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-DropZone'\n   */\n  className?: ClassNameOrFunction<DropZoneRenderProps>\n}\n\nexport const DropZoneContext = createContext<ContextValue<DropZoneProps, HTMLDivElement>>(null);\n\n/**\n * A drop zone is an area into which one or multiple objects can be dragged and dropped.\n */\nexport const DropZone = forwardRef(function DropZone(props: DropZoneProps, ref: ForwardedRef<HTMLDivElement>) {\n  let {isDisabled = false} = props;\n  [props, ref] = useContextProps(props, ref, DropZoneContext);\n  let dropzoneRef = useObjectRef(ref);\n  let buttonRef = useRef<HTMLButtonElement>(null);\n  let {dropProps, dropButtonProps, isDropTarget} = useDrop({...props, ref: buttonRef, hasDropButton: true});\n  let {buttonProps} = useButton(dropButtonProps || {}, buttonRef);\n  let {hoverProps, isHovered} = useHover(props);\n  let {focusProps, isFocused, isFocusVisible} = useFocusRing();\n  let stringFormatter = useLocalizedStringFormatter(intlMessages, 'react-aria-components');\n\n  let textId = useSlotId();\n  let ariaLabel = props['aria-label'] || stringFormatter.format('dropzoneLabel');\n  let messageId = props['aria-labelledby'];\n  let ariaLabelledby = [textId, messageId].filter(Boolean).join(' ');\n  let labelProps = useLabels({'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby});\n\n\n  let {clipboardProps} = useClipboard({\n    isDisabled,\n    onPaste: (items) => props.onDrop?.({\n      type: 'drop',\n      items,\n      x: 0,\n      y: 0,\n      dropOperation: 'copy'\n    })\n  });\n\n  let renderProps = useRenderProps({\n    ...props,\n    values: {isHovered, isFocused, isFocusVisible, isDropTarget, isDisabled},\n    defaultClassName: 'react-aria-DropZone'\n  });\n  let DOMProps = filterDOMProps(props, {global: true});\n  delete DOMProps.id;\n\n  return (\n    <Provider\n      values={[\n        [TextContext, {id: textId, slot: 'label'}]\n      ]}>\n      <dom.div\n        {...mergeProps(DOMProps, renderProps, dropProps, hoverProps)}\n        slot={props.slot || undefined}\n        ref={dropzoneRef}\n        onClick={(e) => {\n          let target = getEventTarget(e) as HTMLElement | null;\n          while (target && nodeContains(dropzoneRef.current, target)) {\n            if (isFocusable(target)) {\n              break;\n            } else if (target === dropzoneRef.current) {\n              buttonRef.current?.focus();\n              break;\n            }\n\n            target = target.parentElement;\n          }\n        }}\n        data-hovered={isHovered || undefined}\n        data-focused={isFocused || undefined}\n        data-focus-visible={isFocusVisible || undefined}\n        data-drop-target={isDropTarget || undefined}\n        data-disabled={isDisabled || undefined}>\n        <VisuallyHidden>\n          <button\n            {...mergeProps(buttonProps, focusProps, clipboardProps, labelProps)}\n            ref={buttonRef} />\n        </VisuallyHidden>\n        {renderProps.children}\n      </dom.div>\n    </Provider>\n  );\n});\n"],"names":[],"version":3,"file":"DropZone.mjs.map"}