'use strict';

var defineProperty = require('../../defineProperty-lChFfVqi.js');
var react = require('@honeybadger-io/react');
var reactUtils_HoneybadgerErrorBoundary_constants = require('./constants.js');
var reactUtils_HoneybadgerErrorBoundary_FallbackComponent = require('./FallbackComponent.js');
var reactUtils_HoneybadgerErrorBoundary_utils = require('./utils.js');
var jsxRuntime = require('react/jsx-runtime');
require('../../typeof-D4ZZ_FlZ.js');
require('react');
require('dompurify');
require('@bigbinary/neetoui/Button');
require('@bigbinary/neetoui/Typography');
require('ramda');
require('react-i18next');

function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { defineProperty._defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var HoneybadgerErrorBoundary = function HoneybadgerErrorBoundary(_ref) {
  var children = _ref.children,
    _ref$ErrorComponent = _ref.ErrorComponent,
    ErrorComponent = _ref$ErrorComponent === void 0 ? reactUtils_HoneybadgerErrorBoundary_FallbackComponent : _ref$ErrorComponent,
    _ref$filterErrors = _ref.filterErrors,
    filterErrors = _ref$filterErrors === void 0 ? undefined : _ref$filterErrors,
    config = _ref.config;
  react.Honeybadger.beforeNotify(function (notice) {
    var _globalProps$user;
    if (!notice) return false;
    var isIgnorable = reactUtils_HoneybadgerErrorBoundary_constants.IGNORABLE_ERRORS_REGEX.test(notice.message) || reactUtils_HoneybadgerErrorBoundary_constants.IGNORABLE_ERROR_NAMES_REGEX.test(notice.name) || reactUtils_HoneybadgerErrorBoundary_constants.IGNORABLE_STACKS_REGEX.test(notice.stack) || reactUtils_HoneybadgerErrorBoundary_utils.isNeetoReplaySecurityError(notice) || (filterErrors === null || filterErrors === void 0 ? void 0 : filterErrors(notice)) === false;
    if (isIgnorable) return false;
    var context = {
      errorClass: notice.name
    };
    if (notice.name === "ChunkLoadError") {
      context.IGNORABLE_ERROR_NAMES_REGEX = reactUtils_HoneybadgerErrorBoundary_constants.IGNORABLE_ERROR_NAMES_REGEX;
      context.isChunkLoadError = reactUtils_HoneybadgerErrorBoundary_constants.IGNORABLE_ERROR_NAMES_REGEX.test(notice.name);
    }
    var user = (_globalProps$user = globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.email;
    if (user) context.user = user;
    var sessionReplay = reactUtils_HoneybadgerErrorBoundary_utils.getSessionReplayUrl();
    if (sessionReplay) context.sessionReplay = sessionReplay;
    reactUtils_HoneybadgerErrorBoundary_utils.attachContext(notice, context);
    return true;
  });
  var honeybadger = react.Honeybadger.configure(_objectSpread({
    apiKey: globalProps.honeybadgerApiKey,
    environment: globalProps.railsEnv,
    revision: globalProps.honeybadgerRevision,
    developmentEnvironments: ["development", "test"],
    enableUncaught: true,
    async: true,
    breadcrumbsEnabled: true,
    projectRoot: "webpack:///./",
    enableUnhandledRejection: false
  }, config));
  return /*#__PURE__*/jsxRuntime.jsx(react.HoneybadgerErrorBoundary, {
    ErrorComponent: ErrorComponent,
    honeybadger: honeybadger,
    children: children
  });
};

module.exports = HoneybadgerErrorBoundary;
//# sourceMappingURL=HoneybadgerErrorBoundary.js.map
