import "./NumberField.css";
import $053de6aaf5f9b7bd$export$2e2bcd8739ae039 from "./Add.mjs";
import {createFocusableRef as $80ecb974df713a30$export$79d69eee6ae4b329} from "./useDOMRef.mjs";
import $f17037051ff08dc2$export$2e2bcd8739ae039 from "./Dash.mjs";
import {FieldErrorIcon as $9afd80978c252040$export$bda0d075e0e342c9, FieldGroup as $9afd80978c252040$export$f0fe469072bc6950, FieldLabel as $9afd80978c252040$export$1acdcf5a973a8414, HelpText as $9afd80978c252040$export$a67c0bc59081311a, Input as $9afd80978c252040$export$f5b8910cec6cf069} from "./Field.mjs";
import {FormContext as $9b916426527cebe7$export$c24727297075ec6a, useFormProps as $9b916426527cebe7$export$a6b5be5c6b451665} from "./Form.mjs";
import {pressScale as $10ea7662e51a285b$export$56e8cba416805d8d} from "./pressScale.mjs";
import {useSpectrumContextProps as $5ce63c423902f47d$export$764f6146fadd77f7} from "../../icons/useSpectrumContextProps.mjs";
import {jsx as $5qJVF$jsx, jsxs as $5qJVF$jsxs, Fragment as $5qJVF$Fragment} from "react/jsx-runtime";
import {ButtonContext as $5qJVF$ButtonContext} from "react-aria-components/Button";
import {NumberField as $5qJVF$NumberField} from "react-aria-components/NumberField";
import {useContextProps as $5qJVF$useContextProps} from "react-aria-components/slots";
import {createContext as $5qJVF$createContext, forwardRef as $5qJVF$forwardRef, useContext as $5qJVF$useContext, useRef as $5qJVF$useRef, useImperativeHandle as $5qJVF$useImperativeHandle, useMemo as $5qJVF$useMemo} from "react";
import {filterDOMProps as $5qJVF$filterDOMProps} from "react-aria/filterDOMProps";
import {InputContext as $5qJVF$InputContext} from "react-aria-components/Input";
import {mergeProps as $5qJVF$mergeProps} from "react-aria/mergeProps";
import {mergeRefs as $5qJVF$mergeRefs} from "react-aria/mergeRefs";
import {useButton as $5qJVF$useButton} from "react-aria/useButton";
import {useFocusRing as $5qJVF$useFocusRing} from "react-aria/useFocusRing";
import {useHover as $5qJVF$useHover} from "react-aria/useHover";

/*
 * Copyright 2024 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 $675eca1a78ccd399$export$b414a48cf5dcbc11 = /*#__PURE__*/ (0, $5qJVF$createContext)(null);
const $675eca1a78ccd399$var$inputButton = function anonymous(props) {
    let rules = " ";
    if (props.size === "XL") rules += ' -SFnbic-_JaP8ec12';
    else if (props.size === "L") rules += ' -SFnbic-_J0K2hn12';
    else if (props.size === "S") rules += ' -SFnbic-_JJOW22b12';
    else if (props.size === "XS") rules += ' -SFnbic-_JICefdd12';
    else rules += ' -SFnbic-_Jb12';
    rules += ' -Bu7z1c-oa12';
    rules += ' oj12';
    rules += ' nj12';
    rules += ' kj12';
    rules += ' jj12';
    rules += ' sd12';
    rules += ' _Le12';
    rules += ' _Wa12';
    rules += ' _je12';
    rules += ' eb12';
    rules += ' _Ca12';
    if (props.size === "XL") rules += ' ZC12';
    else if (props.size === "L") rules += ' Zo12';
    else if (props.size === "M") rules += ' Zm12';
    else if (props.size === "S") rules += ' Zu12';
    rules += ' Fd12';
    if (props.type === "increment") rules += ' Iy12';
    else rules += ' Iw12';
    rules += ' fa12';
    rules += ' _va12';
    rules += ' Ma12';
    rules += ' Yd12';
    rules += ' Yle12';
    rules += ' Xb12';
    rules += ' Xlb12';
    rules += ' _2b12';
    rules += ' _2lb12';
    if (props.isDisabled) rules += ' gH12';
    else {
        if (props.isPressed) rules += ' gF12';
        else if (props.isFocusVisible) rules += ' gF12';
        else if (props.isHovered) rules += ' gF12';
        else rules += ' gH12';
    }
    if (props.isDisabled) rules += ' gld12';
    else if (props.isHovered) rules += ' gle12';
    else rules += ' glc12';
    if (props.isDisabled) rules += ' pp12';
    else {
        if (props.isPressed) rules += ' po12';
        else if (props.isFocusVisible) rules += ' po12';
        else if (props.isHovered) rules += ' po12';
        else rules += ' pt12';
    }
    rules += ' pla12';
    rules += ' ri12';
    return rules;
};
const $675eca1a78ccd399$var$iconStyles = " _va12 -_8sjo0b-t5ZbAob12";
const $675eca1a78ccd399$var$stepperContainerStyles = function anonymous(props) {
    let rules = " ";
    rules += ' sd12';
    rules += ' _tc12';
    if (props.size === "XL") rules += ' Ue12';
    else if (props.size === "L") rules += ' Ue12';
    else if (props.size === "M") rules += ' Ub12';
    else if (props.size === "S") rules += ' Ue12';
    if (props.size === "XL") rules += ' qe12';
    else if (props.size === "L") rules += ' qe12';
    else if (props.size === "M") rules += ' qb12';
    else if (props.size === "S") rules += ' qe12';
    if (props.size === "XL") rules += ' HWJpoB12';
    else if (props.size === "L") rules += ' HWJpoB12';
    else if (props.size === "M") rules += ' Hs12';
    else if (props.size === "S") rules += ' Hr12';
    return rules;
};
const $675eca1a78ccd399$export$63c5fa0b2fdccd2e = /*#__PURE__*/ (0, $5qJVF$forwardRef)(function NumberField(props1, ref) {
    [props1, ref] = (0, $5ce63c423902f47d$export$764f6146fadd77f7)(props1, ref, $675eca1a78ccd399$export$b414a48cf5dcbc11);
    props1 = (0, $9b916426527cebe7$export$a6b5be5c6b451665)(props1);
    let { label: label, contextualHelp: contextualHelp, description: descriptionMessage, errorMessage: errorMessage, hideStepper: hideStepper, isRequired: isRequired, size: size = 'M', labelPosition: labelPosition = 'top', necessityIndicator: necessityIndicator, labelAlign: labelAlign = 'start', UNSAFE_className: UNSAFE_className = '', UNSAFE_style: UNSAFE_style, ...numberFieldProps } = props1;
    let formContext = (0, $5qJVF$useContext)((0, $9b916426527cebe7$export$c24727297075ec6a));
    let domRef = (0, $5qJVF$useRef)(null);
    let inputRef = (0, $5qJVF$useRef)(null);
    let decrementButtonRef = (0, $5qJVF$useRef)(null);
    let incrementButtonRef = (0, $5qJVF$useRef)(null);
    // Expose imperative interface for ref
    (0, $5qJVF$useImperativeHandle)(ref, ()=>({
            ...(0, $80ecb974df713a30$export$79d69eee6ae4b329)(domRef, inputRef),
            select () {
                if (inputRef.current) inputRef.current.select();
            },
            getInputElement () {
                return inputRef.current;
            }
        }));
    return /*#__PURE__*/ (0, $5qJVF$jsx)((0, $5qJVF$NumberField), {
        ref: domRef,
        isRequired: isRequired,
        ...numberFieldProps,
        style: UNSAFE_style,
        className: UNSAFE_className + function anonymous(props, overrides) {
            let rules = " ";
            let gridColumnStart = false;
            let gridColumnEnd = false;
            let matches = String(overrides || '').matchAll(/(?:^|\s)(J|G|I|H|_u|_v|_s|__A|_d|_J|z|y|B|A|_P|_9|W|_l|_A|_z|_6|Z|N|L)[^\s]+/g);
            for (let p of matches){
                if (p[1] === "z") gridColumnStart = true;
                if (p[1] === "y") gridColumnEnd = true;
                rules += p[0];
            }
            rules += ' se12';
            if (props.isInForm) {
                if (!gridColumnStart) rules += ' z2mU12';
            }
            if (props.isInForm) {
                if (props.labelPosition === "side") {
                    if (!gridColumnEnd) rules += ' yvoofG12';
                }
            }
            if (props.isInForm) rules += ' DLwlgod12';
            else {
                if (props.labelPosition === "side") rules += ' DPlN5qb12';
                else if (props.labelPosition === "top") rules += ' DM8Mfn12';
            }
            if (props.labelPosition === "side") rules += ' EPlN5qb12';
            else if (props.labelPosition === "top") rules += ' E4w1sLc12';
            if (props.labelPosition === "side") rules += ' CbRM95c12';
            else if (props.labelPosition === "top") rules += ' Cxaocre12';
            if (props.size === "XL") {
                rules += ' -_6BNtrc-e12';
                rules += ' vx12';
            } else if (props.size === "L") {
                rules += ' -_6BNtrc-d12';
                rules += ' vx12';
            } else if (props.size === "S") {
                rules += ' -_6BNtrc-b12';
                rules += ' vx12';
            } else if (props.size === "XS") {
                rules += ' -_6BNtrc-a12';
                rules += ' vx12';
            } else {
                rules += ' -_6BNtrc-c12';
                rules += ' vx12';
            }
            rules += ' ea12';
            rules += ' _Fd12';
            rules += ' _FnuYUweb12';
            if (props.size === "XL") rules += ' -BhX7R-Fz12';
            else if (props.size === "L") rules += ' -BhX7R-Fv12';
            else if (props.size === "S") rules += ' -BhX7R-Fp12';
            else if (props.size === "XS") rules += ' -BhX7R-Fn12';
            else rules += ' -BhX7R-Fx12';
            rules += ' -AJjOLd-UVkF0Db12';
            rules += ' qg12';
            rules += ' __ca12';
            return rules;
        }({
            isInForm: !!formContext,
            labelPosition: labelPosition,
            size: size
        }, props1.styles),
        children: ({ isDisabled: isDisabled, isInvalid: isInvalid })=>{
            return /*#__PURE__*/ (0, $5qJVF$jsxs)((0, $5qJVF$Fragment), {
                children: [
                    /*#__PURE__*/ (0, $5qJVF$jsx)((0, $9afd80978c252040$export$1acdcf5a973a8414), {
                        isDisabled: isDisabled,
                        isRequired: isRequired,
                        size: size,
                        labelPosition: labelPosition,
                        labelAlign: labelAlign,
                        necessityIndicator: necessityIndicator,
                        contextualHelp: contextualHelp,
                        children: label
                    }),
                    /*#__PURE__*/ (0, $5qJVF$jsxs)((0, $9afd80978c252040$export$f0fe469072bc6950), {
                        size: size,
                        styles: function anonymous(props) {
                            let rules = " ";
                            rules += ' zXcEWr12';
                            rules += ' yXcEWr12';
                            rules += ' BXcEWr12';
                            rules += ' AXcEWr12';
                            if (props.size === "XL") rules += ' Nl12';
                            else if (props.size === "L") rules += ' Nj12';
                            else if (props.size === "S") rules += ' Nf12';
                            else if (props.size === "XS") rules += ' Ne12';
                            else rules += ' Nk12';
                            if (props.isQuiet) rules += ' _qd12';
                            else rules += ' _qtb12';
                            if (props.size === "XL") rules += ' -Anxdcc-Zt12';
                            else if (props.size === "L") rules += ' -Anxdcc-ZStdtne12';
                            else if (props.size === "S") rules += ' -Anxdcc-Zr12';
                            else rules += ' -Anxdcc-Z3fn9H12';
                            rules += ' __v6TNLWb12';
                            rules += ' SMBFGYc12';
                            rules += ' RfBFGYc12';
                            rules += ' -S_-Sv12';
                            if (props.isStepperHidden) rules += ' -R_-Rv12';
                            else rules += ' -R_-Rd12';
                            return rules;
                        }({
                            size: size,
                            isStepperHidden: hideStepper
                        }),
                        children: [
                            /*#__PURE__*/ (0, $5qJVF$jsx)((0, $5qJVF$InputContext).Consumer, {
                                children: (ctx)=>/*#__PURE__*/ (0, $5qJVF$jsx)((0, $5qJVF$InputContext).Provider, {
                                        value: {
                                            ...ctx,
                                            ref: (0, $5qJVF$mergeRefs)(ctx?.ref, inputRef)
                                        },
                                        children: /*#__PURE__*/ (0, $5qJVF$jsx)((0, $9afd80978c252040$export$f5b8910cec6cf069), {})
                                    })
                            }),
                            isInvalid && /*#__PURE__*/ (0, $5qJVF$jsx)((0, $9afd80978c252040$export$bda0d075e0e342c9), {
                                isDisabled: isDisabled
                            }),
                            !hideStepper && /*#__PURE__*/ (0, $5qJVF$jsxs)("div", {
                                className: $675eca1a78ccd399$var$stepperContainerStyles({
                                    size: size
                                }),
                                children: [
                                    /*#__PURE__*/ (0, $5qJVF$jsx)($675eca1a78ccd399$var$StepButton, {
                                        ref: decrementButtonRef,
                                        slot: "decrement",
                                        style: (renderProps)=>(0, $10ea7662e51a285b$export$56e8cba416805d8d)(decrementButtonRef)(renderProps),
                                        className: (renderProps)=>$675eca1a78ccd399$var$inputButton({
                                                ...renderProps,
                                                type: 'decrement',
                                                size: size
                                            }),
                                        children: /*#__PURE__*/ (0, $5qJVF$jsx)((0, $f17037051ff08dc2$export$2e2bcd8739ae039), {
                                            size: size,
                                            className: $675eca1a78ccd399$var$iconStyles
                                        })
                                    }),
                                    /*#__PURE__*/ (0, $5qJVF$jsx)($675eca1a78ccd399$var$StepButton, {
                                        ref: incrementButtonRef,
                                        slot: "increment",
                                        style: (renderProps)=>(0, $10ea7662e51a285b$export$56e8cba416805d8d)(incrementButtonRef)(renderProps),
                                        className: (renderProps)=>$675eca1a78ccd399$var$inputButton({
                                                ...renderProps,
                                                type: 'increment',
                                                size: size
                                            }),
                                        children: /*#__PURE__*/ (0, $5qJVF$jsx)((0, $053de6aaf5f9b7bd$export$2e2bcd8739ae039), {
                                            size: size,
                                            className: $675eca1a78ccd399$var$iconStyles
                                        })
                                    })
                                ]
                            })
                        ]
                    }),
                    /*#__PURE__*/ (0, $5qJVF$jsx)((0, $9afd80978c252040$export$a67c0bc59081311a), {
                        size: size,
                        isDisabled: isDisabled,
                        isInvalid: isInvalid,
                        description: descriptionMessage,
                        children: errorMessage
                    })
                ]
            });
        }
    });
});
const $675eca1a78ccd399$var$additionalButtonHTMLAttributes = new Set([
    'form',
    'formAction',
    'formEncType',
    'formMethod',
    'formNoValidate',
    'formTarget',
    'name',
    'value'
]);
let $675eca1a78ccd399$var$StepButton = /*#__PURE__*/ (0, $5qJVF$forwardRef)((props, ref)=>{
    [props, ref] = (0, $5qJVF$useContextProps)(props, ref, (0, $5qJVF$ButtonContext));
    let ctx = props;
    /**
   * Must use div for now because Safari pointer event bugs on disabled form elements.
   * Link https://bugs.webkit.org/show_bug.cgi?id=219188.
   */ let { buttonProps: buttonProps, isPressed: isPressed } = (0, $5qJVF$useButton)({
        ...props,
        elementType: 'div'
    }, ref);
    let { focusProps: focusProps, isFocused: isFocused, isFocusVisible: isFocusVisible } = (0, $5qJVF$useFocusRing)(props);
    let { hoverProps: hoverProps, isHovered: isHovered } = (0, $5qJVF$useHover)(props);
    let renderProps = $675eca1a78ccd399$var$useRenderProps({
        ...props,
        values: {
            isHovered: isHovered,
            isPressed: isPressed,
            isFocused: isFocused,
            isFocusVisible: isFocusVisible,
            isDisabled: props.isDisabled || false
        },
        defaultClassName: 'react-aria-Button'
    });
    return /*#__PURE__*/ (0, $5qJVF$jsx)("div", {
        ...(0, $5qJVF$filterDOMProps)(props, {
            propNames: $675eca1a78ccd399$var$additionalButtonHTMLAttributes
        }),
        ...(0, $5qJVF$mergeProps)(buttonProps, focusProps, hoverProps),
        ...renderProps,
        ref: ref,
        slot: props.slot || undefined,
        "data-disabled": props.isDisabled || undefined,
        "data-pressed": ctx.isPressed || isPressed || undefined,
        "data-hovered": isHovered || undefined,
        "data-focused": isFocused || undefined,
        "data-focus-visible": isFocusVisible || undefined
    });
});
// replace from RAC
function $675eca1a78ccd399$var$useRenderProps(props) {
    let { className: className, style: style, children: children, defaultClassName: defaultClassName, defaultChildren: defaultChildren, defaultStyle: defaultStyle, values: values } = props;
    return (0, $5qJVF$useMemo)(()=>{
        let computedClassName;
        let computedStyle;
        let computedChildren;
        if (typeof className === 'function') computedClassName = className({
            ...values,
            defaultClassName: defaultClassName
        });
        else computedClassName = className;
        if (typeof style === 'function') computedStyle = style({
            ...values,
            defaultStyle: defaultStyle || {}
        });
        else computedStyle = style;
        if (typeof children === 'function') computedChildren = children({
            ...values,
            defaultChildren: defaultChildren
        });
        else if (children == null) computedChildren = defaultChildren;
        else computedChildren = children;
        return {
            className: computedClassName ?? defaultClassName,
            style: computedStyle || defaultStyle ? {
                ...defaultStyle,
                ...computedStyle
            } : undefined,
            children: computedChildren ?? defaultChildren,
            'data-rac': ''
        };
    }, [
        className,
        style,
        children,
        defaultClassName,
        defaultChildren,
        defaultStyle,
        values
    ]);
}


export {$675eca1a78ccd399$export$b414a48cf5dcbc11 as NumberFieldContext, $675eca1a78ccd399$export$63c5fa0b2fdccd2e as NumberField};
//# sourceMappingURL=NumberField.mjs.map
