"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _isNotNumber = _interopRequireDefault(require("../../helpers/float/isNotNumber"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _checkFloat = s => {
  var n = s == undefined ? '' : s.toString().replace(/,/g, '.');
  if ((0, _isNotNumber.default)(n)) {
    return false;
  }
  return true;
};
var useFloatProps = decimalSign => {
  var toFloat = s => {
    if (!_checkFloat(s)) {
      //console.log(`toFloat ${typeof s} ${s} => 0.0 (not float)`)

      return 0.0;
    }
    return parseFloat(s.toString().replace(/,/g, '.'));
  };
  var fromFloat = f => {
    if ((0, _isNotNumber.default)(f)) {
      //console.log(`fromFloat ${typeof f} ${f} => "" (not number)`)
      return '';
    }
    var s = parseFloat(f).toString().replace('.', decimalSign);

    //console.log(`fromFloat ${f} => ${s}`)

    return s;
  };
  var t = {
    from: fromFloat,
    to: toFloat
  };
  return t;
};
var _default = useFloatProps;
exports.default = _default;