import * as React from 'react';
import { S as Slider } from './Slider-6a70ba99.js';
import { a3 as Input, t as toastApi } from './MapEditView-67426f04.js';
import classNames from 'classnames';
import { isNumber } from 'lodash';

var prefixCls = 'dm-map-base-slider-input';
var InputWraper = function (props) {
    var value = props.value, onPressEnter = props.onPressEnter;
    var _changeValue = function (value) {
        var _value = Number(value);
        if (isNumber(_value)) {
            onPressEnter && onPressEnter(_value);
        }
        else {
            toastApi.warning('Illegal number');
        }
    };
    var _onPressEnter = function (e) {
        var target = e.target;
        _changeValue(target.value);
    };
    var _onBlur = function (e) {
        var target = e.target;
        _changeValue(target.value);
    };
    var _value = value === null || value === void 0 ? void 0 : value.toString();
    return (React.createElement("div", { style: { width: 70 } },
        React.createElement(Input, { size: "compact", type: "menu-bg", block: true, allowClear: false, defaultValue: _value, onPressEnter: _onPressEnter, onBlur: _onBlur })));
};
var SliderInput = function (props) {
    var min = props.min, max = props.max, step = props.step, className = props.className, value = props.value, range = props.range, onChange = props.onChange, _a = props.renderInput, renderInput = _a === void 0 ? true : _a;
    var _onAfterChange = function (value) {
        onChange && onChange(value);
    };
    return (React.createElement("div", { className: classNames(prefixCls, className) },
        React.createElement("div", { style: { flex: 1 } },
            React.createElement(Slider, { range: range, min: min, max: max, step: step, size: "small", defaultValue: value, onAfterChange: _onAfterChange, getTooltipPopupContainer: function (node) { return node === null || node === void 0 ? void 0 : node.closest('.dm-page-root'); } })),
        renderInput && React.createElement(InputWraper, { value: value, onPressEnter: _onAfterChange })));
};

export { SliderInput as S };
