"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.d = (exports1, definition)=>{
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
    __webpack_require__.r = (exports1)=>{
        if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    NumberField: ()=>NumberField_NumberField
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const apollo_wind_namespaceObject = require("@uipath/apollo-wind");
const external_react_namespaceObject = require("react");
const NumberField_NumberField = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(function({ field, value, onChange, error }) {
    const [localValue, setLocalValue] = (0, external_react_namespaceObject.useState)(value ?? field.defaultValue ?? '');
    const debounceTimer = (0, external_react_namespaceObject.useRef)(null);
    (0, external_react_namespaceObject.useEffect)(()=>{
        setLocalValue(value ?? field.defaultValue ?? '');
    }, [
        value,
        field.defaultValue
    ]);
    (0, external_react_namespaceObject.useEffect)(()=>()=>{
            if (debounceTimer.current) {
                clearTimeout(debounceTimer.current);
                debounceTimer.current = null;
            }
        }, []);
    const handleChange = (0, external_react_namespaceObject.useCallback)((e)=>{
        const newValue = e.target.value;
        setLocalValue(newValue);
        if (debounceTimer.current) {
            clearTimeout(debounceTimer.current);
            debounceTimer.current = null;
        }
        const debounceDelay = field.debounce || 0;
        if (debounceDelay > 0) debounceTimer.current = setTimeout(()=>{
            const numValue = '' === newValue ? void 0 : Number(newValue);
            onChange(numValue);
            debounceTimer.current = null;
        }, debounceDelay);
        else {
            const numValue = '' === newValue ? void 0 : Number(newValue);
            onChange(numValue);
        }
    }, [
        field.debounce,
        onChange
    ]);
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
        className: "flex flex-col gap-1",
        children: [
            /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("label", {
                htmlFor: `field-${field.key}`,
                className: "text-[13px] text-(--canvas-foreground-de-emp)",
                children: field.label
            }),
            /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
                className: "flex items-center gap-2",
                children: [
                    /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("input", {
                        id: `field-${field.key}`,
                        className: (0, apollo_wind_namespaceObject.cn)('nodrag flex-1 px-3 py-2 text-[13px] font-mono border border-(--canvas-border) rounded bg-(--canvas-background) text-(--canvas-foreground) outline-none transition-colors', 'focus:border-(--canvas-primary)', 'disabled:opacity-50 disabled:cursor-not-allowed', '[appearance:textfield] [&::-webkit-inner-spin-button]:hidden [&::-webkit-outer-spin-button]:hidden', error && 'border-(--canvas-error)'),
                        type: "number",
                        value: localValue,
                        onChange: handleChange,
                        placeholder: field.placeholder,
                        disabled: field.disabled,
                        min: field.min,
                        max: field.max,
                        step: field.step
                    }),
                    field.suffix && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
                        className: "shrink-0 text-[13px] text-(--canvas-foreground-de-emp) whitespace-nowrap",
                        children: field.suffix
                    })
                ]
            }),
            field.helpText && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
                className: "text-[12px] text-(--canvas-foreground-de-emp) block",
                children: field.helpText
            }),
            error && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
                className: "text-[12px] text-(--canvas-error-text) block",
                children: error
            })
        ]
    });
});
exports.NumberField = __webpack_exports__.NumberField;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "NumberField"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
