import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// (C) 2026 GoodData Corporation
import { useCallback } from "react";
import { UiButton } from "../../@ui/UiButton/UiButton.js";
import { useFileInput } from "../hooks/useFileInput.js";
/**
 * @internal
 */
export function FilePickerButton({ buttonLabel, acceptedFileTypes, multiple = false, disabled = false, ariaLabel, onFilesSelected, buttonProps, }) {
    const { inputRef, handleInputChange } = useFileInput(onFilesSelected);
    const onButtonClick = useCallback(() => {
        if (disabled) {
            return;
        }
        inputRef.current?.click();
    }, [disabled, inputRef]);
    return (_jsxs(_Fragment, { children: [
            _jsx(UiButton, { isDisabled: disabled, label: buttonLabel, onClick: onButtonClick, accessibilityConfig: { ariaLabel }, ...buttonProps }), _jsx("input", { ref: inputRef, hidden: true, type: "file", disabled: disabled, accept: acceptedFileTypes, multiple: multiple, onChange: handleInputChange })
        ] }));
}
