import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
import _inherits from "@babel/runtime/helpers/inherits";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
var _excluded = ["providerFactory"];
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
import React from 'react';
import { WithProviders } from '../../provider-factory';

// eslint-disable-next-line no-duplicate-imports

export default function withActivityProvider(WrappedComponent) {
  return /*#__PURE__*/function (_React$Component) {
    function WithActivityProvider() {
      var _this;
      _classCallCheck(this, WithActivityProvider);
      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
        args[_key] = arguments[_key];
      }
      _this = _callSuper(this, WithActivityProvider, [].concat(args));
      _defineProperty(_this, "renderNode", function (providers) {
        var _ref = _this.props,
          _providerFactory = _ref.providerFactory,
          props = _objectWithoutProperties(_ref, _excluded);
        var activityProvider = providers.activityProvider;

        // Ignored via go/ees005
        // eslint-disable-next-line @typescript-eslint/no-explicit-any, react/jsx-props-no-spreading
        return /*#__PURE__*/React.createElement(WrappedComponent, _extends({
          activityProvider: activityProvider
        }, props));
      });
      return _this;
    }
    _inherits(WithActivityProvider, _React$Component);
    return _createClass(WithActivityProvider, [{
      key: "render",
      value: function render() {
        var providerFactory = this.props.providerFactory;
        return /*#__PURE__*/React.createElement(WithProviders
        // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
        , {
          providers: ['activityProvider'],
          providerFactory: providerFactory,
          renderNode: this.renderNode
        });
      }
    }]);
  }(React.Component);
}