"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));

var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));

var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));

var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));

var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));

var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

var _react = _interopRequireDefault(require("react"));

var _propTypes = _interopRequireDefault(require("prop-types"));

var _grades = require("./keys/grades");

var _utils = require("./keys/utils");

var _keypad = _interopRequireDefault(require("./keypad"));

function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }

function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }

var toOldModel = function toOldModel(d) {
  if (d.command) {
    return {
      value: d.command,
      type: 'command'
    };
  } else if (d.write) {
    return {
      value: d.write
    };
  } else if (d.keystroke) {
    return {
      type: 'cursor',
      value: d.keystroke
    };
  }
};

var HorizontalKeypad = /*#__PURE__*/function (_React$Component) {
  (0, _inherits2["default"])(HorizontalKeypad, _React$Component);

  var _super = _createSuper(HorizontalKeypad);

  function HorizontalKeypad() {
    var _this;

    (0, _classCallCheck2["default"])(this, HorizontalKeypad);

    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    _this = _super.call.apply(_super, [this].concat(args));
    (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "keypadPress", function (data) {
      var onClick = _this.props.onClick;
      onClick(toOldModel(data));
    });
    return _this;
  }

  (0, _createClass2["default"])(HorizontalKeypad, [{
    key: "render",
    value: function render() {
      var _this$props = this.props,
          mode = _this$props.mode,
          onFocus = _this$props.onFocus,
          noDecimal = _this$props.noDecimal,
          className = _this$props.className,
          additionalKeys = _this$props.additionalKeys,
          layoutForKeyPad = _this$props.layoutForKeyPad;
      var normalizedKeys = (0, _grades.normalizeAdditionalKeys)(additionalKeys);
      return /*#__PURE__*/_react["default"].createElement(_keypad["default"], {
        className: className,
        onFocus: onFocus,
        noDecimal: noDecimal,
        layoutForKeyPad: layoutForKeyPad,
        additionalKeys: (0, _utils.extendKeySet)((0, _grades.keysForGrade)(mode), normalizedKeys),
        onPress: this.keypadPress,
        mode: mode
      });
    }
  }]);
  return HorizontalKeypad;
}(_react["default"].Component);

exports["default"] = HorizontalKeypad;
(0, _defineProperty2["default"])(HorizontalKeypad, "propTypes", {
  className: _propTypes["default"].string,
  mode: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
  layoutForKeyPad: _propTypes["default"].object,
  onClick: _propTypes["default"].func.isRequired,
  onFocus: _propTypes["default"].func,
  noDecimal: _propTypes["default"].bool,
  additionalKeys: _propTypes["default"].array
});
(0, _defineProperty2["default"])(HorizontalKeypad, "defaultProps", {
  mode: 'scientific',
  noDecimal: false,
  additionalKeys: []
});
//# sourceMappingURL=horizontal-keypad.js.map