"use strict";

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

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

var _i18nFrontTranslate = require("../../../utils/i18n-front-translate");

var _popup = _interopRequireDefault(require("../../popup"));

require("./index.css");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

var StrLengthOverflowError = function StrLengthOverflowError(_ref) {
  var strLength = _ref.strLength,
      maxLength = _ref.maxLength;
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, strLength > maxLength ? /*#__PURE__*/_react["default"].createElement("span", {
    className: "error-popup-text-wrapper"
  }, (0, _i18nFrontTranslate.inputWordTrans)(strLength, maxLength)) : null);
};

var InputWithErrPopup = function InputWithErrPopup(_ref2) {
  var strLength = _ref2.strLength,
      maxLength = _ref2.maxLength,
      position = _ref2.position,
      _ref2$forceRender = _ref2.forceRender,
      forceRender = _ref2$forceRender === void 0 ? false : _ref2$forceRender,
      _ref2$destroyPopupOnH = _ref2.destroyPopupOnHide,
      destroyPopupOnHide = _ref2$destroyPopupOnH === void 0 ? true : _ref2$destroyPopupOnH,
      children = _ref2.children;
  return (
    /*#__PURE__*/
    // @ts-ignore
    _react["default"].createElement(_popup["default"], {
      popup: /*#__PURE__*/_react["default"].createElement(StrLengthOverflowError, {
        strLength: strLength,
        maxLength: maxLength
      }),
      popupVisible: true,
      popupPlacement: position,
      forceRender: forceRender,
      action: ["focus"],
      destroyPopupOnHide: destroyPopupOnHide
    }, children)
  );
};

var _default = InputWithErrPopup;
exports["default"] = _default;