"use strict";
exports.id = 6498;
exports.ids = [6498];
exports.modules = {

/***/ 706498:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Z": () => (/* binding */ IntegerSlider)
/* harmony export */ });
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(920997);
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(545725);
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(antd__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(616689);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _cocalc_util_theme__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(990821);
/* harmony import */ var _cocalc_util_theme__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_cocalc_util_theme__WEBPACK_IMPORTED_MODULE_3__);




function IntegerSlider({ value , onChange , min , max , maxText , defaultValue , initialValue , units , presets , disabled =false , step =1  }) {
    function toNumber(x) {
        return typeof x === "number" ? x : min;
    }
    const { 0: val , 1: setVal  } = (0,react__WEBPACK_IMPORTED_MODULE_2__.useState)(value ?? initialValue ?? defaultValue ?? min);
    return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.Fragment, {
        children: [
            /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(antd__WEBPACK_IMPORTED_MODULE_1__.Row, {
                children: [
                    /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(antd__WEBPACK_IMPORTED_MODULE_1__.Col, {
                        span: 12,
                        children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(antd__WEBPACK_IMPORTED_MODULE_1__.Slider, {
                            disabled: disabled,
                            style: {
                                width: "100%"
                            },
                            min: min,
                            max: max,
                            onChange: (x)=>{
                                onChange(x);
                                setVal(x);
                            },
                            value: value != null ? toNumber(value) : val,
                            defaultValue: initialValue,
                            step: step
                        })
                    }),
                    /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(antd__WEBPACK_IMPORTED_MODULE_1__.Col, {
                        span: 12,
                        children: [
                            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(antd__WEBPACK_IMPORTED_MODULE_1__.InputNumber, {
                                min: min,
                                max: maxText ?? max,
                                step: step,
                                disabled: disabled,
                                style: {
                                    marginLeft: "16px",
                                    marginBottom: "5px",
                                    minWidth: "8ex",
                                    width: "20ex"
                                },
                                defaultValue: initialValue,
                                value: value ?? val,
                                onChange: (value)=>{
                                    let val = toNumber(value);
                                    if (step !== 1) {
                                        // quantize val to a multiple of step
                                        val = Math.round(val / step) * step;
                                    }
                                    onChange(val);
                                    setVal(val);
                                },
                                addonAfter: units
                            }),
                            defaultValue != null && /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(antd__WEBPACK_IMPORTED_MODULE_1__.Button, {
                                type: "dashed",
                                disabled: disabled || (value ?? val) == defaultValue,
                                style: {
                                    marginLeft: "5px"
                                },
                                onClick: ()=>{
                                    onChange(defaultValue);
                                    setVal(defaultValue);
                                },
                                children: [
                                    "Default: ",
                                    defaultValue
                                ]
                            })
                        ]
                    })
                ]
            }),
            presets && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
                children: presets.map((number)=>/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(antd__WEBPACK_IMPORTED_MODULE_1__.Tag, {
                        color: disabled ? _cocalc_util_theme__WEBPACK_IMPORTED_MODULE_3__.COLORS.GRAY_LL : "blue",
                        style: {
                            cursor: disabled ? "not-allowed" : "pointer"
                        },
                        onClick: ()=>{
                            if (disabled) return;
                            onChange(number);
                            setVal(number);
                        },
                        children: number
                    }, number))
            })
        ]
    });
};


/***/ })

};
;