import React__default from "react";
import index from "../../../../../../resize-observer-polyfill@1.5.1/node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js";
import { findDOMNode } from "react-dom";
var __extends = globalThis && globalThis.__extends || function() {
  var extendStatics = function(d, b) {
    extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
      d2.__proto__ = b2;
    } || function(d2, b2) {
      for (var p in b2)
        if (Object.prototype.hasOwnProperty.call(b2, p))
          d2[p] = b2[p];
    };
    return extendStatics(d, b);
  };
  return function(d, b) {
    if (typeof b !== "function" && b !== null)
      throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
    extendStatics(d, b);
    function __() {
      this.constructor = d;
    }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  };
}();
var ResizeObserverComponent = function(_super) {
  __extends(ResizeObserverComponent2, _super);
  function ResizeObserverComponent2() {
    var _this = _super !== null && _super.apply(this, arguments) || this;
    _this.componentWillUnmount = function() {
      if (_this.resizeObserver) {
        _this.destroyResizeObserver();
      }
    };
    _this.createResizeObserver = function() {
      _this.resizeObserver = new index(function(entry) {
        var onResize = _this.props.onResize;
        onResize && onResize(entry);
      });
      _this.resizeObserver.observe(findDOMNode(_this));
    };
    _this.destroyResizeObserver = function() {
      _this.resizeObserver && _this.resizeObserver.disconnect();
      _this.resizeObserver = null;
    };
    return _this;
  }
  ResizeObserverComponent2.prototype.componentDidMount = function() {
    if (!React__default.isValidElement(this.props.children)) {
      console.warn("The children of ResizeObserver is invalid.");
    } else {
      this.createResizeObserver();
    }
  };
  ResizeObserverComponent2.prototype.componentDidUpdate = function() {
    if (!this.resizeObserver && findDOMNode(this)) {
      this.createResizeObserver();
    }
  };
  ResizeObserverComponent2.prototype.render = function() {
    return this.props.children;
  };
  return ResizeObserverComponent2;
}(React__default.Component);
const ResizeObserver = ResizeObserverComponent;
export {
  ResizeObserver as default
};
//# sourceMappingURL=resizeObserver.js.map
