"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.InputCounter = void 0;
var react_1 = __importStar(require("react"));
var utils_service_1 = require("../../../services/utils.service");
var web_1 = require("../../Input/web");
var InputCounter_style_1 = __importDefault(require("./InputCounter.style"));
exports.InputCounter = react_1.default.forwardRef(function InputCounter(_a, ref) {
    var name = _a.name, title = _a.title, onEnter = _a.onEnter;
    var input = react_1.useRef();
    function addNumber() {
        var value = Number(utils_service_1.OnlyNumbers(input.current.value));
        input.current.value = (value + 1);
    }
    function subNumber() {
        var value = Number(utils_service_1.OnlyNumbers(input.current.value));
        input.current.value = (value <= 0 ? 0 : value - 1);
    }
    return (react_1.default.createElement(InputCounter_style_1.default, null,
        react_1.default.createElement(web_1.Input, { ref: input, name: name, title: title, onEnter: onEnter, number: true, withoutDotNumber: true, textCenter: true, prefix: react_1.default.createElement("div", { className: "button-action", onClick: subNumber, "data-testid": "sub-number" },
                react_1.default.createElement("i", { className: "fas fa-minus-circle" })), suffix: react_1.default.createElement("div", { className: "button-action", onClick: addNumber, "data-testid": "add-number" },
                react_1.default.createElement("i", { className: "fas fa-plus-circle" })) })));
});
//# sourceMappingURL=InputCounter.js.map