"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _react = _interopRequireWildcard(require("react"));
var _reactErrorBoundary = require("react-error-boundary");
var _lozenge = _interopRequireDefault(require("@atlaskit/lozenge"));
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
var withErrorBoundary = function withErrorBoundary(Component) {
  return function (props) {
    var fallback = (0, _react.useMemo)(function () {
      var _props$testId;
      return /*#__PURE__*/_react.default.createElement(_lozenge.default, (0, _extends2.default)({
        appearance: props === null || props === void 0 ? void 0 : props.appearance
      }, (0, _platformFeatureFlags.fg)('platform-component-visual-refresh') ? {
        isBold: true
      } : undefined, {
        testId: "".concat((_props$testId = props === null || props === void 0 ? void 0 : props.testId) !== null && _props$testId !== void 0 ? _props$testId : 'smart-element-lozenge-action', "-fallback")
      }), props === null || props === void 0 ? void 0 : props.text);
    }, [props === null || props === void 0 ? void 0 : props.appearance, props === null || props === void 0 ? void 0 : props.testId, props === null || props === void 0 ? void 0 : props.text]);
    return /*#__PURE__*/_react.default.createElement(_reactErrorBoundary.ErrorBoundary, {
      fallback: fallback
    }, /*#__PURE__*/_react.default.createElement(Component, props));
  };
};
var _default = exports.default = withErrorBoundary;