import {dom as $7230ffa83bc0c2cf$export$df3a06d6289f983e, Provider as $7230ffa83bc0c2cf$export$2881499e37b75b9a, useContextProps as $7230ffa83bc0c2cf$export$29f1550f4b0d4415, useRenderProps as $7230ffa83bc0c2cf$export$4d86445c2cf5e3} from "./utils.mjs";
import $7DqZ6$intlStringsmjs from "./intlStrings.mjs";
import {TextContext as $efe09c6d1c304b50$export$9afb8bc826b033ea} from "./Text.mjs";
import {useDrop as $7DqZ6$useDrop} from "react-aria/useDrop";
import {filterDOMProps as $7DqZ6$filterDOMProps} from "react-aria/private/utils/filterDOMProps";
import {getEventTarget as $7DqZ6$getEventTarget, nodeContains as $7DqZ6$nodeContains} from "react-aria/private/utils/shadowdom/DOMFunctions";
import {isFocusable as $7DqZ6$isFocusable} from "react-aria/private/utils/isFocusable";
import {mergeProps as $7DqZ6$mergeProps} from "react-aria/mergeProps";
import $7DqZ6$react, {createContext as $7DqZ6$createContext, forwardRef as $7DqZ6$forwardRef, useRef as $7DqZ6$useRef} from "react";
import {useButton as $7DqZ6$useButton} from "react-aria/useButton";
import {useClipboard as $7DqZ6$useClipboard} from "react-aria/useClipboard";
import {useFocusRing as $7DqZ6$useFocusRing} from "react-aria/useFocusRing";
import {useHover as $7DqZ6$useHover} from "react-aria/useHover";
import {useLabels as $7DqZ6$useLabels} from "react-aria/private/utils/useLabels";
import {useLocalizedStringFormatter as $7DqZ6$useLocalizedStringFormatter} from "react-aria/useLocalizedStringFormatter";
import {useObjectRef as $7DqZ6$useObjectRef} from "react-aria/useObjectRef";
import {useSlotId as $7DqZ6$useSlotId} from "react-aria/private/utils/useId";
import {VisuallyHidden as $7DqZ6$VisuallyHidden} from "react-aria/VisuallyHidden";


function $parcel$interopDefault(a) {
  return a && a.__esModule ? a.default : a;
}
/*
 * Copyright 2023 Adobe. All rights reserved.
 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License. You may obtain a copy
 * of the License at http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under
 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
 * OF ANY KIND, either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */ 

















const $070c0dd15dc89b58$export$14a72053295ff9a6 = /*#__PURE__*/ (0, $7DqZ6$createContext)(null);
const $070c0dd15dc89b58$export$3c6489d84dc98b6 = /*#__PURE__*/ (0, $7DqZ6$forwardRef)(function DropZone(props, ref) {
    let { isDisabled: isDisabled = false } = props;
    [props, ref] = (0, $7230ffa83bc0c2cf$export$29f1550f4b0d4415)(props, ref, $070c0dd15dc89b58$export$14a72053295ff9a6);
    let dropzoneRef = (0, $7DqZ6$useObjectRef)(ref);
    let buttonRef = (0, $7DqZ6$useRef)(null);
    let { dropProps: dropProps, dropButtonProps: dropButtonProps, isDropTarget: isDropTarget } = (0, $7DqZ6$useDrop)({
        ...props,
        ref: buttonRef,
        hasDropButton: true
    });
    let { buttonProps: buttonProps } = (0, $7DqZ6$useButton)(dropButtonProps || {}, buttonRef);
    let { hoverProps: hoverProps, isHovered: isHovered } = (0, $7DqZ6$useHover)(props);
    let { focusProps: focusProps, isFocused: isFocused, isFocusVisible: isFocusVisible } = (0, $7DqZ6$useFocusRing)();
    let stringFormatter = (0, $7DqZ6$useLocalizedStringFormatter)((0, ($parcel$interopDefault($7DqZ6$intlStringsmjs))), 'react-aria-components');
    let textId = (0, $7DqZ6$useSlotId)();
    let ariaLabel = props['aria-label'] || stringFormatter.format('dropzoneLabel');
    let messageId = props['aria-labelledby'];
    let ariaLabelledby = [
        textId,
        messageId
    ].filter(Boolean).join(' ');
    let labelProps = (0, $7DqZ6$useLabels)({
        'aria-label': ariaLabel,
        'aria-labelledby': ariaLabelledby
    });
    let { clipboardProps: clipboardProps } = (0, $7DqZ6$useClipboard)({
        isDisabled: isDisabled,
        onPaste: (items)=>props.onDrop?.({
                type: 'drop',
                items: items,
                x: 0,
                y: 0,
                dropOperation: 'copy'
            })
    });
    let renderProps = (0, $7230ffa83bc0c2cf$export$4d86445c2cf5e3)({
        ...props,
        values: {
            isHovered: isHovered,
            isFocused: isFocused,
            isFocusVisible: isFocusVisible,
            isDropTarget: isDropTarget,
            isDisabled: isDisabled
        },
        defaultClassName: 'react-aria-DropZone'
    });
    let DOMProps = (0, $7DqZ6$filterDOMProps)(props, {
        global: true
    });
    delete DOMProps.id;
    return /*#__PURE__*/ (0, $7DqZ6$react).createElement((0, $7230ffa83bc0c2cf$export$2881499e37b75b9a), {
        values: [
            [
                (0, $efe09c6d1c304b50$export$9afb8bc826b033ea),
                {
                    id: textId,
                    slot: 'label'
                }
            ]
        ]
    }, /*#__PURE__*/ (0, $7DqZ6$react).createElement((0, $7230ffa83bc0c2cf$export$df3a06d6289f983e).div, {
        ...(0, $7DqZ6$mergeProps)(DOMProps, renderProps, dropProps, hoverProps),
        slot: props.slot || undefined,
        ref: dropzoneRef,
        onClick: (e)=>{
            let target = (0, $7DqZ6$getEventTarget)(e);
            while(target && (0, $7DqZ6$nodeContains)(dropzoneRef.current, target)){
                if ((0, $7DqZ6$isFocusable)(target)) break;
                else if (target === dropzoneRef.current) {
                    buttonRef.current?.focus();
                    break;
                }
                target = target.parentElement;
            }
        },
        "data-hovered": isHovered || undefined,
        "data-focused": isFocused || undefined,
        "data-focus-visible": isFocusVisible || undefined,
        "data-drop-target": isDropTarget || undefined,
        "data-disabled": isDisabled || undefined
    }, /*#__PURE__*/ (0, $7DqZ6$react).createElement((0, $7DqZ6$VisuallyHidden), null, /*#__PURE__*/ (0, $7DqZ6$react).createElement("button", {
        ...(0, $7DqZ6$mergeProps)(buttonProps, focusProps, clipboardProps, labelProps),
        ref: buttonRef
    })), renderProps.children));
});


export {$070c0dd15dc89b58$export$14a72053295ff9a6 as DropZoneContext, $070c0dd15dc89b58$export$3c6489d84dc98b6 as DropZone};
//# sourceMappingURL=DropZone.mjs.map
