"use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;exports.__esModule = true;exports.IgnoreLayerClick = void 0;var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));var _react = _interopRequireDefault(require("react"));
var _globalObject = require("@skbkontur/global-object");


var _rootNode = require("../../lib/rootNode");
var _isInstanceOf = require("../../lib/isInstanceOf");
var _CommonWrapper = require("../CommonWrapper");var _class, _IgnoreLayerClickWrapper;var






IgnoreLayerClick = exports.IgnoreLayerClick = /*#__PURE__*/function (_React$Component) {function IgnoreLayerClick() {return _React$Component.apply(this, arguments) || this;}(0, _inheritsLoose2.default)(IgnoreLayerClick, _React$Component);var _proto = IgnoreLayerClick.prototype;_proto.
  render = function render() {
    var child = _react.default.Children.only(this.props.children);
    return this.props.active ? /*#__PURE__*/_react.default.createElement(IgnoreLayerClickWrapper, null, child) : child;
  };return IgnoreLayerClick;}(_react.default.Component);






// NOTE Используется только в команде Контур.Бухгалтерия
var
IgnoreLayerClickWrapper = (0, _rootNode.rootNode)(_class = (_IgnoreLayerClickWrapper = /*#__PURE__*/function (_React$Component2) {function IgnoreLayerClickWrapper() {var _this;for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {args[_key] = arguments[_key];}_this = _React$Component2.call.apply(_React$Component2, [this].concat(args)) || this;_this.



    element = null;_this.


























    handleMouseDown = function (event) {
      event.stopPropagation();
    };return _this;}(0, _inheritsLoose2.default)(IgnoreLayerClickWrapper, _React$Component2);var _proto2 = IgnoreLayerClickWrapper.prototype;_proto2.componentDidMount = function componentDidMount() {var element = (0, _rootNode.getRootNode)(this);if ((0, _isInstanceOf.isInstanceOf)(element, _globalObject.globalObject.Element)) {element.addEventListener('mousedown', this.handleMouseDown);this.element = element;}};_proto2.componentWillUnmount = function componentWillUnmount() {if (this.element) {this.element.removeEventListener('mousedown', this.handleMouseDown);this.element = null;}};_proto2.render = function render() {return /*#__PURE__*/_react.default.createElement(_CommonWrapper.CommonWrapper, (0, _extends2.default)({ rootNodeRef: this.setRootNode }, this.props), _react.default.Children.only(this.props.children));};return IgnoreLayerClickWrapper;}(_react.default.Component), _IgnoreLayerClickWrapper.__KONTUR_REACT_UI__ = 'IgnoreLayerClick', _IgnoreLayerClickWrapper.displayName = 'IgnoreLayerClick', _IgnoreLayerClickWrapper)) || _class;