import {dom as $b7b7a92703138c9b$export$df3a06d6289f983e, useContextProps as $b7b7a92703138c9b$export$29f1550f4b0d4415, useRenderProps as $b7b7a92703138c9b$export$4d86445c2cf5e3, useSlot as $b7b7a92703138c9b$export$9d4c57ee4c6ffdd8} from "./utils.js";
import {LabelContext as $3e4839e5b30e7b17$export$75b6ee27786ba447} from "./Label.js";
import {useProgressBar as $lG3gV$useProgressBar} from "react-aria/useProgressBar";
import {clamp as $lG3gV$clamp} from "react-stately/private/utils/number";
import {filterDOMProps as $lG3gV$filterDOMProps} from "react-aria/private/utils/filterDOMProps";
import {mergeProps as $lG3gV$mergeProps} from "react-aria/mergeProps";
import $lG3gV$react, {createContext as $lG3gV$createContext, forwardRef as $lG3gV$forwardRef} from "react";

/*
 * Copyright 2022 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 $71551be8b98e6856$export$e9f3bf65a26ce129 = /*#__PURE__*/ (0, $lG3gV$createContext)(null);
const $71551be8b98e6856$export$c17561cb55d4db30 = /*#__PURE__*/ (0, $lG3gV$forwardRef)(function ProgressBar(props, ref) {
    [props, ref] = (0, $b7b7a92703138c9b$export$29f1550f4b0d4415)(props, ref, $71551be8b98e6856$export$e9f3bf65a26ce129);
    let { value: value = 0, minValue: minValue = 0, maxValue: maxValue = 100, isIndeterminate: isIndeterminate = false } = props;
    value = (0, $lG3gV$clamp)(value, minValue, maxValue);
    let [labelRef, label] = (0, $b7b7a92703138c9b$export$9d4c57ee4c6ffdd8)(!props['aria-label'] && !props['aria-labelledby']);
    let { progressBarProps: progressBarProps, labelProps: labelProps } = (0, $lG3gV$useProgressBar)({
        ...props,
        label: label
    });
    // Calculate the width of the progress bar as a percentage
    let percentage = isIndeterminate ? undefined : (value - minValue) / (maxValue - minValue) * 100;
    let renderProps = (0, $b7b7a92703138c9b$export$4d86445c2cf5e3)({
        ...props,
        defaultClassName: 'react-aria-ProgressBar',
        values: {
            percentage: percentage,
            valueText: progressBarProps['aria-valuetext'],
            isIndeterminate: isIndeterminate
        }
    });
    let DOMProps = (0, $lG3gV$filterDOMProps)(props, {
        global: true
    });
    return /*#__PURE__*/ (0, $lG3gV$react).createElement((0, $b7b7a92703138c9b$export$df3a06d6289f983e).div, {
        ...(0, $lG3gV$mergeProps)(DOMProps, renderProps, progressBarProps),
        ref: ref,
        slot: props.slot || undefined
    }, /*#__PURE__*/ (0, $lG3gV$react).createElement((0, $3e4839e5b30e7b17$export$75b6ee27786ba447).Provider, {
        value: {
            ...labelProps,
            ref: labelRef,
            elementType: 'span'
        }
    }, renderProps.children));
});


export {$71551be8b98e6856$export$e9f3bf65a26ce129 as ProgressBarContext, $71551be8b98e6856$export$c17561cb55d4db30 as ProgressBar};
//# sourceMappingURL=ProgressBar.js.map
